Mercurial > gemma
view client/src/components/importconfiguration/types/WaterwayProfiles.vue @ 4643:a1a9b1eab57c stree-experiment
Use append/slicing trick to simplify tree traversals.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 11 Oct 2019 23:46:35 +0200 |
parents | 439e1865a2d2 |
children | 1ff56484db4e |
line wrap: on
line source
<template> <div> <div class="mb-2 px-2"> <div :key="1" class="flex-column mr-4"> <div class="flex-row text-left"> <small class="text-muted"> <translate>Email Notification</translate> </small> </div> <div class="flex-flex-row text-left"> <toggle-button v-model="eMailNotification" class="mt-2" :speed="100" :labels="{ checked: this.$options.on, unchecked: this.$options.off }" :width="60" :height="30" /> </div> </div> <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 form-control-sm" 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-2 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 form-control-sm" 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-2 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 form-control-sm" 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 text-left px-2"> <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 justify-content-between w-100 p-2 border-top"> <button :key="1" @click="back()" class="btn btn-sm btn-warning"> Back </button> <button :key="2" type="submit" @click="submit" class="btn btn-sm btn-info submit-button" > <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"; 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, eMailNotification: false }; }, 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); if (this.eMailNotification) { formData.append("send-email", this.eMailNotification); } 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}` }); }); } }, on: "on", off: "off" }; </script> <style lang="scss" scoped></style>