Skip to content

Commit

Permalink
Added toast notification for identify LEDs
Browse files Browse the repository at this point in the history
- Added success toast notification messages for identify
  LEDs present at Inventory and LEDs page and Overview.

- Import of Toast was not present in Overview's Inventory
  card and DIMM slot table, fixed it.

Signed-off-by: Nikhil Ashoka <a.nikhil@ibm.com>
Change-Id: If9ad84e66f6f15616cb8af51b1e84d8d06b1afd0
  • Loading branch information
Nikhil-Ashoka authored and sivaprabug committed May 21, 2024
1 parent 0736813 commit f11a190
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 36 deletions.
4 changes: 3 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@
},
"toast": {
"errorDisableIdentifyLed": "Error disabling Identify LED.",
"errorEnableIdentifyLed": "Error enabling Identify LED."
"errorEnableIdentifyLed": "Error enabling Identify LED.",
"successDisableIdentifyLed": "Successfully disabled Identify LED.",
"successEnableIdentifyLed": "Successfully enabled Identify LED."
}
},
"pageKeyClear": {
Expand Down
33 changes: 22 additions & 11 deletions src/store/modules/HardwareStatus/AssemblyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,28 @@ const AssemblyStore = {
],
};

return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
dispatch('getAssemblyInfo');
console.log('error', error);
if (led.identifyLed) {
throw new Error(i18n.t('pageInventory.toast.errorEnableIdentifyLed'));
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
return await api
.patch(uri, updatedIdentifyLedValue)
.then(() => {
if (led.identifyLed) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
dispatch('getAssemblyInfo');
console.log('error', error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageInventory.toast.errorEnableIdentifyLed'),
);
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
},
},
};
Expand Down
9 changes: 8 additions & 1 deletion src/store/modules/HardwareStatus/BmcStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ const BmcStore = {
};
return await api
.patch(uri, updatedIdentifyLedValue)
.then(() => dispatch('getBmcInfo'))
.then(() => {
dispatch('getBmcInfo');
if (led.identifyLed) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
dispatch('getBmcInfo');
console.log('error', error);
Expand Down
9 changes: 8 additions & 1 deletion src/store/modules/HardwareStatus/ChassisStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ const ChassisStore = {
};
return await api
.patch(uri, updatedIdentifyLedValue)
.then(() => dispatch('getChassisInfo'))
.then(() => {
dispatch('getChassisInfo');
if (led.identifyLed) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
dispatch('getChassisInfo');
console.log('error', error);
Expand Down
33 changes: 22 additions & 11 deletions src/store/modules/HardwareStatus/MemoryStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,28 @@ const MemoryStore = {
const updatedIdentifyLedValue = {
LocationIndicatorActive: led.identifyLed,
};
return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
dispatch('getDimms');
console.log('error', error);
if (led.identifyLed) {
throw new Error(i18n.t('pageInventory.toast.errorEnableIdentifyLed'));
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
return await api
.patch(uri, updatedIdentifyLedValue)
.then(() => {
if (led.identifyLed) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
dispatch('getDimms');
console.log('error', error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageInventory.toast.errorEnableIdentifyLed'),
);
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
},
},
};
Expand Down
33 changes: 22 additions & 11 deletions src/store/modules/HardwareStatus/ProcessorStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,28 @@ const ProcessorStore = {
const updatedIdentifyLedValue = {
LocationIndicatorActive: led.identifyLed,
};
return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
dispatch('getProcessorsInfo');
console.log('error', error);
if (led.identifyLed) {
throw new Error(i18n.t('pageInventory.toast.errorEnableIdentifyLed'));
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
return await api
.patch(uri, updatedIdentifyLedValue)
.then(() => {
if (led.identifyLed) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
dispatch('getProcessorsInfo');
console.log('error', error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageInventory.toast.errorEnableIdentifyLed'),
);
} else {
throw new Error(
i18n.t('pageInventory.toast.errorDisableIdentifyLed'),
);
}
});
},
},
};
Expand Down
7 changes: 7 additions & 0 deletions src/store/modules/HardwareStatus/SystemStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ const SystemStore = {
.patch('/redfish/v1/Systems/system', {
LocationIndicatorActive: ledState,
})
.then(() => {
if (ledState) {
return i18n.t('pageInventory.toast.successEnableIdentifyLed');
} else {
return i18n.t('pageInventory.toast.successDisableIdentifyLed');
}
})
.catch((error) => {
commit('setSystemInfo', this.state.system.systems[0]);
console.log('error', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default {
toggleIdentifyLedSwitch(state) {
this.$store
.dispatch('system/changeIdentifyLedState', state)
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default {
memberId: row.id,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
hasIdentifyLed(identifyLed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
// TO DO: remove hasIdentifyLed method once the following story is merged:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
// TO DO: Remove this method when the LocationIndicatorActive is added from backend.
Expand Down
3 changes: 3 additions & 0 deletions src/views/HardwareStatus/Inventory/InventoryTableDimmSlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
import StatusIcon from '@/components/Global/StatusIcon';
import TableCellCount from '@/components/Global/TableCellCount';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
import TableSortMixin from '@/components/Mixins/TableSortMixin';
import Search from '@/components/Global/Search';
Expand All @@ -206,6 +207,7 @@ import TableRowExpandMixin, {
export default {
components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
mixins: [
BVToastMixin,
TableRowExpandMixin,
DataFormatterMixin,
TableSortMixin,
Expand Down Expand Up @@ -287,6 +289,7 @@ export default {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
hasIdentifyLed(identifyLed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export default {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
// TO DO: remove hasIdentifyLed when the following is merged:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export default {
toggleIdentifyLedSwitch(state) {
this.$store
.dispatch('system/changeIdentifyLedState', state)
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/views/Overview/OverviewInventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@

<script>
import OverviewCard from './OverviewCard';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
export default {
name: 'Inventory',
components: {
OverviewCard,
},
mixins: [BVToastMixin],
computed: {
systems() {
let systemData = this.$store.getters['system/systems'][0];
Expand All @@ -50,6 +52,7 @@ export default {
toggleIdentifyLedSwitch(state) {
this.$store
.dispatch('system/changeIdentifyLedState', state)
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
},
Expand Down

0 comments on commit f11a190

Please sign in to comment.