17c1cfe7eSKonstantin Aladyshev<template> 27c1cfe7eSKonstantin Aladyshev <b-modal id="add-destination" ref="modal" @ok="onOk" @hidden="resetForm"> 37c1cfe7eSKonstantin Aladyshev <template #modal-title> 47c1cfe7eSKonstantin Aladyshev {{ $t('pageSnmpAlerts.modal.addSnmpDestinationTitle') }} 57c1cfe7eSKonstantin Aladyshev </template> 67c1cfe7eSKonstantin Aladyshev <b-form id="form-destination"> 77c1cfe7eSKonstantin Aladyshev <b-container> 87c1cfe7eSKonstantin Aladyshev <b-row> 97c1cfe7eSKonstantin Aladyshev <b-col sm="6"> 107c1cfe7eSKonstantin Aladyshev <!-- Add new SNMP alert destination type --> 117c1cfe7eSKonstantin Aladyshev <b-form-group 127c1cfe7eSKonstantin Aladyshev :label="$t('pageSnmpAlerts.modal.ipaddress')" 137c1cfe7eSKonstantin Aladyshev label-for="ip-address" 147c1cfe7eSKonstantin Aladyshev > 157c1cfe7eSKonstantin Aladyshev <b-form-input 167c1cfe7eSKonstantin Aladyshev id="ip-Address" 177c1cfe7eSKonstantin Aladyshev v-model="form.ipAddress" 18de23ea23SSurya V :state="getValidationState(v$.form.ipAddress)" 197c1cfe7eSKonstantin Aladyshev data-test-id="snmpAlerts-input-ipAddress" 207c1cfe7eSKonstantin Aladyshev type="text" 21de23ea23SSurya V @blur="v$.form.ipAddress.$touch()" 227c1cfe7eSKonstantin Aladyshev /> 237c1cfe7eSKonstantin Aladyshev 247c1cfe7eSKonstantin Aladyshev <b-form-invalid-feedback role="alert"> 25*69be824aSSurya Venkatesan <template v-if="v$.form.ipAddress.required.$invalid"> 267c1cfe7eSKonstantin Aladyshev {{ $t('global.form.fieldRequired') }} 277c1cfe7eSKonstantin Aladyshev </template> 28*69be824aSSurya Venkatesan <template v-if="v$.form.ipAddress.ipAddress.$invalid"> 297c1cfe7eSKonstantin Aladyshev {{ $t('global.form.invalidFormat') }} 307c1cfe7eSKonstantin Aladyshev </template> 317c1cfe7eSKonstantin Aladyshev </b-form-invalid-feedback> 327c1cfe7eSKonstantin Aladyshev </b-form-group> 337c1cfe7eSKonstantin Aladyshev </b-col> 347c1cfe7eSKonstantin Aladyshev <b-col> 357c1cfe7eSKonstantin Aladyshev <b-form-group label-for="port"> 367c1cfe7eSKonstantin Aladyshev <template #label> 377c1cfe7eSKonstantin Aladyshev {{ $t('pageSnmpAlerts.modal.port') }} - 387c1cfe7eSKonstantin Aladyshev <span class="form-text d-inline"> 397c1cfe7eSKonstantin Aladyshev {{ $t('global.form.optional') }} 407c1cfe7eSKonstantin Aladyshev </span> 417c1cfe7eSKonstantin Aladyshev </template> 427c1cfe7eSKonstantin Aladyshev <b-form-input 437c1cfe7eSKonstantin Aladyshev id="port" 447c1cfe7eSKonstantin Aladyshev v-model="form.port" 457c1cfe7eSKonstantin Aladyshev type="text" 46de23ea23SSurya V :state="getValidationState(v$.form.port)" 477c1cfe7eSKonstantin Aladyshev data-test-id="snmpAlerts-input-port" 48de23ea23SSurya V @blur="v$.form.port.$touch()" 497c1cfe7eSKonstantin Aladyshev /> 507c1cfe7eSKonstantin Aladyshev <b-form-invalid-feedback role="alert"> 517c1cfe7eSKonstantin Aladyshev <template 52de23ea23SSurya V v-if="!v$.form.port.minLength || !v$.form.port.maxLength" 537c1cfe7eSKonstantin Aladyshev > 547c1cfe7eSKonstantin Aladyshev {{ 557c1cfe7eSKonstantin Aladyshev $t('global.form.valueMustBeBetween', { 567c1cfe7eSKonstantin Aladyshev min: 0, 577c1cfe7eSKonstantin Aladyshev max: 65535, 587c1cfe7eSKonstantin Aladyshev }) 597c1cfe7eSKonstantin Aladyshev }} 607c1cfe7eSKonstantin Aladyshev </template> 617c1cfe7eSKonstantin Aladyshev </b-form-invalid-feedback> 627c1cfe7eSKonstantin Aladyshev </b-form-group> 637c1cfe7eSKonstantin Aladyshev </b-col> 647c1cfe7eSKonstantin Aladyshev </b-row> 657c1cfe7eSKonstantin Aladyshev </b-container> 667c1cfe7eSKonstantin Aladyshev </b-form> 677c1cfe7eSKonstantin Aladyshev <template #modal-footer="{ cancel }"> 687c1cfe7eSKonstantin Aladyshev <b-button variant="secondary" @click="cancel()"> 697c1cfe7eSKonstantin Aladyshev {{ $t('global.action.cancel') }} 707c1cfe7eSKonstantin Aladyshev </b-button> 717c1cfe7eSKonstantin Aladyshev <b-button 727c1cfe7eSKonstantin Aladyshev form="form-user" 737c1cfe7eSKonstantin Aladyshev type="submit" 747c1cfe7eSKonstantin Aladyshev variant="primary" 757c1cfe7eSKonstantin Aladyshev data-test-id="snmpAlerts-button-ok" 767c1cfe7eSKonstantin Aladyshev @click="onOk" 777c1cfe7eSKonstantin Aladyshev > 787c1cfe7eSKonstantin Aladyshev {{ $t('pageSnmpAlerts.addDestination') }} 797c1cfe7eSKonstantin Aladyshev </b-button> 807c1cfe7eSKonstantin Aladyshev </template> 817c1cfe7eSKonstantin Aladyshev </b-modal> 827c1cfe7eSKonstantin Aladyshev</template> 837c1cfe7eSKonstantin Aladyshev 847c1cfe7eSKonstantin Aladyshev<script> 857d6b44cbSEd Tanousimport { required, ipAddress, minValue, maxValue } from '@vuelidate/validators'; 867c1cfe7eSKonstantin Aladyshevimport VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; 877d6b44cbSEd Tanousimport { useVuelidate } from '@vuelidate/core'; 88de23ea23SSurya Vimport { useI18n } from 'vue-i18n'; 897c1cfe7eSKonstantin Aladyshev 907c1cfe7eSKonstantin Aladyshevexport default { 917c1cfe7eSKonstantin Aladyshev mixins: [VuelidateMixin], 927d6b44cbSEd Tanous setup() { 937d6b44cbSEd Tanous return { 947d6b44cbSEd Tanous v$: useVuelidate(), 957d6b44cbSEd Tanous }; 967d6b44cbSEd Tanous }, 977c1cfe7eSKonstantin Aladyshev data() { 987c1cfe7eSKonstantin Aladyshev return { 99de23ea23SSurya V $t: useI18n().t, 1007c1cfe7eSKonstantin Aladyshev form: { 1017c1cfe7eSKonstantin Aladyshev ipaddress: null, 1027c1cfe7eSKonstantin Aladyshev port: null, 1037c1cfe7eSKonstantin Aladyshev }, 1047c1cfe7eSKonstantin Aladyshev }; 1057c1cfe7eSKonstantin Aladyshev }, 1067c1cfe7eSKonstantin Aladyshev validations() { 1077c1cfe7eSKonstantin Aladyshev return { 1087c1cfe7eSKonstantin Aladyshev form: { 1097c1cfe7eSKonstantin Aladyshev ipAddress: { 1107c1cfe7eSKonstantin Aladyshev required, 1117c1cfe7eSKonstantin Aladyshev ipAddress, 1127c1cfe7eSKonstantin Aladyshev }, 1137c1cfe7eSKonstantin Aladyshev port: { 1147c1cfe7eSKonstantin Aladyshev minValue: minValue(0), 1157c1cfe7eSKonstantin Aladyshev maxValue: maxValue(65535), 1167c1cfe7eSKonstantin Aladyshev }, 1177c1cfe7eSKonstantin Aladyshev }, 1187c1cfe7eSKonstantin Aladyshev }; 1197c1cfe7eSKonstantin Aladyshev }, 1207c1cfe7eSKonstantin Aladyshev methods: { 1217c1cfe7eSKonstantin Aladyshev handleSubmit() { 122de23ea23SSurya V this.v$.$touch(); 123de23ea23SSurya V if (this.v$.$invalid) return; 1247c1cfe7eSKonstantin Aladyshev this.$emit('ok', { 1257c1cfe7eSKonstantin Aladyshev ipAddress: this.form.ipAddress, 1267c1cfe7eSKonstantin Aladyshev port: this.form.port, 1277c1cfe7eSKonstantin Aladyshev }); 1287c1cfe7eSKonstantin Aladyshev this.closeModal(); 1297c1cfe7eSKonstantin Aladyshev }, 1307c1cfe7eSKonstantin Aladyshev closeModal() { 1317c1cfe7eSKonstantin Aladyshev this.$nextTick(() => { 1327c1cfe7eSKonstantin Aladyshev this.$refs.modal.hide(); 1337c1cfe7eSKonstantin Aladyshev }); 1347c1cfe7eSKonstantin Aladyshev }, 1357c1cfe7eSKonstantin Aladyshev resetForm() { 1367c1cfe7eSKonstantin Aladyshev this.form.ipAddress = ''; 1377c1cfe7eSKonstantin Aladyshev this.form.port = ''; 138de23ea23SSurya V this.v$.$reset(); 1397c1cfe7eSKonstantin Aladyshev this.$emit('hidden'); 1407c1cfe7eSKonstantin Aladyshev }, 1417c1cfe7eSKonstantin Aladyshev onOk(bvModalEvt) { 1427c1cfe7eSKonstantin Aladyshev // prevent modal close 1437c1cfe7eSKonstantin Aladyshev bvModalEvt.preventDefault(); 1447c1cfe7eSKonstantin Aladyshev this.handleSubmit(); 1457c1cfe7eSKonstantin Aladyshev }, 1467c1cfe7eSKonstantin Aladyshev }, 1477c1cfe7eSKonstantin Aladyshev}; 1487c1cfe7eSKonstantin Aladyshev</script> 149