diff client/src/components/importoverview/ImportOverview.vue @ 2799:e19fac818aab

import_overview: specifying single imports via URL should open the overview with all logentries of the according hour and open the details for the specified import
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 25 Mar 2019 16:16:58 +0100
parents 718ec88fbeed
children fb7cc59f5e12
line wrap: on
line diff
--- a/client/src/components/importoverview/ImportOverview.vue	Mon Mar 25 15:42:53 2019 +0100
+++ b/client/src/components/importoverview/ImportOverview.vue	Mon Mar 25 16:16:58 2019 +0100
@@ -195,6 +195,40 @@
     }
   },
   methods: {
+    showSingleRessource(id) {
+      id = id * 1;
+      this.loadDetails(id)
+        .then(response => {
+          this.$store.commit("imports/setCurrentDetails", response.data);
+          const { enqueued } = response.data;
+          this.$store.commit("imports/setStartDate", startOfHour(enqueued));
+          this.$store.commit("imports/setEndDate", endOfHour(enqueued));
+          this.$store.commit("imports/showDetailsFor", id);
+          this.loadLogs();
+        })
+        .catch(error => {
+          this.loading = false;
+          this.$store.commit("imports/setCurrentDetails", {});
+          const { status, data } = error.response;
+          displayError({
+            title: this.$gettext("Backend Error"),
+            message: `${status}: ${data.message || data}`
+          });
+        });
+    },
+    loadDetails(id) {
+      return new Promise((resolve, reject) => {
+        HTTP.get("/imports/" + id, {
+          headers: { "X-Gemma-Auth": localStorage.getItem("token") }
+        })
+          .then(response => {
+            resolve(response);
+          })
+          .catch(error => {
+            reject(error);
+          });
+      });
+    },
     determineInterval(pointInTime) {
       let start, end;
       switch (this.selectedInterval) {
@@ -251,9 +285,7 @@
         })
         .then(() => {
           if (this.show != -1) {
-            HTTP.get("/imports/" + this.show, {
-              headers: { "X-Gemma-Auth": localStorage.getItem("token") }
-            })
+            this.loadDetails(this.show)
               .then(response => {
                 this.$store.commit("imports/setCurrentDetails", response.data);
                 this.loading = false;
@@ -348,6 +380,10 @@
     }
   },
   watch: {
+    $route() {
+      const { id } = this.$route.params;
+      if (id) this.showSingleRessource(id);
+    },
     selectedInterval() {
       const now = new Date();
       switch (this.selectedInterval) {
@@ -396,13 +432,21 @@
     }
   },
   mounted() {
-    this.$store.commit("application/searchQuery", "");
-    this.loadLogs();
+    const { id } = this.$route.params;
+    if (!id) {
+      this.$store.commit("application/searchQuery", "");
+      this.loadLogs();
+    } else {
+      this.showSingleRessource(id);
+    }
   }
 };
 </script>
 
 <style lang="scss" scoped>
+.overview {
+  max-height: 90vh;
+}
 .date {
   font-stretch: condensed;
 }