Mercurial > gemma
view client/src/components/importconfiguration/types/ApprovedGaugeMeasurement.vue @ 4329:83eb99662a91
client: improve ability to test FW diagrams
* Restructure code in fairwayavailability.js to seperate external data
retrieval and adding the data into the store. Good side effects are
that using a mutation for setting test data is easier and only
one commit call is necessary, which means less clutter in the state history.
* Adding an example how to use this for testing to docs/developers.md .
* Bump copyright year for one file.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 04 Sep 2019 17:05:43 +0200 |
parents | 439e1865a2d2 |
children | 008bc1ae8897 |
line wrap: on
line source
<template> <div> <div class="d-flex 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-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 form-control-sm" id="originator" /> <span class="text-left text-danger"> <small v-if="!originator"> <translate>Please enter an originator</translate> </small> </span> </div> </div> <div class="mt-4 flex-column px-2 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 w-100 mt-3 border-top justify-content-between p-2"> <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" > <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"; import app from "@/main"; export default { name: "importapprovedgaugemeasurements", data() { return { disableUploadButton: false, uploadLabel: this.$gettext("choose file to upload"), uploadFile: null, originator: "viadonau", eMailNotification: false }; }, 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); if (this.eMailNotification) { formData.append("send-email", this.eMailNotification); } 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"), on: "on", off: "off" }; </script> <style lang="scss" scoped></style>