Handle long running task plugins

This commit is contained in:
Joel Collins 2019-06-17 15:05:13 +01:00
parent 5f19d6392f
commit 1b9dac120b
2 changed files with 36 additions and 7 deletions

View file

@ -18,7 +18,11 @@
<hr>
<tabIcon v-for="plugin in $store.state.apiPlugins" :key="plugin.id" :id="plugin.id" :uk-icon="plugin.icon" :requireConnection="plugin.requiresConnection" :currentTab="currentTab" @set-tab="setTab">
<tabIcon v-for="plugin in $store.state.apiPlugins" @set-tab="setTab"
:key="plugin.id"
:id="plugin.id"
:requireConnection="plugin.requiresConnection"
:currentTab="currentTab">
<i class="material-icons">{{ plugin.icon || "extension" }}</i>
</tabIcon>
@ -40,8 +44,17 @@
<paneSettings/>
</tabContent>
<tabContent v-for="plugin in $store.state.apiPlugins" :key="plugin.id" :id="plugin.id" :requireConnection="plugin.requiresConnection" :currentTab="currentTab">
<JsonForm v-for="form in plugin.forms" :key="form.route" :route="form.route" :schema="form.schema"/>
<tabContent v-for="plugin in $store.state.apiPlugins"
:key="plugin.id"
:id="plugin.id"
:requireConnection="plugin.requiresConnection"
:currentTab="currentTab">
<JsonForm v-for="form in plugin.forms"
:key="form.route"
:route="form.route"
:isTask="form.isTask"
:submitLabel="form.submitLabel"
:schema="form.schema"/>
</tabContent>
</div>

View file

@ -23,7 +23,7 @@
<div class="center-spinner" uk-spinner></div>
</div>
<button v-bind:hidden="taskRunning" type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">Submit</button>
<button v-bind:hidden="taskRunning" type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">{{ submitLabel }}</button>
</form>
</template>
@ -58,6 +58,16 @@ export default {
'route': {
type: String,
required: true
},
'isTask': {
type: Boolean,
required: false,
default: false
},
'submitLabel': {
type: String,
required: false,
default: "Submit"
}
},
@ -75,7 +85,12 @@ export default {
},
submitForm() {
this.newQuickRequest(this.formData)
if (this.isTask == true) {
this.newLongRequest(this.formData)
}
else {
this.newQuickRequest(this.formData)
}
},
newQuickRequest: function(params) {
@ -100,8 +115,9 @@ export default {
// Start the store polling TaskId for success
return this.$store.dispatch('pollTask', [response.data.id, null, null])
})
.then(() => {
console.log("Successfully finished task")
.then(response => {
console.log("Successfully finished task with response:")
console.log(response)
})
.catch(error => {
this.modalError(error) // Let mixin handle error