Added plugin schemas to Vuex store

This commit is contained in:
Joel Collins 2019-06-14 17:40:40 +01:00
parent e60fd375e3
commit 36eb3b4396

View file

@ -15,6 +15,7 @@ export default new Vuex.Store({
error: '',
apiConfig: {},
apiState: {},
apiPlugins: [],
globalSettings: {
disableStream: false,
autoGpuPreview: false,
@ -38,6 +39,9 @@ export default new Vuex.Store({
commitState(state, stateData) {
state.apiState = stateData;
},
commitPlugins(state, pluginData) {
state.apiPlugins = pluginData;
},
changeSetting(state, [key, value]) {
state.globalSettings[key] = value;
},
@ -47,6 +51,7 @@ export default new Vuex.Store({
state.error = null
state.apiConfig = {}
state.apiState = {}
state.apiPlugins = []
},
setConnected(state) {
state.waiting = false
@ -72,6 +77,9 @@ export default new Vuex.Store({
.then (() => {
context.dispatch('updateState')
})
.then (() => {
context.dispatch('updatePlugins')
})
.then (() => {
resolve()
})
@ -116,6 +124,25 @@ export default new Vuex.Store({
return new Promise(sendRequest)
},
updatePlugins(context, uri=`${context.getters.uri}/plugin`) {
context.commit('changeWaiting', true)
var sendRequest = function(resolve, reject) {
axios.get(uri)
.then(response => {
console.log("PLUGINS")
console.log(response.data)
context.commit('commitPlugins', response.data)
context.commit('setConnected')
resolve()
})
.catch(error => {
reject(new Error(error))
})
}
return new Promise(sendRequest)
},
pollTask(context, [taskId, timeout, interval]) {
var endTime = Number(new Date()) + (timeout*1000 || 30000);
interval = interval*1000 || 500;