Skip to content

Commit

Permalink
Pre-release fixes (#573)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
annehaley authored Aug 26, 2022
1 parent 41481bf commit d1c5def
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 234 deletions.
149 changes: 74 additions & 75 deletions web_client/src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -323,81 +323,80 @@ export default {
fill-height
fluid
>
<v-row no-gutters>
<v-col cols="2">
Scan:
</v-col>
<v-col
cols="6"
class="grey--text"
>
<div
:class="currentViewData.scanLink ? 'link' : ''"
style="display:inline"
@click="openScanLink"
>
<b>{{ currentViewData.scanName }}</b>
<div
class="d-flex flex-column"
style="width: 100%"
>
<div class="d-flex justify-space-between">
<div>
Scan:
<p
:class="currentViewData.scanLink ? 'link' : 'grey--text'"
style="display:inline"
@click="openScanLink"
>
<b>{{ currentViewData.scanName }}</b>
</p>
<p
class="grey--text"
style="display:inline"
>
{{ currentViewData.scanPositionString }}
</p>
</div>
{{ currentViewData.scanPositionString }}
</v-col>
<v-col
cols="4"
class="text-right"
>
<v-btn
:disabled="!currentViewData.upTo"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('previous')"
>
<v-icon>fa-caret-up</v-icon>
</v-btn>
<v-btn
:disabled="!currentViewData.downTo"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('next')"
>
<v-icon>fa-caret-down</v-icon>
</v-btn>
</v-col>
</v-row>
<v-row no-gutters>
<v-col cols="2">
Frame:
</v-col>
<v-col
cols="6"
class="grey--text"
>
{{ currentViewData.framePositionString }}
</v-col>
<v-col
cols="4"
class="text-right"
>
<v-btn
:disabled="!previousFrame"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('back')"
>
<v-icon>fa-caret-left</v-icon>
</v-btn>
<v-btn
:disabled="!nextFrame"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('forward')"
>
<v-icon>fa-caret-right</v-icon>
</v-btn>
</v-col>
</v-row>
<div>
<v-btn
:disabled="!currentViewData.upTo"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('previous')"
>
<v-icon>fa-caret-up</v-icon>
</v-btn>
<v-btn
:disabled="!currentViewData.downTo"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('next')"
>
<v-icon>fa-caret-down</v-icon>
</v-btn>
</div>
</div>
<div class="d-flex justify-space-between">
<div>
Frame:
<p
class="grey--text"
style="display:inline"
>
{{ currentViewData.framePositionString }}
</p>
</div>
<div>
<v-btn
:disabled="!previousFrame"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('back')"
>
<v-icon>fa-caret-left</v-icon>
</v-btn>
<v-btn
:disabled="!nextFrame"
small
depressed
class="transparent-btn"
@mousedown="handleKeyPress('forward')"
>
<v-icon>fa-caret-right</v-icon>
</v-btn>
</div>
</div>
</div>

<window-widget
:representation="representation"
Expand All @@ -408,7 +407,7 @@ export default {
<v-col
cols="12"
class="grey lighten-4"
style="height: 100px; overflow:auto; margin-bottom: 10px"
style="height: 100px; overflow:auto; margin: 15px 0px"
>
<ScanDecision
v-for="decision in currentViewData.scanDecisions"
Expand Down
127 changes: 66 additions & 61 deletions web_client/src/components/DataImportExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,71 +31,76 @@ export default defineComponent({
const exporting = ref(false);
async function importData() {
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;
}
this.$emit('save', async () => {
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 {
Expand Down Expand Up @@ -236,8 +241,8 @@ export default defineComponent({
<v-divider class="my-3" />

<v-card-text
v-for="importError in importErrorList"
:key="importError"
v-for="(importError, index) in importErrorList"
:key="index"
class="console-format"
>
{{ importError }}
Expand Down
4 changes: 3 additions & 1 deletion web_client/src/components/ProjectSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -77,6 +77,7 @@ export default defineComponent({
exportPathError.value = '';
}, 3000);
}
if (callback) callback();
}
return {
Expand Down Expand Up @@ -209,6 +210,7 @@ export default defineComponent({
<DataImportExport
:import-path="importPath"
:export-path="exportPath"
@save="save"
/>
<div style="flex-grow:2">
<v-btn
Expand Down
Loading

0 comments on commit d1c5def

Please sign in to comment.