Mercurial > gemma
diff client/src/store/imports.js @ 1724:79a18eb1672b
import: POC import saveable
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 09 Jan 2019 10:18:35 +0100 |
parents | 1b25e7a3a92e |
children | b24a54c684bd |
line wrap: on
line diff
--- a/client/src/store/imports.js Tue Jan 08 20:11:12 2019 +0100 +++ b/client/src/store/imports.js Wed Jan 09 10:18:35 2019 +0100 @@ -31,8 +31,16 @@ MONTHLY: "monthly" }; +const IMPORTTYPEKIND = { + bottleneck: "bn", + fairwayawailability: "fa", + gaugemeasurement: "ga", + waterwayaxis: "wx" +}; + const initializeCurrentSchedule = () => { return { + id: null, importType: null, schedule: null, import_: null, @@ -111,7 +119,53 @@ } }, actions: { - getSchedules({ commit }) { + deleteSchedule({ commit }, id) { + return new Promise((resolve, reject) => { + HTTP.delete("imports/config/" + id, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, + saveCurrentSchedule({ commit }, data) { + return new Promise((resolve, reject) => { + const create = true; + if (create) { + HTTP.post("imports/config", data, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); + } else { + const { id } = data; + HTTP.patch("imports/config/" + id, data, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }) + .then(response => { + resolve(response); + }) + .catch(error => { + reject(error); + }); + } + }); + }, + loadSchedules({ commit }) { return new Promise((resolve, reject) => { HTTP.get("/imports/config", { headers: { "X-Gemma-Auth": localStorage.getItem("token") } @@ -171,4 +225,4 @@ } }; -export { imports, STATES, SCHEDULES, IMPORTTYPES }; +export { imports, STATES, SCHEDULES, IMPORTTYPES, IMPORTTYPEKIND };