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> |
Dixsie Wolmers | 4d1dbb5 | 2020-08-24 21:43:25 -0500 | [diff] [blame] | 45 | <b-button variant="primary" type="submit" class="mb-3"> |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 46 | {{ $t('global.action.save') }} |
| 47 | </b-button> |
| 48 | </b-form> |
| 49 | </div> |
| 50 | </template> |
| 51 | |
| 52 | <script> |
| 53 | import { mapState } from 'vuex'; |
SurenNeware | f295d1b | 2020-08-26 14:50:56 +0530 | [diff] [blame] | 54 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 55 | import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin'; |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 56 | import { useI18n } from 'vue-i18n'; |
Surya Venkatesan | 1a814b9 | 2024-09-23 16:29:01 +0530 | [diff] [blame] | 57 | import { useVuelidate } from '@vuelidate/core'; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 58 | |
| 59 | export default { |
| 60 | name: 'BootSettings', |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 61 | mixins: [BVToastMixin, LoadingBarMixin], |
Surya Venkatesan | 1a814b9 | 2024-09-23 16:29:01 +0530 | [diff] [blame] | 62 | setup() { |
| 63 | return { |
| 64 | v$: useVuelidate(), |
| 65 | }; |
| 66 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 67 | data() { |
| 68 | return { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 69 | $t: useI18n().t, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 70 | form: { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 71 | bootOption: this.$store.getters['serverBootSettings/bootSource'], |
| 72 | oneTimeBoot: this.$store.getters['serverBootSettings/overrideEnabled'], |
| 73 | tpmPolicyOn: this.$store.getters['serverBootSettings/tpmEnabled'], |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 74 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 75 | }; |
| 76 | }, |
| 77 | computed: { |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 78 | ...mapState('serverBootSettings', [ |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 79 | 'bootSourceOptions', |
| 80 | 'bootSource', |
| 81 | 'overrideEnabled', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 82 | 'tpmEnabled', |
| 83 | ]), |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 84 | }, |
| 85 | watch: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 86 | bootSource: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 87 | this.form.bootOption = value; |
| 88 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 89 | overrideEnabled: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 90 | this.form.oneTimeBoot = value; |
| 91 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 92 | tpmEnabled: function (value) { |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 93 | this.form.tpmPolicyOn = value; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 94 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 95 | }, |
| 96 | validations: { |
| 97 | // Empty validations to leverage vuelidate form states |
| 98 | // to check for changed values |
| 99 | form: { |
| 100 | bootOption: {}, |
| 101 | oneTimeBoot: {}, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 102 | tpmPolicyOn: {}, |
| 103 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 104 | }, |
| 105 | created() { |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 106 | this.$store |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 107 | .dispatch('serverBootSettings/getTpmPolicy') |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 108 | .finally(() => |
Ed Tanous | 8132399 | 2024-02-27 11:26:24 -0800 | [diff] [blame] | 109 | this.$root.$emit('server-power-operations-boot-settings-complete'), |
Sukanya Pandey | 7f6edb6 | 2021-03-30 19:49:08 +0530 | [diff] [blame] | 110 | ); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 111 | }, |
| 112 | methods: { |
| 113 | handleSubmit() { |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 114 | this.startLoader(); |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 115 | const tpmPolicyChanged = this.v$.form.tpmPolicyOn.$dirty; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 116 | let settings; |
Lei YU | e6807a4 | 2021-06-29 09:13:22 +0800 | [diff] [blame] | 117 | let bootSource = this.form.bootOption; |
| 118 | let overrideEnabled = this.form.oneTimeBoot; |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 119 | let tpmEnabled = null; |
| 120 | |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 121 | if (tpmPolicyChanged) tpmEnabled = this.form.tpmPolicyOn; |
| 122 | settings = { bootSource, overrideEnabled, tpmEnabled }; |
| 123 | |
| 124 | this.$store |
Derick Montague | 71114fe | 2021-05-06 18:17:34 -0500 | [diff] [blame] | 125 | .dispatch('serverBootSettings/saveSettings', settings) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 126 | .then((message) => this.successToast(message)) |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 127 | .catch(({ message }) => this.errorToast(message)) |
| 128 | .finally(() => { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 129 | this.v$.form.$reset(); |
Yoshie Muranaka | 5c97797 | 2020-04-30 09:48:23 -0700 | [diff] [blame] | 130 | this.endLoader(); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 131 | }); |
| 132 | }, |
| 133 | onChangeSelect(selectedOption) { |
Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 134 | this.v$.form.bootOption.$touch(); |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 135 | // Disable one time boot if selected boot option is 'None' |
| 136 | if (selectedOption === 'None') this.form.oneTimeBoot = false; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 137 | }, |
| 138 | }, |
Yoshie Muranaka | c05ff64 | 2020-02-26 14:23:15 -0800 | [diff] [blame] | 139 | }; |
| 140 | </script> |