Mercurial > gemma
comparison 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 |
comparison
equal
deleted
inserted
replaced
3624:3012d0b3badc | 3625:a688a478e35f |
---|---|
12 * Thomas Junk <thomas.junk@intevation.de> | 12 * Thomas Junk <thomas.junk@intevation.de> |
13 * Markus Kottländer <markus.kottlaender@intevation.de> | 13 * Markus Kottländer <markus.kottlaender@intevation.de> |
14 * Bernhard E. Reiter <bernhard.reiter@intevation.de> | 14 * Bernhard E. Reiter <bernhard.reiter@intevation.de> |
15 */ | 15 */ |
16 | 16 |
17 import { HTTP } from "@/lib/http"; | |
18 import { displayError } from "@/lib/errors"; | |
17 import { version } from "../../package.json"; | 19 import { version } from "../../package.json"; |
18 | 20 |
19 // initial state | 21 // initial state |
20 const init = () => { | 22 const init = () => { |
21 return { | 23 return { |
138 config: (state, config) => { | 140 config: (state, config) => { |
139 state.config = config; | 141 state.config = config; |
140 } | 142 } |
141 }, | 143 }, |
142 actions: { | 144 actions: { |
143 loadConfig({ commit, state }) { | 145 loadConfig({ commit }) { |
144 if (!Object.keys(state.config).length) { | 146 HTTP.get("/system/settings", { |
145 setTimeout(() => { | 147 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
146 commit("config", { | 148 }).then(response => { |
147 ecdis_url: "https://service.d4d-portal.info/wms/", | 149 commit("config", response.data); |
148 bn_revtime_multiplier: 1.5, | 150 }); |
149 gm_min_values_14d: 1124, | 151 }, |
150 gm_latest_hours: 24, | 152 saveConfig(context, config) { |
151 gm_forecast_offset_24h: 15, | 153 HTTP.put("/system/settings", config, { |
152 gm_forecast_offset_72h: 15, | 154 headers: { |
153 gm_forecast_vs_reality_nsc_24h: -12.5, | 155 "X-Gemma-Auth": localStorage.getItem("token"), |
154 gm_forecast_vs_reality_nsc_72h: -12.5, | 156 "Content-type": "application/json" |
155 morphology_classbreaks: [ | 157 } |
156 1, | 158 }).catch(error => { |
157 1.5, | 159 const { status, data } = error.response; |
158 1.7, | 160 displayError({ |
159 1.9, | 161 title: "Backend Error", |
160 2.1, | 162 message: `${status}: ${data.message || data}` |
161 2.3, | 163 }); |
162 2.5, | 164 }); |
163 2.7, | |
164 2.9, | |
165 3.1, | |
166 3.3, | |
167 3.5, | |
168 4.0, | |
169 4.5, | |
170 5, | |
171 5.5, | |
172 6, | |
173 6.5, | |
174 7 | |
175 ], | |
176 morphology_classbreaks_compare: [ | |
177 -2, | |
178 -1.9, | |
179 -1.8, | |
180 -1.7, | |
181 -1.6, | |
182 -1.5, | |
183 -1.4, | |
184 -1.3, | |
185 -1.2, | |
186 -1.1, | |
187 -1, | |
188 -0.9, | |
189 -0.8, | |
190 -0.7, | |
191 -0.6, | |
192 -0.5, | |
193 -0.4, | |
194 -0.3, | |
195 -0.2, | |
196 -0.1, | |
197 0, | |
198 0.1, | |
199 0.2, | |
200 0.3, | |
201 0.4, | |
202 0.5, | |
203 0.6, | |
204 0.7, | |
205 0.8, | |
206 0.9, | |
207 1, | |
208 1.1, | |
209 1.2, | |
210 1.3, | |
211 1.4, | |
212 1.5, | |
213 1.6, | |
214 1.7, | |
215 1.8, | |
216 1.9, | |
217 2 | |
218 ] | |
219 }); | |
220 }, 1000); | |
221 } | |
222 } | 165 } |
223 } | 166 } |
224 }; | 167 }; |