Mercurial > gemma
changeset 5572:3b842e951317 surveysperbottleneckid
change use from name of bottleneck to its id.
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 20 Jul 2021 17:07:51 +0200 |
parents | 9321d9fb719f |
children | 5d95f3b7c45f |
files | client/src/components/Bottlenecks.vue client/src/components/Pdftool.vue client/src/components/fairway/AvailableFairwayDepthDialogue.vue client/src/components/fairway/BottleneckDialogue.vue client/src/components/fairway/Fairwayprofile.vue client/src/components/importoverview/SoundingResultDetail.vue client/src/components/map/MapPopup.vue client/src/store/bottlenecks.js client/src/store/fairwayprofile.js pkg/controllers/surveys.go |
diffstat | 10 files changed, 60 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Bottlenecks.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/Bottlenecks.vue Tue Jul 20 17:07:51 2021 +0200 @@ -138,7 +138,7 @@ this.$store .dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.properties.name + bottleneck.properties.bottleneck_id ) .then(() => { this.$store.commit("bottlenecks/selectedSurvey", survey); @@ -155,7 +155,7 @@ this.$store .dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.properties.name + bottleneck.properties.bottleneck_id ) .then(() => { this.$store.dispatch("map/moveToFeauture", { @@ -175,12 +175,15 @@ this.openBottleneckSurveys = null; } else { this.loading = bottleneck; - HTTP.get("/surveys/" + encodeURIComponent(bottleneck.properties.name), { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-type": "text/xml; charset=UTF-8" + HTTP.get( + "/surveys/" + encodeURIComponent(bottleneck.properties.bottleneck_id), + { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-type": "text/xml; charset=UTF-8" + } } - }) + ) .then(response => { this.openBottleneckSurveys = response.data.surveys.sort((a, b) => { return a.date_info < b.date_info ? 1 : -1;
--- a/client/src/components/Pdftool.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/Pdftool.vue Tue Jul 20 17:07:51 2021 +0200 @@ -826,7 +826,7 @@ this.pdf.doc.setTextColor(color); let textOptions = { baseline: "hanging" }; let str1_1 = this.$gettext("Bottleneck") + ": "; - let str1_2 = this.selectedBottleneck; + let str1_2 = this.bottleneckForPrint; let str2_1 = this.$gettext("Survey date") + ": "; let str2_2 = survey.date_info + " (" + SURVEYTYPES[survey["survey_type"]] + ")";
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Tue Jul 20 17:07:51 2021 +0200 @@ -659,11 +659,11 @@ .setVisible(true); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - this.selectedFairwayAvailabilityFeature.properties.name + this.selectedFairwayAvailabilityFeature.properties.bottleneck_id ); this.$store.commit( "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + this.selectedFairwayAvailabilityFeature.properties.bottleneck_id ); } if (this.type === this.$options.STRETCH) { @@ -833,7 +833,7 @@ }, setSelectedBottleneck() { const bn = this.bottlenecksList.filter( - x => x.properties.name === this.selectedBottleneck + x => x.properties.bottleneck_id === this.selectedBottleneck )[0]; this.$store.commit( "fairwayavailability/setSelectedFairwayAvailability",
--- a/client/src/components/fairway/BottleneckDialogue.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/fairway/BottleneckDialogue.vue Tue Jul 20 17:07:51 2021 +0200 @@ -29,7 +29,7 @@ <option v-for="bn in bottlenecksForCountry" :key="bn.properties.id" - :value="bn.properties.name" + :value="bn.properties.bottleneck_id" > {{ bn.properties.name }} </option> @@ -373,7 +373,7 @@ isAllowedToDelete() { const userCountryCode = this.userCountries[this.user]; const bottleneck = this.bottlenecksList.find( - bn => bn.properties.name === this.selectedBottleneck + bn => bn.properties.bottleneck_id === this.selectedBottleneck ); if (!bottleneck) return; if (this.isWaterwayAdmin || this.isSysAdmin) { @@ -421,8 +421,11 @@ get() { return this.$store.state.bottlenecks.selectedBottleneck; }, - set(name) { - this.$store.dispatch("bottlenecks/setSelectedBottleneck", name); + set(bottleneck_id) { + this.$store.dispatch( + "bottlenecks/setSelectedBottleneck", + bottleneck_id + ); } }, selectedWaterLevel: { @@ -517,7 +520,7 @@ .getLayer("BOTTLENECKS") .getSource() .getFeatures() - .find(f => f.get("objnam") === this.selectedBottleneck) + .find(f => f.get("bottleneck_id") === this.selectedBottleneck) : null; } }, @@ -525,7 +528,7 @@ selectedBottleneck() { this.$store.dispatch("fairwayprofile/previousCuts"); this.cutLabel = - this.selectedBottleneck + " (" + new Date().toISOString() + ")"; + this.bottleneck.get("objnam") + " (" + new Date().toISOString() + ")"; }, selectedSurvey(survey) { this.loadProfile(survey); @@ -726,7 +729,8 @@ JSON.parse(localStorage.getItem("previousCuts")) || []; const newEntry = { label: this.cutLabel, - bottleneckName: this.selectedBottleneck, + bottleneckName: this.bottleneck.get("objnam"), + bottleneckId: this.bottleneck.get("bottleneck_id"), coordinates: [...this.startPoint, ...this.endPoint], timestamp: new Date().getTime(), depth: this.depth, @@ -739,7 +743,6 @@ if (previousCuts.length > 100) previousCuts.shift(); localStorage.setItem("previousCuts", JSON.stringify(previousCuts)); this.$store.dispatch("fairwayprofile/previousCuts"); - this.showLabelInput = false; displayInfo({ title: this.$gettext("Profile saved!"), @@ -811,12 +814,12 @@ }, takeMeThere() { const bottleneck = this.bottlenecksList.find( - bn => bn.properties.name === this.selectedBottleneck + bn => bn.properties.bottleneck_id === this.selectedBottleneck ); if (!bottleneck) return; this.$store.commit( "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + bottleneck.properties.name ); this.$store.dispatch("map/moveToFeauture", { feature: bottleneck,
--- a/client/src/components/fairway/Fairwayprofile.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/fairway/Fairwayprofile.vue Tue Jul 20 17:07:51 2021 +0200 @@ -239,9 +239,9 @@ this.waterlevelValid && this.refWaterlevelValid ? `${this.$options.filters.waterlevel(this.waterlevel)} m` : this.$gettext("No valid value available"); - return `${this.$gettext("Fairwayprofile")}: ${ - this.selectedBottleneck - } (${dates.join( + return `${this.$gettext("Fairwayprofile")}: ${this.bottleneck.get( + "objnam" + )} (${dates.join( ", " )}) WL: ${waterlevelLabel} ( ${waterlevelMeasurement} )`; }, @@ -266,7 +266,7 @@ .getLayer("BOTTLENECKS") .getSource() .getFeatures() - .find(f => f.get("objnam") === this.selectedBottleneck); + .find(f => f.get("bottleneck_id") === this.selectedBottleneck); }, waterlevel() { return this.selectedWaterLevel === "ref" @@ -286,7 +286,7 @@ fileName() { return this.downloadFilename( this.$gettext("Fairwayprofile"), - this.selectedBottleneck + this.bottleneck.get("objnam") ); } }, @@ -446,7 +446,10 @@ }, downloadPDF() { let fairwayInfo = - this.selectedBottleneck + " (" + this.selectedSurvey.date_info + ")"; + this.bottleneck.get("objnam") + + " (" + + this.selectedSurvey.date_info + + ")"; this.generatePDF({ templateData: this.templateData, diagramTitle: fairwayInfo
--- a/client/src/components/importoverview/SoundingResultDetail.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/importoverview/SoundingResultDetail.vue Tue Jul 20 17:07:51 2021 +0200 @@ -56,7 +56,7 @@ preventZoomOut: true }); this.$store - .dispatch("bottlenecks/setSelectedBottleneck", bottleneck) + .dispatch("bottlenecks/setSelectedBottleneck", bottleneck) //This has to be changed to bottleneck_id .then(() => { this.$store.commit("bottlenecks/setSelectedSurveyByDate", date); });
--- a/client/src/components/map/MapPopup.vue Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/components/map/MapPopup.vue Tue Jul 20 17:07:51 2021 +0200 @@ -180,7 +180,7 @@ this.$store.commit("application/showProfiles", true); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.get("objnam") + bottleneck.get("bottleneck_id") ); this.$store.dispatch("map/moveToBoundingBox", { boundingBox: bottleneck @@ -190,10 +190,10 @@ .getExtent(), zoom: 16 }); - this.$store.commit( - "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + const bn = this.bottlenecks.find( + b => b.get("bottleneck_id") == this.selectedBottleneck ); + this.$store.commit("bottlenecks/setBottleneckForPrint", bn.name); this.close(); }, openGauges(gauge) { @@ -209,7 +209,7 @@ this.$store.commit("fairwayavailability/type", TYPES.BOTTLENECK); this.$store.dispatch( "bottlenecks/setSelectedBottleneck", - bottleneck.get("objnam") + bottleneck.get("bottleneck_id") ); this.$store.dispatch("map/moveToBoundingBox", { boundingBox: bottleneck @@ -219,10 +219,10 @@ .getExtent(), zoom: 16 }); - this.$store.commit( - "bottlenecks/setBottleneckForPrint", - this.selectedBottleneck + const bn = this.bottlenecks.find( + b => b.bottleneck_id == this.selectedBottleneck ); + this.$store.commit("bottlenecks/setBottleneckForPrint", bn.name); this.openFairwayAvailability(); }, openFairwayAvailabilityForStretch(stretch) {
--- a/client/src/store/bottlenecks.js Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/store/bottlenecks.js Tue Jul 20 17:07:51 2021 +0200 @@ -14,8 +14,8 @@ */ import { HTTP } from "@/lib/http"; import { WFS } from "ol/format"; +import { compareAsc } from "date-fns"; import { displayError } from "@/lib/errors"; -import { compareAsc } from "date-fns"; // initial state const init = () => { return { @@ -77,8 +77,8 @@ setBottlenecksList: (state, bottlenecksList) => { state.bottlenecksList = bottlenecksList; }, - setSelectedBottleneck: (state, name) => { - state.selectedBottleneck = name; + setSelectedBottleneck: (state, value) => { + state.selectedBottleneck = value; }, setSurveys(state, surveys) { state.surveys = surveys; @@ -98,9 +98,9 @@ } }, actions: { - setSelectedBottleneck({ state, commit, rootState }, name) { + setSelectedBottleneck({ state, commit, rootState }, id) { return new Promise((resolve, reject) => { - if (name !== state.selectedBottleneck) { + if (id !== state.selectedBottleneck) { commit("selectedSurvey", null); commit("fairwayprofile/additionalSurvey", null, { root: true }); commit("fairwayprofile/clearCurrentProfile", null, { root: true }); @@ -111,10 +111,10 @@ .clear(); }); } - commit("setSelectedBottleneck", name); - if (name) { + commit("setSelectedBottleneck", id); + if (id) { commit("surveysLoading", true); - HTTP.get("/surveys/" + encodeURIComponent(name), { + HTTP.get("/surveys/" + encodeURIComponent(id), { headers: { "X-Gemma-Auth": localStorage.getItem("token"), "Content-type": "text/xml; charset=UTF-8"
--- a/client/src/store/fairwayprofile.js Tue Jul 20 11:50:17 2021 +0200 +++ b/client/src/store/fairwayprofile.js Tue Jul 20 17:07:51 2021 +0200 @@ -1,3 +1,5 @@ +import { HTTP } from "@/lib/http"; +import LineString from "ol/geom/LineString"; /* This is Free Software under GNU Affero General Public License v >= 3.0 * without warranty, see README.md and license for details. * @@ -13,13 +15,11 @@ * Markus Kottländer <markuks.kottlaender@intevation.de> */ import Vue from "vue"; -import { HTTP } from "@/lib/http"; -import { prepareProfile } from "@/lib/geo"; -import LineString from "ol/geom/LineString"; +import { displayError } from "@/lib/errors"; +import { featureToFairwayCoordinates } from "@/lib/geo"; import { generateFeatureRequest } from "@/lib/geo"; import { getLength } from "ol/sphere"; -import { displayError } from "@/lib/errors"; -import { featureToFairwayCoordinates } from "@/lib/geo"; +import { prepareProfile } from "@/lib/geo"; // initial state const init = () => { @@ -316,7 +316,7 @@ previousCuts .filter(cut => { return ( - cut.bottleneckName === rootState.bottlenecks.selectedBottleneck + cut.bottleneckId === rootState.bottlenecks.selectedBottleneck ); }) .sort((a, b) => (a.timestamp < b.timestamp ? 1 : -1))
--- a/pkg/controllers/surveys.go Tue Jul 20 11:50:17 2021 +0200 +++ b/pkg/controllers/surveys.go Tue Jul 20 17:07:51 2021 +0200 @@ -42,7 +42,7 @@ LEFT JOIN waterway.gauges_reference_water_levels AS r ON s.depth_reference = r.depth_reference AND g.location = r.location AND g.validity = r.validity -WHERE b.objnam = $1` +WHERE b.bottleneck_id = $1` ) func listSurveys(req *http.Request) (jr mw.JSONResult, err error) {