Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 1 | <template> |
Dixsie Wolmers | d7e7a16 | 2020-07-20 18:35:33 -0500 | [diff] [blame] | 2 | <div class="form-background p-3"> |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 3 | <b-form novalidate @submit.prevent="handleSubmit"> |
| 4 | <b-form-group |
| 5 | :label=" |
| 6 | $t('pageServerPowerOperations.bootSettings.bootSettingsOverride') |
| 7 | " |
| 8 | label-for="boot-option" |
| 9 | class="mb-3" |
| 10 | > |
| 11 | <b-form-select |
| 12 | id="boot-option" |
| 13 | v-model="form.bootOption" |
| 14 | :disabled="bootSourceOptions.length === 0" |
| 15 | :options="bootSourceOptions" |
| 16 | @change="onChangeSelect" |
| 17 | > |
| 18 | </b-form-select> |
| 19 | </b-form-group> |
| 20 | <b-form-checkbox |
| 21 | v-model="form.oneTimeBoot" |
| 22 | class="mb-4" |
| 23 | :disabled="form.bootOption === 'None'" |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 24 | @change="v$.form.oneTimeBoot.$touch()" |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 25 | > |
| 26 | {{ $t('pageServerPowerOperations.bootSettings.enableOneTimeBoot') }} |
| 27 | </b-form-checkbox> |
| 28 | <b-form-group |
| 29 | :label="$t('pageServerPowerOperations.bootSettings.tpmRequiredPolicy')" |
| 30 | > |
| 31 | <b-form-text id="tpm-required-policy-help-block"> |
| 32 | {{ |
| 33 | $t('pageServerPowerOperations.bootSettings.tpmRequiredPolicyHelper') |
| 34 | }} |
| 35 | </b-form-text> |
| 36 | <b-form-checkbox |
| 37 | id="tpm-required-policy" |
| 38 | v-model="form.tpmPolicyOn" |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 39 | aria-describedby="tpm-required-policy-help-block" |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 40 | @change="v$.form.tpmPolicyOn.$touch()" |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 41 | > |
SurenNeware | f295d1b | 2020-08-26 14:50:56 +0530 | [diff] [blame] | 42 | {{ $t('global.status.enabled') }} |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 43 | </b-form-checkbox> |
| 44 | </b-form-group> |
Aravinth S | 99fe228 | 2025-08-20 15:08:17 +0530 | [diff] [blame^] | 45 | <b-button |
| 46 | variant="primary" |
| 47 | type="submit" |
| 48 | class="mb-3" |
| 49 | :disabled="isButtonDisable" |
| 50 | > |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 51 | {{ $t('global.action.save') }} |
| 52 | </b-button> |
| 53 | </b-form> |
| 54 | </div> |
| 55 | </template> |
| 56 | |
| 57 | <script> |
| 58 | import { mapState } from 'vuex'; |
SurenNeware | f295d1b | 2020-08-26 14:50:56 +0530 | [diff] [blame] | 59 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 60 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 61 | import { useI18n } from 'vue-i18n'; |
Surya Venkatesan | 1a814b9 | 2024-09-23 16:29:01 +0530 | [diff] [blame] | 62 | import { useVuelidate } from '@vuelidate/core'; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 63 | |
| 64 | export default { |
| 65 | name: 'BootSettings', |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 66 | mixins: [BVToastMixin, LoadingBarMixin], |
Aravinth S | 99fe228 | 2025-08-20 15:08:17 +0530 | [diff] [blame^] | 67 | props: { |
| 68 | isButtonDisable: { |
| 69 | required: true, |
| 70 | type: Boolean, |
| 71 | default: false, |
| 72 | }, |
| 73 | }, |
Surya Venkatesan | 1a814b9 | 2024-09-23 16:29:01 +0530 | [diff] [blame] | 74 | setup() { |
| 75 | return { |
| 76 | v$: useVuelidate(), |
| 77 | }; |
| 78 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 79 | data() { |
| 80 | return { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 81 | $t: useI18n().t, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 82 | form: { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 83 | bootOption: this.$store.getters['serverBootSettings/bootSource'], |
| 84 | oneTimeBoot: this.$store.getters['serverBootSettings/overrideEnabled'], |
| 85 | tpmPolicyOn: this.$store.getters['serverBootSettings/tpmEnabled'], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 86 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 87 | }; |
| 88 | }, |
| 89 | computed: { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 90 | ...mapState('serverBootSettings', [ |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 91 | 'bootSourceOptions', |
| 92 | 'bootSource', |
| 93 | 'overrideEnabled', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 94 | 'tpmEnabled', |
| 95 | ]), |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 96 | }, |
| 97 | watch: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 98 | bootSource: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 99 | this.form.bootOption = value; |
| 100 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 101 | overrideEnabled: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 102 | this.form.oneTimeBoot = value; |
| 103 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 104 | tpmEnabled: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 105 | this.form.tpmPolicyOn = value; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 106 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 107 | }, |
| 108 | validations: { |
| 109 | // Empty validations to leverage vuelidate form states |
| 110 | // to check for changed values |
| 111 | form: { |
| 112 | bootOption: {}, |
| 113 | oneTimeBoot: {}, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 114 | tpmPolicyOn: {}, |
| 115 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 116 | }, |
| 117 | created() { |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 118 | this.$store |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 119 | .dispatch('serverBootSettings/getTpmPolicy') |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 120 | .finally(() => |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 121 | this.$root.$emit('server-power-operations-boot-settings-complete'), |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 122 | ); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 123 | }, |
| 124 | methods: { |
| 125 | handleSubmit() { |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 126 | this.startLoader(); |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 127 | const tpmPolicyChanged = this.v$.form.tpmPolicyOn.$dirty; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 128 | let settings; |
Lei YU | e6807a4 | 2021-06-29 09:13:22 +0800 | [diff] [blame] | 129 | let bootSource = this.form.bootOption; |
| 130 | let overrideEnabled = this.form.oneTimeBoot; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 131 | let tpmEnabled = null; |
| 132 | |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 133 | if (tpmPolicyChanged) tpmEnabled = this.form.tpmPolicyOn; |
| 134 | settings = { bootSource, overrideEnabled, tpmEnabled }; |
| 135 | |
| 136 | this.$store |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 137 | .dispatch('serverBootSettings/saveSettings', settings) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 138 | .then((message) => this.successToast(message)) |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 139 | .catch(({ message }) => this.errorToast(message)) |
| 140 | .finally(() => { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 141 | this.v$.form.$reset(); |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 142 | this.endLoader(); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 143 | }); |
| 144 | }, |
| 145 | onChangeSelect(selectedOption) { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 146 | this.v$.form.bootOption.$touch(); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 147 | // Disable one time boot if selected boot option is 'None' |
| 148 | if (selectedOption === 'None') this.form.oneTimeBoot = false; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 149 | }, |
| 150 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 151 | }; |
| 152 | </script> |