Re-modeled Power restore radio buttons
When a user selects a radio button and saves, the selected setting should be patched.
- Computed properties on generated bootstrap-vue radio buttons causes errors.
- Re-modeled radio buttons to take Redfish api data on component render.
- Mapped selected radio button value to patch the Redfish api property.
- Added translations.
Signed-off-by: Kenneth Fullbright <kennyneedsmilky@gmail.com>
Change-Id: I22ce75d9ef840d7f0c2659bba855093e5b4559f4
diff --git a/src/views/Settings/PowerRestorePolicy/PowerRestorePolicy.vue b/src/views/Settings/PowerRestorePolicy/PowerRestorePolicy.vue
index 8589aed..06e30f3 100644
--- a/src/views/Settings/PowerRestorePolicy/PowerRestorePolicy.vue
+++ b/src/views/Settings/PowerRestorePolicy/PowerRestorePolicy.vue
@@ -5,15 +5,11 @@
<b-row>
<b-col sm="8" md="6" xl="12">
<b-form-group :label="$t('pagePowerRestorePolicy.powerPoliciesLabel')">
- <b-form-radio
- v-for="policy in powerRestorePolicies"
- :key="policy.state"
+ <b-form-radio-group
v-model="currentPowerRestorePolicy"
- :value="policy.state"
+ :options="options"
name="power-restore-policy"
- >
- {{ policy.desc }}
- </b-form-radio>
+ ></b-form-radio-group>
</b-form-group>
</b-col>
</b-row>
@@ -41,6 +37,7 @@
data() {
return {
policyValue: null,
+ options: [],
};
},
computed: {
@@ -58,12 +55,24 @@
},
created() {
this.startLoader();
- Promise.all([
- this.$store.dispatch('powerPolicy/getPowerRestorePolicies'),
- this.$store.dispatch('powerPolicy/getPowerRestoreCurrentPolicy'),
- ]).finally(() => this.endLoader());
+ this.renderPowerRestoreSettings();
},
methods: {
+ renderPowerRestoreSettings() {
+ Promise.all([
+ this.$store.dispatch('powerPolicy/getPowerRestorePolicies'),
+ this.$store.dispatch('powerPolicy/getPowerRestoreCurrentPolicy'),
+ ]).finally(() => {
+ this.options.length = 0;
+ this.powerRestorePolicies.map((item) => {
+ this.options.push({
+ text: this.$t(`pagePowerRestorePolicy.policiesDesc.${item.state}`),
+ value: `${item.state}`,
+ });
+ });
+ this.endLoader();
+ });
+ },
submitForm() {
this.startLoader();
this.$store
@@ -73,7 +82,9 @@
)
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message))
- .finally(() => this.endLoader());
+ .finally(() => {
+ this.renderPowerRestoreSettings();
+ });
},
},
};