1b34349d4SDixsie Wolmers<template> 2b34349d4SDixsie Wolmers <b-modal 3b34349d4SDixsie Wolmers id="modal-add-ipv4" 4b34349d4SDixsie Wolmers ref="modal" 5b34349d4SDixsie Wolmers :title="$t('pageNetwork.table.addIpv4Address')" 6b34349d4SDixsie Wolmers @hidden="resetForm" 7b34349d4SDixsie Wolmers > 8b34349d4SDixsie Wolmers <b-form id="form-ipv4" @submit.prevent="handleSubmit"> 9b34349d4SDixsie Wolmers <b-row> 10b34349d4SDixsie Wolmers <b-col sm="6"> 11b34349d4SDixsie Wolmers <b-form-group 12b34349d4SDixsie Wolmers :label="$t('pageNetwork.modal.ipAddress')" 13b34349d4SDixsie Wolmers label-for="ipAddress" 14b34349d4SDixsie Wolmers > 15b34349d4SDixsie Wolmers <b-form-input 16b34349d4SDixsie Wolmers id="ipAddress" 17b34349d4SDixsie Wolmers v-model="form.ipAddress" 18b34349d4SDixsie Wolmers type="text" 19de23ea23SSurya V :state="getValidationState(v$.form.ipAddress)" 20de23ea23SSurya V @input="v$.form.ipAddress.$touch()" 21b34349d4SDixsie Wolmers /> 22b34349d4SDixsie Wolmers <b-form-invalid-feedback role="alert"> 23*4626aec4SSurya Venkatesan <template v-if="v$.form.ipAddress.required.$invalid"> 24b34349d4SDixsie Wolmers {{ $t('global.form.fieldRequired') }} 25b34349d4SDixsie Wolmers </template> 26*4626aec4SSurya Venkatesan <template v-if="v$.form.ipAddress.ipAddress.$invalid"> 27b34349d4SDixsie Wolmers {{ $t('global.form.invalidFormat') }} 28b34349d4SDixsie Wolmers </template> 29b34349d4SDixsie Wolmers </b-form-invalid-feedback> 30b34349d4SDixsie Wolmers </b-form-group> 31b34349d4SDixsie Wolmers </b-col> 32b34349d4SDixsie Wolmers <b-col sm="6"> 33b34349d4SDixsie Wolmers <b-form-group 34b34349d4SDixsie Wolmers :label="$t('pageNetwork.modal.gateway')" 35b34349d4SDixsie Wolmers label-for="gateway" 36b34349d4SDixsie Wolmers > 37b34349d4SDixsie Wolmers <b-form-input 38b34349d4SDixsie Wolmers id="gateway" 39b34349d4SDixsie Wolmers v-model="form.gateway" 40b34349d4SDixsie Wolmers type="text" 41de23ea23SSurya V :state="getValidationState(v$.form.gateway)" 42de23ea23SSurya V @input="v$.form.gateway.$touch()" 43b34349d4SDixsie Wolmers /> 44b34349d4SDixsie Wolmers <b-form-invalid-feedback role="alert"> 45*4626aec4SSurya Venkatesan <template v-if="v$.form.gateway.required.$invalid"> 46b34349d4SDixsie Wolmers {{ $t('global.form.fieldRequired') }} 47b34349d4SDixsie Wolmers </template> 48*4626aec4SSurya Venkatesan <template v-if="v$.form.gateway.ipAddress.$invalid"> 49b34349d4SDixsie Wolmers {{ $t('global.form.invalidFormat') }} 50b34349d4SDixsie Wolmers </template> 51b34349d4SDixsie Wolmers </b-form-invalid-feedback> 52b34349d4SDixsie Wolmers </b-form-group> 53b34349d4SDixsie Wolmers </b-col> 54b34349d4SDixsie Wolmers </b-row> 55b34349d4SDixsie Wolmers <b-row> 56b34349d4SDixsie Wolmers <b-col sm="6"> 57b34349d4SDixsie Wolmers <b-form-group 58b34349d4SDixsie Wolmers :label="$t('pageNetwork.modal.subnetMask')" 59b34349d4SDixsie Wolmers label-for="subnetMask" 60b34349d4SDixsie Wolmers > 61b34349d4SDixsie Wolmers <b-form-input 62b34349d4SDixsie Wolmers id="subnetMask" 63b34349d4SDixsie Wolmers v-model="form.subnetMask" 64b34349d4SDixsie Wolmers type="text" 65de23ea23SSurya V :state="getValidationState(v$.form.subnetMask)" 66de23ea23SSurya V @input="v$.form.subnetMask.$touch()" 67b34349d4SDixsie Wolmers /> 68b34349d4SDixsie Wolmers <b-form-invalid-feedback role="alert"> 69*4626aec4SSurya Venkatesan <template v-if="v$.form.subnetMask.required.$invalid"> 70b34349d4SDixsie Wolmers {{ $t('global.form.fieldRequired') }} 71b34349d4SDixsie Wolmers </template> 72*4626aec4SSurya Venkatesan <template v-if="v$.form.subnetMask.ipAddress.$invalid"> 73b34349d4SDixsie Wolmers {{ $t('global.form.invalidFormat') }} 74b34349d4SDixsie Wolmers </template> 75b34349d4SDixsie Wolmers </b-form-invalid-feedback> 76b34349d4SDixsie Wolmers </b-form-group> 77b34349d4SDixsie Wolmers </b-col> 78b34349d4SDixsie Wolmers </b-row> 79b34349d4SDixsie Wolmers </b-form> 80b34349d4SDixsie Wolmers <template #modal-footer="{ cancel }"> 81b34349d4SDixsie Wolmers <b-button variant="secondary" @click="cancel()"> 82b34349d4SDixsie Wolmers {{ $t('global.action.cancel') }} 83b34349d4SDixsie Wolmers </b-button> 84b34349d4SDixsie Wolmers <b-button form="form-ipv4" type="submit" variant="primary" @click="onOk"> 85b34349d4SDixsie Wolmers {{ $t('global.action.add') }} 86b34349d4SDixsie Wolmers </b-button> 87b34349d4SDixsie Wolmers </template> 88b34349d4SDixsie Wolmers </b-modal> 89b34349d4SDixsie Wolmers</template> 90b34349d4SDixsie Wolmers 91b34349d4SDixsie Wolmers<script> 92b34349d4SDixsie Wolmersimport VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; 937d6b44cbSEd Tanousimport { useVuelidate } from '@vuelidate/core'; 947d6b44cbSEd Tanous 957d6b44cbSEd Tanousimport { ipAddress, required } from '@vuelidate/validators'; 96de23ea23SSurya Vimport { useI18n } from 'vue-i18n'; 97b34349d4SDixsie Wolmers 98b34349d4SDixsie Wolmersexport default { 99b34349d4SDixsie Wolmers mixins: [VuelidateMixin], 100b34349d4SDixsie Wolmers props: { 101b34349d4SDixsie Wolmers defaultGateway: { 102b34349d4SDixsie Wolmers type: String, 103b34349d4SDixsie Wolmers default: '', 104b34349d4SDixsie Wolmers }, 105b34349d4SDixsie Wolmers }, 1067d6b44cbSEd Tanous setup() { 1077d6b44cbSEd Tanous return { 1087d6b44cbSEd Tanous v$: useVuelidate(), 1097d6b44cbSEd Tanous }; 1107d6b44cbSEd Tanous }, 111b34349d4SDixsie Wolmers data() { 112b34349d4SDixsie Wolmers return { 113de23ea23SSurya V $t: useI18n().t, 114b34349d4SDixsie Wolmers form: { 115b34349d4SDixsie Wolmers ipAddress: '', 116b34349d4SDixsie Wolmers gateway: '', 117b34349d4SDixsie Wolmers subnetMask: '', 118b34349d4SDixsie Wolmers }, 119b34349d4SDixsie Wolmers }; 120b34349d4SDixsie Wolmers }, 121b34349d4SDixsie Wolmers watch: { 122b34349d4SDixsie Wolmers defaultGateway() { 123b34349d4SDixsie Wolmers this.form.gateway = this.defaultGateway; 124b34349d4SDixsie Wolmers }, 125b34349d4SDixsie Wolmers }, 126b34349d4SDixsie Wolmers validations() { 127b34349d4SDixsie Wolmers return { 128b34349d4SDixsie Wolmers form: { 129b34349d4SDixsie Wolmers ipAddress: { 130b34349d4SDixsie Wolmers required, 131b34349d4SDixsie Wolmers ipAddress, 132b34349d4SDixsie Wolmers }, 133b34349d4SDixsie Wolmers gateway: { 134b34349d4SDixsie Wolmers required, 135b34349d4SDixsie Wolmers ipAddress, 136b34349d4SDixsie Wolmers }, 137b34349d4SDixsie Wolmers subnetMask: { 138b34349d4SDixsie Wolmers required, 139b34349d4SDixsie Wolmers ipAddress, 140b34349d4SDixsie Wolmers }, 141b34349d4SDixsie Wolmers }, 142b34349d4SDixsie Wolmers }; 143b34349d4SDixsie Wolmers }, 144b34349d4SDixsie Wolmers methods: { 145b34349d4SDixsie Wolmers handleSubmit() { 146de23ea23SSurya V this.v$.$touch(); 147de23ea23SSurya V if (this.v$.$invalid) return; 148b34349d4SDixsie Wolmers this.$emit('ok', { 149b34349d4SDixsie Wolmers Address: this.form.ipAddress, 150b34349d4SDixsie Wolmers Gateway: this.form.gateway, 151b34349d4SDixsie Wolmers SubnetMask: this.form.subnetMask, 152b34349d4SDixsie Wolmers }); 153b34349d4SDixsie Wolmers this.closeModal(); 154b34349d4SDixsie Wolmers }, 155b34349d4SDixsie Wolmers closeModal() { 156b34349d4SDixsie Wolmers this.$nextTick(() => { 157b34349d4SDixsie Wolmers this.$refs.modal.hide(); 158b34349d4SDixsie Wolmers }); 159b34349d4SDixsie Wolmers }, 160b34349d4SDixsie Wolmers resetForm() { 161b34349d4SDixsie Wolmers this.form.ipAddress = null; 162b34349d4SDixsie Wolmers this.form.gateway = this.defaultGateway; 163b34349d4SDixsie Wolmers this.form.subnetMask = null; 164de23ea23SSurya V this.v$.$reset(); 165b34349d4SDixsie Wolmers this.$emit('hidden'); 166b34349d4SDixsie Wolmers }, 167b34349d4SDixsie Wolmers onOk(bvModalEvt) { 168b34349d4SDixsie Wolmers // prevent modal close 169b34349d4SDixsie Wolmers bvModalEvt.preventDefault(); 170b34349d4SDixsie Wolmers this.handleSubmit(); 171b34349d4SDixsie Wolmers }, 172b34349d4SDixsie Wolmers }, 173b34349d4SDixsie Wolmers}; 174b34349d4SDixsie Wolmers</script> 175