Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 1 | <template> |
| 2 | <b-container fluid="xl"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 3 | <page-title :description="$t('pageNetwork.pageDescription')" /> |
| 4 | <page-section :section-title="$t('pageNetwork.interface')"> |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 5 | <b-row> |
| 6 | <b-col lg="3"> |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 7 | <b-form-group |
| 8 | label-for="interface-select" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 9 | :label="$t('pageNetwork.form.networkInterface')" |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 10 | > |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 11 | <b-form-select |
| 12 | id="interface-select" |
| 13 | v-model="selectedInterfaceIndex" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 14 | :disabled="loading" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 15 | data-test-id="network-select-interface" |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 16 | :options="interfaceSelectOptions" |
| 17 | @change="selectInterface" |
| 18 | > |
| 19 | </b-form-select> |
| 20 | </b-form-group> |
| 21 | </b-col> |
| 22 | </b-row> |
| 23 | </page-section> |
| 24 | <b-form novalidate @submit.prevent="submitForm"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 25 | <b-form-group :disabled="loading"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 26 | <page-section :section-title="$t('pageNetwork.system')"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 27 | <b-row> |
| 28 | <b-col lg="3"> |
| 29 | <b-form-group |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 30 | :label="$t('pageNetwork.form.defaultGateway')" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 31 | label-for="default-gateway" |
| 32 | > |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 33 | <b-form-input |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 34 | id="default-gateway" |
| 35 | v-model.trim="form.gateway" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 36 | data-test-id="network-input-gateway" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 37 | type="text" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 38 | :state="getValidationState($v.form.gateway)" |
| 39 | @change="$v.form.gateway.$touch()" |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 40 | /> |
| 41 | <b-form-invalid-feedback role="alert"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 42 | <div v-if="!$v.form.gateway.required"> |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 43 | {{ $t('global.form.fieldRequired') }} |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 44 | </div> |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 45 | <div v-if="!$v.form.gateway.ipAddress"> |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 46 | {{ $t('global.form.invalidFormat') }} |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 47 | </div> |
| 48 | </b-form-invalid-feedback> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 49 | </b-form-group> |
| 50 | </b-col> |
| 51 | <b-col lg="3"> |
| 52 | <b-form-group |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 53 | :label="$t('pageNetwork.form.hostname')" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 54 | label-for="hostname-field" |
| 55 | > |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 56 | <b-form-input |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 57 | id="hostname-field" |
| 58 | v-model.trim="form.hostname" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 59 | data-test-id="network-input-hostname" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 60 | type="text" |
| 61 | :state="getValidationState($v.form.hostname)" |
| 62 | @change="$v.form.hostname.$touch()" |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 63 | /> |
| 64 | <b-form-invalid-feedback role="alert"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 65 | <div v-if="!$v.form.hostname.required"> |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 66 | {{ $t('global.form.fieldRequired') }} |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 67 | </div> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 68 | <div v-if="!$v.form.hostname.validateHostname"> |
| 69 | {{ |
| 70 | $t('global.form.lengthMustBeBetween', { min: 1, max: 64 }) |
| 71 | }} |
| 72 | </div> |
| 73 | </b-form-invalid-feedback> |
| 74 | </b-form-group> |
| 75 | </b-col> |
| 76 | <b-col lg="3"> |
| 77 | <b-form-group |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 78 | :label="$t('pageNetwork.form.macAddress')" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 79 | label-for="mac-address" |
| 80 | > |
| 81 | <b-form-input |
| 82 | id="mac-address" |
| 83 | v-model.trim="form.macAddress" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 84 | data-test-id="network-input-macAddress" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 85 | type="text" |
| 86 | :state="getValidationState($v.form.macAddress)" |
| 87 | @change="$v.form.macAddress.$touch()" |
| 88 | /> |
| 89 | <b-form-invalid-feedback role="alert"> |
| 90 | <div v-if="!$v.form.macAddress.required"> |
| 91 | {{ $t('global.form.fieldRequired') }} |
| 92 | </div> |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 93 | <div v-if="!$v.form.macAddress.macAddress"> |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 94 | {{ $t('global.form.invalidFormat') }} |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 95 | </div> |
| 96 | </b-form-invalid-feedback> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 97 | </b-form-group> |
| 98 | </b-col> |
| 99 | </b-row> |
| 100 | </page-section> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 101 | <page-section :section-title="$t('pageNetwork.ipv4')"> |
| 102 | <b-form-group :label="$t('pageNetwork.ipv4Configuration')"> |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 103 | <b-form-text id="enable-secure-help-block"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 104 | {{ $t('pageNetwork.ipv4Helper') }} |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 105 | </b-form-text> |
| 106 | <b-form-radio |
| 107 | v-model="form.dhcpEnabled" |
| 108 | name="dhcp-radio" |
| 109 | :value="true" |
| 110 | @change="onChangeIpv4Config" |
| 111 | > |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 112 | {{ $t('pageNetwork.dhcp') }} |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 113 | </b-form-radio> |
| 114 | <b-form-radio |
| 115 | v-model="form.dhcpEnabled" |
| 116 | name="static-radio" |
| 117 | :value="false" |
| 118 | @change="onChangeIpv4Config" |
| 119 | > |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 120 | {{ $t('pageNetwork.static') }} |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 121 | </b-form-radio> |
| 122 | </b-form-group> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 123 | <b-row> |
| 124 | <b-col lg="9" class="mb-3"> |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 125 | <h3 class="h4"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 126 | {{ $t('pageNetwork.dhcp') }} |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 127 | </h3> |
| 128 | <b-table |
| 129 | responsive="md" |
| 130 | hover |
| 131 | :fields="ipv4DhcpTableFields" |
| 132 | :items="form.ipv4DhcpTableItems" |
| 133 | :empty-text="$t('global.table.emptyMessage')" |
| 134 | class="mb-0" |
| 135 | show-empty |
| 136 | > |
| 137 | <template #cell(Address)="{ item, index }"> |
| 138 | <b-form-input |
| 139 | v-model.trim="item.Address" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 140 | :data-test-id="`network-input-dhcpIpv4-${index}`" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 141 | :aria-label=" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 142 | $t('pageNetwork.table.dhcpIpv4AddressRow') + |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 143 | ' ' + |
| 144 | (index + 1) |
| 145 | " |
| 146 | readonly |
| 147 | /> |
| 148 | </template> |
| 149 | <template #cell(SubnetMask)="{ item, index }"> |
| 150 | <b-form-input |
| 151 | v-model.trim="item.SubnetMask" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 152 | :data-test-id="`network-input-subnetMask-${index}`" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 153 | :aria-label=" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 154 | $t('pageNetwork.table.dhcpIpv4SubnetRow') + |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 155 | ' ' + |
| 156 | (index + 1) |
| 157 | " |
| 158 | readonly |
| 159 | /> |
| 160 | </template> |
| 161 | <template #cell(actions)="{ item, index }"> |
| 162 | <table-row-action |
| 163 | v-for="(action, actionIndex) in item.actions" |
| 164 | :key="actionIndex" |
| 165 | :value="action.value" |
| 166 | :title="action.title" |
| 167 | :enabled="false" |
| 168 | @click-table-action=" |
| 169 | onDeleteIpv4StaticTableRow($event, index) |
| 170 | " |
| 171 | > |
| 172 | <template #icon> |
| 173 | <icon-trashcan v-if="action.value === 'delete'" /> |
| 174 | </template> |
| 175 | </table-row-action> |
| 176 | </template> |
| 177 | </b-table> |
| 178 | </b-col> |
| 179 | <b-col lg="9" class="mb-3"> |
| 180 | <h3 class="h4"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 181 | {{ $t('pageNetwork.static') }} |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 182 | </h3> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 183 | <b-table |
| 184 | responsive="md" |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 185 | hover |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 186 | :fields="ipv4StaticTableFields" |
| 187 | :items="form.ipv4StaticTableItems" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 188 | :empty-text="$t('global.table.emptyMessage')" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 189 | class="mb-0" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 190 | show-empty |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 191 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 192 | <template #cell(Address)="{ item, index }"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 193 | <b-form-input |
| 194 | v-model.trim="item.Address" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 195 | :data-test-id="`network-input-staticIpv4-${index}`" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 196 | :aria-label=" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 197 | $t('pageNetwork.table.staticIpv4AddressRow') + |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 198 | ' ' + |
| 199 | (index + 1) |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 200 | " |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 201 | :state=" |
| 202 | getValidationState( |
| 203 | $v.form.ipv4StaticTableItems.$each.$iter[index].Address |
| 204 | ) |
| 205 | " |
| 206 | @change=" |
| 207 | $v.form.ipv4StaticTableItems.$each.$iter[ |
| 208 | index |
| 209 | ].Address.$touch() |
| 210 | " |
| 211 | /> |
| 212 | <b-form-invalid-feedback role="alert"> |
| 213 | <div |
| 214 | v-if=" |
| 215 | !$v.form.ipv4StaticTableItems.$each.$iter[index].Address |
| 216 | .required |
| 217 | " |
| 218 | > |
| 219 | {{ $t('global.form.fieldRequired') }} |
| 220 | </div> |
| 221 | <div |
| 222 | v-if=" |
| 223 | !$v.form.ipv4StaticTableItems.$each.$iter[index].Address |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 224 | .ipAddress |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 225 | " |
| 226 | > |
| 227 | {{ $t('global.form.invalidFormat') }} |
| 228 | </div> |
| 229 | </b-form-invalid-feedback> |
| 230 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 231 | <template #cell(SubnetMask)="{ item, index }"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 232 | <b-form-input |
| 233 | v-model.trim="item.SubnetMask" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 234 | :data-test-id="`network-input-subnetMask-${index}`" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 235 | :aria-label=" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 236 | $t('pageNetwork.table.staticIpv4SubnetRow') + |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 237 | ' ' + |
| 238 | (index + 1) |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 239 | " |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 240 | :state=" |
| 241 | getValidationState( |
| 242 | $v.form.ipv4StaticTableItems.$each.$iter[index] |
| 243 | .SubnetMask |
| 244 | ) |
| 245 | " |
| 246 | @change=" |
| 247 | $v.form.ipv4StaticTableItems.$each.$iter[ |
| 248 | index |
| 249 | ].SubnetMask.$touch() |
| 250 | " |
| 251 | /> |
| 252 | <b-form-invalid-feedback role="alert"> |
| 253 | <div |
| 254 | v-if=" |
| 255 | !$v.form.ipv4StaticTableItems.$each.$iter[index] |
| 256 | .SubnetMask.required |
| 257 | " |
| 258 | > |
| 259 | {{ $t('global.form.fieldRequired') }} |
| 260 | </div> |
| 261 | <div |
| 262 | v-if=" |
| 263 | !$v.form.ipv4StaticTableItems.$each.$iter[index] |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 264 | .SubnetMask.ipAddress |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 265 | " |
| 266 | > |
| 267 | {{ $t('global.form.invalidFormat') }} |
| 268 | </div> |
| 269 | </b-form-invalid-feedback> |
| 270 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 271 | <template #cell(actions)="{ item, index }"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 272 | <table-row-action |
| 273 | v-for="(action, actionIndex) in item.actions" |
| 274 | :key="actionIndex" |
| 275 | :value="action.value" |
| 276 | :title="action.title" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 277 | @click-table-action=" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 278 | onDeleteIpv4StaticTableRow($event, index) |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 279 | " |
| 280 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 281 | <template #icon> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 282 | <icon-trashcan v-if="action.value === 'delete'" /> |
| 283 | </template> |
| 284 | </table-row-action> |
| 285 | </template> |
| 286 | </b-table> |
| 287 | <b-button variant="link" @click="addIpv4StaticTableRow"> |
| 288 | <icon-add /> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 289 | {{ $t('pageNetwork.table.addStaticIpv4Address') }} |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 290 | </b-button> |
| 291 | </b-col> |
| 292 | </b-row> |
| 293 | </page-section> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 294 | <page-section :section-title="$t('pageNetwork.staticDns')"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 295 | <b-row> |
| 296 | <b-col lg="4" class="mb-3"> |
| 297 | <b-table |
| 298 | responsive |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 299 | hover |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 300 | :fields="dnsTableFields" |
| 301 | :items="form.dnsStaticTableItems" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 302 | :empty-text="$t('global.table.emptyMessage')" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 303 | class="mb-0" |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 304 | show-empty |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 305 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 306 | <template #cell(address)="{ item, index }"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 307 | <b-form-input |
| 308 | v-model.trim="item.address" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 309 | :data-test-id="`network-input-dnsAddress-${index}`" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 310 | :aria-label=" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 311 | $t('pageNetwork.table.staticDnsRow') + ' ' + (index + 1) |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 312 | " |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 313 | :state=" |
| 314 | getValidationState( |
| 315 | $v.form.dnsStaticTableItems.$each.$iter[index].address |
| 316 | ) |
| 317 | " |
| 318 | @change=" |
| 319 | $v.form.dnsStaticTableItems.$each.$iter[ |
| 320 | index |
| 321 | ].address.$touch() |
| 322 | " |
| 323 | /> |
| 324 | <b-form-invalid-feedback role="alert"> |
| 325 | <div |
| 326 | v-if=" |
| 327 | !$v.form.dnsStaticTableItems.$each.$iter[index].address |
| 328 | .required |
| 329 | " |
| 330 | > |
| 331 | {{ $t('global.form.fieldRequired') }} |
| 332 | </div> |
| 333 | <div |
| 334 | v-if=" |
| 335 | !$v.form.dnsStaticTableItems.$each.$iter[index].address |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 336 | .ipAddress |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 337 | " |
| 338 | > |
| 339 | {{ $t('global.form.invalidFormat') }} |
| 340 | </div> |
| 341 | </b-form-invalid-feedback> |
| 342 | </template> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 343 | <template #cell(actions)="{ item, index }"> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 344 | <table-row-action |
| 345 | v-for="(action, actionIndex) in item.actions" |
| 346 | :key="actionIndex" |
| 347 | :value="action.value" |
| 348 | :title="action.title" |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 349 | @click-table-action="onDeleteDnsTableRow($event, index)" |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 350 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 351 | <template #icon> |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 352 | <icon-trashcan v-if="action.value === 'delete'" /> |
| 353 | </template> |
| 354 | </table-row-action> |
| 355 | </template> |
| 356 | </b-table> |
| 357 | <b-button variant="link" @click="addDnsTableRow"> |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 358 | <icon-add /> {{ $t('pageNetwork.table.addDns') }} |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 359 | </b-button> |
| 360 | </b-col> |
| 361 | </b-row> |
| 362 | </page-section> |
| 363 | <b-button |
| 364 | variant="primary" |
| 365 | type="submit" |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 366 | data-test-id="network-button-saveNetworkSettings" |
Mateusz Gapski | 471f2e0 | 2020-07-27 14:43:26 +0200 | [diff] [blame] | 367 | > |
| 368 | {{ $t('global.action.saveSettings') }} |
| 369 | </b-button> |
| 370 | </b-form-group> |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 371 | </b-form> |
| 372 | </b-container> |
| 373 | </template> |
| 374 | |
| 375 | <script> |
| 376 | import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; |
| 377 | import IconAdd from '@carbon/icons-vue/es/add--alt/20'; |
| 378 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | d73f496 | 2020-12-09 08:52:23 -0800 | [diff] [blame] | 379 | import LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 380 | import PageSection from '@/components/Global/PageSection'; |
| 381 | import PageTitle from '@/components/Global/PageTitle'; |
| 382 | import TableRowAction from '@/components/Global/TableRowAction'; |
| 383 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin'; |
| 384 | import { mapState } from 'vuex'; |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 385 | import { |
| 386 | required, |
| 387 | helpers, |
| 388 | ipAddress, |
| 389 | macAddress, |
| 390 | } from 'vuelidate/lib/validators'; |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 391 | |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 392 | // Hostname pattern |
| 393 | const validateHostname = helpers.regex('validateHostname', /^\S{0,64}$/); |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 394 | |
| 395 | export default { |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 396 | name: 'Network', |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 397 | components: { |
| 398 | PageTitle, |
| 399 | PageSection, |
| 400 | TableRowAction, |
| 401 | IconTrashcan, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 402 | IconAdd, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 403 | }, |
| 404 | mixins: [BVToastMixin, VuelidateMixin, LoadingBarMixin], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 405 | beforeRouteLeave(to, from, next) { |
| 406 | this.hideLoader(); |
| 407 | next(); |
| 408 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 409 | data() { |
| 410 | return { |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 411 | ipv4DhcpTableFields: [ |
| 412 | { |
| 413 | key: 'Address', |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 414 | label: this.$t('pageNetwork.table.ipAddress'), |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 415 | }, |
| 416 | { |
| 417 | key: 'SubnetMask', |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 418 | label: this.$t('pageNetwork.table.subnet'), |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 419 | }, |
| 420 | { key: 'actions', label: '', tdClass: 'text-right' }, |
| 421 | ], |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 422 | ipv4StaticTableFields: [ |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 423 | { |
| 424 | key: 'Address', |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 425 | label: this.$t('pageNetwork.table.ipAddress'), |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 426 | }, |
| 427 | { |
| 428 | key: 'SubnetMask', |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 429 | label: this.$t('pageNetwork.table.subnet'), |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 430 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 431 | { key: 'actions', label: '', tdClass: 'text-right' }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 432 | ], |
| 433 | dnsTableFields: [ |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 434 | { |
| 435 | key: 'address', |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 436 | label: this.$t('pageNetwork.table.ipAddress'), |
Dixsie Wolmers | e3c9c09 | 2020-05-20 23:27:56 -0500 | [diff] [blame] | 437 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 438 | { key: 'actions', label: '', tdClass: 'text-right' }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 439 | ], |
| 440 | selectedInterfaceIndex: 0, |
| 441 | selectedInterface: {}, |
| 442 | form: { |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 443 | dhcpEnabled: null, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 444 | gateway: '', |
| 445 | hostname: '', |
| 446 | macAddress: '', |
| 447 | ipv4StaticTableItems: [], |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 448 | ipv4DhcpTableItems: [], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 449 | dnsStaticTableItems: [], |
| 450 | }, |
Yoshie Muranaka | d73f496 | 2020-12-09 08:52:23 -0800 | [diff] [blame] | 451 | loading, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 452 | }; |
| 453 | }, |
| 454 | validations() { |
| 455 | return { |
| 456 | form: { |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 457 | gateway: { required, ipAddress }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 458 | hostname: { required, validateHostname }, |
| 459 | ipv4StaticTableItems: { |
| 460 | $each: { |
| 461 | Address: { |
| 462 | required, |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 463 | ipAddress, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 464 | }, |
| 465 | SubnetMask: { |
| 466 | required, |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 467 | ipAddress, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 468 | }, |
| 469 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 470 | }, |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 471 | macAddress: { required, macAddress: macAddress() }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 472 | dnsStaticTableItems: { |
| 473 | $each: { |
| 474 | address: { |
| 475 | required, |
Dixsie | 71aa455 | 2021-03-26 12:38:03 -0500 | [diff] [blame] | 476 | ipAddress, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 477 | }, |
| 478 | }, |
| 479 | }, |
| 480 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 481 | }; |
| 482 | }, |
| 483 | computed: { |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 484 | ...mapState('network', [ |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 485 | 'ethernetData', |
| 486 | 'interfaceOptions', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 487 | 'defaultGateway', |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 488 | ]), |
| 489 | interfaceSelectOptions() { |
| 490 | return this.interfaceOptions.map((option, index) => { |
| 491 | return { |
| 492 | text: option, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 493 | value: index, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 494 | }; |
| 495 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 496 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 497 | }, |
| 498 | watch: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 499 | ethernetData: function () { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 500 | this.selectInterface(); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 501 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 502 | }, |
| 503 | created() { |
| 504 | this.startLoader(); |
| 505 | this.$store |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 506 | .dispatch('network/getEthernetData') |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 507 | .finally(() => this.endLoader()); |
| 508 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 509 | methods: { |
| 510 | selectInterface() { |
| 511 | this.selectedInterface = this.ethernetData[this.selectedInterfaceIndex]; |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 512 | this.getIpv4DhcpTableItems(); |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 513 | this.getIpv4StaticTableItems(); |
| 514 | this.getDnsStaticTableItems(); |
| 515 | this.getInterfaceSettings(); |
| 516 | }, |
| 517 | getInterfaceSettings() { |
| 518 | this.form.gateway = this.defaultGateway; |
| 519 | this.form.hostname = this.selectedInterface.HostName; |
| 520 | this.form.macAddress = this.selectedInterface.MACAddress; |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 521 | this.form.dhcpEnabled = this.selectedInterface.DHCPv4.DHCPEnabled; |
| 522 | }, |
| 523 | onChangeIpv4Config(value) { |
| 524 | this.form.dhcpEnabled = value; |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 525 | }, |
| 526 | getDnsStaticTableItems() { |
| 527 | const dns = this.selectedInterface.StaticNameServers || []; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 528 | this.form.dnsStaticTableItems = dns.map((server) => { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 529 | return { |
| 530 | address: server, |
| 531 | actions: [ |
| 532 | { |
| 533 | value: 'delete', |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 534 | enabled: this.form.dhcpEnabled, |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 535 | title: this.$t('pageNetwork.table.deleteDns'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 536 | }, |
| 537 | ], |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 538 | }; |
| 539 | }); |
| 540 | }, |
| 541 | addDnsTableRow() { |
| 542 | this.$v.form.dnsStaticTableItems.$touch(); |
| 543 | this.form.dnsStaticTableItems.push({ |
| 544 | address: '', |
| 545 | actions: [ |
| 546 | { |
| 547 | value: 'delete', |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 548 | enabled: this.form.dhcpEnabled, |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 549 | title: this.$t('pageNetwork.table.deleteDns'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 550 | }, |
| 551 | ], |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 552 | }); |
| 553 | }, |
| 554 | deleteDnsTableRow(index) { |
| 555 | this.$v.form.dnsStaticTableItems.$touch(); |
| 556 | this.form.dnsStaticTableItems.splice(index, 1); |
| 557 | }, |
| 558 | onDeleteDnsTableRow(action, row) { |
| 559 | this.deleteDnsTableRow(row); |
| 560 | }, |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 561 | getIpv4DhcpTableItems() { |
| 562 | const addresses = this.selectedInterface.IPv4Addresses || []; |
| 563 | this.form.ipv4DhcpTableItems = addresses |
| 564 | .filter((ipv4) => ipv4.AddressOrigin === 'DHCP') |
| 565 | .map((ipv4) => { |
| 566 | return { |
| 567 | Address: ipv4.Address, |
| 568 | SubnetMask: ipv4.SubnetMask, |
| 569 | actions: [ |
| 570 | { |
| 571 | value: 'delete', |
| 572 | enabled: false, |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 573 | title: this.$t('pageNetwork.table.deleteDhcpIpv4'), |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 574 | }, |
| 575 | ], |
| 576 | }; |
| 577 | }); |
| 578 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 579 | getIpv4StaticTableItems() { |
| 580 | const addresses = this.selectedInterface.IPv4StaticAddresses || []; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 581 | this.form.ipv4StaticTableItems = addresses.map((ipv4) => { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 582 | return { |
| 583 | Address: ipv4.Address, |
| 584 | SubnetMask: ipv4.SubnetMask, |
| 585 | actions: [ |
| 586 | { |
| 587 | value: 'delete', |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 588 | enabled: this.form.dhcpEnabled, |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 589 | title: this.$t('pageNetwork.table.deleteStaticIpv4'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 590 | }, |
| 591 | ], |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 592 | }; |
| 593 | }); |
| 594 | }, |
| 595 | addIpv4StaticTableRow() { |
| 596 | this.$v.form.ipv4StaticTableItems.$touch(); |
| 597 | this.form.ipv4StaticTableItems.push({ |
| 598 | Address: '', |
| 599 | SubnetMask: '', |
| 600 | actions: [ |
| 601 | { |
| 602 | value: 'delete', |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 603 | enabled: this.form.dhcpEnabled, |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 604 | title: this.$t('pageNetwork.table.deleteStaticIpv4'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 605 | }, |
| 606 | ], |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 607 | }); |
| 608 | }, |
| 609 | deleteIpv4StaticTableRow(index) { |
| 610 | this.$v.form.ipv4StaticTableItems.$touch(); |
| 611 | this.form.ipv4StaticTableItems.splice(index, 1); |
| 612 | }, |
| 613 | onDeleteIpv4StaticTableRow(action, row) { |
| 614 | this.deleteIpv4StaticTableRow(row); |
| 615 | }, |
| 616 | submitForm() { |
Dixsie Wolmers | 4d1dbb5 | 2020-08-24 21:43:25 -0500 | [diff] [blame] | 617 | this.$v.$touch(); |
| 618 | if (this.$v.$invalid) return; |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 619 | this.startLoader(); |
| 620 | let networkInterfaceSelected = this.selectedInterface; |
| 621 | let selectedInterfaceIndex = this.selectedInterfaceIndex; |
| 622 | let interfaceId = networkInterfaceSelected.Id; |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 623 | let isDhcpEnabled = this.form.dhcpEnabled; |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 624 | let macAddress = this.form.macAddress; |
| 625 | let hostname = this.form.hostname; |
| 626 | let networkSettingsForm = { |
| 627 | interfaceId, |
| 628 | hostname, |
| 629 | macAddress, |
| 630 | selectedInterfaceIndex, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 631 | }; |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 632 | // Enabling DHCP without any available IP addresses will bring network down |
| 633 | if (this.form.ipv4DhcpTableItems.length) { |
| 634 | networkSettingsForm.isDhcpEnabled = isDhcpEnabled; |
| 635 | } else { |
| 636 | networkSettingsForm.isDhcpEnabled = false; |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 637 | this.errorToast(this.$t('pageNetwork.toast.errorSaveDhcpSettings')); |
Dixsie Wolmers | 157d2ff | 2020-12-16 14:25:04 -0600 | [diff] [blame] | 638 | } |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 639 | networkSettingsForm.staticIpv4 = this.form.ipv4StaticTableItems.map( |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 640 | (updateIpv4) => { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 641 | delete updateIpv4.actions; |
| 642 | updateIpv4.Gateway = this.form.gateway; |
| 643 | return updateIpv4; |
| 644 | } |
| 645 | ); |
| 646 | networkSettingsForm.staticNameServers = this.form.dnsStaticTableItems.map( |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 647 | (updateDns) => { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 648 | return updateDns.address; |
| 649 | } |
| 650 | ); |
| 651 | this.$store |
Sandeepa Singh | f67f769 | 2021-07-19 18:04:18 +0530 | [diff] [blame] | 652 | .dispatch('network/updateInterfaceSettings', networkSettingsForm) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 653 | .then((success) => { |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 654 | this.successToast(success); |
| 655 | }) |
| 656 | .catch(({ message }) => this.errorToast(message)) |
| 657 | .finally(() => { |
| 658 | this.$v.form.$reset(); |
| 659 | this.endLoader(); |
| 660 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 661 | }, |
| 662 | }, |
Dixsie Wolmers | bb81d55 | 2020-02-26 19:52:28 -0600 | [diff] [blame] | 663 | }; |
| 664 | </script> |