summaryrefslogtreecommitdiff
path: root/src/views/_sila/Settings/TransferInfo/ModalSnmp.vue
blob: 54679720dea655f9410053b1e8277f1d778f31cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
  <b-modal
    id="modal-snmp"
    ref="modal"
    :title="$t('global.action.add')"
    @hidden="resetForm"
  >
    <b-form id="form-snmp" @submit.prevent="handleSubmit">
      <b-row>
        <b-col sm="6">
          <b-form-group
            :label="$t('pageTransfer.snmp.host')"
            label-for="snmpHost"
          >
            <b-form-input id="snmpHost" v-model="host" type="text" />
          </b-form-group>
        </b-col>
        <b-col sm="6">
          <b-form-group
            :label="$t('pageTransfer.snmp.port')"
            label-for="snmpPort"
          >
            <b-form-input id="snmpPort" v-model="port" type="text" />
          </b-form-group>
        </b-col>
      </b-row>
    </b-form>
    <template #modal-footer="{ cancel }">
      <b-button variant="secondary" @click="cancel()">
        {{ $t('global.action.cancel') }}
      </b-button>
      <b-button form="form-snmp" type="submit" variant="primary" @click="onOk">
        {{ $t('global.action.add') }}
      </b-button>
    </template>
  </b-modal>
</template>

<script>
import VuelidateMixin from '@/components/_sila/Mixins/VuelidateMixin.js';

export default {
  mixins: [VuelidateMixin],
  data() {
    return {
      form: {
        Destination: null,
        SubscriptionType: 'SNMPTrap',
        Protocol: 'SNMPv2c',
        Context: 'testContext',
      },
      host: null,
      port: null,
    };
  },
  methods: {
    handleSubmit() {
      this.$emit('ok', {
        ...this.form,
        Destination: this.host + this.port,
      });
      this.closeModal();
    },
    closeModal() {
      this.$nextTick(() => {
        this.$refs.modal.hide();
      });
    },
    resetForm() {
      this.host = null;
      this.port = null;
      this.form.Destination = null;
      this.$emit('hidden');
    },
    onOk(bvModalEvt) {
      // prevent modal close
      bvModalEvt.preventDefault();
      this.handleSubmit();
    },
  },
};
</script>