From 6172828846941e04c644be7f54b052dfcf36e29c Mon Sep 17 00:00:00 2001
From: Vitalii Lysak <v.lysak@dunice.net>
Date: Tue, 13 Sep 2022 15:39:22 +0300
Subject: rename

---
 src/views/_sila/Settings/TransferInfo/Snmp.vue | 125 +++++++++++++++++++++++++
 1 file changed, 125 insertions(+)
 create mode 100644 src/views/_sila/Settings/TransferInfo/Snmp.vue

(limited to 'src/views/_sila/Settings/TransferInfo/Snmp.vue')

diff --git a/src/views/_sila/Settings/TransferInfo/Snmp.vue b/src/views/_sila/Settings/TransferInfo/Snmp.vue
new file mode 100644
index 00000000..2b4ae3c7
--- /dev/null
+++ b/src/views/_sila/Settings/TransferInfo/Snmp.vue
@@ -0,0 +1,125 @@
+<template>
+  <page-section :section-title="$t('pageTransfer.snmp.snmpTitle')">
+    <b-row class="snmp-warning mb-5">
+      <b-col xs="12" sm="12">
+        <b-form-group
+          :label="$t('pageTransfer.snmp.host')"
+          label-for="snmp-host"
+        >
+          <b-form-input
+            id="snmp-host"
+            v-model="form.host"
+            :disabled="isNotAdmin"
+          />
+        </b-form-group>
+      </b-col>
+      <b-col xs="12" sm="12">
+        <b-form-group
+          :label="$t('pageTransfer.snmp.port')"
+          label-for="snmp-port"
+        >
+          <b-form-input
+            id="snmp-port"
+            v-model="form.port"
+            type="number"
+            :disabled="isNotAdmin"
+          />
+        </b-form-group>
+      </b-col>
+      <b-col xs="4" class="d-flex justify-content-end align-items-start">
+        <b-button variant="primary" :disabled="isNotAdmin" @click="saveSnmp">
+          {{ $t('global.action.add') }}
+        </b-button>
+      </b-col>
+    </b-row>
+    <b-row>
+      <b-col>
+        <b-table
+          hover
+          responsive="md"
+          show-empty
+          :fields="fields"
+          :empty-text="$t('global.table.emptyMessage')"
+        >
+        </b-table>
+      </b-col>
+    </b-row>
+  </page-section>
+</template>
+
+<script>
+import PageSection from '@/components/_sila/Global/PageSection';
+import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin';
+import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin';
+
+export default {
+  name: 'Snmp',
+  components: {
+    PageSection,
+  },
+  mixins: [BVToastMixin, DataFormatterMixin],
+
+  data() {
+    return {
+      form: {
+        user: '',
+        password: '',
+        host: '',
+        port: '',
+        auth: false,
+        ssl: false,
+      },
+      fields: [
+        {
+          key: 'name',
+          label: this.$t('pageTransfer.table.userName'),
+          formatter: this.dataFormatter,
+        },
+        {
+          key: 'value',
+          label: this.$t('pageTransfer.table.value'),
+          formatter: this.dataFormatter,
+          tdClass: 'text-nowrap',
+        },
+      ],
+    };
+  },
+  computed: {
+    isNotAdmin() {
+      return (
+        this.$store.getters['authentication/role'] === 'ReadOnly' ||
+        this.$store.getters['authentication/role'] === 'Operator'
+      );
+    },
+  },
+  methods: {
+    saveSnmp() {
+      if (!this.form.auth) {
+        // eslint-disable-next-line no-unused-vars
+        const { user, password, ...formWithoutCredits } = this.form;
+        this.form = formWithoutCredits;
+      }
+
+      this.$store
+        .dispatch('snmpStore/setSnmpSettings', this.form)
+        .then((message) => this.successToast(message))
+        .catch(({ message }) => this.errorToast(message));
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.switch-group {
+  margin-bottom: 1.5rem;
+}
+.snmp-warning {
+  width: 50%;
+  @media (max-width: 1200px) {
+    width: 75%;
+  }
+  @media (max-width: 576px) {
+    width: 100%;
+  }
+}
+</style>
-- 
cgit v1.2.3

