changeset 1429:f4b3fb43b311

automatic imports WIP added
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 29 Nov 2018 16:41:49 +0100
parents ec0a0542c221
children 4e24c2db0bf5
files client/src/components/Sidebar.vue client/src/main.js client/src/router.js client/src/store/imports.js
diffstat 4 files changed, 139 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Sidebar.vue	Thu Nov 29 16:17:54 2018 +0100
+++ b/client/src/components/Sidebar.vue	Thu Nov 29 16:41:49 2018 +0100
@@ -58,6 +58,10 @@
           <font-awesome-icon icon="tasks" fixed-width></font-awesome-icon>
           <span v-translate class="fix-trans-space">Importqueue</span>
         </router-link>
+        <router-link v-if="this.$options.IMPORTSCHEDULE" to="importschedule">
+          <font-awesome-icon icon="clock" fixed-width></font-awesome-icon>
+          <translate>Importschedule</translate>
+        </router-link>
       </div>
       <hr class="m-0">
       <a href="#" @click="logoff">
@@ -108,6 +112,7 @@
       ];
     }
   },
+  IMPORTSCHEDULE: process.env.VUE_APP_FEATURE_IMPORTSCHEDULE,
   methods: {
     logoff() {
       this.$store.commit("reset");
--- a/client/src/main.js	Thu Nov 29 16:17:54 2018 +0100
+++ b/client/src/main.js	Thu Nov 29 16:41:49 2018 +0100
@@ -29,91 +29,95 @@
 import VTooltip from "v-tooltip";
 import { library } from "@fortawesome/fontawesome-svg-core";
 import {
+  faAngleDown,
+  faAngleLeft,
+  faAngleRight,
+  faAngleUp,
+  faBars,
+  faBook,
+  faChartArea,
+  faCheck,
+  faCity,
+  faClipboardCheck,
+  faClock,
+  faCopy,
+  faDrawPolygon,
+  faExclamationTriangle,
   faEye,
   faEyeSlash,
-  faCopy,
-  faCheck,
-  faTimes,
+  faFilePdf,
+  faFolderPlus,
   faInfo,
   faLayerGroup,
-  faChartArea,
+  faMapMarkedAlt,
+  faMinus,
+  faPaperPlane,
+  faPencilAlt,
+  faPlus,
+  faPowerOff,
   faRuler,
-  faDrawPolygon,
-  faAngleDown,
-  faAngleUp,
-  faAngleLeft,
-  faAngleRight,
-  faFolderPlus,
-  faFilePdf,
-  faBars,
   faSearch,
   faShip,
-  faUpload,
-  faTasks,
-  faUsersCog,
-  faMapMarkedAlt,
-  faClipboardCheck,
-  faWrench,
-  faBook,
-  faPowerOff,
-  faTrash,
+  faSortAmountDown,
+  faSortAmountUp,
+  faSpinner,
   faStar,
+  faTasks,
+  faTimes,
+  faTrash,
+  faUpload,
   faUser,
-  faExclamationTriangle,
-  faPaperPlane,
-  faPlus,
-  faMinus,
-  faSortAmountUp,
-  faSortAmountDown,
-  faSpinner,
-  faCity,
-  faWater
+  faUsersCog,
+  faWater,
+  faWrench
 } from "@fortawesome/free-solid-svg-icons";
 import { faAdn } from "@fortawesome/free-brands-svg-icons";
 import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
 import VueClipboard from "vue-clipboard2";
 
 library.add(
+  faAdn,
+  faAngleDown,
+  faAngleLeft,
+  faAngleRight,
+  faAngleUp,
+  faBars,
+  faBook,
+  faChartArea,
+  faCheck,
+  faCity,
+  faClipboardCheck,
+  faClock,
+  faCopy,
+  faDrawPolygon,
+  faExclamationTriangle,
   faEye,
   faEyeSlash,
-  faCopy,
-  faCheck,
-  faTimes,
+  faFilePdf,
+  faFolderPlus,
   faInfo,
   faLayerGroup,
-  faChartArea,
+  faMapMarkedAlt,
+  faMinus,
+  faPaperPlane,
+  faPencilAlt,
+  faPlus,
+  faPowerOff,
   faRuler,
-  faDrawPolygon,
-  faAngleDown,
-  faAngleUp,
-  faAngleLeft,
-  faAngleRight,
-  faFolderPlus,
-  faFilePdf,
-  faBars,
   faSearch,
   faShip,
-  faUpload,
-  faTasks,
-  faUsersCog,
-  faMapMarkedAlt,
-  faClipboardCheck,
-  faWrench,
-  faBook,
-  faPowerOff,
-  faTrash,
+  faSortAmountDown,
+  faSortAmountUp,
+  faSpinner,
   faStar,
-  faAdn,
+  faTasks,
+  faTimes,
+  faTrash,
+  faUpload,
   faUser,
-  faExclamationTriangle,
-  faPaperPlane,
-  faPlus,
-  faMinus,
-  faSortAmountUp,
-  faSortAmountDown,
-  faSpinner,
-  faCity,
-  faWater
+  faUsersCog,
+  faWater,
+  faWrench
 );
 Vue.component("font-awesome-icon", FontAwesomeIcon);
 
--- a/client/src/router.js	Thu Nov 29 16:17:54 2018 +0100
+++ b/client/src/router.js	Thu Nov 29 16:41:49 2018 +0100
@@ -25,6 +25,8 @@
   import("./components/admin/usermanagement/Usermanagement.vue");
 const Logs = () => import("./components/admin/Logs.vue");
 const Importqueue = () => import("./components/admin/Importqueue.vue");
+const Importschedule = () =>
+  import("./components/admin/importschedule/Importschedule.vue");
 const Systemconfiguration = () =>
   import("./components/admin/Systemconfiguration.vue");
 
@@ -93,7 +95,23 @@
         requiresAuth: true
       },
       beforeEnter: (to, from, next) => {
-        const isWaterwayAdmin = store.getters["user/isSysAdmin"];
+        const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"];
+        if (!isWaterwayAdmin) {
+          next("/");
+        } else {
+          next();
+        }
+      }
+    },
+    {
+      path: "/importschedule",
+      name: "importschedule",
+      component: Importschedule,
+      meta: {
+        requiresAuth: true
+      },
+      beforeEnter: (to, from, next) => {
+        const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"];
         if (!isWaterwayAdmin) {
           next("/");
         } else {
--- a/client/src/store/imports.js	Thu Nov 29 16:17:54 2018 +0100
+++ b/client/src/store/imports.js	Thu Nov 29 16:41:49 2018 +0100
@@ -22,11 +22,29 @@
   REJECTED: "REJECTED"
 };
 
+const SCHEDULES = {
+  DAILY: "daily",
+  MONTHLY: "monthly"
+};
+
 // initial state
 const init = () => {
   return {
     imports: [],
-    staging: []
+    staging: [],
+    schedules: [],
+    importScheduleDetail: null,
+    importScheduleDetailVisible: false
+  };
+};
+
+const newImportScheduleDetail = () => {
+  return {
+    import: "",
+    type: "",
+    author: "",
+    schedule: "",
+    emailNotification: null
   };
 };
 
@@ -35,6 +53,21 @@
   namespaced: true,
   state: init(),
   mutations: {
+    clearImportScheduleDetail: state => {
+      state.importScheduleDetail = newImportScheduleDetail();
+    },
+    deleteSchedule: (state, index) => {
+      state.schedules.splice(index, 1);
+    },
+    setImportScheduleDetailInvisible: state => {
+      state.importScheduleDetailVisible = false;
+    },
+    setImportScheduleDetailVisible: state => {
+      state.importScheduleDetailVisible = true;
+    },
+    setSchedules: (state, schedules) => {
+      state.schedules = schedules;
+    },
     setImports: (state, imports) => {
       state.imports = imports;
     },
@@ -58,6 +91,21 @@
     }
   },
   actions: {
+    getSchedules({ commit }) {
+      throw new Error("Not Implemented!");
+      return new Promise((resolve, reject) => {
+        HTTP.get("/imports", {
+          headers: { "X-Gemma-Auth": localStorage.getItem("token") }
+        })
+          .then(response => {
+            commit("setImports", response.data.imports);
+            resolve(response);
+          })
+          .catch(error => {
+            reject(error);
+          });
+      });
+    },
     getImports({ commit }) {
       return new Promise((resolve, reject) => {
         HTTP.get("/imports", {
@@ -85,23 +133,8 @@
             reject(error);
           });
       });
-    },
-    setStaging({ commit }, results) {
-      return new Promise((resolve, reject) => {
-        throw "Not implemented!";
-        HTTP.get("/imports?states=pending", {
-          headers: { "X-Gemma-Auth": localStorage.getItem("token") }
-        })
-          .then(response => {
-            commit("setStaging", response.data.imports);
-            resolve(response);
-          })
-          .catch(error => {
-            reject(error);
-          });
-      });
     }
   }
 };
 
-export { imports, STATES };
+export { imports, STATES, SCHEDULES };