Mercurial > gemma
view client/src/components/importoverview/ImportOverview.vue @ 2725:9465749410ba
client: import overview: use table body component
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Tue, 19 Mar 2019 12:53:25 +0100 |
parents | 305af1e2975d |
children | 375c9dd935ad |
line wrap: on
line source
<template> <div class="overview"> <UIBoxHeader icon="clipboard-check" title="Import review" :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 mb-1 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> <UITableHeader :columns="[ { id: 'id', title: 'Id', width: '79px' }, { id: 'kind', title: 'Kind', width: '53px' }, { id: 'enqueued', title: 'Enqueued', width: '138px' }, { id: 'user', title: 'User', width: '105px' }, { id: 'signer', title: 'Signer', width: '105px' }, { id: 'state', title: 'Status', width: '72px' }, { id: 'warning', icon: 'exclamation-triangle', width: '44px' } ]" @sortingChanged="sortBy" /> <UITableBody :data="imports" maxHeight="80vh" v-slot="{ item: entry }"> <LogEntry :entry="entry"></LogEntry> </UITableBody> </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, mapGetters } 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", "reviewed"]), ...mapGetters("imports", ["filters"]) }, methods: { sortBy() {}, loadLogs() { this.loading = true; this.$store .dispatch("imports/getImports", this.filters) .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>