Mercurial > gemma
diff client/src/store/fairwayavailability.js @ 3407:7ea54c3b3fd6
afd: breaks for bottlenecks
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 23 May 2019 13:37:35 +0200 |
parents | 3675c60afd4f |
children | f2e8f8beb913 |
line wrap: on
line diff
--- a/client/src/store/fairwayavailability.js Thu May 23 13:09:49 2019 +0200 +++ b/client/src/store/fairwayavailability.js Thu May 23 13:37:35 2019 +0200 @@ -41,6 +41,12 @@ DEPTH: "depth" }; +const TYPES = { + BOTTLENECKS: "bottlenecks", + SECTIONS: "sections", + STRETCHES: "stretches" +}; + const FREQUENCIES = { MONTHLY: "monthly", QUARTERLY: "quarterly", @@ -162,18 +168,43 @@ actions: { loadAvailableFairwayDepth: ({ commit }, options) => { return new Promise((resolve, reject) => { - const { feature, frequency, LOS } = options; + const { + feature, + frequency, + LOS, + depthLimit1, + depthLimit2, + widthLimit1, + widthLimit2, + limitingFactor, + type + } = options; + if (type !== TYPES.BOTTLENECKS) return; let { from, to } = options; let name = feature.constructor.name === "Feature" ? feature.get("objnam") : feature.properties.name; [from, to] = getIntervallBorders(from, to, frequency); + let additionalParams = ""; + let endpoint = ""; + switch (type) { + case TYPES.BOTTLENECKS: + endpoint = "bottleneck"; + if (limitingFactor === LIMITINGFACTORS.DEPTH) + additionalParams = `&breaks=${depthLimit1},${depthLimit2}`; + if (limitingFactor === LIMITINGFACTORS.WIDTH) + additionalParams = `&breaks=${widthLimit1},${widthLimit2}`; + break; + default: + throw new Error("Wrong selection"); + } const start = encodeURIComponent("00:00:00+00:00"); const end = encodeURIComponent("23:59:59+00:00"); - const URL = `/data/bottleneck/fairway-depth/${encodeURIComponent( + const URL = `/data/${endpoint}/fairway-depth/${encodeURIComponent( name - )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}`; + )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`; + console.log(URL); HTTP.get(URL, { headers: { "X-Gemma-Auth": localStorage.getItem("token") } })