17affc529SSandeepa Singhimport api from '@/store/api'; 27affc529SSandeepa Singhimport i18n from '@/i18n'; 37affc529SSandeepa Singh 47affc529SSandeepa Singhconst ProcessorStore = { 57affc529SSandeepa Singh namespaced: true, 67affc529SSandeepa Singh state: { 77affc529SSandeepa Singh processors: [], 87affc529SSandeepa Singh }, 97affc529SSandeepa Singh getters: { 107affc529SSandeepa Singh processors: (state) => state.processors, 117affc529SSandeepa Singh }, 127affc529SSandeepa Singh mutations: { 137affc529SSandeepa Singh setProcessorsInfo: (state, data) => { 147affc529SSandeepa Singh state.processors = data.map((processor) => { 157affc529SSandeepa Singh const { 167affc529SSandeepa Singh Id, 177affc529SSandeepa Singh Status = {}, 187affc529SSandeepa Singh PartNumber, 197affc529SSandeepa Singh SerialNumber, 207affc529SSandeepa Singh SparePartNumber, 217affc529SSandeepa Singh InstructionSet, 227affc529SSandeepa Singh Manufacturer, 237affc529SSandeepa Singh Model, 247affc529SSandeepa Singh Name, 257affc529SSandeepa Singh ProcessorArchitecture, 267affc529SSandeepa Singh ProcessorType, 277affc529SSandeepa Singh Version, 287affc529SSandeepa Singh AssetTag, 297affc529SSandeepa Singh MinSpeedMHz, 307affc529SSandeepa Singh MaxSpeedMHz, 317affc529SSandeepa Singh TotalCores, 327affc529SSandeepa Singh TotalThreads, 339f61234aSSneha Patel Location, 347affc529SSandeepa Singh LocationIndicatorActive, 357affc529SSandeepa Singh } = processor; 367affc529SSandeepa Singh return { 377affc529SSandeepa Singh id: Id, 387affc529SSandeepa Singh health: Status.Health, 397affc529SSandeepa Singh healthRollup: Status.HealthRollup, 407affc529SSandeepa Singh partNumber: PartNumber, 417affc529SSandeepa Singh sparePartNumber: SparePartNumber, 427affc529SSandeepa Singh serialNumber: SerialNumber, 437affc529SSandeepa Singh statusState: Status.State, 447affc529SSandeepa Singh instructionSet: InstructionSet, 457affc529SSandeepa Singh manufacturer: Manufacturer, 467affc529SSandeepa Singh model: Model, 477affc529SSandeepa Singh name: Name, 487affc529SSandeepa Singh processorArchitecture: ProcessorArchitecture, 497affc529SSandeepa Singh processorType: ProcessorType, 507affc529SSandeepa Singh version: Version, 517affc529SSandeepa Singh assetTag: AssetTag, 527affc529SSandeepa Singh minSpeedMHz: MinSpeedMHz, 537affc529SSandeepa Singh maxSpeedMHz: MaxSpeedMHz, 547affc529SSandeepa Singh totalCores: TotalCores, 557affc529SSandeepa Singh totalThreads: TotalThreads, 569f61234aSSneha Patel locationNumber: Location?.PartLocation?.ServiceLabel, 577affc529SSandeepa Singh identifyLed: LocationIndicatorActive, 587affc529SSandeepa Singh uri: processor['@odata.id'], 597affc529SSandeepa Singh }; 607affc529SSandeepa Singh }); 617affc529SSandeepa Singh }, 627affc529SSandeepa Singh }, 637affc529SSandeepa Singh actions: { 647affc529SSandeepa Singh async getProcessorsInfo({ commit }) { 657affc529SSandeepa Singh return await api 66*8841b7d4SSean Zhang .get(`${await this.dispatch('global/getSystemPath')}/Processors`) 677affc529SSandeepa Singh .then(({ data: { Members = [] } }) => 688132399cSEd Tanous Members.map((member) => api.get(member['@odata.id'])), 697affc529SSandeepa Singh ) 707affc529SSandeepa Singh .then((promises) => api.all(promises)) 717affc529SSandeepa Singh .then((response) => { 727affc529SSandeepa Singh const data = response.map(({ data }) => data); 737affc529SSandeepa Singh commit('setProcessorsInfo', data); 747affc529SSandeepa Singh }) 757affc529SSandeepa Singh .catch((error) => console.log(error)); 767affc529SSandeepa Singh }, 777affc529SSandeepa Singh // Waiting for the following to be merged to test the Identify Led: 787affc529SSandeepa Singh // https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/37045 797affc529SSandeepa Singh async updateIdentifyLedValue({ dispatch }, led) { 807affc529SSandeepa Singh const uri = led.uri; 817affc529SSandeepa Singh const updatedIdentifyLedValue = { 827affc529SSandeepa Singh LocationIndicatorActive: led.identifyLed, 837affc529SSandeepa Singh }; 84f11a1901SNikhil Ashoka return await api 85f11a1901SNikhil Ashoka .patch(uri, updatedIdentifyLedValue) 86f11a1901SNikhil Ashoka .then(() => { 87f11a1901SNikhil Ashoka if (led.identifyLed) { 88f11a1901SNikhil Ashoka return i18n.t('pageInventory.toast.successEnableIdentifyLed'); 89f11a1901SNikhil Ashoka } else { 90f11a1901SNikhil Ashoka return i18n.t('pageInventory.toast.successDisableIdentifyLed'); 91f11a1901SNikhil Ashoka } 92f11a1901SNikhil Ashoka }) 93f11a1901SNikhil Ashoka .catch((error) => { 947affc529SSandeepa Singh dispatch('getProcessorsInfo'); 957affc529SSandeepa Singh console.log('error', error); 967affc529SSandeepa Singh if (led.identifyLed) { 97f11a1901SNikhil Ashoka throw new Error( 98f11a1901SNikhil Ashoka i18n.t('pageInventory.toast.errorEnableIdentifyLed'), 99f11a1901SNikhil Ashoka ); 1007affc529SSandeepa Singh } else { 1017affc529SSandeepa Singh throw new Error( 1028132399cSEd Tanous i18n.t('pageInventory.toast.errorDisableIdentifyLed'), 1037affc529SSandeepa Singh ); 1047affc529SSandeepa Singh } 1057affc529SSandeepa Singh }); 1067affc529SSandeepa Singh }, 1077affc529SSandeepa Singh }, 1087affc529SSandeepa Singh}; 1097affc529SSandeepa Singh 1107affc529SSandeepa Singhexport default ProcessorStore; 111