From 869808ebb6f630c279dac5fd6e9fa8ab3daed7ef Mon Sep 17 00:00:00 2001 From: Alexander Kaschta <alexander.kaschta9@kit.edu> Date: Tue, 3 Dec 2024 00:05:44 +0100 Subject: [PATCH] UPD: Finish BCDRequestForm UI --- src/components/BCDRequestForm.vue | 58 +++++++++++++++++-------------- src/locales/de.json | 4 ++- src/locales/en.json | 4 ++- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/components/BCDRequestForm.vue b/src/components/BCDRequestForm.vue index 703c07ae7..fa7df58ef 100644 --- a/src/components/BCDRequestForm.vue +++ b/src/components/BCDRequestForm.vue @@ -182,14 +182,18 @@ {{ $t('components.bcd_request_form.dhcp_pool_wish') }} </b-form-checkbox> </b-form-group> - <b-form-group :label="$t('components.bcd_request_form.dhcp_pool_size')"> - <b-form-select v-model="dhcp_pool_size_select" :options="translated_dhcp_pool_size"> - <template #first> - <b-form-select-option :value="null" disabled>{{ $t('system.please_select') }}</b-form-select-option> - </template> - </b-form-select> + <b-form-group :label="$t('components.bcd_request_form.dhcp_pool_size')" + :disabled="!dhcp_pool_wish_value || loading_edit_action" + :description="$t('components.bcd_request_form.dhcp_pool_size_note')"> + <b-form-input v-model="dhcp_pool_size_value" type="number" min="2" step="1" + :state="checkDHCPPoolSize" + :max="getSubnetSize(this.subnet_size_select ?? 29) - 5"/> + <b-form-invalid-feedback> + {{ $t('components.bcd_request_form.dhcp_pool_size_error') }} + </b-form-invalid-feedback> </b-form-group> - <b-form-group :label="$t('components.bcd_request_form.device_location')"> + <b-form-group :label="$t('components.bcd_request_form.device_location')" + :disabled="!types_of_subnets_select || loading_edit_action"> <b-form-checkbox>{{ $t('components.bcd_request_form.device_locations.cs') }}</b-form-checkbox> <b-form-checkbox>{{ $t('components.bcd_request_form.device_locations.cn') }}</b-form-checkbox> <b-form-checkbox>{{ $t('components.bcd_request_form.device_locations.vm_cluster_unknown') }}</b-form-checkbox> @@ -199,7 +203,8 @@ <b-form-checkbox>{{ $t('components.bcd_request_form.device_locations.scc_server_room_cn') }}</b-form-checkbox> <b-form-checkbox>{{ $t('components.bcd_request_form.device_locations.vpn_wifi_to_vlan') }}</b-form-checkbox> </b-form-group> - <b-form-group :label="$t('components.bcd_request_form.realized_services')"> + <b-form-group :label="$t('components.bcd_request_form.realized_services')" + :disabled="!types_of_subnets_select || loading_edit_action"> <b-form-checkbox>{{ $t('components.bcd_request_form.realizable_services.vpn2vlan') }} <a href="https://www.scc.kit.edu/ts-vpn2vlan" target="_blank"> <netvs-icon icon="external_link"></netvs-icon> @@ -214,6 +219,16 @@ </b-form-group> </b-form> </b-overlay> + <template #modal-footer="{ ok, cancel }"> + <b-button variant="secondary" @click="cancel()"> + {{ $t('components.patch_request_form.cancel') }} + </b-button> + <b-button variant="primary" :disabled="!types_of_subnets_select" @click="ok()"> + {{ $t('components.patch_request_form.send') }} + <b-spinner small v-show="sending"/> + <netvs-icon v-show="status_icon !== null" :icon="status_icon"></netvs-icon> + </b-button> + </template> </b-modal> </template> @@ -242,7 +257,7 @@ export default { access_from_internet_value: null, access_from_internet_explanation_value: null, dhcp_pool_wish_value: null, - dhcp_pool_size_select: null, + dhcp_pool_size_value: '2', dhcp_own_server_value: null, dhcp_wish_value: null, protection_requirements_select: null, @@ -275,26 +290,14 @@ export default { { value: 26, translation_key: 'components.bcd_request_form.ipv4_subnet_sizes.size_26' }, { value: 25, translation_key: 'components.bcd_request_form.ipv4_subnet_sizes.size_25' }, { value: 24, translation_key: 'components.bcd_request_form.ipv4_subnet_sizes.size_24' } - ] + ], + sending: false, + status_icon: null } }, computed: { - translated_dhcp_pool_size() { - // Calculate the number of ipv4 addresses - const subnet_size = ipaddress.ipv4_subnet_size(this.subnet_size_select ?? 29) - - const dhcp_pool_size_options = [] - - for (let dhcp_pool_size = 2; dhcp_pool_size <= subnet_size - 5; dhcp_pool_size++) { - // Generate the entries dynamically - dhcp_pool_size_options.push({ - value: dhcp_pool_size, - translation_key: 'components.bcd_request_form.dhcp_pool_address_count', - translation_args: { number: dhcp_pool_size } - }) - } - - return this.translateOptions(dhcp_pool_size_options) + checkDHCPPoolSize() { + return parseInt(this.dhcp_pool_size_value) >= 2 && parseInt(this.dhcp_pool_size_value) <= (this.getSubnetSize(this.subnet_size_select ?? 29) - 5) }, translated_protection_requirements() { return this.translateOptions(this.protection_requirements_options) @@ -316,6 +319,9 @@ export default { } }, methods: { + getSubnetSize(value) { + return ipaddress.ipv4_subnet_size(value) + }, async update() { await this.updateOEs() }, diff --git a/src/locales/de.json b/src/locales/de.json index ec83b1f73..2a3fce95e 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -37,7 +37,9 @@ "dhcp_own": "Eigener DHCP-Server", "dhcp_own_question": "Wird ein eigener DHCP-Server betrieben?", "dhcp_pool": "DHCP-Pool", - "dhcp_pool_size": "Wie groß soll der DHCP-Pool sein?", + "dhcp_pool_size": "Wie viele Adressen soll der DHCP-Pool haben?", + "dhcp_pool_size_note": "Der DHCP-Pool kann zwischen zwei und der Subnetzgröße minus fünf Adressen groß sein.", + "dhcp_pool_size_error": "Der angegebene Wert liegt nicht außerhalb der erlaubten Grenzen.", "dhcp_pool_address_count": "{number} Adressen", "dhcp_pool_wish": "Wird zusätzlich ein DHCP-Pool gewünscht?", "dhcp_wish": "Wird DHCP gewünscht?", diff --git a/src/locales/en.json b/src/locales/en.json index f32c04be0..97d59a722 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -37,7 +37,9 @@ "dhcp_own": "Own DHCP Server", "dhcp_own_question": "Do you operate your own DHCP server?", "dhcp_pool": "DHCP-Pool", - "dhcp_pool_size": "How large should the DHCP pool be?", + "dhcp_pool_size": "How many addresses should the DHCP pool contain?", + "dhcp_pool_size_note": "The DHCP pool can have between two and the subnet size minus five addresses.", + "dhcp_pool_size_error": "The given value is not within the specified boundaries.", "dhcp_pool_address_count": "{number} addresses", "dhcp_pool_wish": "Is a DHCP pool also desired?", "dhcp_wish": "Is DHCP wished?", -- GitLab