changeset 5339:7365efe9f67d extented-report

Added downloadlink for DQLReports in Infotool In order to download reports on dataquality a link was added to the downloads section in the infotool. In case there are downloads available (e.g user manual is available) this section becomes visible. The old behavior for the single link is now extended for the whole section. The link for the DQLReports is only available for the roles of - Waterway Administrator - System Administrator
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 17 Jun 2021 14:36:01 +0200
parents f8e7f043d968
children ac1986c23889
files client/.env client/src/components/identify/Identify.vue
diffstat 2 files changed, 42 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/client/.env	Tue Jun 15 22:00:20 2021 +0200
+++ b/client/.env	Thu Jun 17 14:36:01 2021 +0200
@@ -15,4 +15,4 @@
 VUE_APP_SILENCE_TRANSLATIONWARNINGS =
 
 #Url of user manual
-VUE_APP_USER_MANUAL_URL=
+VUE_APP_USER_MANUAL_URL=
\ No newline at end of file
--- a/client/src/components/identify/Identify.vue	Tue Jun 15 22:00:20 2021 +0200
+++ b/client/src/components/identify/Identify.vue	Thu Jun 17 14:36:01 2021 +0200
@@ -181,16 +181,26 @@
         </div>
       </div>
       <div
-        v-if="userManualUrl"
+        v-if="hasDownloads"
         class="border-top text-left pl-2"
         style="font-size: 90%;"
       >
         <translate>Download</translate>
-        <a
-          :href="userManualUrl ? userManualUrl : '#'"
-          :download="usermanualFilename"
-          ><translate> User Manual</translate></a
-        >
+        <div class="d-flex flex-column">
+          <a
+            v-if="DQLDownloadAllowed"
+            href="#"
+            @click="downloadDataQualityReport"
+          >
+            <translate>Data quality report</translate>
+          </a>
+          <a
+            v-if="userManualUrl"
+            :href="userManualUrl ? userManualUrl : '#'"
+            :download="usermanualFilename"
+            ><translate> User Manual</translate></a
+          >
+        </div>
       </div>
       <div class="versioninfo border-top box-body">
         <span v-translate="{ license: 'AGPL-3.0-or-later' }">
@@ -272,6 +282,8 @@
 import classifications from "@/lib/classifications";
 import { styleFactory } from "@/components/layers/styles";
 import filters from "@/lib/filters";
+import { HTTP } from "@/lib/http";
+import { format } from "date-fns";
 
 const {
   recencyColorCodes,
@@ -296,9 +308,16 @@
     ...mapGetters("map", ["filteredIdentifiedFeatures"]),
     ...mapState("map", ["currentMeasurement"]),
     ...mapState("gauges", ["gauges"]),
+    ...mapGetters("user", ["isWaterwayAdmin", "isSysAdmin"]),
+    DQLDownloadAllowed() {
+      return this.isWaterwayAdmin || this.isSysAdmin;
+    },
     identifiedLabel() {
       return this.$gettext("Identified Features");
     },
+    hasDownloads() {
+      return this.DQLDownloadAllowed || this.userManualUrl;
+    },
     usermanualFilename() {
       return this.$gettext("User Manual");
     },
@@ -401,6 +420,22 @@
     }
   },
   methods: {
+    downloadDataQualityReport() {
+      HTTP.get(`/data/report/gauges`, {
+        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);
+      });
+    },
     getGaugeStatusText(feature) {
       if (/bottleneck/.test(feature.getId())) return this.refGaugeStatusText;
       return this.gaugeStatusText;