summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/RegistrationModuleEdit.vue
diff options
context:
space:
mode:
authorUdo Walter2018-11-12 05:59:16 +0100
committerUdo Walter2018-11-12 05:59:16 +0100
commit5a15373dcd76ed7371dbbee88104dd0c4384a889 (patch)
tree1d2c798f7602e17c007d67d279a7cb1ee754b053 /webapp/src/components/RegistrationModuleEdit.vue
parent[iDoIT] Rework the import method to use batch requests (diff)
downloadbas-5a15373dcd76ed7371dbbee88104dd0c4384a889.tar.gz
bas-5a15373dcd76ed7371dbbee88104dd0c4384a889.tar.xz
bas-5a15373dcd76ed7371dbbee88104dd0c4384a889.zip
[registration] add configurator for registration hooks
Diffstat (limited to 'webapp/src/components/RegistrationModuleEdit.vue')
-rw-r--r--webapp/src/components/RegistrationModuleEdit.vue120
1 files changed, 120 insertions, 0 deletions
diff --git a/webapp/src/components/RegistrationModuleEdit.vue b/webapp/src/components/RegistrationModuleEdit.vue
new file mode 100644
index 0000000..cc4189d
--- /dev/null
+++ b/webapp/src/components/RegistrationModuleEdit.vue
@@ -0,0 +1,120 @@
+<i18n>
+{
+ "en": {
+ "name": "Name",
+ "description": "Description",
+ "type": "Script type",
+ "groups": "Groups",
+ "script": "Script",
+ "titleNew": "Create hook",
+ "titleExisting": "Edit hook"
+ },
+ "de": {
+ "name": "Name",
+ "description": "Beschreibung",
+ "type": "Skript Art",
+ "groups": "Gruppen",
+ "script": "Script",
+ "titleNew": "Hook erstellen",
+ "titleExisting": "Hook bearbeiten"
+ }
+}
+</i18n>
+
+<template>
+ <v-card>
+ <v-card-title primary-title class="dialog-title elevation-3">
+ <div class="headline">{{ dialog.info.id ? $t('titleExisting') : $t('titleNew') }}</div>
+ </v-card-title>
+ <v-card-text>
+ <v-layout row wrap>
+ <v-flex xs12 sm9>
+ <v-text-field prepend-icon="label" :label="$t('name')" color="primary" v-model="name"></v-text-field>
+ </v-flex>
+ <v-flex xs12 sm2 offset-sm1>
+ <v-select prepend-icon="label" color="primary" :items="types" :label="$t('type')" v-model="type" menu-props="offsetY"></v-select>
+ </v-flex>
+ </v-layout>
+ <v-autocomplete
+ prepend-icon="device_hub"
+ :items="groupList"
+ v-model="groups"
+ :label="$t('groups')"
+ color="primary"
+ multiple
+ item-value="id"
+ item-text="name"
+ small-chips
+ deletable-chips
+ ></v-autocomplete>
+ <v-textarea prepend-icon="description" rows="3" :label="$t('description')" color="primary" v-model="description"></v-textarea>
+ <v-textarea prepend-icon="code" rows="20" :label="$t('script')" color="primary" v-model="script"></v-textarea>
+ </v-card-text>
+ <v-divider></v-divider>
+ <v-card-actions>
+ <v-spacer></v-spacer>
+ <v-btn flat="flat" @click="setDialog({ show: false })">{{ $t('cancel') }}</v-btn>
+ <v-btn :color="dialog.info.id ? 'primary' : 'success'" @click="saveHook">{{ dialog.info.id ? $t('save') : $t('create') }}</v-btn>
+ </v-card-actions>
+ </v-card>
+</template>
+
+<script>
+import axios from 'axios'
+import { mapState } from 'vuex'
+
+export default {
+ name: 'RegistrationModuleEdit',
+ data () {
+ return {
+ name: '',
+ description: '',
+ type: '',
+ groups: [],
+ script: '',
+ types: ['BASH', 'IPXE']
+ }
+ },
+ computed: {
+ ...mapState('registration', ['dialog', 'groupList'])
+ },
+ watch: {
+ dialog: {
+ immediate: true,
+ deep: true,
+ handler (value) {
+ if (value.type === 'edit' && value.show) {
+ this.name = value.info.name
+ this.description = value.info.description
+ this.type = value.info.type || 'BASH'
+ this.groups = value.info.groups ? value.info.groups.map(x => x.id) : []
+ this.script = value.info.script
+ }
+ }
+ }
+ },
+ methods: {
+ setDialog (data) {
+ this.$store.commit('registration/setDialog', data)
+ },
+ async saveHook () {
+ await axios.post('/api/registrations/hooks/' + this.dialog.info.id, {
+ name: this.name,
+ description: this.description,
+ type: this.type,
+ groups: this.groups,
+ script: this.script
+ })
+ this.$store.dispatch('registration/loadHooks')
+ this.setDialog({ show: false })
+ }
+ }
+}
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style scoped>
+.dialog-title {
+ z-index: 1;
+}
+</style>