Commit 90b1aaaa authored by Janis Streib's avatar Janis Streib 🦉

ADD: simple bulk delete for records in bcd record view (#11)

parent efa235f2
Pipeline #130095 passed with stages
in 4 minutes and 26 seconds
......@@ -2,7 +2,7 @@
<b-tr v-if="block.type == 'free'"
variant="success"
style="padding: 0 !important; height: 1rem;">
<b-td colspan="3" style="padding: 0 0 5px 0"></b-td>
<b-td colspan="4" style="padding: 0 0 5px 0"></b-td>
<b-td style="padding: 2px 0 5px 0.75rem">
<b-badge href="#" @click="create_item_func('A', block.first)" variant="success"><span
v-if="block.space > 1">{{ block.space }}</span><span v-else>Eine</span> freie
......@@ -13,7 +13,7 @@
</b-tr>
<b-tr :key="'block_lower_' + item.data + '_' + index" v-else variant="warning"
style="padding: 0 !important; height: 1rem;">
<b-td colspan="3" style="padding: 0 0 5px 0"></b-td>
<b-td colspan="4" style="padding: 0 0 5px 0"></b-td>
<b-td style="padding: 2px 0 5px 0.75rem">
<b-badge href="#" @click="create_item_func('A', block.first)" variant="warning"><span
v-if="block.space > 1">{{ block.space }}</span><span v-else>Eine</span> reservierte
......
......@@ -225,6 +225,18 @@
<b-table-simple responsive class="table b-table" v-if="collapse_states[2+index]">
<b-thead>
<b-tr>
<b-th>
<!--b-checkbox :indeterminate="toggleAllIsUnkn(record_type)" v-model="toggle_all[record_type]" @input="toggleAll(record_type)"
:unchecked-value="false"></b-checkbox!-->
<b-button :id="record_type + '_bulk'" :disabled="!canEnableBulkAction(record_type)"
@click="bulkDelete(record_type)" variant="outline-danger">
<font-awesome-icon :icon="['far', 'trash-alt']"></font-awesome-icon>
</b-button>
<b-tooltip :target="record_type+'_bulk'" triggers="hover"
variant="danger" placement="right">
Neuen Record anlegen
</b-tooltip>
</b-th>
<b-th style="vertical-align: middle;"
:aria-sort="(sort_by[record_type] == 'fqdn')?sort_dir[record_type]:'none'"
@click="changeSort(record_type, 'fqdn')">
......@@ -271,6 +283,10 @@
</template>
<b-tr
:key="item.fqdn + '_' + item.data">
<b-td>
<b-checkbox class="text-center"
v-model="records_checked[record_type + '_' + item.fqdn + '_' + item.data]"></b-checkbox>
</b-td>
<b-td>
{{ item.fqdn }}
<b-badge variant="secondary" v-if="item.fqdn_type === 'domain'">Domain</b-badge>
......@@ -396,6 +412,8 @@ export default {
components: {FilterInput, EVLogViewer, Loading, DBEditor, BCDFreeAddressBlock, RRDataView},
data() {
return {
toggle_all: {},
records_checked: {},
sort_by: {},
sort_dir: {},
asc_v4_blocklist: [],
......@@ -493,6 +511,37 @@ export default {
}
},
methods: {
bulkDelete(rec_type) {
for (const b of this.records[rec_type]) {
if (this.records_checked[rec_type + '_' + b.fqdn + '_' + b.data]) {
this.deleteItem(b, false)
this.$root.$set(this.records_checked, rec_type + '_' + b.fqdn + '_' + b.data, false)
}
}
},
canEnableBulkAction(rec_type) {
let check_count = 0
for (const b of this.records[rec_type]) {
if (this.records_checked[rec_type + '_' + b.fqdn + '_' + b.data]) {
check_count++
}
}
return check_count > 0
},
toggleAllIsUnkn(rec_type) {
let uncheck_count = 0
for (const b of this.records[rec_type]) {
if (!this.records_checked[rec_type + '_' + b.fqdn + '_' + b.data]) {
uncheck_count++
}
}
return uncheck_count > 0 && uncheck_count < (this.records[rec_type].length - 1)
},
toggleAll(rec_type) {
for (const b of this.filterSortPerType(rec_type)) {
this.$root.$set(this.records_checked, rec_type + '_' + b.fqdn + '_' + b.data, this.toggle_all[rec_type])
}
},
reverseIfDesc(rec_type, arr) {
return (this.sort_dir[rec_type] === 'ascending') ? arr : [...arr].reverse()
},
......@@ -540,7 +589,6 @@ export default {
return recs
},
changeSort: function (rec_type, col) {
window.console.debug(col)
if (this.sort_by[rec_type] === col) {
if (this.sort_dir[rec_type] === 'ascending') {
this.$root.$set(this.sort_dir, rec_type, 'descending')
......@@ -683,7 +731,6 @@ export default {
continue
}
let last = ipaddress.ip_to_int(subnet.cidr.split('/')[0])
window.console.debug('Current hard maxium: ' + ipaddress.ip_net_get_last(subnet.cidr))
const hard_maximum = ipaddress.ip_to_int(ipaddress.ip_net_get_last(subnet.cidr))
let cur = null
while (working_arecs.length > 0) {
......@@ -744,7 +791,6 @@ export default {
}
last = cur
}
window.console.debug(this.asc_v4_blocklist)
if (cur !== hard_maximum) {
// The last fucking block
const blk = {
......@@ -791,7 +837,6 @@ export default {
})
}
blk.containing_blocks = containing_blocks
window.console.debug(blk)
this.asc_v4_blocklist.push(blk)
}
}
......
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