comparison client/src/components/identify/Identify.vue @ 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 96a544504818
children 2578fd6f4c63
comparison
equal deleted inserted replaced
5338:f8e7f043d968 5339:7365efe9f67d
179 > 179 >
180 <translate>No features identified.</translate> 180 <translate>No features identified.</translate>
181 </div> 181 </div>
182 </div> 182 </div>
183 <div 183 <div
184 v-if="userManualUrl" 184 v-if="hasDownloads"
185 class="border-top text-left pl-2" 185 class="border-top text-left pl-2"
186 style="font-size: 90%;" 186 style="font-size: 90%;"
187 > 187 >
188 <translate>Download</translate> 188 <translate>Download</translate>
189 <a 189 <div class="d-flex flex-column">
190 :href="userManualUrl ? userManualUrl : '#'" 190 <a
191 :download="usermanualFilename" 191 v-if="DQLDownloadAllowed"
192 ><translate> User Manual</translate></a 192 href="#"
193 > 193 @click="downloadDataQualityReport"
194 >
195 <translate>Data quality report</translate>
196 </a>
197 <a
198 v-if="userManualUrl"
199 :href="userManualUrl ? userManualUrl : '#'"
200 :download="usermanualFilename"
201 ><translate> User Manual</translate></a
202 >
203 </div>
194 </div> 204 </div>
195 <div class="versioninfo border-top box-body"> 205 <div class="versioninfo border-top box-body">
196 <span v-translate="{ license: 'AGPL-3.0-or-later' }"> 206 <span v-translate="{ license: 'AGPL-3.0-or-later' }">
197 This app uses <i>gemma</i>, which is Free Software under <br /> 207 This app uses <i>gemma</i>, which is Free Software under <br />
198 %{ license } without warranty, see docs for details. 208 %{ license } without warranty, see docs for details.
270 import { formatter } from "./formatter"; 280 import { formatter } from "./formatter";
271 import { getCenter } from "ol/extent"; 281 import { getCenter } from "ol/extent";
272 import classifications from "@/lib/classifications"; 282 import classifications from "@/lib/classifications";
273 import { styleFactory } from "@/components/layers/styles"; 283 import { styleFactory } from "@/components/layers/styles";
274 import filters from "@/lib/filters"; 284 import filters from "@/lib/filters";
285 import { HTTP } from "@/lib/http";
286 import { format } from "date-fns";
275 287
276 const { 288 const {
277 recencyColorCodes, 289 recencyColorCodes,
278 gmAvailabilityColorCodes, 290 gmAvailabilityColorCodes,
279 forecastAccuracyColorCodes, 291 forecastAccuracyColorCodes,
294 ...mapGetters("application", ["versionStr"]), 306 ...mapGetters("application", ["versionStr"]),
295 ...mapState("application", ["showIdentify", "userManualUrl", "config"]), 307 ...mapState("application", ["showIdentify", "userManualUrl", "config"]),
296 ...mapGetters("map", ["filteredIdentifiedFeatures"]), 308 ...mapGetters("map", ["filteredIdentifiedFeatures"]),
297 ...mapState("map", ["currentMeasurement"]), 309 ...mapState("map", ["currentMeasurement"]),
298 ...mapState("gauges", ["gauges"]), 310 ...mapState("gauges", ["gauges"]),
311 ...mapGetters("user", ["isWaterwayAdmin", "isSysAdmin"]),
312 DQLDownloadAllowed() {
313 return this.isWaterwayAdmin || this.isSysAdmin;
314 },
299 identifiedLabel() { 315 identifiedLabel() {
300 return this.$gettext("Identified Features"); 316 return this.$gettext("Identified Features");
317 },
318 hasDownloads() {
319 return this.DQLDownloadAllowed || this.userManualUrl;
301 }, 320 },
302 usermanualFilename() { 321 usermanualFilename() {
303 return this.$gettext("User Manual"); 322 return this.$gettext("User Manual");
304 }, 323 },
305 gaugeStatusColor() { 324 gaugeStatusColor() {
399 }); 418 });
400 } 419 }
401 } 420 }
402 }, 421 },
403 methods: { 422 methods: {
423 downloadDataQualityReport() {
424 HTTP.get(`/data/report/gauges`, {
425 responseType: "blob",
426 headers: {
427 "X-Gemma-Auth": localStorage.getItem("token")
428 }
429 }).then(response => {
430 const link = document.createElement("a");
431 const now = new Date();
432 link.href = window.URL.createObjectURL(new Blob([response.data]));
433 link.download = `DataQualityReport-${format(now, "YYYY-MM-DD")}.xlsx`;
434 document.body.appendChild(link);
435 link.click();
436 document.body.removeChild(link);
437 });
438 },
404 getGaugeStatusText(feature) { 439 getGaugeStatusText(feature) {
405 if (/bottleneck/.test(feature.getId())) return this.refGaugeStatusText; 440 if (/bottleneck/.test(feature.getId())) return this.refGaugeStatusText;
406 return this.gaugeStatusText; 441 return this.gaugeStatusText;
407 }, 442 },
408 getGaugeStatusColor(feature) { 443 getGaugeStatusColor(feature) {