changeset 2975:2a29bf8776d0 unified_import

unified_imports: waterway profiles moved to new UI
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 08 Apr 2019 17:17:01 +0200
parents e161e1ffb6b5
children ac5ba5a0e963
files client/src/components/ImportWaterwayProfiles.vue client/src/components/Sidebar.vue client/src/components/importconfiguration/Import.vue client/src/components/importconfiguration/ImportApprovedGaugeMeasurement.vue client/src/components/importconfiguration/ImportDetails.vue client/src/components/importconfiguration/ImportWaterwayProfiles.vue client/src/router.js
diffstat 7 files changed, 181 insertions(+), 204 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/ImportWaterwayProfiles.vue	Mon Apr 08 16:44:15 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-<template>
-  <div class="d-flex flex-row">
-    <Spacer />
-    <div class="card sysconfig mt-2 shadow-xs w-100 h-100 mr-2">
-      <UIBoxHeader icon="upload" :title="importWaterwayProfilesLabel" />
-      <div class="card-body stretches-card">
-        <div class="w-95 ml-auto mr-auto mt-4 mb-4">
-          <div class="mb-4">
-            <div class="d-flex flex-row">
-              <div class="flex-column w-100">
-                <div class="flex-row text-left">
-                  <small class="text-muted"> <translate>URL</translate> </small>
-                </div>
-                <div class="w-100">
-                  <input class="form-control" type="url" v-model="url" />
-                </div>
-              </div>
-            </div>
-            <div v-if="!url" class="d-flex flex-row">
-              <small
-                ><translate class="text-danger"
-                  >Please enter a URL</translate
-                ></small
-              >
-            </div>
-            <div class="d-flex flex-row">
-              <div class="flex-column mt-3 mr-3 w-50">
-                <div class="flex-row text-left">
-                  <small class="text-muted">
-                    <translate>Featuretype</translate>
-                  </small>
-                </div>
-                <div class="w-100">
-                  <input
-                    class="form-control"
-                    type="text"
-                    v-model="featureType"
-                  />
-                </div>
-                <div v-if="!featureType" class="d-flex flex-row">
-                  <small
-                    ><translate class="text-danger"
-                      >Please enter a Featuretype</translate
-                    ></small
-                  >
-                </div>
-              </div>
-              <div class="flex-column mt-3 w-50">
-                <div class="flex-row text-left">
-                  <small class="text-muted">
-                    <translate>SortBy</translate>
-                  </small>
-                </div>
-                <div class="w-100">
-                  <input class="form-control" type="text" v-model="sortBy" />
-                </div>
-                <div v-if="!sortBy" class="d-flex flex-row">
-                  <small
-                    ><translate class="text-danger"
-                      >Please enter SortBy</translate
-                    ></small
-                  >
-                </div>
-              </div>
-            </div>
-          </div>
-          <div class="d-flex flex-row text-left">
-            <div class="mt-3 mb-3 flex-column w-100">
-              <div class="custom-file">
-                <input
-                  accept=".csv"
-                  type="file"
-                  @change="fileSelected"
-                  class="custom-file-input"
-                  id="uploadFile"
-                />
-                <label class="pointer custom-file-label" for="uploadFile">
-                  {{ uploadLabel }}
-                </label>
-              </div>
-            </div>
-          </div>
-          <div class="buttons text-right">
-            <button
-              :disabled="disableUploadButton"
-              @click="submit"
-              class="btn btn-info mt-4"
-              type="button"
-            >
-              <font-awesome-icon class="fa-fw mr-2" fixed-width icon="play" />
-              <translate>Trigger import</translate>
-            </button>
-          </div>
-        </div>
-      </div>
-    </div>
-  </div>
-</template>
-
-<script>
-/* This is Free Software under GNU Affero General Public License v >= 3.0
- * without warranty, see README.md and license for details.
- *
- * SPDX-License-Identifier: AGPL-3.0-or-later
- * License-Filename: LICENSES/AGPL-3.0.txt
- *
- * Copyright (C) 2018 by via donau
- *   – Österreichische Wasserstraßen-Gesellschaft mbH
- * Software engineering by Intevation GmbH
- *
- * Author(s):
- * Thomas Junk <thomas.junk@intevation.de>
- */
-
-import { displayError, displayInfo } from "@/lib/errors.js";
-import { HTTP } from "@/lib/http";
-
-export default {
-  name: "importwaterwayprofiles",
-  components: {
-    Spacer: () => import("./Spacer")
-  },
-  data() {
-    return {
-      url: "https://service.d4d-portal.info/wamos/wfs/",
-      sortBy: "hydro_scamin",
-      featureType: "ws-wamos:ienc_wtwprf",
-      disableUploadButton: false,
-      uploadLabel: this.$gettext("choose file to upload"),
-      uploadFile: null
-    };
-  },
-  computed: {
-    importWaterwayProfilesLabel() {
-      return this.$gettext("Import Waterway Profiles");
-    }
-  },
-  methods: {
-    fileSelected(e) {
-      const files = e.target.files || e.dataTransfer.files;
-      if (!files) return;
-      this.uploadLabel = files[0].name;
-      this.uploadFile = files[0];
-    },
-    submit() {
-      if (!this.url || !this.featureType || !this.sortBy || !this.uploadFile)
-        return;
-      let formData = new FormData();
-      formData.append("wp", this.uploadFile);
-      formData.append("url", this.url);
-      formData.append("feature-type", this.featureType);
-      formData.append("sort-by", this.sortBy);
-      HTTP.post("/imports/wp", formData, {
-        headers: {
-          "X-Gemma-Auth": localStorage.getItem("token"),
-          "Content-Type": "multipart/form-data"
-        }
-      })
-        .then(() => {
-          displayInfo({
-            title: this.$gettext("Import"),
-            message:
-              this.uploadLabel + this.$gettext(" was successfully uploaded.")
-          });
-          this.url = "https://service.d4d-portal.info/wamos/wfs/";
-          this.uploadFile = null;
-          this.uploadLabel = this.$gettext("choose file to upload");
-        })
-        .catch(error => {
-          const { status, data } = error.response;
-          const messages = data.messages ? data.messages.join(", ") : "";
-          displayError({
-            title: this.$gettext("Backend Error"),
-            message: `${status}: ${messages}`
-          });
-        });
-    }
-  }
-};
-</script>
-
-<style lang="scss" scoped></style>
--- a/client/src/components/Sidebar.vue	Mon Apr 08 16:44:15 2019 +0200
+++ b/client/src/components/Sidebar.vue	Mon Apr 08 17:17:01 2019 +0200
@@ -49,10 +49,6 @@
             <font-awesome-icon class="fa-fw mr-2" fixed-width icon="upload" />
             <span class="fix-trans-space" v-translate>Soundingresults</span>
           </router-link>
