Mercurial > gemma
changeset 5396:064ac1014713 extented-report
Make DQL-Downloads a bit more dynamic
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 02 Jul 2021 17:14:04 +0200 |
parents | 661e8a2deed9 |
children | bda102c56cfc |
files | client/src/components/Sidebar.vue client/src/components/identify/Identify.vue client/src/components/importconfiguration/ScheduledImports.vue client/src/store/importschedule.js |
diffstat | 4 files changed, 73 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Sidebar.vue Fri Jul 02 14:16:02 2021 +0200 +++ b/client/src/components/Sidebar.vue Fri Jul 02 17:14:04 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 Fri Jul 02 14:16:02 2021 +0200 +++ b/client/src/components/identify/Identify.vue Fri Jul 02 17:14:04 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 Fri Jul 02 14:16:02 2021 +0200 +++ b/client/src/components/importconfiguration/ScheduledImports.vue Fri Jul 02 17:14:04 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;
--- a/client/src/store/importschedule.js Fri Jul 02 14:16:02 2021 +0200 +++ b/client/src/store/importschedule.js Fri Jul 02 17:14:04 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, {