summaryrefslogtreecommitdiff
path: root/src/views/_sila/Settings/TransferInfo/Snmp.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/_sila/Settings/TransferInfo/Snmp.vue')
-rw-r--r--src/views/_sila/Settings/TransferInfo/Snmp.vue81
1 files changed, 55 insertions, 26 deletions
diff --git a/src/views/_sila/Settings/TransferInfo/Snmp.vue b/src/views/_sila/Settings/TransferInfo/Snmp.vue
index 8a7ca730..4a0e0abe 100644
--- a/src/views/_sila/Settings/TransferInfo/Snmp.vue
+++ b/src/views/_sila/Settings/TransferInfo/Snmp.vue
@@ -6,7 +6,7 @@
<b-button
variant="primary"
:disabled="isNotAdmin"
- @click="initSnmpModal()"
+ @click="initAddModal()"
>
<icon-add />
{{ $t('global.action.add') }}
@@ -15,23 +15,27 @@
<b-table
responsive="md"
hover
- :fields="snmpTableFields"
- :items="form.snmpTableItems"
+ :busy="loading"
+ :fields="fields"
+ :items="subscribers"
:empty-text="$t('global.table.emptyMessage')"
show-empty
>
- <template #cell(actions)="{ item, index }">
+ <!-- table actions column -->
+ <template #cell(actions)="{ item }">
<table-row-action
- v-for="(action, actionIndex) in item.actions"
- :key="actionIndex"
+ v-for="(action, index) in item.actions"
+ :key="index"
:value="action.value"
- :title="action.title"
:enabled="action.enabled"
- @click-table-action="onSnmpTableAction(action, $event, index)"
+ :title="action.title"
+ @click-table-action="onTableAction($event, item)"
>
<template #icon>
- <icon-edit v-if="action.value === 'edit'" />
- <icon-trashcan v-if="action.value === 'delete'" />
+ <icon-trashcan
+ v-if="action.value === 'delete'"
+ :data-test-id="`snmp-tableRowAction-delete-${index}`"
+ />
</template>
</table-row-action>
</template>
@@ -44,39 +48,34 @@
<script>
import PageSection from '@/components/_sila/Global/PageSection';
import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin';
+import TableRowAction from '@/components/_sila/Global/TableRowAction';
+import LoadingBarMixin, {
+ loading,
+} from '@/components/_sila/Mixins/LoadingBarMixin';
import IconAdd from '@carbon/icons-vue/es/add--alt/20';
-import IconEdit from '@carbon/icons-vue/es/edit/20';
import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
-import TableRowAction from '@/components/_sila/Global/TableRowAction';
export default {
name: 'Snmp',
components: {
IconAdd,
- IconEdit,
IconTrashcan,
PageSection,
TableRowAction,
},
- mixins: [BVToastMixin],
+ mixins: [BVToastMixin, LoadingBarMixin],
data() {
return {
- form: {
- snmpTableItems: [],
- },
+ loading,
actions: [
{
- value: 'edit',
- title: this.$t('global.action.edit'),
- },
- {
value: 'delete',
title: this.$t('global.action.delete'),
},
],
- snmpTableFields: [
+ fields: [
{
key: 'host',
label: this.$t('pageTransfer.snmp.host'),
@@ -90,6 +89,19 @@ export default {
};
},
computed: {
+ subscribers() {
+ return this.$store.getters['snmpStore/subscribers'].map((subscriber) => {
+ return {
+ ...subscriber,
+ actions: [
+ {
+ value: 'delete',
+ title: this.$t('pageTransfer.snmp.delSubscriber'),
+ },
+ ],
+ };
+ });
+ },
isNotAdmin() {
return (
this.$store.getters['authentication/role'] === 'ReadOnly' ||
@@ -99,13 +111,30 @@ export default {
},
created() {
- this.getSnmpItems();
+ this.startLoader();
+ this.$store.dispatch('snmpStore/getSubscribers').finally(() => {
+ this.endLoader();
+ this.isBusy = false;
+ });
},
methods: {
- getSnmpItems() {},
- initSnmpModal() {},
- onSnmpTableAction() {},
+ onTableAction($event, { Id }) {
+ if ($event === 'delete') {
+ this.deleteSubscriber(Id);
+ }
+ },
+ deleteSubscriber(index) {
+ this.startLoader();
+ this.$store
+ .dispatch('snmpStore/deleteSubscriber', index)
+ .then((success) => this.successToast(success))
+ .catch(({ message }) => this.errorToast(message))
+ .finally(() => this.endLoader());
+ },
+ initAddModal() {
+ this.$bvModal.show('modal-snmp');
+ },
},
};
</script>