changeset 5353:2578fd6f4c63 extented-report

changed DQL path to default. Added error handling.
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 22 Jun 2021 14:06:49 +0200
parents 979f139cde4d
children 16c026da50b1
files client/src/components/identify/Identify.vue
diffstat 1 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/identify/Identify.vue	Tue Jun 22 13:13:32 2021 +0200
+++ b/client/src/components/identify/Identify.vue	Tue Jun 22 14:06:49 2021 +0200
@@ -284,6 +284,7 @@
 import filters from "@/lib/filters";
 import { HTTP } from "@/lib/http";
 import { format } from "date-fns";
+import { displayError } from "@/lib/errors";
 
 const {
   recencyColorCodes,
@@ -421,20 +422,32 @@
   },
   methods: {
     downloadDataQualityReport() {
-      HTTP.get(`/data/report/gauges`, {
+      HTTP.get(`/data/report/default`, {
         responseType: "blob",
         headers: {
           "X-Gemma-Auth": localStorage.getItem("token")
         }
-      }).then(response => {
-        const link = document.createElement("a");
-        const now = new Date();
-        link.href = window.URL.createObjectURL(new Blob([response.data]));
-        link.download = `DataQualityReport-${format(now, "YYYY-MM-DD")}.xlsx`;
-        document.body.appendChild(link);
-        link.click();
-        document.body.removeChild(link);
-      });
+      })
+        .then(response => {
+          const link = document.createElement("a");
+          const now = new Date();
+          link.href = window.URL.createObjectURL(new Blob([response.data]));
+          link.download = `DataQualityReport-${format(now, "YYYY-MM-DD")}.xlsx`;
+          document.body.appendChild(link);
+          link.click();
+          document.body.removeChild(link);
+        })
+        .catch(error => {
+          let message = "Backend not reachable";
+          if (error.response) {
+            const { status, data } = error.response;
+            message = `${status}: ${data.message || data}`;
+          }
+          displayError({
+            title: this.$gettext("Backend Error"),
+            message: message
+          });
+        });
     },
     getGaugeStatusText(feature) {
       if (/bottleneck/.test(feature.getId())) return this.refGaugeStatusText;