# HG changeset patch # User Thomas Junk # Date 1540379394 -7200 # Node ID a55f20dc8d8d8afeb008c9ec23c721f2fe5a1cbc # Parent 96ea805d44b90497a0a34891f6d23379ba1a47bc refac: store profiles by date diff -r 96ea805d44b9 -r a55f20dc8d8d client/src/application/Main.vue --- a/client/src/application/Main.vue Wed Oct 24 12:29:25 2018 +0200 +++ b/client/src/application/Main.vue Wed Oct 24 13:09:54 2018 +0200 @@ -1,8 +1,29 @@ @@ -66,6 +87,10 @@ "availableSurveys" ]), ...mapState("morphstore", ["selectedMorph"]), + coordinates() { + const currentSurveyDate = this.selectedMorph.date_info; + return this.currentProfile[currentSurveyDate]; + }, additionalSurveys() { if (!this.availableSurveys) return []; return this.availableSurveys.surveys.filter(x => { diff -r 96ea805d44b9 -r a55f20dc8d8d client/src/fairway/store.js --- a/client/src/fairway/store.js Wed Oct 24 12:29:25 2018 +0200 +++ b/client/src/fairway/store.js Wed Oct 24 13:09:54 2018 +0200 @@ -24,7 +24,7 @@ totalLength: 0, minAlt: 0, maxAlt: 0, - currentProfile: [], + currentProfile: {}, waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], selectedWaterLevel: DEMOLEVEL, fairwayCoordinates: [], @@ -43,7 +43,8 @@ setSelectedWaterLevel: (state, level) => { state.selectedWaterLevel = level; }, - profileLoaded: (state, response) => { + profileLoaded: (state, answer) => { + const { response, surveyDate } = answer; const { data } = response; const coordinates = data.geometry.coordinates; if (!coordinates) return; @@ -51,7 +52,7 @@ const endPoint = state.endPoint; const geoJSON = data; const result = prepareProfile({ geoJSON, startPoint, endPoint }); - state.currentProfile = result.points; + state.currentProfile[surveyDate] = result.points; state.minAlt = result.minAlt; state.maxAlt = result.maxAlt; state.totalLength = result.lengthPolyLine; @@ -66,7 +67,7 @@ state.fairwayCoordinates = coordinates; }, clearCurrentProfile: state => { - state.currentProfile = []; + state.currentProfile = {}; } } }; diff -r 96ea805d44b9 -r a55f20dc8d8d client/src/map/Maplayer.vue --- a/client/src/map/Maplayer.vue Wed Oct 24 12:29:25 2018 +0200 +++ b/client/src/map/Maplayer.vue Wed Oct 24 13:09:54 2018 +0200 @@ -188,7 +188,10 @@ headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) .then(response => { - this.$store.commit("fairwayprofile/profileLoaded", response); + this.$store.commit("fairwayprofile/profileLoaded", { + response: response, + surveyDate: survey.date_info + }); }) .then(() => { var vectorSource = this.getLayerByName(