Mercurial > gemma
view client/src/components/stretches/StretchForm.vue @ 5338:f8e7f043d968 extented-report
Fixed example_conf.toml for new report-path.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 15 Jun 2021 22:00:20 +0200 |
parents | 6b054b91d9b2 |
children |
line wrap: on
line source
<template> <div class="d-flex flex-column"> <div class="ml-2 mr-2 my-3"> <div class="custom-file mt-3"> <input accept=".zip,.txt" 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 justify-content-between mt-2 p-2 border-top"> <button @click="$parent.showForm = false" class="btn btn-sm btn-warning"> <translate>Back</translate> </button> <button @click="save" type="submit" class="shadow-sm btn btn-sm btn-info submit-button" :disabled="!uploadFile" > <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, 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> * Markus Kottländer <markus.kottlaender@intevation.de> */ import { displayError, displayInfo } from "@/lib/errors"; import { HTTP } from "@/lib/http"; export default { props: ["editStretch"], data() { return { uploadLabel: this.$gettext(this.$options.UPLOADLABEL), uploadFile: null }; }, computed: {}, methods: { initialState() { this.uploadFile = null; this.uploadLabel = this.$options.UPLOADLABEL; this.$parent.showForm = false; }, fileSelected(e) { const files = e.target.files || e.dataTransfer.files; if (!files) return; this.uploadLabel = files[0].name; this.uploadFile = files[0]; }, save() { let formData = new FormData(); formData.append("stsh", this.uploadFile); HTTP.post(`/imports/stsh`, formData, { headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) .then(() => { displayInfo({ title: this.$gettext("Import"), message: this.$gettext("Upload of stretch complete") }); this.initialState(); }) .catch(error => { let message = "Backend not reachable"; if (error.response) { const { status, data } = error.response; message = `${status}: ${data.message || data}`; } displayError({ title: this.$gettext("Backend Error"), message: message }); }); } }, mounted() {}, UPLOADLABEL: "choose a .zip shapefile" }; </script>