-          <router-link to="/importwaterwayprofiles">
-            <font-awesome-icon class="fa-fw mr-2" fixed-width icon="upload" />
-            <span class="fix-trans-space" v-translate>Waterway Profiles</span>
-          </router-link>
           <router-link to="/importschedule">
             <font-awesome-icon class="fa-fw mr-2" fixed-width icon="clock" />
             <translate class="fix-trans-space">Imports</translate>
--- a/client/src/components/importconfiguration/Import.vue	Mon Apr 08 16:44:15 2019 +0200
+++ b/client/src/components/importconfiguration/Import.vue	Mon Apr 08 17:17:01 2019 +0200
@@ -69,7 +69,11 @@
       </button>
       <button
         :key="2"
-        v-if="mode === $options.MODES.EDIT && !isOnetime"
+        v-if="
+          mode === $options.MODES.EDIT &&
+            currentSchedule.importType &&
+            !isOnetime
+        "
         type="submit"
         class="shadow-sm btn btn-info submit-button  mr-3"
       >
--- a/client/src/components/importconfiguration/ImportApprovedGaugeMeasurement.vue	Mon Apr 08 16:44:15 2019 +0200
+++ b/client/src/components/importconfiguration/ImportApprovedGaugeMeasurement.vue	Mon Apr 08 17:17:01 2019 +0200
@@ -84,6 +84,9 @@
   },
   methods: {
     back() {
+      this.uploadLabel = this.$gettext("choose file to upload");
+      this.uploadFile = null;
+      this.originator = "viadonau";
       this.$store.commit("importschedule/setListMode");
     },
     fileSelected(e) {
--- a/client/src/components/importconfiguration/ImportDetails.vue	Mon Apr 08 16:44:15 2019 +0200
+++ b/client/src/components/importconfiguration/ImportDetails.vue	Mon Apr 08 17:17:01 2019 +0200
@@ -45,6 +45,7 @@
     <ApprovedGaugeMeasurement
       v-if="Import === $options.IMPORTTYPES.APPROVEDGAUGEMEASUREMENTS"
     />
+    <WaterwayProfiles v-if="Import === $options.IMPORTTYPES.WATERWAYPROFILES" />
   </div>
 </template>
 
@@ -78,7 +79,8 @@
 export default {
   components: {
     ApprovedGaugeMeasurement: () =>
-      import("./ImportApprovedGaugeMeasurement.vue")
+      import("./ImportApprovedGaugeMeasurement.vue"),
+    WaterwayProfiles: () => import("./ImportWaterwayProfiles")
   },
   data() {
     return {};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/components/importconfiguration/ImportWaterwayProfiles.vue	Mon Apr 08 17:17:01 2019 +0200
@@ -0,0 +1,170 @@
+<template>
+  <div>
+    <div class="mb-4">
+      <div class="d-flex flex-row">
+        <div class="flex-column w-100">
+          <div class="flex-row text-left">
+            <small class="text-muted"> <translate>URL</translate> </small>
+          </div>
+          <div class="w-100">
+            <input class="form-control" type="url" v-model="url" />
+          </div>
+        </div>
+      </div>
+      <div v-if="!url" class="d-flex flex-row">
+        <small
+          ><translate class="text-danger">Please enter a URL</translate></small
+        >
+      </div>
+      <div class="d-flex flex-row">
+        <div class="flex-column mt-3 mr-3 w-50">
+          <div class="flex-row text-left">
+            <small class="text-muted">
+              <translate>Featuretype</translate>
+            </small>
+          </div>
+          <div class="w-100">
+            <input class="form-control" type="text" v-model="featureType" />
+          </div>
+          <div v-if="!featureType" class="d-flex flex-row">
+            <small
+              ><translate class="text-danger"
+                >Please enter a Featuretype</translate
+              ></small
+            >
+          </div>
+        </div>
+        <div class="flex-column mt-3 w-50">
+          <div class="flex-row text-left">
+            <small class="text-muted">
+              <translate>SortBy</translate>
+            </small>
+          </div>
+          <div class="w-100">
+            <input class="form-control" type="text" v-model="sortBy" />
+          </div>
+          <div v-if="!sortBy" class="d-flex flex-row">
+            <small
+              ><translate class="text-danger"
+                >Please enter SortBy</translate
+              ></small
+            >
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="d-flex flex-row text-left">
+      <div class="mt-3 mb-3 flex-column w-100">
+        <div class="custom-file">
+          <input
+            accept=".csv"
+            type="file"
+            @change="fileSelected"
+            class="custom-file-input"
+            id="uploadFile"
+          />
+          <label class="pointer custom-file-label" for="uploadFile">
+            {{ uploadLabel }}
+          </label>
+        </div>
+      </div>
+    </div>
+    <div class="d-flex flex-row-reverse w-100 mt-3">
+      <button :key="1" @click="back()" class="btn btn-warning">
+        Back
+      </button>
+      <button
+        :key="2"
+        type="submit"
+        @click="submit"
+        class="shadow-sm btn btn-info submit-button  mr-3"
+      >
+        <translate>Submit</translate>
+      </button>
+    </div>
+  </div>
+</template>
+
+<script>
+/* This is Free Software under GNU Affero General Public License v >= 3.0
+ * without warranty, see README.md and license for details.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ * License-Filename: LICENSES/AGPL-3.0.txt
+ *
+ * Copyright (C) 2018 by via donau
+ *   – Österreichische Wasserstraßen-Gesellschaft mbH
+ * Software engineering by Intevation GmbH
+ *
+ * Author(s):
+ * Thomas Junk <thomas.junk@intevation.de>
+ */
+
+import { displayError, displayInfo } from "@/lib/errors.js";
+import { HTTP } from "@/lib/http";
+
+export default {
+  data() {
+    return {
+      url: "https://service.d4d-portal.info/wamos/wfs/",
+      sortBy: "hydro_scamin",
+      featureType: "ws-wamos:ienc_wtwprf",
+      disableUploadButton: false,
+      uploadLabel: this.$gettext("choose file to upload"),
+      uploadFile: null
+    };
+  },
+  computed: {
+    importWaterwayProfilesLabel() {
+      return this.$gettext("Import Waterway Profiles");
+    }
+  },
+  methods: {
+    back() {
+      this.url = "https://service.d4d-portal.info/wamos/wfs/";
+      this.uploadFile = null;
+      this.uploadLabel = this.$gettext("choose file to upload");
+      this.$store.commit("importschedule/setListMode");
+    },
+    fileSelected(e) {
+      const files = e.target.files || e.dataTransfer.files;
+      if (!files) return;
+      this.uploadLabel = files[0].name;
+      this.uploadFile = files[0];
+    },
+    submit() {
+      if (!this.url || !this.featureType || !this.sortBy || !this.uploadFile)
+        return;
+      let formData = new FormData();
+      formData.append("wp", this.uploadFile);
+      formData.append("url", this.url);
+      formData.append("feature-type", this.featureType);
+      formData.append("sort-by", this.sortBy);
+      HTTP.post("/imports/wp", formData, {
+        headers: {
+          "X-Gemma-Auth": localStorage.getItem("token"),
+          "Content-Type": "multipart/form-data"
+        }
+      })
+        .then(() => {
+          displayInfo({
+            title: this.$gettext("Import"),
+            message:
+              this.uploadLabel + this.$gettext(" was successfully uploaded.")
+          });
+          this.back();
+        })
+        .catch(error => {
+          const { status, data } = error.response;
+          const messages = data.messages ? data.messages.join(", ") : "";
+          displayError({
+            title: this.$gettext("Backend Error"),
+            message: `${status}: ${messages}`
+          });
+        });
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>
--- a/client/src/router.js	Mon Apr 08 16:44:15 2019 +0200
+++ b/client/src/router.js	Mon Apr 08 17:17:01 2019 +0200
@@ -97,22 +97,6 @@
       }
     },
     {
-      path: "/importwaterwayprofiles",
-      name: "waterwayprofiles",
-      component: () => import("./components/ImportWaterwayProfiles"),
-      meta: {
-        requiresAuth: true
-      },
-      beforeEnter: (to, from, next) => {
-        const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"];
-        if (!isWaterwayAdmin) {
-          next("/login");
-        } else {
-          next();
-        }
-      }
-    },
-    {
       path: "/importschedule",
       name: "importschedule",
       component: () => import("./components/importschedule/Importschedule.vue"),