diff client/src/components/Sidebar.vue @ 2651:9f3856337f55

import_overview: new unified interface as default
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 14 Mar 2019 14:53:17 +0100
parents 472b0e653644
children 906e9a13592f
line wrap: on
line diff
--- a/client/src/components/Sidebar.vue	Thu Mar 14 14:50:20 2019 +0100
+++ b/client/src/components/Sidebar.vue	Thu Mar 14 14:53:17 2019 +0100
@@ -1,7 +1,7 @@
 <template>
   <div class="position-relative">
-    <span class="indicator" v-if="!showSidebar && staging.length">
-      {{ staging.length }}
+    <span class="indicator" v-if="!showSidebar && stagingNotifications">
+      {{ stagingNotifications }}
     </span>
     <div :class="sidebarStyle">
       <div
@@ -35,8 +35,8 @@
               icon="clipboard-check"
             ></font-awesome-icon>
             <span class="fix-trans-space" v-translate>Staging area</span>
-            <span class="indicator" v-if="showSidebar && staging.length">
-              {{ staging.length }}
+            <span class="indicator" v-if="showSidebar && stagingNotifications">
+              {{ stagingNotifications }}
             </span>
           </router-link>
         </div>
@@ -154,14 +154,19 @@
 import { mapGetters, mapState } from "vuex";
 import { logOff } from "@/lib/session.js";
 import { displayError } from "@/lib/errors";
+import { HTTP } from "@/lib/http";
 
 export default {
   name: "sidebar",
   props: ["routeName"],
+  data() {
+    return {
+      stagingNotifications: null
+    };
+  },
   computed: {
     ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]),
     ...mapState("user", ["user"]),
-    ...mapState("imports", ["staging"]),
     ...mapState("application", [
       "showSidebar",
       "showSearchbarLastState",
@@ -197,13 +202,21 @@
       );
     },
     updateIndicators() {
-      this.$store.dispatch("imports/getStaging").catch(error => {
-        const { status, data } = error.response;
-        displayError({
-          title: "Backend Error",
-          message: `${status}: ${data.message || data}`
+      this.$store;
+      HTTP.get("/imports?states=pending", {
+        headers: { "X-Gemma-Auth": localStorage.getItem("token") }
+      })
+        .then(response => {
+          const { imports } = response.data;
+          this.stagingNotifications = imports.length;
+        })
+        .catch(error => {
+          const { status, data } = error.response;
+          displayError({
+            title: "Backend Error",
+            message: `${status}: ${data.message || data}`
+          });
         });
-      });
     }
   },
   mounted() {