Mercurial > gemma
comparison client/src/store/fairwayavailability.js @ 3486:1fbb6dc7d362
fairwayavailability: refactor constants
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 27 May 2019 16:33:30 +0200 |
parents | 4eefeeae03fc |
children | 624c64670d48 |
comparison
equal
deleted
inserted
replaced
3485:ef4803f87631 | 3486:1fbb6dc7d362 |
---|---|
30 WIDTH: "width", | 30 WIDTH: "width", |
31 DEPTH: "depth" | 31 DEPTH: "depth" |
32 }; | 32 }; |
33 | 33 |
34 const TYPES = { | 34 const TYPES = { |
35 BOTTLENECKS: "bottlenecks", | 35 BOTTLENECK: "bottleneck", |
36 SECTIONS: "sections", | 36 SECTION: "section", |
37 STRETCHES: "stretches" | 37 STRETCH: "stretch" |
38 }; | 38 }; |
39 | 39 |
40 const FREQUENCIES = { | 40 const FREQUENCIES = { |
41 MONTHLY: "monthly", | 41 MONTHLY: "monthly", |
42 QUARTERLY: "quarterly", | 42 QUARTERLY: "quarterly", |
65 } | 65 } |
66 }; | 66 }; |
67 | 67 |
68 const init = () => { | 68 const init = () => { |
69 return { | 69 return { |
70 type: "bottlenecks", | 70 type: TYPES.BOTTLENECK, |
71 selectedFairwayAvailabilityFeature: null, | 71 selectedFairwayAvailabilityFeature: null, |
72 to: format(new Date(), "YYYY-MM-DD"), | 72 to: format(new Date(), "YYYY-MM-DD"), |
73 from: format(subYears(new Date(), 1), "YYYY-MM-DD"), | 73 from: format(subYears(new Date(), 1), "YYYY-MM-DD"), |
74 frequency: FREQUENCIES.MONTHLY, | 74 frequency: FREQUENCIES.MONTHLY, |
75 limitingFactor: null, | 75 limitingFactor: null, |
220 : feature.get("objnam"); | 220 : feature.get("objnam"); |
221 [from, to] = getIntervallBorders(from, to, frequency); | 221 [from, to] = getIntervallBorders(from, to, frequency); |
222 let additionalParams = ""; | 222 let additionalParams = ""; |
223 let endpoint = ""; | 223 let endpoint = ""; |
224 switch (type) { | 224 switch (type) { |
225 case TYPES.BOTTLENECKS: | 225 case TYPES.BOTTLENECK: |
226 endpoint = "bottleneck"; | 226 endpoint = "bottleneck"; |
227 if (limitingFactor === LIMITINGFACTORS.DEPTH) | 227 if (limitingFactor === LIMITINGFACTORS.DEPTH) |
228 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; | 228 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; |
229 if (limitingFactor === LIMITINGFACTORS.WIDTH) | 229 if (limitingFactor === LIMITINGFACTORS.WIDTH) |
230 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; | 230 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; |
231 break; | 231 break; |
232 case TYPES.SECTIONS: | 232 case TYPES.SECTION: |
233 endpoint = "section"; | 233 endpoint = "section"; |
234 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; | 234 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
235 break; | 235 break; |
236 case TYPES.STRETCHES: | 236 case TYPES.STRETCH: |
237 endpoint = "stretch"; | 237 endpoint = "stretch"; |
238 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; | 238 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
239 break; | 239 break; |
240 default: | 240 default: |
241 throw new Error("Wrong selection"); | 241 throw new Error("Wrong selection"); |
283 const start = encodeURIComponent("00:00:00+00:00"); | 283 const start = encodeURIComponent("00:00:00+00:00"); |
284 const end = encodeURIComponent("23:59:59+00:00"); | 284 const end = encodeURIComponent("23:59:59+00:00"); |
285 let additionalParams = ""; | 285 let additionalParams = ""; |
286 let endpoint = ""; | 286 let endpoint = ""; |
287 switch (type) { | 287 switch (type) { |
288 case TYPES.BOTTLENECKS: | 288 case TYPES.BOTTLENECK: |
289 endpoint = "bottleneck"; | 289 endpoint = "bottleneck"; |
290 if (limitingFactor === LIMITINGFACTORS.DEPTH) | 290 if (limitingFactor === LIMITINGFACTORS.DEPTH) |
291 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; | 291 additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; |
292 if (limitingFactor === LIMITINGFACTORS.WIDTH) | 292 if (limitingFactor === LIMITINGFACTORS.WIDTH) |
293 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; | 293 additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; |
294 break; | 294 break; |
295 case TYPES.SECTIONS: | 295 case TYPES.SECTION: |
296 endpoint = "section"; | 296 endpoint = "section"; |
297 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; | 297 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
298 break; | 298 break; |
299 case TYPES.STRETCHES: | 299 case TYPES.STRETCH: |
300 endpoint = "stretch"; | 300 endpoint = "stretch"; |
301 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; | 301 additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`; |
302 break; | 302 break; |
303 default: | 303 default: |
304 endpoint = "bottleneck"; | 304 endpoint = "bottleneck"; |