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