Mercurial > gemma
diff client/src/store/application.js @ 3625:a688a478e35f configuration
implemented configuration backend and frontend
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 07 Jun 2019 12:53:41 +0200 |
parents | 30a9fdac70f0 |
children | 67984bf6dba6 |
line wrap: on
line diff
--- a/client/src/store/application.js Wed Jun 05 18:50:54 2019 +0200 +++ b/client/src/store/application.js Fri Jun 07 12:53:41 2019 +0200 @@ -14,6 +14,8 @@ * Bernhard E. Reiter <bernhard.reiter@intevation.de> */ +import { HTTP } from "@/lib/http"; +import { displayError } from "@/lib/errors"; import { version } from "../../package.json"; // initial state @@ -140,85 +142,26 @@ } }, actions: { - loadConfig({ commit, state }) { - if (!Object.keys(state.config).length) { - setTimeout(() => { - commit("config", { - ecdis_url: "https://service.d4d-portal.info/wms/", - bn_revtime_multiplier: 1.5, - gm_min_values_14d: 1124, - gm_latest_hours: 24, - gm_forecast_offset_24h: 15, - gm_forecast_offset_72h: 15, - gm_forecast_vs_reality_nsc_24h: -12.5, - gm_forecast_vs_reality_nsc_72h: -12.5, - morphology_classbreaks: [ - 1, - 1.5, - 1.7, - 1.9, - 2.1, - 2.3, - 2.5, - 2.7, - 2.9, - 3.1, - 3.3, - 3.5, - 4.0, - 4.5, - 5, - 5.5, - 6, - 6.5, - 7 - ], - morphology_classbreaks_compare: [ - -2, - -1.9, - -1.8, - -1.7, - -1.6, - -1.5, - -1.4, - -1.3, - -1.2, - -1.1, - -1, - -0.9, - -0.8, - -0.7, - -0.6, - -0.5, - -0.4, - -0.3, - -0.2, - -0.1, - 0, - 0.1, - 0.2, - 0.3, - 0.4, - 0.5, - 0.6, - 0.7, - 0.8, - 0.9, - 1, - 1.1, - 1.2, - 1.3, - 1.4, - 1.5, - 1.6, - 1.7, - 1.8, - 1.9, - 2 - ] - }); - }, 1000); - } + loadConfig({ commit }) { + HTTP.get("/system/settings", { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }).then(response => { + commit("config", response.data); + }); + }, + saveConfig(context, config) { + HTTP.put("/system/settings", config, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "application/json" + } + }).catch(error => { + const { status, data } = error.response; + displayError({ + title: "Backend Error", + message: `${status}: ${data.message || data}` + }); + }); } } };