Mercurial > gemma
changeset 1593:bbbc27a7ec99
unattended imports: manual trigger of import
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Fri, 14 Dec 2018 13:30:19 +0100 |
parents | c12cec1d7692 |
children | e3abd3b3ebc6 |
files | client/src/components/importschedule/Importscheduledetail.vue client/src/store/imports.js |
diffstat | 2 files changed, 146 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/importschedule/Importscheduledetail.vue Fri Dec 14 13:25:19 2018 +0100 +++ b/client/src/components/importschedule/Importscheduledetail.vue Fri Dec 14 13:30:19 2018 +0100 @@ -3,7 +3,7 @@ class="importscheduledetails fadeIn animated" v-if="importScheduleDetailVisible" > - <div class="card h-100 shadow-xs"> + <div class="card shadow-xs importscheduledetailscard pb-5"> <h6 class="mb-0 py-2 px-3 border-bottom d-flex text-info align-items-center" > @@ -15,7 +15,7 @@ <div class="card-body"> <form @submit.prevent="save" class="ml-2 mr-2"> <div class="d-flex flex-row w-100"> - <div class="flex-column w-100"> + <div class="flex-column w-50 mr-3"> <div class="flex-row text-left"> <small class="text-muted"> <translate>Imports</translate> @@ -27,23 +27,61 @@ > </select> </div> - </div> - <div class="d-flex flex-row mt-3 w-100 justify-content-between"> - <div class="flex-column w-100"> + <div v-if="import_" class="flex-column w-50"> <div class="flex-row text-left"> <small class="text-muted"> <translate>Importtype</translate> </small> </div> <select + :disabled="fixedSource" v-model="importSource" class="custom-select" id="importsource" > - <option></option> + <option :value="this.$options.IMPORTSOURCES.SOAP" + ><translate>SOAP</translate></option + > </select> </div> </div> + <div v-if="isURLRequired"> + <div class="d-flex flex-row"> + <div class="flex-column mt-3 mr-3 w-100"> + <div class="flex-row text-left"> + <small class="text-muted"> <translate>URL</translate> </small> + </div> + <div class="w-100"> + <input v-model="url" class="form-control" type="url" /> + </div> + </div> + <div class="flex-column mt-3 text-left"> + <div class="d-flex flex-row"> + <small class="text-muted mr-2" + ><translate>Insecure</translate> + </small> + </div> + <div class="d-flex flex-row"> + <toggle-button + v-model="insecure" + class="mt-2" + :speed="100" + :color="{ + checked: '#FF0000', + unchecked: '#E9ECEF', + disabled: '#CCCCCC' + }" + :labels="{ + checked: this.$options.on, + unchecked: this.$options.off + }" + :width="60" + :height="30" + /> + </div> + </div> + </div> + </div> <div class="flex-column mt-3 w-100 mr-2"> <div class="flex-row text-left"> <small class="text-muted"> @@ -59,8 +97,8 @@ checked: this.$options.on, unchecked: this.$options.off }" - :width="50" - :height="20" + :width="60" + :height="30" /> </div> </div> @@ -220,14 +258,14 @@ checked: this.$options.on, unchecked: this.$options.off }" - :width="50" - :height="20" + :width="60" + :height="30" /> </div> </div> <div class="flex-column w-100 mr-2"> <div class="flex-row text-left"> - <small class="text-muted"> <translate>Email</translate> </small> + <small class="text-muted"><translate>Email</translate> </small> </div> <input :disabled="!eMailNotification" @@ -238,7 +276,12 @@ <button type="submit" class="shadow-sm btn btn-info submit-button"> <translate>Submit</translate> </button> - <button type="button" class="shadow-sm btn btn-outline-info trigger"> + <button + @click="triggerManualImport" + type="button" + class="shadow-sm btn btn-outline-info trigger" + :disabled="!triggerActive" + > <font-awesome-icon class="fa-fw mr-2" fixed-width @@ -254,8 +297,9 @@ <script> import { mapState } from "vuex"; -import { displayInfo } from "../../lib/errors.js"; +import { displayInfo, displayError } from "../../lib/errors.js"; import app from "../../main.js"; +import { HTTP } from "../../lib/http.js"; export default { name: "importscheduledetail", @@ -273,22 +317,18 @@ hour: null, day: null, dayOfMonth: null, - simple: null + simple: null, + url: null, + insecure: false, + triggerActive: true }; }, - watch: { - cronString() { - if (this.isWeekly(this.cronString)) { - this.simple = "weekly"; - } - if (this.isMonthly(this.cronString)) { - this.simple = "monthly"; - } - } - }, IMPORTTYPES: { BOTTLENECK: "BOTTLENECK" }, + IMPORTSOURCES: { + SOAP: "SOAP" + }, EVERY: app.$gettext("Every"), MINUTESPAST: app.$gettext("minutes past"), ON: app.$gettext("on"), @@ -326,8 +366,27 @@ 11: app.$gettext("November"), 12: app.$gettext("December") }, + watch: { + cronString() { + if (this.isWeekly(this.cronString)) { + this.simple = "weekly"; + } + if (this.isMonthly(this.cronString)) { + this.simple = "monthly"; + } + }, + import_() { + if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) { + this.importSource = this.$options.IMPORTSOURCES.SOAP; + } + } + }, computed: { ...mapState("imports", ["importScheduleDetailVisible"]), + isURLRequired() { + if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) return true; + return false; + }, cronString: { get() { let getValue = value => { @@ -341,6 +400,10 @@ const wd = getValue("day"); return `${min} ${h} ${dm} ${m} ${wd}`; } + }, + fixedSource() { + if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) return true; + return false; } }, methods: { @@ -350,6 +413,23 @@ isMonthly(cron) { return /\d{1,2} \d{1,2} \d{1,2} \* \*/.test(cron); }, + initialize() { + this.importType = null; + this.schedule = null; + this.import_ = null; + this.importSource = null; + this.eMailNotification = false; + this.easyCron = true; + this.cronMode = ""; + this.minutes = null; + this.month = null; + this.hour = null; + this.day = null; + this.dayOfMonth = null; + this.simple = null; + this.url = null; + this.insecure = false; + }, clearInputs() { this.minutes = null; this.month = null; @@ -357,14 +437,49 @@ this.day = null; this.dayOfMonth = null; }, + triggerManualImport() { + if (!this.triggerActive) return; + let data = {}; + if (this.import_ === this.$options.IMPORTTYPES.BOTTLENECK) { + if (!this.url) return; + data["url"] = this.url; + data["insecure"] = this.insecure; + } + const importTypes = { + BOTTLENECK: "bottleneck" + }; + this.triggerActive = false; + HTTP.post("imports/" + importTypes[this.import_], data, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + } + }) + .then(response => { + const { id } = response.data; + displayInfo({ + title: this.$gettext("Import"), + message: this.$gettext("Manually triggered import: #") + id + }); + }) + .catch(error => { + const { status, data } = error.response; + displayError({ + title: this.gettext("Backend Error"), + message: `${status}: ${data.message || data}` + }); + }) + .finally(() => { + this.triggerActive = true; + }); + }, save() { displayInfo({ - title: "Import", - message: "under construction" + title: this.$gettext("Import"), + message: this.$gettext("under construction") }); }, closeDetailview() { - this.$store.commit("imports/clearImportScheduleDetail"); + this.initialize(); this.$store.commit("imports/setImportScheduleDetailInvisible"); } }, @@ -379,8 +494,11 @@ </script> <style lang="scss" scoped> +.importscheduledetailscard { + min-height: 550px; +} + .importscheduledetails { - height: 620px; width: 100%; margin-top: $offset; margin-right: $offset;
--- a/client/src/store/imports.js Fri Dec 14 13:25:19 2018 +0100 +++ b/client/src/store/imports.js Fri Dec 14 13:30:19 2018 +0100 @@ -33,29 +33,15 @@ imports: [], staging: [], schedules: [], - importScheduleDetail: null, importScheduleDetailVisible: false }; }; -const newImportScheduleDetail = () => { - return { - import: "", - type: "", - author: "", - schedule: "", - emailNotification: null - }; -}; - const imports = { init, namespaced: true, state: init(), mutations: { - clearImportScheduleDetail: state => { - state.importScheduleDetail = newImportScheduleDetail(); - }, deleteSchedule: (state, index) => { state.schedules.splice(index, 1); },