Mercurial > gemma
comparison client/src/store/fairwayavailability.js @ 3355:9625c6120d18
merge
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 21 May 2019 16:12:12 +0200 |
parents | e12e8bf044a6 b01bf2399c20 |
children | 8974efd71917 |
comparison
equal
deleted
inserted
replaced
3354:e12e8bf044a6 | 3355:9625c6120d18 |
---|---|
32 depthlimit2: 230, | 32 depthlimit2: 230, |
33 breadthlimit1: null, | 33 breadthlimit1: null, |
34 breadthlimit2: null, | 34 breadthlimit2: null, |
35 fwData: null, | 35 fwData: null, |
36 fwLNWLData: null, | 36 fwLNWLData: null, |
37 fwLNWLOverviewData: [], | |
37 legend: null, | 38 legend: null, |
38 LOS: 3 | 39 LOS: 3 |
39 }; | 40 }; |
40 }; | 41 }; |
41 | 42 |
42 const fairwayavailability = { | 43 const fairwayavailability = { |
43 init, | 44 init, |
44 namespaced: true, | 45 namespaced: true, |
45 state: init(), | 46 state: init(), |
47 getters: { | |
48 fwLNWLOverviewData: state => feature => { | |
49 return state.fwLNWLOverviewData.find( | |
50 d => d.feature.get("id") === feature.get("id") | |
51 ); | |
52 } | |
53 }, | |
46 mutations: { | 54 mutations: { |
47 type: (state, type) => { | 55 type: (state, type) => { |
48 state.type = type; | 56 state.type = type; |
49 }, | 57 }, |
50 setLOS: (state, LOS) => { | 58 setLOS: (state, LOS) => { |
74 setSelectedFairwayAvailability: (state, feature) => { | 82 setSelectedFairwayAvailability: (state, feature) => { |
75 state.selectedFairwayAvailabilityFeature = feature; | 83 state.selectedFairwayAvailabilityFeature = feature; |
76 }, | 84 }, |
77 setFwData: (state, fwData) => { | 85 setFwData: (state, fwData) => { |
78 state.fwData = fwData; | 86 state.fwData = fwData; |
87 }, | |
88 addFwLNWLOverviewData: (state, data) => { | |
89 let existingIndex = state.fwLNWLOverviewData.findIndex( | |
90 d => d.feature.get("id") === data.feature.get("id") | |
91 ); | |
92 if (existingIndex !== -1) | |
93 state.fwLNWLOverviewData.splice(existingIndex, 1); | |
94 state.fwLNWLOverviewData.push(data); | |
79 }, | 95 }, |
80 setLegend: (state, header) => { | 96 setLegend: (state, header) => { |
81 const headerEntries = header.split(","); | 97 const headerEntries = header.split(","); |
82 headerEntries.shift(); | 98 headerEntries.shift(); |
83 state.legend = headerEntries.map(x => { | 99 state.legend = headerEntries.map(x => { |
134 }) | 150 }) |
135 .catch(error => { | 151 .catch(error => { |
136 reject(error); | 152 reject(error); |
137 }); | 153 }); |
138 }); | 154 }); |
155 }, | |
156 loadAvailableFairwayDepthLNWL: (context, options) => { | |
157 return new Promise((resolve, reject) => { | |
158 const { feature, from, to, frequency, LOS } = options; | |
159 let name = | |
160 feature.constructor.name === "Feature" | |
161 ? feature.get("objnam") | |
162 : feature.properties.name; | |
163 const start = encodeURIComponent("00:00:00+00:00"); | |
164 const end = encodeURIComponent("23:59:59+00:00"); | |
165 const URL = `/data/bottleneck/availability/${encodeURIComponent( | |
166 name | |
167 )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}`; | |
168 HTTP.get(URL, { | |
169 headers: { "X-Gemma-Auth": localStorage.getItem("token") } | |
170 }) | |
171 .then(response => { | |
172 resolve(response.data); | |
173 }) | |
174 .catch(error => { | |
175 reject(error); | |
176 }); | |
177 }); | |
139 } | 178 } |
140 } | 179 } |
141 }; | 180 }; |
142 | 181 |
143 export { FREQUENCIES, fairwayavailability }; | 182 export { FREQUENCIES, fairwayavailability }; |