Skip to content

Commit 2d32b55

Browse files
Sandeepa Singhrfrandse
authored andcommitted
Deconfig-Toggles (#110)
* Deconfig-Toggles * Updated some translation keys
1 parent e692e00 commit 2d32b55

File tree

4 files changed

+115
-15
lines changed

4 files changed

+115
-15
lines changed

src/store/modules/Settings/HardwareDeconfigurationStore.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import api from '@/store/api';
2+
import i18n from '@/i18n';
23

34
const HardwareDeconfigurationStore = {
45
namespaced: true,
@@ -59,6 +60,8 @@ const HardwareDeconfigurationStore = {
5960
id: data.Id,
6061
location: locationCode,
6162
functionalState: data.Status?.Health,
63+
settings: data.Enabled,
64+
uri: data['@odata.id'],
6265
};
6366
});
6467
return coreData;
@@ -87,12 +90,52 @@ const HardwareDeconfigurationStore = {
8790
size: data.CapacityMiB,
8891
locationCode: data.Location?.PartLocation?.ServiceLabel,
8992
deconfigurationType: data.Status?.Conditions?.MessageArgs[0],
93+
settings: data.Enabled,
94+
uri: data['@odata.id'],
9095
};
9196
});
9297
commit('setDimms', dimmsData);
9398
})
9499
);
95100
},
101+
async updateSettingsState({ dispatch }, settingsState) {
102+
const uri = settingsState.uri;
103+
const updatedSettingsValue = {
104+
Enabled: settingsState.settings,
105+
};
106+
return await api.patch(uri, updatedSettingsValue).catch((error) => {
107+
dispatch('getDimms');
108+
console.log('error', error);
109+
if (settingsState.settings) {
110+
throw new Error(
111+
i18n.t('pageHardwareDeconfiguration.toast.errorEnablingSetting')
112+
);
113+
} else {
114+
throw new Error(
115+
i18n.t('pageHardwareDeconfiguration.toast.errorDisablingSetting')
116+
);
117+
}
118+
});
119+
},
120+
async updateCoresSettingsState({ dispatch }, settingsState) {
121+
const uri = settingsState.uri;
122+
const updatedSettingsValue = {
123+
Enabled: settingsState.settings,
124+
};
125+
return await api.patch(uri, updatedSettingsValue).catch((error) => {
126+
dispatch('getProcessors');
127+
console.log('error', error);
128+
if (settingsState.settings) {
129+
throw new Error(
130+
i18n.t('pageHardwareDeconfiguration.toast.errorEnablingSetting')
131+
);
132+
} else {
133+
throw new Error(
134+
i18n.t('pageHardwareDeconfiguration.toast.errorDisablingSetting')
135+
);
136+
}
137+
});
138+
},
96139
},
97140
};
98141

src/views/Settings/HardwareDeconfiguration/HardwareDeconfiguration.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<b-container fluid="xl">
3-
<page-title :description="$t('pageDeconfigurationHardware.description')" />
3+
<page-title :description="$t('pageHardwareDeconfiguration.description')" />
44
<page-section>
55
<b-row>
66
<b-col>
77
<b-card no-body>
88
<b-tabs content-class="mt-3" fill>
9-
<b-tab :title="$t('pageDeconfigurationHardware.memoryDimms')"
9+
<b-tab :title="$t('pageHardwareDeconfiguration.memoryDimms')"
1010
><memory-dimms
1111
/></b-tab>
12-
<b-tab :title="$t('pageDeconfigurationHardware.processorCores')"
12+
<b-tab :title="$t('pageHardwareDeconfiguration.processorCores')"
1313
><processor-cores
1414
/></b-tab>
1515
</b-tabs>

