From d1c5defcc88c6d2c8e5dcf2245275a26301e15ef Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Fri, 26 Aug 2022 13:08:38 -0400 Subject: [PATCH] Pre-release fixes (#573) * Import and export implicitly save settings * Fix recursion error when crosshair click location is undefined * Use more flex boxes in Control Panel * Remove border from window widget * Trigger snackbar via event, not via error --- web_client/src/components/ControlPanel.vue | 149 +++++++------- .../src/components/DataImportExport.vue | 127 ++++++------ web_client/src/components/ProjectSettings.vue | 4 +- web_client/src/components/WindowWidget.vue | 185 +++++++++--------- web_client/src/django.ts | 1 - web_client/src/store/index.ts | 2 +- web_client/src/views/Frame.vue | 8 + web_client/src/views/Projects.vue | 6 + 8 files changed, 248 insertions(+), 234 deletions(-) diff --git a/web_client/src/components/ControlPanel.vue b/web_client/src/components/ControlPanel.vue index 8d4b97db..5d303a5c 100644 --- a/web_client/src/components/ControlPanel.vue +++ b/web_client/src/components/ControlPanel.vue @@ -323,81 +323,80 @@ export default { fill-height fluid > - - - Scan: - - -
- {{ currentViewData.scanName }} +
+
+
+ Scan: +

+ {{ currentViewData.scanName }} +

+

+ {{ currentViewData.scanPositionString }} +

- {{ currentViewData.scanPositionString }} - - - - fa-caret-up - - - fa-caret-down - - - - - - Frame: - - - {{ currentViewData.framePositionString }} - - - - fa-caret-left - - - fa-caret-right - - - +
+ + fa-caret-up + + + fa-caret-down + +
+
+
+
+ Frame: +

+ {{ currentViewData.framePositionString }} +

+
+
+ + fa-caret-left + + + fa-caret-right + +
+
+
{ + importing.value = true; + importErrorText.value = ''; + importErrors.value = false; + try { + let response; + if (isGlobal.value) { + response = await djangoRest.globalImport(); + } else { + response = await djangoRest.projectImport(currentProject.value.id); + } + importing.value = false; + if (response.detail) { + importErrors.value = true; + importErrorText.value = response.detail; + importErrorList.value = response.errors; + } else { + this.$snackbar({ + text: 'Import finished.', + timeout: 6000, + }); + } - this.$snackbar({ - text: 'Import finished.', - timeout: 6000, - }); - - if (!isGlobal.value) { - await loadProject(currentProject.value); - } else { - projects.value.forEach( - async (project: Project) => { - const taskOverview = await djangoRest.projectTaskOverview(project.id); - store.commit.setTaskOverview(taskOverview); - }, - ); + if (!isGlobal.value) { + await loadProject(currentProject.value); + } else { + projects.value.forEach( + async (project: Project) => { + const taskOverview = await djangoRest.projectTaskOverview(project.id); + store.commit.setTaskOverview(taskOverview); + }, + ); + } + } catch (ex) { + const text = ex || 'Import failed due to server error.'; + importErrors.value = true; + importErrorText.value = text; + importing.value = false; } - } catch (ex) { - const text = ex || 'Import failed due to server error.'; - importErrors.value = true; - importErrorText.value = text; - importing.value = false; - } - importDialog.value = false; + importDialog.value = false; + }); } async function exportData() { - exporting.value = true; - try { - let response; - if (isGlobal.value) { - response = await djangoRest.globalExport(); - } else { - response = await djangoRest.projectExport(currentProject.value.id); - } - if (response.detail) { + this.$emit('save', async () => { + exporting.value = true; + try { + let response; + if (isGlobal.value) { + response = await djangoRest.globalExport(); + } else { + response = await djangoRest.projectExport(currentProject.value.id); + } + if (response.detail) { + importErrors.value = true; + importErrorText.value = response.detail; + importErrorList.value = response.warnings; + } else { + this.$snackbar({ + text: 'Saved data to file successfully.', + timeout: 6000, + }); + } + } catch (ex) { + const text = ex || 'Export failed due to server error.'; importErrors.value = true; - importErrorText.value = response.detail; - importErrorList.value = response.warnings; + importErrorText.value = text; + importing.value = false; } - this.$snackbar({ - text: 'Saved data to file successfully.', - timeout: 6000, - }); - } catch (ex) { - const text = ex || 'Export failed due to server error.'; - importErrors.value = true; - importErrorText.value = text; - importing.value = false; - } - exporting.value = false; + exporting.value = false; + }); } return { @@ -236,8 +241,8 @@ export default defineComponent({ {{ importError }} diff --git a/web_client/src/components/ProjectSettings.vue b/web_client/src/components/ProjectSettings.vue index 809371a5..8a235fc4 100644 --- a/web_client/src/components/ProjectSettings.vue +++ b/web_client/src/components/ProjectSettings.vue @@ -46,7 +46,7 @@ export default defineComponent({ const exportPathError = ref(''); const form = ref(null); - async function save() { + async function save(callback) { if (!form.value.validate()) { return; } @@ -77,6 +77,7 @@ export default defineComponent({ exportPathError.value = ''; }, 3000); } + if (callback) callback(); } return { @@ -209,6 +210,7 @@ export default defineComponent({