Mercurial > gemma
changeset 2976:ac5ba5a0e963 unified_import
merge with default
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 09 Apr 2019 08:51:02 +0200 |
parents | 2a29bf8776d0 (diff) 7c301ff449bc (current diff) |
children | ab26fb7a76f6 |
files | |
diffstat | 11 files changed, 720 insertions(+), 369 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/App.vue Mon Apr 08 18:54:13 2019 +0200 +++ b/client/src/components/App.vue Tue Apr 09 08:51:02 2019 +0200 @@ -79,7 +79,7 @@ ...mapState("user", ["isAuthenticated"]), ...mapState("application", ["contextBoxContent", "showSearchbar"]), isMapVisible() { - return /importoverview|stretches|review|bottlenecks|mainview/.test( + return /importconfiguration|importoverview|stretches|review|bottlenecks|mainview/.test( this.routeName ); },
--- a/client/src/components/Contextbox.vue Mon Apr 08 18:54:13 2019 +0200 +++ b/client/src/components/Contextbox.vue Tue Apr 09 08:51:02 2019 +0200 @@ -6,6 +6,9 @@ <ImportOverview v-if="contextBoxContent === 'importoverview'" ></ImportOverview> + <ImportConfiguration + v-if="contextBoxContent === 'importconfiguration'" + ></ImportConfiguration> </div> </template> @@ -31,7 +34,9 @@ Bottlenecks: () => import("@/components/Bottlenecks"), Stretches: () => import("@/components/ImportStretches.vue"), ImportOverview: () => - import("@/components/importoverview/ImportOverview.vue") + import("@/components/importoverview/ImportOverview.vue"), + ImportConfiguration: () => + import("@/components/importconfiguration/Import.vue") }, computed: { ...mapState("application", [
--- a/client/src/components/ImportApprovedGaugeMeasurement.vue Mon Apr 08 18:54:13 2019 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,140 +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="importGaugmeasurmentLabel" /> - <div class="card-body stretches-card"> - <div class="w-95 ml-auto mr-auto mt-4 mb-4"> - <div class="d-flex flex-column text-left w-25"> - <label class="text-nowrap" for="originator"> - <small class="text-muted" - >{{ $options.ORIGINATOR }} / {{ $options.FROM }}</small - > - </label> - <input - type="text" - v-model="originator" - class="form-control" - id="originator" - /> - <span class="text-left text-danger"> - <small v-if="!originator"> - <translate>Please enter an originator</translate> - </small> - </span> - </div> - <div class="mt-4 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> -</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 { HTTP } from "@/lib/http"; -import { displayError, displayInfo } from "@/lib/errors.js"; -import app from "@/main"; - -export default { - name: "importapprovedgaugemeasurements", - data() { - return { - disableUploadButton: false, - uploadLabel: this.$gettext("choose file to upload"), - uploadFile: null, - originator: "viadonau" - }; - }, - computed: { - importGaugmeasurmentLabel() { - return this.$gettext("Import approved gaugemeasurements"); - } - }, - methods: { - initialState() { - this.uploadLabel = this.$gettext("choose file to upload"); - this.uploadFile = null; - this.originator = "viadonau"; - }, - 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.originator || !this.uploadFile) return; - let formData = new FormData(); - formData.append("agm", this.uploadFile); - formData.append("originator", this.originator); - HTTP.post("/imports/agm", formData, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token"), - "Content-Type": "multipart/form-data" - } - }) - .then(() => { - displayInfo({ - title: this.$gettext("Import"), - message: this.$gettext( - "Starting import of Approved Gauge Measurements" - ) - }); - this.initialState(); - }) - .catch(error => { - const { status, data } = error.response; - displayError({ - title: this.$gettext("Backend Error"), - message: `${status}: ${data.message || data}` - }); - }); - } - }, - components: { - Spacer: () => import("./Spacer") - }, - ORIGINATOR: app.$gettext("originator"), - FROM: app.$gettext("from") -}; -</script> - -<style lang="scss" scoped></style>
--- a/client/src/components/ImportWaterwayProfiles.vue Mon Apr 08 18:54:13 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 18:54:13 2019 +0200 +++ b/client/src/components/Sidebar.vue Tue Apr 09 08:51:02 2019 +0200 @@ -49,20 +49,14 @@ <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="/importapprovedgaugemeasurement"> - <font-awesome-icon class="fa-fw mr-2" fixed-width icon="upload" /> - <span class="fix-trans-space" v-translate - >Approved Gaugemeasurements</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> </router-link> + <router-link to="/imports/configuration"> + <font-awesome-icon class="fa-fw mr-2" fixed-width icon="clock" /> + <translate class="fix-trans-space">Imports (New)</translate> + </router-link> <small class="text-muted pl-3"> <translate>Systemadministration</translate> </small>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/importconfiguration/Import.vue Tue Apr 09 08:51:02 2019 +0200 @@ -0,0 +1,256 @@ +<template> + <div> + <UIBoxHeader icon="clock" :title="title" /> + <div v-if="mode === $options.MODES.LIST" class="mb-3"> + <UISpinnerOverlay v-if="loading" /> + <UITableHeader + :columns="[ + { id: 'id', title: `${idLabel}`, class: 'col-1' }, + { id: 'kind', title: `${typeLabel}`, class: 'col-2' }, + { id: 'user', title: `${authorLabel}`, class: 'col-2' }, + { id: 'config.cron', title: `${scheduleLabel}`, class: 'col-2' }, + { id: 'config.send-email', title: `${emailLabel}`, class: 'col-2' } + ]" + /> + <UITableBody + :data="filteredSchedules | sortTable(sortColumn, sortDirection)" + :isActive="item => currentSchedule && item.id === currentSchedule.id" + > + <template v-slot:row="{ item: schedule }"> + <div class="table-cell col-1">{{ schedule.id }}</div> + <div class="table-cell col-2"> + {{ schedule.kind.toUpperCase() }} + </div> + <div class="table-cell col-2">{{ schedule.user }}</div> + <div class="table-cell col-2">{{ schedule.config.cron }}</div> + <div class="table-cell col-2"> + <font-awesome-icon + v-if="schedule.config['send-email']" + class="fa-fw mr-2" + fixed-width + icon="check" + /> + </div> + <div class="table-cell col justify-content-end"> + <button + @click="triggerManualImport(schedule.id)" + class="btn btn-xs btn-dark mr-1" + :disabled="importScheduleDetailVisible" + > + <font-awesome-icon icon="play" fixed-width /> + </button> + <button + @click="editSchedule(schedule.id)" + class="btn btn-xs btn-dark mr-1" + :disabled="importScheduleDetailVisible" + > + <font-awesome-icon icon="pencil-alt" fixed-width /> + </button> + <button + @click="deleteSchedule(schedule)" + class="btn btn-xs btn-dark" + :disabled="importScheduleDetailVisible" + > + <font-awesome-icon icon="trash" fixed-width /> + </button> + </div> + </template> + </UITableBody> + </div> + <ImportDetails v-if="mode === $options.MODES.EDIT"></ImportDetails> + <div class="d-flex flex-row-reverse w-100 mb-3"> + <button + :key="1" + v-if="mode === $options.MODES.EDIT && !isOnetime" + @click="back()" + class="btn btn-warning mr-3" + > + Back + </button> + <button + :key="2" + v-if=" + mode === $options.MODES.EDIT && + currentSchedule.importType && + !isOnetime + " + type="submit" + class="shadow-sm btn btn-info submit-button mr-3" + > + <translate>Submit</translate> + </button> + <button + :key="3" + v-if="mode === $options.MODES.LIST && !isOnetime" + @click="newConfiguration()" + class="btn btn-info mr-3" + > + <translate>New import</translate> + </button> + <button + v-if=" + mode === $options.MODES.EDIT && + currentSchedule.importType && + !isOnetime + " + @click="triggerManualImport" + type="button" + class="shadow-sm btn btn-outline-info trigger mr-auto ml-3" + > + <font-awesome-icon class="fa-fw mr-2" fixed-width icon="play" /> + <translate>Trigger import</translate> + </button> + </div> + </div> +</template> + +<style></style> + +<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> + * Markus Kottländer <markus.kottlaender@intevation.de> + */ +import { mapState } from "vuex"; +import { displayInfo, displayError } from "@/lib/errors"; +import { HTTP } from "@/lib/http"; +import { + IMPORTTYPES, + MODES + // IMPORTTYPEKIND, + // initializeCurrentSchedule +} from "@/store/importschedule"; + +export default { + components: { + ImportDetails: () => import("./ImportDetails.vue") + }, + data() { + return { + loading: false, + sortColumn: "", + sortDirection: "" + }; + }, + methods: { + back() { + this.$store.commit("importschedule/setListMode"); + }, + newConfiguration() { + this.$store.commit("importschedule/setEditMode"); + }, + getSchedules() { + this.loading = true; + this.$store + .dispatch("importschedule/loadSchedules") + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }) + .finally(() => { + this.loading = false; + }); + }, + editSchedule(id) { + this.$store + .dispatch("importschedule/loadSchedule", id) + .then(() => { + this.$store.commit("importschedule/setImportScheduleDetailVisible"); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + }, + triggerManualImport(id) { + HTTP.get("/imports/config/" + id + "/run", { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } + }) + .then(response => { + const { id } = response.data; + displayInfo({ + title: this.$gettext("Imports"), + message: this.$gettext("Manually triggered import: #") + id + }); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + } + }, + computed: { + ...mapState("application", ["searchQuery"]), + ...mapState("importschedule", [ + "mode", + "schedules", + "currentSchedule", + "importScheduleDetailVisible" + ]), + isOnetime() { + for (let kind of [ + this.$options.IMPORTTYPES.SOUNDINGRESULTS, + this.$options.IMPORTTYPES.APPROVEDGAUGEMEASUREMENTS, + this.$options.IMPORTTYPES.WATERWAYPROFILES + ]) { + if (kind === this.currentSchedule.importType) return true; + } + return false; + }, + title() { + return this.$gettext("Imports"); + }, + filteredSchedules() { + return this.schedules.filter(s => { + return (s.id + s.kind) + .toLowerCase() + .includes(this.searchQuery.toLowerCase()); + }); + }, + importScheduleLabel() { + return this.$gettext("Import Schedule"); + }, + idLabel() { + return this.$gettext("ID"); + }, + typeLabel() { + return this.$gettext("Type"); + }, + authorLabel() { + return this.$gettext("Author"); + }, + scheduleLabel() { + return this.$gettext("Schedule"); + }, + emailLabel() { + return this.$gettext("Email"); + } + }, + mounted() { + this.$store.commit("importschedule/setListMode"); + this.$store.commit("importschedule/clearCurrentSchedule"); + this.getSchedules(); + }, + IMPORTTYPES: IMPORTTYPES, + MODES: MODES +}; +</script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/importconfiguration/ImportApprovedGaugeMeasurement.vue Tue Apr 09 08:51:02 2019 +0200 @@ -0,0 +1,132 @@ +<template> + <div> + <div class="d-flex flex-column text-left w-25"> + <label class="text-nowrap" for="originator"> + <small class="text-muted" + >{{ $options.ORIGINATOR }} / {{ $options.FROM }}</small + > + </label> + <input + type="text" + v-model="originator" + class="form-control" + id="originator" + /> + <span class="text-left text-danger"> + <small v-if="!originator"> + <translate>Please enter an originator</translate> + </small> + </span> + </div> + <div class="mt-4 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 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 { HTTP } from "@/lib/http"; +import { displayError, displayInfo } from "@/lib/errors.js"; +import app from "@/main"; + +export default { + name: "importapprovedgaugemeasurements", + data() { + return { + disableUploadButton: false, + uploadLabel: this.$gettext("choose file to upload"), + uploadFile: null, + originator: "viadonau" + }; + }, + computed: { + importGaugmeasurmentLabel() { + return this.$gettext("Import approved gaugemeasurements"); + } + }, + methods: { + back() { + this.uploadLabel = this.$gettext("choose file to upload"); + this.uploadFile = null; + this.originator = "viadonau"; + 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.originator || !this.uploadFile) return; + let formData = new FormData(); + formData.append("agm", this.uploadFile); + formData.append("originator", this.originator); + HTTP.post("/imports/agm", formData, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token"), + "Content-Type": "multipart/form-data" + } + }) + .then(() => { + displayInfo({ + title: this.$gettext("Import"), + message: this.$gettext( + "Starting import of Approved Gauge Measurements" + ) + }); + this.back(); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.$gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }); + } + }, + ORIGINATOR: app.$gettext("originator"), + FROM: app.$gettext("from") +}; +</script> + +<style lang="scss" scoped></style>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/importconfiguration/ImportDetails.vue Tue Apr 09 08:51:02 2019 +0200 @@ -0,0 +1,108 @@ +<template> + <div class="mt-3 mb-3 mr-3 ml-3"> + <select v-model="Import" class="custom-select" id="importtype"> + <optgroup :label="regularLabel"> + <option :value="$options.IMPORTTYPES.BOTTLENECK"> + <translate>Bottlenecks</translate> + </option> + <option :value="$options.IMPORTTYPES.WATERWAYAXIS"> + <translate>Waterway axis</translate> + </option> + <option :value="$options.IMPORTTYPES.GAUGEMEASUREMENT"> + <translate>Gauge measurement</translate> + </option> + <option :value="$options.IMPORTTYPES.FAIRWAYAVAILABILITY"> + <translate>Available fairway depths</translate> + </option> + <option :value="$options.IMPORTTYPES.WATERWAYAREA"> + <translate>Waterway area</translate> + </option> + <option :value="$options.IMPORTTYPES.FAIRWAYDIMENSION"> + <translate>Fairway dimension</translate> + </option> + <option :value="$options.IMPORTTYPES.WATERWAYGAUGES"> + <translate>Waterway gauges</translate> + </option> + <option :value="$options.IMPORTTYPES.DISTANCEMARKSVIRTUAL"> + <translate>Distance marks virtual</translate> + </option> + <option :value="$options.IMPORTTYPES.DISTANCEMARKSASHORE"> + <translate>Distance marks ashore</translate> + </option> + </optgroup> + <optgroup :label="onetimeLabel"> + <option :value="$options.IMPORTTYPES.SOUNDINGRESULTS"> + <translate>Soundingresults</translate> + </option> + <option :value="$options.IMPORTTYPES.APPROVEDGAUGEMEASUREMENTS"> + <translate>Approved Gaugemeasurements</translate> + </option> + <option :value="$options.IMPORTTYPES.WATERWAYPROFILES"> + <translate>Waterway Profiles</translate> + </option> + </optgroup> + </select> + <ApprovedGaugeMeasurement + v-if="Import === $options.IMPORTTYPES.APPROVEDGAUGEMEASUREMENTS" + /> + <WaterwayProfiles v-if="Import === $options.IMPORTTYPES.WATERWAYPROFILES" /> + </div> +</template> + +<style lang="scss" scoped></style> + +<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, 2019 by via donau + * – Österreichische Wasserstraßen-Gesellschaft mbH + * Software engineering by Intevation GmbH + * + * Author(s): + * Thomas Junk <thomas.junk@intevation.de> + * Tom Gottfried <tom.gottfried@intevation.de> + */ +import { + IMPORTTYPES + // IMPORTTYPEKIND, + // initializeCurrentSchedule +} from "@/store/importschedule"; +import { mapState } from "vuex"; +// import { displayInfo, displayError } from "@/lib/errors.js"; +// import app from "@/main.js"; +// import { HTTP } from "@/lib/http"; + +export default { + components: { + ApprovedGaugeMeasurement: () => + import("./ImportApprovedGaugeMeasurement.vue"), + WaterwayProfiles: () => import("./ImportWaterwayProfiles") + }, + data() { + return {}; + }, + computed: { + ...mapState("importschedule", ["currentSchedule"]), + Import: { + get() { + return this.currentSchedule.importType; + }, + set(value) { + this.$store.commit("importschedule/setImportType", value); + } + }, + onetimeLabel() { + return this.$gettext("Onetime Imports"); + }, + regularLabel() { + return this.$gettext("Regular Imports"); + } + }, + methods: {}, + IMPORTTYPES: IMPORTTYPES +}; +</script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/importconfiguration/ImportWaterwayProfiles.vue Tue Apr 09 08:51:02 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 18:54:13 2019 +0200 +++ b/client/src/router.js Tue Apr 09 08:51:02 2019 +0200 @@ -97,38 +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: "/importapprovedgaugemeasurement", - name: "approvedgaugemeasurement", - component: () => import("./components/ImportApprovedGaugeMeasurement"), - 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"), @@ -175,6 +143,26 @@ } }, { + path: "/imports/configuration", + name: "importconfiguration", + component: Maplayer, + meta: { + requiresAuth: true + }, + beforeEnter: (to, from, next) => { + const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; + if (!isWaterwayAdmin) { + next("/login"); + } else { + store.commit("application/searchQuery", ""); + store.commit("application/showContextBox", true); + store.commit("application/contextBoxContent", "importconfiguration"); + store.commit("application/showSearchbar", true); + next(); + } + } + }, + { path: "/imports/overview/:id?", name: "importoverview", component: Maplayer,
--- a/client/src/store/importschedule.js Mon Apr 08 18:54:13 2019 +0200 +++ b/client/src/store/importschedule.js Tue Apr 09 08:51:02 2019 +0200 @@ -27,7 +27,10 @@ FAIRWAYDIMENSION: "fairwaydimension", WATERWAYGAUGES: "waterwaygauges", DISTANCEMARKSVIRTUAL: "distancemarksvirtual", - DISTANCEMARKSASHORE: "distancemarksashore" + DISTANCEMARKSASHORE: "distancemarksashore", + SOUNDINGRESULTS: "soundingresults", + APPROVEDGAUGEMEASUREMENTS: "approvedgaugemeasurements", + WATERWAYPROFILES: "waterwayprofiles" }; const KINDIMPORTTYPE = { @@ -88,12 +91,18 @@ }; }; +const MODES = { + LIST: "list", + EDIT: "edit" +}; + // initial state const init = () => { return { schedules: [], importScheduleDetailVisible: false, - currentSchedule: initializeCurrentSchedule() + currentSchedule: initializeCurrentSchedule(), + mode: MODES.LIST }; }; @@ -102,6 +111,16 @@ namespaced: true, state: init(), mutations: { + setEditMode: state => { + state.mode = MODES.EDIT; + }, + setListMode: state => { + state.currentSchedule = initializeCurrentSchedule(); + state.mode = MODES.LIST; + }, + setImportType: (state, type) => { + Vue.set(state.currentSchedule, "importType", type); + }, clearCurrentSchedule: state => { state.currentSchedule = initializeCurrentSchedule(); }, @@ -320,5 +339,6 @@ importschedule, initializeCurrentSchedule, IMPORTTYPES, - IMPORTTYPEKIND + IMPORTTYPEKIND, + MODES };