Mercurial > gemma
diff client/src/store/imports.js @ 1889:b6d0460b069d
define stretches: Now with store-backend
At present added stretches are stored in vuex.
In addition to that, logic for persistence is provided
but is currently commented out.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 18 Jan 2019 10:04:55 +0100 |
parents | 954a099425df |
children | 1aa864cccddc |
line wrap: on
line diff
--- a/client/src/store/imports.js Fri Jan 18 09:47:05 2019 +0100 +++ b/client/src/store/imports.js Fri Jan 18 10:04:55 2019 +0100 @@ -97,6 +97,7 @@ // initial state const init = () => { return { + stretches: [], imports: [], staging: [], schedules: [], @@ -111,6 +112,13 @@ namespaced: true, state: init(), mutations: { + setStretches: (state, stretches) => { + state.stretches = stretches; + }, + // only for prototype purposes delete after real backend is active + addStretch: (state, stretch) => { + state.stretches.push(stretch); + }, clearCurrentSchedule: state => { state.currentSchedule = initializeCurrentSchedule(); }, @@ -210,6 +218,36 @@ } }, actions: { + loadStretches({ commit }) { + throw new Error("Not active"); + return new Promise((resolve, reject) => { + HTTP.get("/imports/stretches", { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }) + .then(response => { + commit("setStretches", response.data); + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, + saveStretch({ commit }, stretch) { + throw new Error("Not active"); + return new Promise((resolve, reject) => { + HTTP.post("/imports/stretches", stretch, { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }) + .then(response => { + commit("setStretches", response.data); + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, loadSchedule({ commit }, id) { return new Promise((resolve, reject) => { HTTP.get("/imports/config/" + id, {