Actually send requests
This commit is contained in:
parent
09f9ad6f7d
commit
f6ddd7f1c2
1 changed files with 49 additions and 6 deletions
|
|
@ -19,12 +19,17 @@
|
|||
</component>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="uk-button uk-button-primary uk-form-small uk-float-right uk-margin-small uk-width-1-1">Submit</button>
|
||||
<div class="uk-text-center uk-container" v-if="taskRunning">
|
||||
<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>
|
||||
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import numberInput from "./fieldComponents/numberInput";
|
||||
import selectList from "./fieldComponents/selectList";
|
||||
|
|
@ -58,7 +63,8 @@ export default {
|
|||
|
||||
data: function () {
|
||||
return {
|
||||
formData: {}
|
||||
formData: {},
|
||||
taskRunning: false
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -69,15 +75,52 @@ export default {
|
|||
},
|
||||
|
||||
submitForm() {
|
||||
console.log(`Mock-submitting form to ${this.submitApiUri}:`)
|
||||
console.log(this.formData)
|
||||
}
|
||||
this.newQuickRequest(this.formData)
|
||||
},
|
||||
|
||||
newQuickRequest: function(params) {
|
||||
console.log(this.submitApiUri)
|
||||
console.log(params)
|
||||
// Send a quick request
|
||||
axios.post(this.submitApiUri, params)
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
// TODO: Have this perform a GET request to update all available parameters
|
||||
})
|
||||
.catch(error => {
|
||||
this.modalError(error) // Let mixin handle error
|
||||
})
|
||||
},
|
||||
|
||||
newLongRequest: function(params) {
|
||||
this.taskRunning = true
|
||||
axios.post(this.submitApiUri, params)
|
||||
.then(response => {
|
||||
console.log("Task ID: " + response.data.id)
|
||||
// Start the store polling TaskId for success
|
||||
return this.$store.dispatch('pollTask', [response.data.id, null, null])
|
||||
})
|
||||
.then(() => {
|
||||
console.log("Successfully finished task")
|
||||
})
|
||||
.catch(error => {
|
||||
this.modalError(error) // Let mixin handle error
|
||||
})
|
||||
.finally(() => {
|
||||
console.log("Cleaning up after task.")
|
||||
this.taskRunning = false
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
computed: {
|
||||
pluginApiUri: function () {
|
||||
return this.$store.getters.uri + "/plugin"
|
||||
},
|
||||
|
||||
submitApiUri: function () {
|
||||
return this.$store.getters.uri + this.route
|
||||
return this.pluginApiUri + this.route
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue