Auto-populate workflow dropdown
This commit is contained in:
parent
0177596fb6
commit
3beb8e1147
2 changed files with 55 additions and 0 deletions
|
|
@ -208,6 +208,16 @@ class SmartScanThing(lt.Thing):
|
||||||
raise ScanNotRunningError("Cannot get ongoing scan if scan is not running.")
|
raise ScanNotRunningError("Cannot get ongoing scan if scan is not running.")
|
||||||
return self._ongoing_scan
|
return self._ongoing_scan
|
||||||
|
|
||||||
|
@lt.property
|
||||||
|
def all_workflow_names(self) -> list[str]:
|
||||||
|
"""Return a list of all available Scan Workflows."""
|
||||||
|
return list(self._all_workflows.keys())
|
||||||
|
|
||||||
|
@lt.property
|
||||||
|
def workflow_display_names(self) -> dict[str, str]:
|
||||||
|
"""Return a list of the display names of all available Scan Workflows."""
|
||||||
|
return {name: wf.display_name for name, wf in self._all_workflows.items()}
|
||||||
|
|
||||||
_scan_data: Optional[ActiveScanData] = None
|
_scan_data: Optional[ActiveScanData] = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,24 @@
|
||||||
<div uk-grid class="uk-height-1-1 uk-margin-remove uk-padding-remove">
|
<div uk-grid class="uk-height-1-1 uk-margin-remove uk-padding-remove">
|
||||||
<div class="control-component uk-padding-small">
|
<div class="control-component uk-padding-small">
|
||||||
<div v-show="!scanning" v-observe-visibility="visibilityChanged" class="uk-padding-small">
|
<div v-show="!scanning" v-observe-visibility="visibilityChanged" class="uk-padding-small">
|
||||||
|
<!-- Workflow Selection Dropdown -->
|
||||||
|
<div class="uk-margin">
|
||||||
|
<label class="uk-form-label">Workflow</label>
|
||||||
|
|
||||||
|
<select
|
||||||
|
class="uk-select uk-form-small"
|
||||||
|
:value="workflowName"
|
||||||
|
@change="setWorkflow($event.target.value)"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="(label, name) in workflowOptions"
|
||||||
|
:key="name"
|
||||||
|
:value="name"
|
||||||
|
>
|
||||||
|
{{ label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<h4 v-if="workflowDisplayName" class="workflow-name">
|
<h4 v-if="workflowDisplayName" class="workflow-name">
|
||||||
{{ workflowDisplayName }}
|
{{ workflowDisplayName }}
|
||||||
</h4>
|
</h4>
|
||||||
|
|
@ -145,6 +163,7 @@ export default {
|
||||||
workflowSettings: [],
|
workflowSettings: [],
|
||||||
workflowDisplayName: undefined,
|
workflowDisplayName: undefined,
|
||||||
workflowBlurb: undefined,
|
workflowBlurb: undefined,
|
||||||
|
workflowOptions: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -159,6 +178,10 @@ export default {
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
this.readSettings();
|
this.readSettings();
|
||||||
|
this.workflowOptions = await this.readThingProperty(
|
||||||
|
"smart_scan",
|
||||||
|
"workflow_display_names",
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -216,6 +239,28 @@ export default {
|
||||||
setTimeout(this.pollScan, 1000); // keep rescheduling until it's stopped
|
setTimeout(this.pollScan, 1000); // keep rescheduling until it's stopped
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async setWorkflow(name) {
|
||||||
|
try {
|
||||||
|
this.workflowName = name;
|
||||||
|
|
||||||
|
await this.writeThingProperty(
|
||||||
|
"smart_scan",
|
||||||
|
"workflow_name",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
|
||||||
|
// refresh UI
|
||||||
|
await this.readSettings();
|
||||||
|
} catch (err) {
|
||||||
|
this.modalError(err);
|
||||||
|
|
||||||
|
// revert if server rejected
|
||||||
|
this.workflowName = await this.readThingProperty(
|
||||||
|
"smart_scan",
|
||||||
|
"workflow_name"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
async downloadZipFile(response) {
|
async downloadZipFile(response) {
|
||||||
const scan_name = response.input.scan_name;
|
const scan_name = response.input.scan_name;
|
||||||
const filename = `${scan_name}_images.zip`;
|
const filename = `${scan_name}_images.zip`;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue