# HG changeset patch # User Markus Kottlaender # Date 1553185863 -3600 # Node ID 71e7237110baa7fe0cb09cad00f5209a2c03341a # Parent c6fba10926cc87127b070b20412c8a22303e8ab4 client: spuc8: prepared diagram diff -r c6fba10926cc -r 71e7237110ba client/src/components/gauge/Gauges.vue --- a/client/src/components/gauge/Gauges.vue Thu Mar 21 17:04:37 2019 +0100 +++ b/client/src/components/gauge/Gauges.vue Thu Mar 21 17:31:03 2019 +0100 @@ -68,7 +68,11 @@ Show Waterlevels
- @@ -149,6 +153,9 @@ if (this.activeSplitscreenId === "gauge-waterlevel") { this.showWaterlevelDiagram(); } + if (this.activeSplitscreenId === "gauge-hydrological-conditions") { + this.showHydrologicalConditionsDiagram(); + } } }, methods: { @@ -212,6 +219,53 @@ this.loading = false; }); }, + showHydrologicalConditionsDiagram() { + // for panning the map to the gauge on opening the diagram: needs to be + // set outside of the expandCallback to not always refer to the currently + // selectedGauge + let coordinates = this.selectedGauge.geometry.coordinates; + + // configure splitscreen + let splitscreenConf = { + id: "gauge-hydrological-conditions", + component: "hydrological-conditions", + title: + this.$gettext("Hydrological Conditions") + + ": " + + this.gaugeLabel(this.selectedGauge), + icon: "ruler-vertical", + closeCallback: () => { + this.$store.commit("gauges/selectedGaugeISRS", null); + this.$store.commit("gauges/meanWaterlevels", []); + }, + expandCallback: () => { + this.$store.commit("map/moveMap", { + coordinates, + zoom: 17, + preventZoomOut: true + }); + } + }; + this.$store.commit("application/addSplitscreen", splitscreenConf); + this.$store.commit("application/activeSplitscreenId", splitscreenConf.id); + this.$store.commit("application/splitscreenLoading", true); + this.loading = true; + this.$store.commit("application/showSplitscreen", true); + + this.$store + .dispatch("gauges/loadMeanWaterlevels") + .catch(error => { + const { status, data } = error.response; + displayError({ + title: "Backend Error", + message: `${status}: ${data.message || data}` + }); + }) + .finally(() => { + this.$store.commit("application/splitscreenLoading", false); + this.loading = false; + }); + }, gaugeLabel(gauge) { return `${gauge.properties.objname} (${this.isrsInfo(gauge).orc})`; }, diff -r c6fba10926cc -r 71e7237110ba client/src/components/gauge/HydrologicalConditions.vue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/gauge/HydrologicalConditions.vue Thu Mar 21 17:31:03 2019 +0100 @@ -0,0 +1,394 @@ + + + + + diff -r c6fba10926cc -r 71e7237110ba client/src/components/gauge/Waterlevel.vue --- a/client/src/components/gauge/Waterlevel.vue Thu Mar 21 17:04:37 2019 +0100 +++ b/client/src/components/gauge/Waterlevel.vue Thu Mar 21 17:31:03 2019 +0100 @@ -178,7 +178,7 @@ y = d3.scaleLinear().range([mainHeight, 0]), y2 = d3.scaleLinear().range([navHeight, 0]); // find min/max values for the waterlevel axis - // including hdc/ldc (+/- 100 cm) + // including HDC (+ 1/8 HDC-LDC) and LDC (- 1/4 HDC-LDC) let WaterlevelMinMax = d3.extent( [ ...this.waterlevels, diff -r c6fba10926cc -r 71e7237110ba client/src/components/splitscreen/Splitscreen.vue --- a/client/src/components/splitscreen/Splitscreen.vue Thu Mar 21 17:04:37 2019 +0100 +++ b/client/src/components/splitscreen/Splitscreen.vue Thu Mar 21 17:31:03 2019 +0100 @@ -63,7 +63,9 @@ export default { components: { Fairwayprofile: () => import("@/components/fairway/Fairwayprofile"), - Waterlevel: () => import("@/components/gauge/Waterlevel") + Waterlevel: () => import("@/components/gauge/Waterlevel"), + HydrologicalConditions: () => + import("@/components/gauge/HydrologicalConditions") }, computed: { ...mapState("application", ["showSplitscreen", "splitscreenLoading"]), diff -r c6fba10926cc -r 71e7237110ba client/src/store/gauges.js --- a/client/src/store/gauges.js Thu Mar 21 17:04:37 2019 +0100 +++ b/client/src/store/gauges.js Thu Mar 21 17:31:03 2019 +0100 @@ -22,6 +22,7 @@ gauges: [], selectedGaugeISRS: null, waterlevels: [], + meanWaterlevels: [], nashSutcliffe: null, dateFrom: dateFrom, dateTo: new Date() @@ -49,6 +50,9 @@ waterlevels: (state, data) => { state.waterlevels = data; }, + meanWaterlevels: (state, data) => { + state.meanWaterlevels = data; + }, nashSutcliffe: (state, data) => { state.nashSutcliffe = data; }, @@ -129,6 +133,27 @@ }); }); }, + loadMeanWaterlevels({ /*state,*/ commit }) { + return new Promise(resolve => { + setTimeout(() => { + commit("meanWaterlevels", [1]); + resolve(); + }, 2000); + }); + // return new Promise((resolve, reject) => { + // HTTP.get(`/data/mean-waterlevels/${state.selectedGaugeISRS}`, { + // headers: { "X-Gemma-Auth": localStorage.getItem("token") } + // }) + // .then(response => { + // commit("meanWaterlevels", response.data); + // resolve(response.data); + // }) + // .catch(error => { + // commit("meanWaterlevels", []); + // reject(error); + // }) + // }); + }, loadNashSutcliffe({ state, commit }) { return new Promise((resolve, reject) => { HTTP.get(`/data/nash-sutcliffe/${state.selectedGaugeISRS}`, {