diff --git a/src/store.js b/src/store.js index 5197cfb1..aa1a67dd 100644 --- a/src/store.js +++ b/src/store.js @@ -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;