Mercurial > gemma
changeset 2447:522024fa06eb
staging: filter logs on server
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 01 Mar 2019 13:00:42 +0100 |
parents | ba15d3534b2b |
children | 8044e379d8ee |
files | client/src/components/importoverview/importlogs/Logs.vue client/src/store/imports.js |
diffstat | 2 files changed, 35 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importoverview/importlogs/Logs.vue Fri Mar 01 12:55:48 2019 +0100 +++ b/client/src/components/importoverview/importlogs/Logs.vue Fri Mar 01 13:00:42 2019 +0100 @@ -10,7 +10,7 @@ <button @click="setFilter('pending')" :class="pendingStyle"> <translate>Pending</translate> </button> - <button @click="setFilter('rejected')" :class="rejectedStyle"> + <button @click="setFilter('declined')" :class="rejectedStyle"> <translate>Rejected</translate> </button> <button @click="setFilter('accepted')" :class="acceptedStyle"> @@ -44,6 +44,7 @@ */ import { mapState } from "vuex"; +import { displayError } from "@/lib/errors.js"; export default { name: "logsection", @@ -52,9 +53,10 @@ }, data() { return { + loading: false, failed: false, pending: false, - rejected: false, + declined: false, accepted: false, warning: false }; @@ -81,8 +83,8 @@ return { btn: true, "btn-sm": true, - "btn-light": !this.rejected, - "btn-info": this.rejected + "btn-light": !this.declined, + "btn-info": this.declined }; }, acceptedStyle() { @@ -104,12 +106,13 @@ }, methods: { setFilter(name) { + if (this.loading) return; this[name] = !this[name]; const allSet = this.failed && this.pending && this.accepted && - this.rejected && + this.declined && this.warning; if (allSet) { this.warning = false; @@ -117,8 +120,32 @@ this.failed = false; this.pending = false; this.accepted = false; - this.rejected = false; + this.declined = false; } + this.loadFiltered(); + }, + loadFiltered() { + this.loading = true; + const filter = [ + "failed", + "pending", + "accepted", + "declined", + "warning" + ].filter(x => this[x]); + this.$store + .dispatch("imports/getImports", filter) + .then(() => { + this.loading = false; + }) + .catch(error => { + this.loading = false; + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); } } };
--- a/client/src/store/imports.js Fri Mar 01 12:55:48 2019 +0100 +++ b/client/src/store/imports.js Fri Mar 01 13:00:42 2019 +0100 @@ -160,7 +160,8 @@ }, getImports({ commit }, filter) { let queryParams = ""; - if (filter) queryParams = "?states=" + filter.join(","); + if (filter && filter.length > 0) + queryParams = "?states=" + filter.join(","); return new Promise((resolve, reject) => { HTTP.get("/imports" + queryParams, { headers: { "X-Gemma-Auth": localStorage.getItem("token") }