WIP: modal progress dialog for TaskSubmitter
Longer-running tasks would benefit hugely from showing the operator a progress indicator. This branch will add a basic log display allowing messages to be shown to the user. This branch may also add an abort button to the above dialog.
This commit is contained in:
parent
778da73a70
commit
5ca8070bc8
2 changed files with 47 additions and 32 deletions
|
|
@ -34,11 +34,22 @@
|
||||||
{{ submitLabel }}
|
{{ submitLabel }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="modal-center" ref="statusModal" class="uk-flex-top" uk-modal>
|
||||||
|
<div class="uk-modal-dialog uk-modal-body uk-margin-auto-vertical">
|
||||||
|
<div>
|
||||||
|
<pre v-for="(item, index) in log" :key="`log_entry_${index}`">
|
||||||
|
{{ item.message }}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import UIkit from "uikit";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TaskSubmitter",
|
name: "TaskSubmitter",
|
||||||
|
|
@ -87,6 +98,11 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: null
|
default: null
|
||||||
|
},
|
||||||
|
modalProgress: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -96,7 +112,8 @@ export default {
|
||||||
taskUrl: null,
|
taskUrl: null,
|
||||||
progress: null,
|
progress: null,
|
||||||
taskStarted: false,
|
taskStarted: false,
|
||||||
taskRunning: false
|
taskRunning: false,
|
||||||
|
log: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -165,7 +182,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
startTask: function() {
|
async startTask() {
|
||||||
// Starts a new Action task
|
// Starts a new Action task
|
||||||
|
|
||||||
this.$emit("submit", this.submitData);
|
this.$emit("submit", this.submitData);
|
||||||
|
|
@ -173,36 +190,32 @@ export default {
|
||||||
|
|
||||||
this.taskStarted = true;
|
this.taskStarted = true;
|
||||||
this.$emit("taskStarted", this.taskId);
|
this.$emit("taskStarted", this.taskId);
|
||||||
axios
|
try {
|
||||||
.post(this.submitUrl, this.submitData)
|
let response = await axios.post(this.submitUrl, this.submitData)
|
||||||
// Get the returned Task ID
|
if (this.statusModal) {
|
||||||
.then(response => {
|
UIkit.modal(this.$refs.statusModal).show();
|
||||||
// Start the store polling TaskId for success
|
}
|
||||||
return this.startPolling(response.data.id, response.data.href);
|
// Start the store polling TaskId for success
|
||||||
})
|
response = await this.startPolling(response.data.id, response.data.href);
|
||||||
.then(response => {
|
this.$emit("response", response);
|
||||||
// Do something with the final response
|
this.$emit("finished");
|
||||||
|
} catch (error) {
|
||||||
this.$emit("response", response);
|
if (!error) {
|
||||||
this.$emit("finished");
|
error = Error("Unknown error");
|
||||||
})
|
}
|
||||||
.catch(error => {
|
this.$emit("error", error);
|
||||||
if (!error) {
|
this.$emit("finished");
|
||||||
error = Error("Unknown error");
|
} finally {
|
||||||
}
|
// Reset taskRunning and taskId
|
||||||
this.$emit("error", error);
|
this.taskRunning = false;
|
||||||
this.$emit("finished");
|
this.taskStarted = false;
|
||||||
})
|
this.taskId = null;
|
||||||
.finally(() => {
|
// Update the form data if we're self-updating
|
||||||
// Reset taskRunning and taskId
|
if (this.selfUpdate) {
|
||||||
this.taskRunning = false;
|
this.getFormData();
|
||||||
this.taskStarted = false;
|
}
|
||||||
this.taskId = null;
|
UIkit.modal(this.$refs.statusModal).hide();
|
||||||
// Update the form data if we're self-updating
|
}
|
||||||
if (this.selfUpdate) {
|
|
||||||
this.getFormData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startPolling: function(taskId, taskUrl) {
|
startPolling: function(taskId, taskUrl) {
|
||||||
|
|
@ -244,6 +257,7 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
// Since the task is still running, we can update the progress bar
|
// Since the task is still running, we can update the progress bar
|
||||||
this.progress = response.data.progress;
|
this.progress = response.data.progress;
|
||||||
|
this.log = response.data.log;
|
||||||
// Check again after timeout
|
// Check again after timeout
|
||||||
setTimeout(checkCondition, interval, resolve, reject);
|
setTimeout(checkCondition, interval, resolve, reject);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
"
|
"
|
||||||
:submit-url="calibrateXYUri"
|
:submit-url="calibrateXYUri"
|
||||||
:submit-label="'Auto-Calibrate using camera'"
|
:submit-label="'Auto-Calibrate using camera'"
|
||||||
|
:modal-progress="true"
|
||||||
@response="onRecalibrateResponse"
|
@response="onRecalibrateResponse"
|
||||||
@error="modalError"
|
@error="modalError"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue