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> <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> <i class="material-icons">{{ plugin.icon || "extension" }}</i>
</tabIcon> </tabIcon>
@ -40,8 +44,17 @@
<paneSettings/> <paneSettings/>
</tabContent> </tabContent>
<tabContent v-for="plugin in $store.state.apiPlugins" :key="plugin.id" :id="plugin.id" :requireConnection="plugin.requiresConnection" :currentTab="currentTab"> <tabContent v-for="plugin in $store.state.apiPlugins"
<JsonForm v-for="form in plugin.forms" :key="form.route" :route="form.route" :schema="form.schema"/> :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> </tabContent>
</div> </div>

View file

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