src/views/Settings/HardwareDeconfiguration/MemoryDimms.vue

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,25 @@
2626
:empty-filtered-text="$t('global.table.emptySearchMessage')"
2727
:busy="isBusy"
2828
@filtered="onFiltered"
29-
@row-selected="onRowSelected($event, filteredDimms.length)"
3029
>
3130
<template #cell(functionalState)="{ value }">
3231
<status-icon :status="statusIcon(value)" /> {{ value }}
3332
</template>
33+
<template #cell(settings)="row">
34+
<b-form-checkbox
35+
v-model="row.item.settings"
36+
name="switch"
37+
switch
38+
@change="toggleSettingsSwitch(row)"
39+
>
40+
<span v-if="row.item.settings">
41+
{{ $t('pageHardwareDeconfiguration.configured') }}
42+
</span>
43+
<span v-else>{{
44+
$t('pageHardwareDeconfiguration.deconfigured')
45+
}}</span>
46+
</b-form-checkbox>
47+
</template>
3448
</b-table>
3549
</b-col>
3650
</b-row>
@@ -66,6 +80,7 @@
6680
<script>
6781
import StatusIcon from '@/components/Global/StatusIcon';
6882
import TableFilter from '@/components/Global/TableFilter';
83+
import BVToastMixin from '@/components/Mixins/BVToastMixin';
6984
import BVPaginationMixin, {
7085
currentPage,
7186
perPage,
@@ -97,6 +112,7 @@ export default {
97112
DataFormatterMixin,
98113
TableSortMixin,
99114
SearchFilterMixin,
115+
BVToastMixin,
100116
],
101117
beforeRouteLeave(to, from, next) {
102118
this.hideLoader();
@@ -110,37 +126,42 @@ export default {
110126
{
111127
key: 'id',
112128
sortable: true,
113-
label: this.$t('pageDeconfigurationHardware.table.id'),
129+
label: this.$t('pageHardwareDeconfiguration.table.id'),
114130
},
115131
{
116132
key: 'location',
117133
formatter: this.dataFormatter,
118-
label: this.$t('pageDeconfigurationHardware.table.size'),
134+
label: this.$t('pageHardwareDeconfiguration.table.size'),
119135
},
120136
{
121137
key: 'locationCode',
122138
formatter: this.dataFormatter,
123-
label: this.$t('pageDeconfigurationHardware.table.locationCode'),
139+
label: this.$t('pageHardwareDeconfiguration.table.locationCode'),
124140
},
125141
{
126142
key: 'functionalState',
127143
sortable: false,
128-
label: this.$t('pageDeconfigurationHardware.table.functionalState'),
144+
label: this.$t('pageHardwareDeconfiguration.table.functionalState'),
129145
tdClass: 'text-nowrap',
130146
},
131147
{
132148
key: 'deconfigurationType',
133149
formatter: this.dataFormatter,
134150
label: this.$t(
135-
'pageDeconfigurationHardware.table.deconfigurationType'
151+
'pageHardwareDeconfiguration.table.deconfigurationType'
136152
),
137153
},
154+
{
155+
key: 'settings',
156+
formatter: this.dataFormatter,
157+
label: this.$t('pageHardwareDeconfiguration.table.settings'),
158+
},
138159
],
139160
tableFilters: [
140161
{
141162
key: 'deconfigurationType',
142163
label: this.$t(
143-
'pageDeconfigurationHardware.table.deconfigurationType'
164+
'pageHardwareDeconfiguration.table.deconfigurationType'
144165
),
145166
values: [
146167
'By Association',
@@ -193,6 +214,14 @@ export default {
193214
onFiltered(filteredItems) {
194215
this.searchTotalFilteredRows = filteredItems.length;
195216
},
217+
toggleSettingsSwitch(row) {
218+
this.$store
219+
.dispatch('hardwareDeconfiguration/updateSettingsState', {
220+
uri: row.item.uri,
221+
settings: row.item.settings,
222+
})
223+
.catch(({ message }) => this.errorToast(message));
224+
},
196225
},
197226
};
198227
</script>

src/views/Settings/HardwareDeconfiguration/ProcessorCores.vue

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343
<template #cell(functionalState)="{ value }">
4444
<status-icon :status="statusIcon(value)" /> {{ value }}
4545
</template>
46+
<template #cell(settings)="row">
47+
<b-form-checkbox
48+
v-model="row.item.settings"
49+
name="switch"
50+
switch
51+
@change="toggleSettingsSwitch(row)"
52+
>
53+
<span v-if="row.item.settings">
54+
{{ $t('pageHardwareDeconfiguration.configured') }}
55+
</span>
56+
<span v-else>{{
57+
$t('pageHardwareDeconfiguration.deconfigured')
58+
}}</span>
59+
</b-form-checkbox>
60+
</template>
4661
</b-table>
4762
</b-col>
4863
</b-row>
@@ -125,32 +140,37 @@ export default {
125140
{
126141
key: 'id',
127142
sortable: true,
128-
label: this.$t('pageDeconfigurationHardware.table.id'),
143+
label: this.$t('pageHardwareDeconfiguration.table.id'),
129144
},
130145
{
131146
key: 'location',
132147
formatter: this.dataFormatter,
133-
label: this.$t('pageDeconfigurationHardware.table.locationCode'),
148+
label: this.$t('pageHardwareDeconfiguration.table.locationCode'),
134149
},
135150
{
136151
key: 'functionalState',
137152
sortable: false,
138-
label: this.$t('pageDeconfigurationHardware.table.functionalState'),
153+
label: this.$t('pageHardwareDeconfiguration.table.functionalState'),
139154
tdClass: 'text-nowrap',
140155
},
141156
{
142157
key: 'deconfigurationType',
143158
formatter: this.dataFormatter,
144159
label: this.$t(
145-
'pageDeconfigurationHardware.table.deconfigurationType'
160+
'pageHardwareDeconfiguration.table.deconfigurationType'
146161
),
147162
},
163+
{
164+
key: 'settings',
165+
formatter: this.dataFormatter,
166+
label: this.$t('pageHardwareDeconfiguration.table.settings'),
167+
},
148168
],
149169
tableFilters: [
150170
{
151171
key: 'deconfigurationType',
152172
label: this.$t(
153-
'pageDeconfigurationHardware.table.deconfigurationType'
173+
'pageHardwareDeconfiguration.table.deconfigurationType'
154174
),
155175
values: [
156176
'By Association',
@@ -205,6 +225,14 @@ export default {
205225
onFiltered(filteredItems) {
206226
this.searchTotalFilteredRows = filteredItems.length;
207227
},
228+
toggleSettingsSwitch(row) {
229+
this.$store
230+
.dispatch('hardwareDeconfiguration/updateCoresSettingsState', {
231+
uri: row.item.uri,
232+
settings: row.item.settings,
233+
})
234+
.catch(({ message }) => this.errorToast(message));
235+
},
208236
},
209237
};
210238
</script>

0 commit comments

Comments
 (0)