Mercurial > gemma
view client/src/components/importoverview/ImportOverview.vue @ 2651:9f3856337f55
import_overview: new unified interface as default
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 14 Mar 2019 14:53:17 +0100 |
parents | client/src/components/importoverview/ImportOverviewAlt.vue@6c1730fc3dc1 |
children | 3c04c8e46bd4 |
line wrap: on
line source
<template> <div class="overview"> <UIBoxHeader icon="clipboard-check" title="Staging Area" :closeCallback="$parent.close" :actions="[{ callback: loadLogs, icon: 'redo' }]" /> <div class="position-relative"> <transition name="fade"> <div class="loading d-flex justify-content-center align-items-center" v-if="loading" > <font-awesome-icon icon="spinner" spin /> </div> </transition> <div class="p-2 d-flex flex-row flex-fill justify-content-between"> <Filters></Filters> <div> <button class="btn btn-sm btn-info" :disabled="!reviewed.length" @click="save" > <translate>Commit</translate> {{ reviewed.length }} </button> </div> </div> <LogEntry class="border-top d-flex-flex-column w-100" :entry="entry" v-for="entry in imports" :key="entry.id" ></LogEntry> </div> </div> </template> <style lang="sass" scoped> .loading background: rgba(255, 255, 255, 0.9) position: absolute z-index: 99 top: 0 right: 0 bottom: 0 left: 0 </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> */ import { mapState } from "vuex"; import { displayError, displayInfo } from "@/lib/errors.js"; import { STATES } from "@/store/imports.js"; export default { name: "importoverviewalt", components: { Filters: () => import("./Filters.vue"), LogEntry: () => import("./LogEntry.vue") }, data() { return { loading: false }; }, computed: { ...mapState("imports", ["imports", "filters", "reviewed"]) }, methods: { loadLogs() { this.loading = true; this.$store .dispatch("imports/getImports") .then(() => { this.loading = false; }) .catch(error => { const { status, data } = error.response; displayError({ title: this.$gettext("Backend Error"), message: `${status}: ${data.message || data}` }); }); }, save() { if (!this.reviewed.length) return; let popupContent = `<table class="table table-sm small mb-0 border-0" style="margin-top: -1px;">`; this.reviewed.forEach(r => { let imp = this.imports.find(i => i.id === r.id); let approved = STATES.APPROVED === r.status; popupContent += `<tr> <td>${imp.id}</td> <td>${imp.kind.toUpperCase()}</td> <td>${this.$options.filters.dateTime(imp.enqueued)}</td> <td class="text-${approved ? "success" : "danger"}"> ${this.$gettext(approved ? "approved" : "declined")} </td> </tr>`; }); popupContent += "</table>"; this.$store.commit("application/popup", { icon: "clipboard-check", title: this.$gettext("Finish Review"), padding: false, big: true, content: popupContent, confirm: { icon: "check", callback: () => { let data = this.reviewed.map(r => ({ id: r.id, state: r.status })); this.$store .dispatch("imports/confirmReview", data) .then(response => { this.loadLogs(); this.$store.commit("imports/setReviewed", []); const messages = response.data .map(x => { if (x.message) return x.message; if (x.error) return x.error; }) .join("\n\n"); displayInfo({ title: "Staging Area", message: messages, options: { timeout: 0, buttons: [{ text: "Ok", action: null, bold: true }] } }); }) .catch(error => { const { status, data } = error.response; displayError({ title: "Backend Error", message: `${status}: ${data.message || data}` }); }); } }, cancel: { label: this.$gettext("Cancel"), icon: "times" } }); } }, watch: { filters() { this.$store.dispatch("imports/getImports", this.filters); } }, mounted() { this.loadLogs(); } }; </script>