diff client/src/store/fairwayavailability.js @ 3437:6a044d6c2cdc

afd: csv download
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 24 May 2019 10:21:06 +0200
parents f2e8f8beb913
children df6c2973f791
line wrap: on
line diff
--- a/client/src/store/fairwayavailability.js	Fri May 24 10:01:40 2019 +0200
+++ b/client/src/store/fairwayavailability.js	Fri May 24 10:21:06 2019 +0200
@@ -87,6 +87,7 @@
     depthlimit2: 230,
     widthlimit1: null,
     widthlimit2: null,
+    csv: null,
     fwData: null,
     fwLNWLData: null,
     fwLNWLOverviewData: [],
@@ -144,6 +145,9 @@
     setFwLNWLData: (state, fwLNWLData) => {
       state.fwLNWLData = fwLNWLData;
     },
+    setCSV: (state, csv) => {
+      state.csv = csv;
+    },
     addFwLNWLOverviewData: (state, data) => {
       let existingIndex = state.fwLNWLOverviewData.findIndex(
         d => d.feature.get("id") === data.feature.get("id")
@@ -209,6 +213,7 @@
         })
           .then(response => {
             const { data } = response;
+            commit("setCSV", data);
             const csv = data.split("\n").filter(x => x !== ""); //omit empty lines
             commit("setLegend", csv.shift());
             let transformed = csv.map(e => {
@@ -241,7 +246,7 @@
           });
       });
     },
-    loadAvailableFairwayDepthLNWL: (context, options) => {
+    loadAvailableFairwayDepthLNWL: ({ commit }, options) => {
       return new Promise((resolve, reject) => {
         const { feature, frequency, LOS } = options;
         let { from, to } = options;
@@ -259,7 +264,9 @@
           headers: { "X-Gemma-Auth": localStorage.getItem("token") }
         })
           .then(response => {
-            resolve(response.data);
+            const { data } = response;
+            commit("setCSV", data);
+            resolve(data);
           })
           .catch(error => {
             reject(error);