blob: 7fbd6bc4127240c238506d85480a2449773f444d [file] [log] [blame]
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07001import api from '@/store/api';
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +05302import i18n from '@/i18n';
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07003
4const SystemStore = {
5 namespaced: true,
6 state: {
Derick Montague602e98a2020-10-21 16:20:00 -05007 systems: [],
Yoshie Muranaka56ee7692020-05-28 13:28:29 -07008 },
9 getters: {
Derick Montague602e98a2020-10-21 16:20:00 -050010 systems: (state) => state.systems,
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070011 },
12 mutations: {
13 setSystemInfo: (state, data) => {
14 const system = {};
15 system.assetTag = data.AssetTag;
16 system.description = data.Description;
Yoshie Muranakac687f102020-06-02 12:01:27 -070017 system.firmwareVersion = data.BiosVersion;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053018 system.hardwareType = data.Name;
Sukanya Pandey05388962021-06-10 15:35:21 +053019 system.health = data.Status?.Health;
Nikhil Ashoka18cde3c2022-01-05 22:21:24 +053020 system.totalSystemMemoryGiB = data.MemorySummary?.TotalSystemMemoryGiB;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070021 system.id = data.Id;
SurenNewarebbf896c2021-01-27 21:50:22 +053022 system.locationIndicatorActive = data.LocationIndicatorActive;
Sneha Patel9f612342021-09-02 12:23:42 -050023 system.locationNumber = data.Location?.PartLocation?.ServiceLabel;
Yoshie Muranakac687f102020-06-02 12:01:27 -070024 system.manufacturer = data.Manufacturer;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070025 system.model = data.Model;
Sukanya Pandey05388962021-06-10 15:35:21 +053026 system.processorSummaryCount = data.ProcessorSummary?.Count;
Nikhil Ashoka18cde3c2022-01-05 22:21:24 +053027 system.processorSummaryCoreCount = data.ProcessorSummary?.CoreCount;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070028 system.powerState = data.PowerState;
29 system.serialNumber = data.SerialNumber;
Tan Siewert223fe5b2025-01-17 19:47:28 +010030 system.serialConsoleEnabled = data.SerialConsole.ServiceEnabled;
31 system.serialConsoleMaxSessions =
32 data.SerialConsole.MaxConcurrentSessions;
Sukanya Pandey05388962021-06-10 15:35:21 +053033 system.healthRollup = data.Status?.HealthRollup;
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053034 system.subModel = data.SubModel;
Sukanya Pandey05388962021-06-10 15:35:21 +053035 system.statusState = data.Status?.State;
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070036 system.systemType = data.SystemType;
37 state.systems = [system];
Derick Montague602e98a2020-10-21 16:20:00 -050038 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070039 },
40 actions: {
41 async getSystem({ commit }) {
42 return await api
Sean Zhang8841b7d2024-06-15 08:42:41 +030043 .get(`${await this.dispatch('global/getSystemPath')}`)
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070044 .then(({ data }) => commit('setSystemInfo', data))
Derick Montague602e98a2020-10-21 16:20:00 -050045 .catch((error) => console.log(error));
46 },
Sukanya Pandey05388962021-06-10 15:35:21 +053047 async changeIdentifyLedState({ commit }, ledState) {
48 return await api
Sean Zhang8841b7d2024-06-15 08:42:41 +030049 .patch(`${await this.dispatch('global/getSystemPath')}`, {
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053050 LocationIndicatorActive: ledState,
51 })
Nikhil Ashokaf11a1902024-05-09 15:17:44 +053052 .then(() => {
53 if (ledState) {
Surya Vde23ea22024-07-11 15:19:46 +053054 return i18n.global.t(
55 'pageInventory.toast.successEnableIdentifyLed',
56 );
Nikhil Ashokaf11a1902024-05-09 15:17:44 +053057 } else {
Surya Vde23ea22024-07-11 15:19:46 +053058 return i18n.global.t(
59 'pageInventory.toast.successDisableIdentifyLed',
60 );
Nikhil Ashokaf11a1902024-05-09 15:17:44 +053061 }
62 })
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053063 .catch((error) => {
Sukanya Pandey05388962021-06-10 15:35:21 +053064 commit('setSystemInfo', this.state.system.systems[0]);
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053065 console.log('error', error);
66 if (ledState) {
67 throw new Error(
Surya Vde23ea22024-07-11 15:19:46 +053068 i18n.global.t('pageInventory.toast.errorEnableIdentifyLed'),
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053069 );
70 } else {
71 throw new Error(
Surya Vde23ea22024-07-11 15:19:46 +053072 i18n.global.t('pageInventory.toast.errorDisableIdentifyLed'),
Sukanya Pandeyeb4cef32021-04-09 15:40:27 +053073 );
74 }
75 });
76 },
Derick Montague602e98a2020-10-21 16:20:00 -050077 },
Yoshie Muranaka56ee7692020-05-28 13:28:29 -070078};
79
80export default SystemStore;