changeset 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 c9032a57996e
children db1052bc162a
files client/src/components/importoverview/ImportOverview.vue client/src/components/importoverview/LogDetail.vue client/src/components/importoverview/LogEntry.vue
diffstat 3 files changed, 69 insertions(+), 25 deletions(-) [+]
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;
 }
--- a/client/src/components/importoverview/LogDetail.vue	Mon Mar 25 15:42:53 2019 +0100
+++ b/client/src/components/importoverview/LogDetail.vue	Mon Mar 25 16:16:58 2019 +0100
@@ -92,8 +92,6 @@
  */
 
 import { mapState } from "vuex";
-import { displayError } from "@/lib/errors.js";
-import { HTTP } from "@/lib/http.js";
 
 export default {
   name: "logdetail",
@@ -105,23 +103,10 @@
     AdditionalLog: () => import("./AdditionalLog.vue")
   },
   mounted() {
-    HTTP.get("/imports/" + this.entry.id, {
-      headers: { "X-Gemma-Auth": localStorage.getItem("token") }
-    })
-      .then(response => {
-        this.$store.commit("imports/setCurrentDetails", response.data);
-        if (this.entry.state === "pending") {
-          this.$store.commit("imports/showAdditionalInfoFor", this.entry.id);
-        }
-        this.$store.commit("imports/showAdditionalLogsFor", this.entry.id);
-      })
-      .catch(error => {
-        const { status, data } = error.response;
-        displayError({
-          title: this.$gettext("Backend Error"),
-          message: `${status}: ${data.message || data}`
-        });
-      });
+    if (this.entry.state === "pending") {
+      this.$store.commit("imports/showAdditionalInfoFor", this.entry.id);
+    }
+    this.$store.commit("imports/showAdditionalLogsFor", this.entry.id);
   },
   methods: {
     toggleAdditionalInfo() {
--- a/client/src/components/importoverview/LogEntry.vue	Mon Mar 25 15:42:53 2019 +0100
+++ b/client/src/components/importoverview/LogEntry.vue	Mon Mar 25 16:16:58 2019 +0100
@@ -117,6 +117,8 @@
  */
 import { mapState } from "vuex";
 import { STATES } from "@/store/imports.js";
+import { displayError } from "@/lib/errors.js";
+import { HTTP } from "@/lib/http.js";
 
 export default {
   name: "importlogentry",
@@ -143,7 +145,20 @@
         this.$store.commit("imports/hideAdditionalInfo");
         this.$store.commit("imports/hideAdditionalLogs");
       } else {
-        this.$store.commit("imports/showDetailsFor", id);
+        HTTP.get("/imports/" + this.entry.id, {
+          headers: { "X-Gemma-Auth": localStorage.getItem("token") }
+        })
+          .then(response => {
+            this.$store.commit("imports/showDetailsFor", id);
+            this.$store.commit("imports/setCurrentDetails", response.data);
+          })
+          .catch(error => {
+            const { status, data } = error.response;
+            displayError({
+              title: this.$gettext("Backend Error"),
+              message: `${status}: ${data.message || data}`
+            });
+          });
       }
     }
   },