Commit 36a7a677 authored by janis.streib's avatar janis.streib 🦉
Browse files

ADD: support for update

parent 58851f5a
Pipeline #105450 passed with stages
in 7 minutes and 34 seconds
This diff is collapsed.
<template>
<div v-if="object_attribute">
<b-form-group
:title="`${object_attribute.descriptionDetail}\n\nName: ${attribute_name}\nReference: ${attribute_reference_name}\nReferencing: ${attribute_referencing}`"
:label="object_attribute.descriptionObjTypeScope">
<b-form-input :value="attribute_preset || ''"
v-if="(input_reducer === null || input_reducer instanceof Boolean)&& (object_attribute.dataType == 'text' || object_attribute.dataType=='fqdn')"
:name="attribute_name" :disabled="input_reducer instanceof Boolean && !input_reducer"
></b-form-input>
<b-form-input :value="attribute_preset || ''"
v-if="(input_reducer === null || input_reducer instanceof Boolean) && (object_attribute.dataType.includes('integer'))" type="number"
:name="attribute_name" :disabled="input_reducer instanceof Boolean && !input_reducer"
></b-form-input>
<b-checkbox :checked="attribute_preset || false" :name="attribute_name"
v-if="object_attribute.dataType=='boolean'" :disabled="input_reducer instanceof Boolean && !input_reducer"></b-checkbox>
<b-form-select :name="attribute_name" v-if="input_reducer instanceof Object" v-model="attribute_preset">
<template v-slot:first>
<b-form-select-option :value="null" disabled>-- Auswahl treffen --</b-form-select-option>
</template>
<template v-for="(data,key) in input_reducer" >
<b-form-select-option :key="key" :value="key">{{data.display_name}}</b-form-select-option>
</template>
</b-form-select>
:title="`${object_attribute.description_detail}\n\nName: ${attribute_name}\nReference: ${attribute_reference_name}\nReferencing: ${attribute_referencing}`"
:label="object_attribute.description_obj_type_scope">
<b-form-input :value="attribute_preset || ''"
v-if="(input_reducer === null || input_reducer instanceof Boolean)&& (object_attribute.data_type == 'text' || object_attribute.data_type=='fqdn')"
:name="attribute_name" :disabled="input_reducer instanceof Boolean && !input_reducer"
></b-form-input>
<b-form-input :value="attribute_preset || ''"
v-if="(input_reducer === null || input_reducer instanceof Boolean) && (object_attribute.data_type.includes('integer'))"
type="number"
:name="attribute_name" :disabled="input_reducer instanceof Boolean && !input_reducer"
></b-form-input>
<b-checkbox :checked="attribute_preset || false" :name="attribute_name"
v-if="object_attribute.data_type=='boolean'"
:disabled="input_reducer instanceof Boolean && !input_reducer"></b-checkbox>
<b-form-select :name="attribute_name" v-if="input_reducer instanceof Object" v-model="attribute_preset">
<template v-slot:first>
<b-form-select-option :value="null" disabled>-- Auswahl treffen --</b-form-select-option>
</template>
<template v-for="(data,key) in input_reducer">
<b-form-select-option :key="key" :value="key">{{ data.display_name }}</b-form-select-option>
</template>
</b-form-select>
</b-form-group>
</div>
</template>
<script>
export default {
name: "DataEditField",
props: {
object_attribute: {
required: true
},
attribute_referencing: null,
attribute_reference_name: null,
attribute_preset: null,
attribute_name: String,
input_reducer: {
type: Object,
default() {
return null
}
}
}
export default {
name: "DataEditField",
props: {
object_attribute: {
required: true
},
attribute_referencing: null,
attribute_reference_name: null,
attribute_preset: null,
attribute_name: {
type: String,
required: true
},
input_reducer: {
type: Object,
default() {
return null
}
}
},
}
</script>
<style scoped>
......
<template>
<div class="fqdn-record-table">
<Loading :data="[fqdn_rrs]">
<div>
<div class="net-filter-direct d-print-none">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><font-awesome-icon icon="filter"/></span>
</div>
<input class="search form-control" id="filter-direct" placeholder="Filter"
autofocus="yes"/>
</div>
</div>
<b-table responsive class="shadow" :items="fqdn_rrs" :fields="fqdn_list_fields">
<template v-slot:cell(info)="data">
<b-dropdown>
<template v-slot:button-content>
<font-awesome-icon :icon="['fas', 'info-circle']"></font-awesome-icon>
</template>
<b-dropdown-item to="references">Referenzen auf FQDN</b-dropdown-item>
</b-dropdown>
</template>
<template v-slot:cell(data)="data">
<code>{{data.value}}</code>
</template>
<template v-slot:cell(actions)="data">
<b-button variant="outline-danger" @click="deleteItem(data.item)">
<font-awesome-icon :icon="['far', 'trash-alt']"></font-awesome-icon>
</b-button>
</template>
</b-table>
<div class="fqdn-record-table">
<Loading :data="[fqdn_rrs]">
<div>
<div class="net-filter-direct d-print-none">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><font-awesome-icon icon="filter"/></span>
</div>
<DBEditor :presets="db_editor_presets" :input_reducer="create_record_reducer" modal_id="create_record"
:object_function="db_editor_function" object_fq_name="dns.record" :old_data="db_editor_old_data"
:non_optionals_order="['fqdn', 'type', 'data', 'fqdn_description', 'target_is_singleton', 'target_is_reverse_unique']"></DBEditor>
</Loading>
</div>
<input class="search form-control" id="filter-direct" placeholder="Filter"
autofocus="yes"/>
</div>
</div>
<b-table responsive class="shadow" :items="fqdn_rrs" :fields="fqdn_list_fields">
<template v-slot:cell(info)="data">
<b-dropdown>
<template v-slot:button-content>
<font-awesome-icon :icon="['fas', 'info-circle']"></font-awesome-icon>
</template>
<b-dropdown-item to="references">Referenzen auf FQDN</b-dropdown-item>
</b-dropdown>
</template>
<template v-slot:cell(data)="data">
<code>{{ data.value }}</code>
</template>
<template v-slot:cell(actions)="data">
<b-button variant="outline-primary" @click="editItem(data.item)">
<font-awesome-icon :icon="['far', 'edit']"></font-awesome-icon>
</b-button>
<b-button variant="outline-danger" @click="deleteItem(data.item)">
<font-awesome-icon :icon="['far', 'trash-alt']"></font-awesome-icon>
</b-button>
</template>
</b-table>
</div>
<DBEditor :presets="db_editor_presets" :input_reducer="create_record_reducer" modal_id="create_record"
:object_function="db_editor_function" object_fq_name="dns.record" :old_data="db_editor_old_data"
:non_optionals_order="['fqdn', 'type', 'data', 'fqdn_description', 'target_is_singleton', 'target_is_reverse_unique']"></DBEditor>
</Loading>
</div>
</template>
<script>
import DBEditor from "./DBEditor";
import RecordTypeService from "@/api-services.gen/dnscfg.record_type"
import RecordService from "@/api-services.gen/dns.record"
import Loading from "./Loading";
import transactionutil from "../util/transactionutil";
import DBEditor from "./DBEditor";
import RecordTypeService from "@/api-services.gen/dnscfg.record_type"
import RecordService from "@/api-services.gen/dns.record"
import Loading from "./Loading";
import transactionutil from "../util/transactionutil";
export default {
name: "FQDNRecordTable",
components: {
Loading,
DBEditor
export default {
name: "FQDNRecordTable",
components: {
Loading,
DBEditor
},
props: {
fqdn_rrs: Array,
fqdn: {
type: String,
required: true
},
},
data() {
return {
db_editor_function: 'create',
db_editor_presets: {'fqdn': this.fqdn},
db_editor_old_data: {},
fqdn_list_fields: [
{
label: 'FQDN',
key: 'fqdn',
sortable: true
},
{
label: 'Weitere Info',
key: 'info',
sortable: false
},
props: {
fqdn_rrs: Array,
fqdn: {
type: String,
required: true
},
{
label: 'Record-Typ',
key: 'type',
sortable: true
},
data() {
return {
db_editor_function: 'create',
db_editor_presets: {'fqdn': this.fqdn},
db_editor_old_data: {},
fqdn_list_fields: [
{
label: 'FQDN',
key: 'fqdn',
sortable: true
},
{
label: 'Weitere Info',
key: 'info',
sortable: false
},
{
label: 'Record-Typ',
key: 'type',
sortable: true
},
{
label: 'Record-Data',
key: 'data',
sortable: true
},
{
label: 'FQDN-Beschreibung',
key: 'fqdn_description',
sortable: true
},
{
label: 'Aktionen',
key: 'actions',
sortable: false
},
],
create_record_reducer: undefined
}
{
label: 'Record-Data',
key: 'data',
sortable: true
},
created() {
let self = this
RecordTypeService.list(this.$store.state.netdb_axios_config, {is_intern: false}).then((response) => {
let types = response.data[0]
let selections = {}
for (let t of types) {
selections[t.name] = {'display_name': t.name}
}
self.create_record_reducer = {
'type': selections
}
})
{
label: 'FQDN-Beschreibung',
key: 'fqdn_description',
sortable: true
},
methods: {
deleteItem: function (item) {
let ta = transactionutil.generateDeleteElement('dns.record', RecordService.deleteParamsList(), item)
this.$store.commit('addTransactionElement', ta)
this.$emit('commited', ta)
if (!this.isMobile() && !this.$store.state.show_sidebar) {
this.$store.state.show_sidebar = true
}
},
createItem: function () {
this.db_editor_function = 'create'
this.db_editor_old_data = {}
this.db_editor_presets = {'fqdn': this.fqdn}
this.$root.$emit('bv::show::modal', 'create_record')
}
}
{
label: 'Aktionen',
key: 'actions',
sortable: false
},
],
create_record_reducer: undefined
}
},
created() {
let self = this
RecordTypeService.list(this.$store.state.netdb_axios_config, {is_intern: false}).then((response) => {
let types = response.data[0]
let selections = {}
for (let t of types) {
selections[t.name] = {'display_name': t.name}
}
self.create_record_reducer = {
'type': selections
}
})
},
methods: {
deleteItem: function (item) {
let ta = transactionutil.generateDeleteElement('dns.record', RecordService.deleteParamsList(), item)
this.$store.commit('addTransactionElement', ta)
this.$emit('commited', ta)
if (!this.isMobile() && !this.$store.state.show_sidebar) {
this.$store.state.show_sidebar = true
}
},
editItem: function (item) {
this.db_editor_function = 'update'
this.db_editor_old_data = item
this.db_editor_presets = item
this.$root.$emit('bv::show::modal', 'create_record')
},
createItem: function () {
this.db_editor_function = 'create'
this.db_editor_old_data = {}
this.db_editor_presets = {'fqdn': this.fqdn}
this.$root.$emit('bv::show::modal', 'create_record')
}
}
}
</script>
<style scoped>
......
import {v4 as uuidv4} from "uuid";
export default {
function2variant(function_name, outline=false) {
function2variant(function_name, outline = false) {
let prefix = outline ? 'outline-' : ''
switch (function_name) {
case 'create':
......@@ -28,12 +28,26 @@ export default {
return function_name
}
},
filer_old_data(params_list, old_data) {
return Object.keys(old_data).reduce(function (filtered, key) {
if (key in params_list && 'old' in params_list[key]) filtered[key] = old_data[key];
return filtered;
}, {})
},
remove_empty_data(params_list, data) {
return Object.keys(data).reduce(function (filtered, key) {
if (!(params_list[key].json_data_type == 'number' && data[key] == '')) filtered[key] = data[key];
return filtered;
}, {})
},
generateDeleteElement(object_fq_name, params_list, old_data) {
let ta = {}
ta['parameters'] = {'new': {}, 'old': Object.keys(old_data).reduce(function (filtered, key) {
ta['parameters'] = {
'new': {}, 'old': Object.keys(old_data).reduce(function (filtered, key) {
if (params_list.old.includes(key)) filtered[key] = old_data[key];
return filtered;
}, {})}
}, {})
}
ta['uuid'] = uuidv4()
ta['object_fq_name'] = object_fq_name
ta['object_function'] = 'delete'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment