diff client/src/store/fairwayavailability.js @ 5259:680be197844d

Merged branch new-fwa.
author Sascha Wilde <wilde@intevation.de>
date Wed, 13 May 2020 11:28:34 +0200
parents 09ec6a748fca
children 791a372553a0
line wrap: on
line diff
--- a/client/src/store/fairwayavailability.js	Tue May 12 16:52:08 2020 +0200
+++ b/client/src/store/fairwayavailability.js	Wed May 13 11:28:34 2020 +0200
@@ -14,17 +14,18 @@
 
 /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "_" }]*/
 
-import { HTTP } from "@/lib/http";
 import {
+  endOfMonth,
+  endOfQuarter,
+  endOfYear,
   format,
   startOfMonth,
-  endOfMonth,
-  startOfYear,
-  endOfYear,
   startOfQuarter,
-  endOfQuarter
+  startOfYear
 } from "date-fns";
 
+import { HTTP } from "@/lib/http";
+
 const LIMITINGFACTORS = {
   WIDTH: "width",
   DEPTH: "depth"
@@ -259,9 +260,16 @@
           type
         } = options;
         let { from, to } = options;
-        let name = feature.hasOwnProperty("properties")
-          ? feature.properties.name
-          : feature.get("objnam");
+        let name = "";
+        if (type === TYPES.BOTTLENECK) {
+          name = feature.hasOwnProperty("properties")
+            ? feature.properties.bottleneck_id
+            : feature.get("bottleneck_id");
+        } else {
+          name = feature.hasOwnProperty("properties")
+            ? feature.properties.name
+            : feature.get("objnam");
+        }
         [from, to] = getIntervallBorders(from, to, frequency);
         let additionalParams = "";
         let endpoint = type;
@@ -275,7 +283,7 @@
         }
         const start = encodeURIComponent("00:00:00+00:00");
         const end = encodeURIComponent("23:59:59+00:00");
-        const URL = `data/${endpoint}/fairway-depth/${encodeURIComponent(
+        const URL = `data/fairway/${endpoint}/${encodeURIComponent(
           name
         )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`;
         HTTP.get(URL, {
@@ -304,9 +312,16 @@
           type
         } = options;
         let { from, to } = options;
-        let name = feature.hasOwnProperty("properties")
-          ? feature.properties.name
-          : feature.get("objnam");
+        let name = "";
+        if (type === TYPES.BOTTLENECK) {
+          name = feature.hasOwnProperty("properties")
+            ? feature.properties.bottleneck_id
+            : feature.get("bottleneck_id");
+        } else {
+          name = feature.hasOwnProperty("properties")
+            ? feature.properties.name
+            : feature.get("objnam");
+        }
         [from, to] = getIntervallBorders(from, to, frequency);
         const start = encodeURIComponent("00:00:00+00:00");
         const end = encodeURIComponent("23:59:59+00:00");
@@ -320,7 +335,7 @@
         } else if (type == TYPES.SECTION || type == TYPES.STRETCH) {
           additionalParams = `&depthbreaks=${depthLimit1},${depthLimit2}&widthbreaks=${widthLimit1},${widthLimit2}`;
         }
-        const URL = `data/${endpoint}/availability/${encodeURIComponent(
+        const URL = `data/availability/${endpoint}/${encodeURIComponent(
           name
         )}?from=${from}T${start}&to=${to}T${end}&mode=${frequency}&los=${LOS}${additionalParams}`;
         HTTP.get(URL, {