Mercurial > gemma
changeset 3617:bcf9713ee359
client: configuration: prepared fetching data accuracy values from backend
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Wed, 05 Jun 2019 14:57:44 +0200 |
parents | 307ddc52a5b9 |
children | c03170a1c333 |
files | client/src/components/systemconfiguration/DataAccuracy.vue client/src/lib/classifications.js client/src/router.js client/src/store/application.js |
diffstat | 4 files changed, 75 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/systemconfiguration/DataAccuracy.vue Wed Jun 05 14:10:57 2019 +0200 +++ b/client/src/components/systemconfiguration/DataAccuracy.vue Wed Jun 05 14:57:44 2019 +0200 @@ -36,7 +36,7 @@ min="1" class="form-control form-control-sm mx-1" style="width: 60px" - v-model="bn_revtime_multiplier" + v-model="config.bn_revtime_multiplier" /> <translate>times the revisiting time.</translate> </div> @@ -49,7 +49,9 @@ > <span v-translate="{ - multiplier: Number(bn_revtime_multiplier).toLocaleString() + multiplier: Number( + config.bn_revtime_multiplier + ).toLocaleString() }" >The latest survey is older than <b>%{multiplier}</b> times the revisiting time.</span @@ -70,8 +72,8 @@ > <span v-translate="{ - hours: Number(gm_latest_hours).toLocaleString(), - values: Number(gm_min_values_14d).toLocaleString() + hours: Number(config.gm_latest_hours).toLocaleString(), + values: Number(config.gm_min_values_14d).toLocaleString() }" >The latest measurement is not older than <b>%{hours}</b> hours and there are at least @@ -94,7 +96,7 @@ min="1" class="form-control form-control-sm mx-1" style="width: 70px" - v-model="gm_min_values_14d" + v-model="config.gm_min_values_14d" /> <translate>measurements in the last 14 days.</translate> </div> @@ -113,7 +115,7 @@ min="1" class="form-control form-control-sm mx-1" style="width: 55px" - v-model="gm_latest_hours" + v-model="config.gm_latest_hours" /> <translate>days.</translate> </div> @@ -133,8 +135,10 @@ > <span v-translate="{ - gm24: Number(gm_forecast_offset_24h).toLocaleString(), - gm72: Number(gm_forecast_offset_72h).toLocaleString() + gm24: Number( + config.gm_forecast_offset_24h + ).toLocaleString(), + gm72: Number(config.gm_forecast_offset_72h).toLocaleString() }" >The highest confidence value is less than <b>%{gm24} cm</b> @@ -162,7 +166,7 @@ min="1" class="form-control form-control-sm mx-1" style="width: 55px" - v-model="gm_forecast_offset_72h" + v-model="config.gm_forecast_offset_72h" /> cm. </div> @@ -184,7 +188,7 @@ min="1" class="form-control form-control-sm mx-1" style="width: 55px" - v-model="gm_forecast_offset_24h" + v-model="config.gm_forecast_offset_24h" /> cm. </div> @@ -205,10 +209,10 @@ <span v-translate="{ nsc24: Number( - gm_forecast_vs_reality_nsc_24h + config.gm_forecast_vs_reality_nsc_24h ).toLocaleString(), nsc72: Number( - gm_forecast_vs_reality_nsc_72h + config.gm_forecast_vs_reality_nsc_72h ).toLocaleString() }" >The Nash-Sutcliffe coefficient is greater than @@ -236,7 +240,7 @@ step="0.1" class="form-control form-control-sm mx-1" style="width: 70px" - v-model="gm_forecast_vs_reality_nsc_72h" + v-model="config.gm_forecast_vs_reality_nsc_72h" /> </div> </div> @@ -256,7 +260,7 @@ step="0.1" class="form-control form-control-sm mx-1" style="width: 70px" - v-model="gm_forecast_vs_reality_nsc_24h" + v-model="config.gm_forecast_vs_reality_nsc_24h" /> </div> </div> @@ -318,21 +322,15 @@ * Markus Kottländer <markus@intevation.de> */ +import { mapState } from "vuex"; + export default { - data() { - return { - 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 - }; + computed: { + ...mapState("application", ["config"]) }, methods: { submit() { - console.log(this.bottleneck_surveys_revtime_multiplier); + this.$store.commit("application/config", this.config); } } };
--- a/client/src/lib/classifications.js Wed Jun 05 14:10:57 2019 +0200 +++ b/client/src/lib/classifications.js Wed Jun 05 14:57:44 2019 +0200 @@ -10,7 +10,9 @@ * * Author(s): * Raimund Renkert <raimund.renkert@intevation.de> + * Markus Kottländer <markus.kottlaender@intevation.de> */ +import store from "@/store/index"; const getGauge = f => { if (f.getId().indexOf("bottlenecks") > -1) { @@ -33,11 +35,13 @@ let revTime = bottleneck.get("revisiting_time") * 30.5; let latest = Date.parse(bottleneck.get("date_max").replace("Z", "")); var diff = Math.floor((Date.now() - latest) / 86400000); + let revTimeMultiplier = + store.state.application.config.bn_revtime_multiplier; if (diff <= revTime) { return "lime"; - } else if (revTime < diff && diff <= revTime * 1.5) { + } else if (revTime < diff && diff <= revTime * revTimeMultiplier) { return "yellow"; - } else if (revTime * 1.5 < diff) { + } else if (revTime * revTimeMultiplier < diff) { return "red"; } }, @@ -48,11 +52,13 @@ if ( gmDate !== undefined && gmDate !== null && - Date.parse(gmDate) > Date.now() - 86400000 // latest value within 24 h + // latest measurement within configured hours + Date.parse(gmDate) > + Date.now() - + store.state.application.config.gm_latest_hours * 60 * 60 * 1000 ) { - // 1344: one value every 15 min in 14 days, but the Hydra says: - // let 85% be enough for now. - const valuesAtLeast = 1124; + // at least configured amount of measurements in last 14 days + const valuesAtLeast = store.state.application.config.gm_min_values_14d; if (gmN !== undefined && gmN !== null && gmN >= valuesAtLeast) { return "lime"; } @@ -65,9 +71,9 @@ let fa3d = gauge.get("forecast_accuracy_3d"); let fa1d = gauge.get("forecast_accuracy_1d"); if (typeof fa3d == "number" && typeof fa1d == "number") { - if (fa1d > 15) { + if (fa1d > store.state.application.config.gm_forecast_offset_24h) { return "red"; - } else if (fa3d > 15) { + } else if (fa3d > store.state.application.config.gm_forecast_offset_72h) { return "yellow"; } else { return "lime"; @@ -79,11 +85,21 @@ let gauge = getGauge(feature); let nsc = gauge.get("nsc_data"); if (nsc && nsc.coeffs.reduce((sum, coeff) => sum + coeff.samples, 0)) { - // 24h < 12.5 - if (nsc.coeffs[0].samples && nsc.coeffs[0].value < -12.5) return "red"; - // 72h < 12.5 - if (nsc.coeffs[2].samples && nsc.coeffs[2].value < -12.5) return "yellow"; - // both > 12.5 + // 24h < configured value + if ( + nsc.coeffs[0].samples && + nsc.coeffs[0].value < + store.state.application.config.gm_forecast_vs_reality_nsc_24h + ) + return "red"; + // 72h < configured value + if ( + nsc.coeffs[2].samples && + nsc.coeffs[2].value < + store.state.application.config.gm_forecast_vs_reality_nsc_72h + ) + return "yellow"; + // both > configured value return "lime"; } // no data available
--- a/client/src/router.js Wed Jun 05 14:10:57 2019 +0200 +++ b/client/src/router.js Wed Jun 05 14:57:44 2019 +0200 @@ -213,6 +213,7 @@ store.commit("user/setExpires", expiresFromPastSession); store.commit("user/setRoles", localStorage.getItem("roles")); store.commit("user/setIsAuthenticate", true); + store.dispatch("application/loadConfig"); } else { store.commit("reset"); store.commit("user/clearAuth");
--- a/client/src/store/application.js Wed Jun 05 14:10:57 2019 +0200 +++ b/client/src/store/application.js Wed Jun 05 14:57:44 2019 +0200 @@ -43,7 +43,8 @@ countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"], searchQuery: "", version, - tempRoute: "" + tempRoute: "", + config: {} }; }; @@ -133,6 +134,26 @@ }, searchQuery: (state, searchQuery) => { state.searchQuery = searchQuery; + }, + config: (state, config) => { + state.config = config; + } + }, + actions: { + loadConfig({ commit, state }) { + if (!Object.keys(state.config).length) { + setTimeout(() => { + commit("config", { + 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 + }); + }, 1000); + } } } };