# HG changeset patch # User Thomas Junk # Date 1559728095 -7200 # Node ID d02d4e31491b3e7c357f3159bb3c4c4753a7593c # Parent 6248a4bc10c7b8676f9d8a203aea983d9ce5d84b sidebar: move staging notifications to store and update notifications after finishing review diff -r 6248a4bc10c7 -r d02d4e31491b client/src/components/Sidebar.vue --- a/client/src/components/Sidebar.vue Wed Jun 05 11:39:25 2019 +0200 +++ b/client/src/components/Sidebar.vue Wed Jun 05 11:48:15 2019 +0200 @@ -100,18 +100,13 @@ import { mapGetters, mapState } from "vuex"; import { logOff } from "@/lib/session"; import { displayError } from "@/lib/errors"; -import { HTTP } from "@/lib/http"; export default { name: "sidebar", - data() { - return { - stagingNotifications: null - }; - }, computed: { ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]), ...mapState("user", ["user", "roles", "isAuthenticated"]), + ...mapState("imports", ["stagingNotifications"]), ...mapState("application", [ "showSidebar", "showSearchbarLastState", @@ -150,12 +145,9 @@ mounted() { const updateIndicators = () => { if (this.isWaterwayAdmin) { - this.$store; - HTTP.get("/imports?states=pending&count=true", { - headers: { "X-Gemma-Auth": localStorage.getItem("token") } - }) - .then(response => { - this.stagingNotifications = response.data; + this.$store + .dispatch("imports/loadStagingNotifications") + .then(() => { if (this.isAuthenticated) { setTimeout(updateIndicators, 15000); } diff -r 6248a4bc10c7 -r d02d4e31491b client/src/components/importoverview/ImportOverview.vue --- a/client/src/components/importoverview/ImportOverview.vue Wed Jun 05 11:39:25 2019 +0200 +++ b/client/src/components/importoverview/ImportOverview.vue Wed Jun 05 11:48:15 2019 +0200 @@ -409,6 +409,7 @@ this.loadLogs(); this.$store.commit("imports/setReviewed", []); this.$store.dispatch("map/refreshLayers"); + this.$store.dispatch("imports/loadStagingNotifications"); const messages = response.data .map(x => { if (x.message) return x.message; diff -r 6248a4bc10c7 -r d02d4e31491b client/src/store/imports.js --- a/client/src/store/imports.js Wed Jun 05 11:39:25 2019 +0200 +++ b/client/src/store/imports.js Wed Jun 05 11:48:15 2019 +0200 @@ -43,6 +43,7 @@ details: [], startDate: startOfHour(new Date()), endDate: endOfHour(new Date()), + stagingNotifications: null, prev: null, next: null }; @@ -98,6 +99,9 @@ } }, mutations: { + setStagingNotifications: (state, stagingNotifications) => { + state.stagingNotifications = stagingNotifications; + }, setPrev: (state, prev) => { state.prev = prev; }, @@ -200,6 +204,20 @@ } }, actions: { + loadStagingNotifications({ commit }) { + return new Promise((resolve, reject) => { + HTTP.get("/imports?states=pending&count=true", { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }) + .then(response => { + commit("setStagingNotifications", response.data); + resolve(response); + }) + .catch(error => { + reject(error); + }); + }); + }, loadStretch(context, name) { return new Promise((resolve, reject) => { getFromWFS("stretches_geoserver", equalToFilter("name", name))