Skip to content

Commit

Permalink
Merge pull request #70 from dacoaster/da/session_restore
Browse files Browse the repository at this point in the history
Da/session restore
  • Loading branch information
dacoaster authored Jul 18, 2023
2 parents 796c430 + 26ac6d9 commit 057786e
Show file tree
Hide file tree
Showing 24 changed files with 592 additions and 328 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yattie",
"version": "0.7.1",
"version": "0.8.0",
"engines": {
"npm": ">=8.0.0 <9.0.0",
"node": ">=16.0.0 <17.0.0"
Expand Down
30 changes: 29 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,44 @@
</template>

<script>
import { IPC_HANDLERS, IPC_FUNCTIONS } from "./modules/constants";
const default_layout = "default";
export default {
name: "App",
computed: {
layout() {
return (this.$route.meta.layout || default_layout) + "-layout";
},
},
beforeCreate() {
// Only restore state for the primary window that opens at HomeView
if (this.$router.history.current.path === "/") {
window.ipc
.invoke(IPC_HANDLERS.DATABASE, {
func: IPC_FUNCTIONS.GET_STATE,
})
.then((state) => {
if (Object.keys(state).length > 0) {
this.$store.commit("restoreState", state);
const currentPath = this.$router.history.current.path;
if (state.path && currentPath !== state.path) {
if (state.path.includes("result")) {
window.ipc.invoke(IPC_HANDLERS.WINDOW, {
func: IPC_FUNCTIONS.SET_WINDOW_SIZE,
data: {
width: 1440,
height: 900,
},
});
}
this.$router.push({ path: state.path });
}
}
});
}
},
};
</script>
<style scoped>
Expand Down
6 changes: 3 additions & 3 deletions src/components/AudioWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default {
data: { url: uri, isPoster: true },
});
if (posterResult.status === STATUSES.ERROR) {
// TODO - Bubble to snackbar
this.$root.$emit("set-snackbar", posterResult.message);
console.log(
"Unable to generate waveform image: " + posterResult.message
);
Expand All @@ -233,7 +233,7 @@ export default {
});
if (audioResult.status === STATUSES.ERROR) {
// TODO - Bubble to snackbar
this.$root.$emit("set-snackbar", audioResult.message);
console.log("Unable to update audio file: " + audioResult.message);
}
this.sessionItem = {
Expand All @@ -242,7 +242,7 @@ export default {
...audioResult.item,
};
this.$root.$emit("update-session", this.sessionItem);
this.$root.$emit("save-data"); // CTODO remove data on all of these
this.$root.$emit("save-data", this.sessionItem);
},
},
};
Expand Down
98 changes: 73 additions & 25 deletions src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ export default {
duration: this.duration,
});
},
startSession(id) {
async startSession(id) {
this.sourceId = id;
this.sourcePickerDialog = false;
Expand All @@ -1099,6 +1099,30 @@ export default {
this.changeSessionStatus(SESSION_STATUSES.START);
}
const sessionId = await window.ipc.invoke(IPC_HANDLERS.DATABASE, {
func: IPC_FUNCTIONS.GET_SESSION_ID,
});
if (sessionId === "") {
const data = {
title: this.$store.state.title,
charter: this.$store.state.charter,
precondition: this.$store.state.precondition,
duration: this.$store.state.duration,
status: this.$store.state.status,
timer: this.$store.state.timer,
started: this.$store.state.started,
ended: this.$store.state.ended,
quickTest: this.$store.state.quickTest,
path: this.$route.path,
};
window.ipc.invoke(IPC_HANDLERS.FILE_SYSTEM, {
func: IPC_FUNCTIONS.CREATE_NEW_SESSION,
data: data,
});
}
if (this.viewMode === "normal") {
const currentPath = this.$router.history.current.path;
if (currentPath !== "/main/workspace") {
Expand Down Expand Up @@ -1261,7 +1285,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
const data = {
Expand Down Expand Up @@ -1340,7 +1364,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log("Unable to generate poster for video: " + message);
}
poster = item.filePath;
Expand All @@ -1366,7 +1390,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
const { id, fileName, filePath } = item;
Expand Down Expand Up @@ -1497,7 +1521,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
const data = {
Expand Down Expand Up @@ -1570,7 +1594,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
let newItem = {
Expand Down Expand Up @@ -1673,9 +1697,15 @@ export default {
},
async saveSession(callback = null) {
this.newSessionDialog = false;
const sessionId = await window.ipc.invoke(IPC_HANDLERS.DATABASE, {
func: IPC_FUNCTIONS.GET_SESSION_ID,
});
const data = {
id: sessionId,
title: this.$store.state.title,
charter: this.$store.state.charter,
mindmap: this.$store.state.mindmap,
precondition: this.$store.state.precondition,
duration: this.$store.state.duration,
status: this.$store.state.status,
Expand Down Expand Up @@ -1721,27 +1751,45 @@ export default {
this.audioErrorDialog = false;
this.endSessionDialog = false;
if (!window.ipc) return;
const data = {
title: this.$store.state.title,
charter: this.$store.state.charter,
precondition: this.$store.state.precondition,
duration: this.$store.state.duration,
status: this.$store.state.status,
timer: this.$store.state.timer,
started: this.$store.state.started,
ended: this.$store.state.ended,
quickTest: this.$store.state.quickTest,
path: this.$route.path,
};
await window.ipc.invoke(IPC_HANDLERS.FILE_SYSTEM, {
func: IPC_FUNCTIONS.CREATE_NEW_SESSION,
data: data,
});
this.$store.commit("clearState");
if (!window.ipc) return;
await window.ipc
.invoke(IPC_HANDLERS.DATABASE, {
func: IPC_FUNCTIONS.RESET_DATA,
})
.then(() => {
window.ipc.invoke(IPC_HANDLERS.WINDOW, {
func: IPC_FUNCTIONS.SET_WINDOW_SIZE,
data: {
width: 800,
height: 600,
},
});
this.stopInterval();
const currentPath = this.$router.history.current.path;
if (currentPath !== "/main") {
this.$router.push({ path: "/main" });
}
});
await window.ipc.invoke(IPC_HANDLERS.DATABASE, {
func: IPC_FUNCTIONS.RESET_DATA,
});
window.ipc.invoke(IPC_HANDLERS.WINDOW, {
func: IPC_FUNCTIONS.SET_WINDOW_SIZE,
data: {
width: 800,
height: 600,
},
});
this.stopInterval();
const currentPath = this.$router.history.current.path;
if (currentPath !== "/main") {
this.$router.push({ path: "/main" });
}
},
async resetSession() {
if (this.resetConfirmDialog) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
// Force the timeline component to update the image through a fake QS
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReviewWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default {
}
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
this.sessionItem.fileName = item.fileName;
Expand Down
4 changes: 2 additions & 2 deletions src/components/TimelineWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
const data = {
Expand Down Expand Up @@ -1168,7 +1168,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
const data = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/VideoWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default {
);
if (status === STATUSES.ERROR) {
// CTODO - bubble up to snackbar
this.$root.$emit("set-snackbar", message);
console.log(message);
} else {
this.sessionItem.filePath = item.filePath;
Expand Down
2 changes: 2 additions & 0 deletions src/components/dialogs/NewSessionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
small
:color="currentTheme.primary"
class="text-capitalize btn"
:style="{ color: currentTheme.white }"
@click="$emit('save')"
>
{{ $tc("caption.save", 1) }}
Expand All @@ -19,6 +20,7 @@
small
:color="currentTheme.background"
class="text-capitalize btn"
:style="{ color: currentTheme.secondary }"
@click="$emit('discard')"
>
{{ $tc("caption.discard", 1) }}
Expand Down
6 changes: 3 additions & 3 deletions src/components/settings/GeneralTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default {
name: "GeneralTab",
components: {},
props: {
metaData: {
metadata: {
type: Object,
default: () => {},
},
Expand All @@ -219,7 +219,7 @@ export default {
},
},
watch: {
metaData: function (newValue) {
metadata: function (newValue) {
this.meta = newValue;
},
config: function (newValue) {
Expand Down Expand Up @@ -259,7 +259,7 @@ export default {
},
data() {
return {
meta: this.metaData,
meta: this.metadata,
setting: this.config,
comment: {
type: "Comment",
Expand Down
29 changes: 17 additions & 12 deletions src/components/testrail/TestRailExportSession.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
return-object
>
</v-select>
<div v-for="(item, i) in itemLists" :key="i">
<div v-for="(item, i) in selectedAttachments" :key="i">
<div
class="image-wrapper"
@click="handleItemClick(item.id)"
Expand Down Expand Up @@ -372,6 +372,20 @@ export default {
}
return temp;
},
selectedAttachments() {
let selectedAttachments = [];
if (this.selectedIds.length > 0) {
this.itemLists.map((item) => {
if (
item.sessionType !== "Summary" &&
this.selectedIds.includes(item.id)
) {
selectedAttachments.push(item);
}
});
}
return selectedAttachments;
},
},
mounted() {},
methods: {
Expand Down Expand Up @@ -541,17 +555,9 @@ export default {
};
let resultId;
if (this.selectedIds.length === 0) {
this.itemLists.map((item) => {
if (item.sessionType !== "Summary") {
this.selectedIds.push(item.id);
}
});
}
let attachmentComments = "";
this.selectedIds.map(async (id, i) => {
const item = this.itemLists.find((item) => item.id === id);
const item = this.selectedAttachments.find((item) => item.id === id);
attachmentComments += item.comment.type + ": " + item.comment.text;
if (i !== this.selectedIds.length - 1) {
attachmentComments += "\n";
Expand Down Expand Up @@ -594,8 +600,7 @@ export default {
const formData = new FormData();
this.projectLoading = true;
this.selectedIds.map(async (id, i) => {
const item = this.itemLists.find((item) => item.id === id);
this.selectedAttachments.map(async (item, i) => {
const response = await fetch(`file:${item.filePath}`);
const file = new File([await response.blob()], item.fileName);
formData.append("attachment", file);
Expand Down
Loading

0 comments on commit 057786e

Please sign in to comment.