From 58c43653761a5ec3dd84f155c7af37c6abb420fb Mon Sep 17 00:00:00 2001 From: Maksim Zakharov Date: Thu, 25 Aug 2022 15:32:34 +0300 Subject: rename None in BootSettings --- src/utilities/_sila/transformBootOption.js | 24 ++++++++++++++++++++++ .../ServerPowerOperations/BootSettings.vue | 24 +++++++++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 src/utilities/_sila/transformBootOption.js diff --git a/src/utilities/_sila/transformBootOption.js b/src/utilities/_sila/transformBootOption.js new file mode 100644 index 00000000..047d9e7f --- /dev/null +++ b/src/utilities/_sila/transformBootOption.js @@ -0,0 +1,24 @@ +export function replaceNone(value) { + if (value === 'None') { + return 'Отключено'; + } else { + return value; + } +} + +export function replaceRevert(value) { + if (value === 'Отключено') { + return 'None'; + } else { + return value; + } +} + +export function replaceNoneArr(arr) { + return arr.map((item) => { + if (item === 'None') { + return 'Отключено'; + } + return item; + }); +} diff --git a/src/views/_sila/Operations/ServerPowerOperations/BootSettings.vue b/src/views/_sila/Operations/ServerPowerOperations/BootSettings.vue index 7ef83b5d..826d8607 100644 --- a/src/views/_sila/Operations/ServerPowerOperations/BootSettings.vue +++ b/src/views/_sila/Operations/ServerPowerOperations/BootSettings.vue @@ -15,7 +15,7 @@ bootSourceOptions.length === 0 || $store.getters['authentication/role'] === 'ReadOnly' " - :options="bootSourceOptions" + :options="bootSourceOptionsReplaced" @change="onChangeSelect" > @@ -24,7 +24,7 @@ v-model="form.oneTimeBoot" class="mb-4" :disabled=" - form.bootOption === 'None' || + form.bootOption === 'Отключено' || $store.getters['authentication/role'] === 'ReadOnly' " @change="$v.form.oneTimeBoot.$touch()" @@ -39,11 +39,11 @@ stacked > - {{ $t(`${bootModeOptions[0]}`) }} + {{ `${bootModeOptions[0]}` }} - {{ $t(`${bootModeOptions[1]}`) }} + {{ `${bootModeOptions[1]}` }} @@ -81,6 +81,11 @@ import { mapState } from 'vuex'; import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin'; import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin'; +import { + replaceNone, + replaceRevert, + replaceNoneArr, +} from '@/utilities/_sila/transformBootOption.js'; export default { name: 'BootSettings', @@ -88,7 +93,9 @@ export default { data() { return { form: { - bootOption: this.$store.getters['serverBootSettings/bootSource'], + bootOption: replaceNone( + this.$store.getters['serverBootSettings/bootSource'] + ), bootMode: this.$store.getters['serverBootSettings/bootMode'], oneTimeBoot: this.$store.getters['serverBootSettings/overrideEnabled'], tpmPolicyOn: this.$store.getters['serverBootSettings/tpmEnabled'], @@ -104,10 +111,13 @@ export default { 'overrideEnabled', 'tpmEnabled', ]), + bootSourceOptionsReplaced() { + return replaceNoneArr(this.bootSourceOptions); + }, }, watch: { bootSource: function (value) { - this.form.bootOption = value; + this.form.bootOption = replaceNone(value); }, bootMode: function (value) { this.form.bootMode = value; @@ -141,7 +151,7 @@ export default { this.startLoader(); const tpmPolicyChanged = this.$v.form.tpmPolicyOn.$dirty; let settings; - let bootSource = this.form.bootOption; + let bootSource = replaceRevert(this.form.bootOption); let overrideEnabled = this.form.oneTimeBoot; let bootMode = this.form.bootMode; let tpmEnabled = null; -- cgit v1.2.3