diff --git a/src/store/files/mutations.js b/src/store/files/mutations.js index 8c7aa752..07a0f3c5 100644 --- a/src/store/files/mutations.js +++ b/src/store/files/mutations.js @@ -2,6 +2,7 @@ import Vue from 'vue' import { getDefaultState } from './index' import { findDirectory } from "@/plugins/helpers" import store from "@/store"; +import axios from "axios"; export default { reset(state) { @@ -56,10 +57,20 @@ export default { }) } + if (file.filename === ".mainsail.json" && payload.requestParams.path === "config") { + fetch('//'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/config/.mainsail.json?time='+Date.now()) + .then(res => res.json()).then(file => { + this.commit('gui/setData', file, { root: true }) + }) + } + if (file.filename === "gui.json" && payload.requestParams.path === "config") { fetch('//'+store.state.socket.hostname+':'+store.state.socket.port+'/server/files/config/gui.json?time='+Date.now()) .then(res => res.json()).then(file => { - this.commit('gui/setData', file, { root: true }); + this.commit('gui/setData', file, { root: true }) + this.dispatch('gui/upload', {}, { root: true }) + + axios.delete('//'+ store.state.socket.hostname+':'+store.state.socket.port +'/server/files/config/gui.json'); }) } } diff --git a/src/store/gui/actions.js b/src/store/gui/actions.js index 85c64304..8c6fe3ee 100644 --- a/src/store/gui/actions.js +++ b/src/store/gui/actions.js @@ -15,7 +15,7 @@ export default { }, upload({ state, rootState }) { - let file = new File([JSON.stringify({ state })], 'gui.json'); + let file = new File([JSON.stringify({ state })], '.mainsail.json'); let formData = new FormData(); formData.append('file', file); @@ -26,9 +26,9 @@ export default { headers: { 'Content-Type': 'multipart/form-data' } } ).then(() => { - window.console.info("gui.json successfully uploaded") + window.console.info(".mainsail.json successfully uploaded") }).catch(() => { - window.console.error("Error save gui.json!") + window.console.error("Error save .mainsail.json!") }); },