Mercurial > gemma
changeset 5398:dcc692a333c0 extented-report
merge
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 05 Jul 2021 08:31:46 +0200 |
parents | bda102c56cfc (diff) 23a30ba08243 (current diff) |
children | 47c2ca05e8ec f5063fa7f666 |
files | |
diffstat | 5 files changed, 157 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Sidebar.vue Sun Jul 04 11:38:30 2021 +0200 +++ b/client/src/components/Sidebar.vue Mon Jul 05 08:31:46 2021 +0200 @@ -148,6 +148,17 @@ } }, mounted() { + this.$store.dispatch("importschedule/loadAvailableReports").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 + }); + }); const updateIndicators = () => { if (this.isWaterwayAdmin) { this.$store
--- a/client/src/components/identify/Identify.vue Sun Jul 04 11:38:30 2021 +0200 +++ b/client/src/components/identify/Identify.vue Mon Jul 05 08:31:46 2021 +0200 @@ -193,13 +193,21 @@ :spin="true" fixed-width /> - <a - v-if="DQLDownloadAllowed" - href="#" - @click="downloadDataQualityReport" - > - <translate>Data quality report</translate> - </a> + <template v-if="DQLDownloadAllowed"> + <a + v-for="(reportName, index) in availableReports" + :key="index" + href="#" + @click="downloadDataQualityReport(reportName)" + > + {{ + reportName + .split("-") + .map(s => (s && s[0].toUpperCase() + s.slice(1)) || "") + .join(" ") + }} + </a> + </template> <a v-if="userManualUrl" :href="userManualUrl ? userManualUrl : '#'" @@ -317,6 +325,7 @@ ...mapState("map", ["currentMeasurement"]), ...mapState("gauges", ["gauges"]), ...mapGetters("user", ["isWaterwayAdmin", "isSysAdmin"]), + ...mapState("importschedule", ["availableReports"]), DQLDownloadAllowed() { if (this.loadingDQL) return false; return this.isWaterwayAdmin || this.isSysAdmin; @@ -429,9 +438,9 @@ } }, methods: { - downloadDataQualityReport() { + downloadDataQualityReport(reportName) { this.loadingDQL = true; - HTTP.get(`/data/report/data-quality-report`, { + HTTP.get(`/data/report/${reportName}`, { responseType: "blob", headers: { "X-Gemma-Auth": localStorage.getItem("token")
--- a/client/src/components/importconfiguration/ScheduledImports.vue Sun Jul 04 11:38:30 2021 +0200 +++ b/client/src/components/importconfiguration/ScheduledImports.vue Mon Jul 05 08:31:46 2021 +0200 @@ -80,6 +80,12 @@ :featureType="featureType" :sortBy="sortBy" /> + <DQLReport + v-if="import_ == $options.IMPORTTYPES.REPORT" + @reportNameChanged="setReportName" + :reportName="reportName" + :availableReports="availableReports" + /> <Faiwaydimensions v-if="import_ == $options.IMPORTTYPES.FAIRWAYDIMENSION" @urlChanged="setUrl" @@ -503,6 +509,7 @@ Bottleneck: () => import("./types/Bottleneck"), Distancemarksvirtual: () => import("./types/Distancemarksvirtual"), Distancemarksashore: () => import("./types/Distancemarksashore"), + DQLReport: () => import("./types/DQLReport"), Faiwaydimensions: () => import("./types/Fairwaydimensions"), Fairwaymarks: () => import("./types/Fairwaymarks"), Gaugemeasurement: () => import("./types/Gaugemeasurement"), @@ -563,6 +570,7 @@ }, computed: { ...mapState("importschedule", [ + "availableReports", "importScheduleDetailVisible", "currentSchedule" ]), @@ -699,6 +707,9 @@ this.uploadLabel = files[0].name; this.uploadFile = files[0]; }, + setReportName(value) { + this.reportName = value; + }, setStatsUpdate(value) { this.statsUpdate = value; }, @@ -793,6 +804,7 @@ this.waitRetry = this.currentSchedule.waitRetry; this.selectedMark = this.currentSchedule.selectedMark; this.statsUpdate = this.currentSchedule.statsUpdate; + this.reportName = this.currentSchedule.reportName; this.retry = this.currentSchedule.trys === null || this.currentSchedule.trys === undefined || @@ -922,14 +934,14 @@ } if (this.waitRetry) data["wait-retry"] = this.waitRetry; if (this.trys) data["trys"] = Number(this.trys); - - if (this.import_ === this.$options.IMPORTTYPES.REPORT) { - data["name"] = "data-quality-report"; - } if (this.import_ === this.$options.IMPORTTYPES.STATSUPDATE) { if (!this.statsUpdate) return; data["name"] = this.statsUpdate; } + if (this.import_ === this.$options.IMPORTTYPES.REPORT) { + if (!this.reportName) return; + data["name"] = this.reportName; + } data["send-email"] = this.eMailNotification; this.triggerActive = false; const type = @@ -1022,7 +1034,8 @@ if (this.waitRetry) config["wait-retry"] = this.waitRetry; if (this.trys) config["trys"] = Number(this.trys); if (this.import_ === this.$options.IMPORTTYPES.REPORT) { - config["name"] = "data-quality-report"; + if (!this.reportName) return; + config["name"] = this.reportName; } if (this.import_ === this.$options.IMPORTTYPES.STATSUPDATE) { if (!this.statsUpdate) return;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/importconfiguration/types/DQLReport.vue Mon Jul 05 08:31:46 2021 +0200 @@ -0,0 +1,84 @@ +<template> + <div> + <div class="d-flex px-2"> + <div class="flex-column w-100"> + <div class="flex-row text-left"> + <small class="text-muted"> + <translate>DQL Report</translate> + </small> + </div> + <div class="w-50"> + <select + v-model="selectedReport" + class="ml-1 mr-1 form-control form-control-sm" + > + <option value="" v-if="this.availableReports.length === 0" + ><translate>No data selectable</translate></option + > + <option + v-for="(option, index) in this.availableReports" + :key="index" + :value="option" + >{{ option }}</option + > + </select> + </div> + </div> + </div> + <div v-if="!selectedReport" class="d-flex px-2"> + <small + ><translate class="text-danger" + >Please select a report to update</translate + ></small + > + </div> + </div> +</template> + +<script> +/* This is Free Software under GNU Affero General Public License v >= 3.0 + * without warranty, see README.md and license for details. + * + * SPDX-License-Identifier: AGPL-3.0-or-later + * License-Filename: LICENSES/AGPL-3.0.txt + * + * Copyright (C) 2018 by via donau + * – Österreichische Wasserstraßen-Gesellschaft mbH + * Software engineering by Intevation GmbH + * + * Author(s): + * Thomas Junk <thomas.junk@intevation.de> + */ +import { displayError } from "@/lib/errors"; + +export default { + name: "reports", + props: ["reportName", "availableReports"], + mounted() { + this.$store.dispatch("importschedule/loadAvailableReports").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 + }); + }); + }, + computed: { + selectedReport: { + get() { + return this.reportName; + }, + set(value) { + this.selected = value; + this.$emit("reportNameChanged", value); + } + } + } +}; +</script> + +<style></style>
--- a/client/src/store/importschedule.js Sun Jul 04 11:38:30 2021 +0200 +++ b/client/src/store/importschedule.js Mon Jul 05 08:31:46 2021 +0200 @@ -117,7 +117,8 @@ trys: null, waitRetry: null, selectedMark: null, - statsUpdate: null + statsUpdate: null, + reportName: null }; }; @@ -130,6 +131,7 @@ const init = () => { return { schedules: [], + availableReports: null, importScheduleDetailVisible: false, currentSchedule: initializeCurrentSchedule(), mode: MODES.LIST @@ -141,6 +143,9 @@ namespaced: true, state: init(), mutations: { + setAvailableReports: (state, value) => { + state.availableReports = value; + }, setEditMode: state => { state.mode = MODES.EDIT; }, @@ -282,9 +287,29 @@ const { name } = config; Vue.set(state.currentSchedule, "statsUpdate", name); } + if (kind === IMPORTTYPES.REPORT) { + const { name } = config; + Vue.set(state.currentSchedule, "reportName", name); + } } }, actions: { + loadAvailableReports({ commit }) { + return new Promise((resolve, reject) => { + HTTP.get("/data/reports", { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }) + .then(response => { + commit("setAvailableReports", response.data.reports); + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, loadSchedule({ commit }, id) { return new Promise((resolve, reject) => { HTTP.get("/imports/config/" + id, {