From a9e97c60752d8aafc03c280e015a5e6b2b0adef7 Mon Sep 17 00:00:00 2001 From: tiwari-nishant Date: Wed, 27 Nov 2024 14:15:49 +0530 Subject: [PATCH] Implemented PCIe Topology page * PCIe Topology Page Vue2 to Vue3 * Jira Story: https://jsw.ibm.com/browse/PFEBMC-2371 --- src/assets/styles/bmc/custom/_card.scss | 1 - src/assets/styles/bmc/custom/_tables.scss | 1 - src/router/routes.js | 9 + src/store/index.js | 3 +- .../Authentication/AuthenticationStore.js | 10 + src/store/modules/GlobalStore.js | 43 + .../HardwareStatus/PcieTopologyStore.js | 162 ++-- .../HardwareStatus/Inventory/Inventory.vue | 7 +- .../Inventory/InventoryServiceIndicator.vue | 4 +- .../Inventory/InventoryTableChassis.vue | 2 +- .../PcieTopology/IdentifyLedsModal.vue | 149 ++-- .../PcieTopology/PcieTopology.vue | 738 ++++++++---------- .../PcieTopology/ResetLinkModal.vue | 133 ++-- src/views/HardwareStatus/Sensors/Sensors.vue | 7 +- src/views/Login/Login.vue | 16 +- src/views/Logs/AuditLogs/AuditLogs.vue | 4 +- 16 files changed, 677 insertions(+), 612 deletions(-) diff --git a/src/assets/styles/bmc/custom/_card.scss b/src/assets/styles/bmc/custom/_card.scss index fdb7b145cb..736ded97b5 100644 --- a/src/assets/styles/bmc/custom/_card.scss +++ b/src/assets/styles/bmc/custom/_card.scss @@ -2,7 +2,6 @@ .bg-success { background-color: theme-color-light($success) !important; } - width: 120%; } .card-header, diff --git a/src/assets/styles/bmc/custom/_tables.scss b/src/assets/styles/bmc/custom/_tables.scss index 91f49c5d13..fb055dd60a 100644 --- a/src/assets/styles/bmc/custom/_tables.scss +++ b/src/assets/styles/bmc/custom/_tables.scss @@ -2,7 +2,6 @@ .b-table-sticky-header { max-height: 75vh; min-height: 100px; - min-width: 116%; border: 1px solid #efefef; .table.b-table { thead { diff --git a/src/router/routes.js b/src/router/routes.js index f50c65c622..a1c6c94a07 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -18,6 +18,7 @@ import Memory from '@/views/ResourceManagement/Memory'; import Power from '@/views/ResourceManagement/Power'; import PowerRestorePolicy from '@/views/Settings/PowerRestorePolicy'; import ConcurrentMaintenance from '../views/HardwareStatus/ConcurrentMaintenance/ConcurrentMaintenance.vue'; +import PcieTopology from '../views/HardwareStatus/PcieTopology/PcieTopology.vue'; import IBMiServiceFunctions from '@/views/Logs/IBMiServiceFunctions'; import Notices from '@/views/Notices/Notices.vue'; import Sessions from '@/views/SecurityAndAccess/Sessions'; @@ -92,6 +93,14 @@ export const routes = [ title: i18n.global.t('appPageTitle.inventory'), }, }, + { + path: '/hardware-status/pcie-topology', + name: 'pcie-topology', + component: PcieTopology, + meta: { + title: i18n.global.t('appPageTitle.pcieTopology'), + }, + }, { path: '/hardware-status/inventory', name: 'inventory', diff --git a/src/store/index.js b/src/store/index.js index 1a3c141bd2..700f4ba044 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -28,7 +28,7 @@ import FabricAdaptersStore from './modules/HardwareStatus/FabricAdaptersStore'; import SystemParametersStore from './modules/ResourceManagement/SystemParametersStore'; import CertificatesStore from './modules/SecurityAndAccess/CertificatesStore'; import UserManagementStore from './modules/SecurityAndAccess/UserManagementStore'; - +import PcieTopologyStore from './modules/HardwareStatus/PcieTopologyStore.js'; // ... (export use other stores) export { EventLogStore, @@ -60,4 +60,5 @@ export { SystemParametersStore, CertificatesStore, UserManagementStore, + PcieTopologyStore }; diff --git a/src/store/modules/Authentication/AuthenticationStore.js b/src/store/modules/Authentication/AuthenticationStore.js index 908975abc9..c4cea36581 100644 --- a/src/store/modules/Authentication/AuthenticationStore.js +++ b/src/store/modules/Authentication/AuthenticationStore.js @@ -62,6 +62,15 @@ export const AuthenticationStore = defineStore('authentication', { const headers = { 'X-Xsrf-Token': cookies.get('X-XSRF-TOKEN'), }; + Cookies.remove('XSRF-TOKEN'); + Cookies.remove('IsAuthenticated'); + localStorage.removeItem('storedModelType'); + localStorage.removeItem('storedUsername'); + localStorage.removeItem('storedCurrentUser'); + localStorage.removeItem('storedHmcManagedValue'); + localStorage.removeItem('storedLanguage'); + this.xsrfCookie = undefined; + this.isAuthenticatedCookie = undefined; return api .post('/logout', { data: [] }, { headers: headers }) .then(() => { @@ -73,6 +82,7 @@ export const AuthenticationStore = defineStore('authentication', { console.log(error); this.logoutRemove(); }); + }, getUserInfo(username) { return api diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js index 607f7271cb..1b72180b4a 100644 --- a/src/store/modules/GlobalStore.js +++ b/src/store/modules/GlobalStore.js @@ -46,13 +46,23 @@ export const GlobalStore = defineStore('global', { username: localStorage.getItem('storedUsername'), isAuthorized: true, userPrivilege: null, + currentUser: JSON.parse(localStorage.getItem('storedCurrentUser')), }), getters: { bootProgressGetter: (state) => state.bootProgress, + isInPhypStandby: (state) => + // SystemHardwareInitializationComplete and after is "PHYP in standby" + state.bootProgress === 'SystemHardwareInitializationComplete' || + state.bootProgress === 'SetupEntered' || + state.bootProgress === 'OSBootStarted' || + state.bootProgress === 'OSRunning', isOSRunningGetter: (state) => state.bootProgress === 'OSRunning', getIsUtcDisplay: (state) => state.isUtcDisplay, safeModeGetter: (state) => state.safeMode, serverStatusGetter: (state) => state.serverStatus, + currentUserGetter: (state) => state.currentUser, + isServiceUser: (state) => + state.currentUser?.RoleId === 'OemIBMServiceAgent' || !state.currentUser, }, actions: { async getBmcTime() { @@ -65,6 +75,9 @@ export const GlobalStore = defineStore('global', { }) .catch((error) => console.log(error)); }, + setCurrentUser (currentUsr) { + this.currentUser = currentUsr + }, getSystemInfo() { api .get('/redfish/v1/Systems/system') @@ -102,6 +115,36 @@ export const GlobalStore = defineStore('global', { return Promise.reject(); }); }, + getCurrentUser( + username = localStorage.getItem('storedUsername') + ) { + if (localStorage.getItem('storedCurrentUser')) return; + return api + .get(`/redfish/v1/AccountService/Accounts/${username}`) + .then(({ data }) => { + this.setCurrentUser(data) + localStorage.setItem( + 'storedCurrentUser', + JSON.stringify(this.currentUser) + ); + }) + .catch((error) => { + console.log(error); + return this.getAccountService(); + }); + }, + getAccountService() { + return api + .get('/redfish/v1/AccountService') + .then((response) => { + if (response.data?.LDAP?.RemoteRoleMapping?.length > 0) { + return Promise.resolve(); + } + }) + .catch(() => { + return Promise.reject(); + }); + }, async getBootProgress() { api .get('/redfish/v1/Systems/system') diff --git a/src/store/modules/HardwareStatus/PcieTopologyStore.js b/src/store/modules/HardwareStatus/PcieTopologyStore.js index 36f1d6d5b1..10becc7fd7 100644 --- a/src/store/modules/HardwareStatus/PcieTopologyStore.js +++ b/src/store/modules/HardwareStatus/PcieTopologyStore.js @@ -1,17 +1,18 @@ import api from '@/store/api'; import i18n from '@/i18n'; +import { defineStore } from 'pinia'; -const PcieTopologyStore = { +export const PcieTopologyStore = defineStore('pcieTopologyStore',{ namespaced: true, - state: { + state: ()=>({ entries: [], - }, + }), getters: { - entries: (state) => state.entries, + entriesGetter: (state) => state.entries, }, - mutations: { - setEntries: (state, data) => { - state.entries = data.map((pcie) => { + actions: { + setEntries(data){ + this.entries = data.map((pcie) => { return { id: pcie?.linkId, resetLinkAvailable: pcie?.resetLinkAvailable, @@ -33,9 +34,7 @@ const PcieTopologyStore = { }; }); }, - }, - actions: { - async resetTheLink(_, requestBody) { + async resetTheLink(requestBody) { const body = { Oem: { IBM: { @@ -69,7 +68,7 @@ const PcieTopologyStore = { console.error('Error', error); }); }, - async getTopologyScreen({ commit }) { + async getTopologyScreen() { let chassisMembers = []; let pcieDeviceMembers = []; let procMembers = []; @@ -1125,16 +1124,17 @@ const PcieTopologyStore = { }); }); rows.push(row); - commit('setEntries', rows); + // commit('setEntries', rows); + this.setEntries(rows) } }); }); }, - async getLedValue(_, requestBody) { + async getLedValue(requestBody) { const uri = requestBody.uri; return await api.get(uri); }, - async updateLedValue(_, requestBody) { + async updateLedValue(requestBody) { await api.all( [''].map(async () => { if (requestBody.type === 'ioSlots') { @@ -1179,78 +1179,90 @@ const PcieTopologyStore = { }), ); }, - async getAllLedValues(_, selectedObj) { + async getAllLedValues(selectedObj) { let returningObj = { pcieBridge: [], localPortLocation: [], remotePortLocation: [], ioSlots: [], }; - await api.all( - [''].map(async () => { - if (selectedObj.pcieBridge?.uri) { - await api.get(selectedObj.pcieBridge?.uri).then(({ data }) => { - returningObj.pcieBridge.push({ + + const fetchPcieBridge = async () => { + if (selectedObj.pcieBridge?.uri) { + const { data } = await api.get(selectedObj.pcieBridge?.uri); + returningObj.pcieBridge.push({ + led: data.LocationIndicatorActive, + locationNumber: data.Location?.PartLocation?.ServiceLabel, + uri: data['@odata.id'], + }); + } + }; + + const fetchLocalPorts = async () => { + if (selectedObj.localPortLocation.length > 0) { + await Promise.all( + selectedObj.localPortLocation.map(async (local) => { + const { data } = await api.get(local.uri); + returningObj.localPortLocation.push({ led: data.LocationIndicatorActive, locationNumber: data.Location?.PartLocation?.ServiceLabel, uri: data['@odata.id'], }); - }); - } - if (selectedObj.localPortLocation.length > 0) { - await api.all( - selectedObj.localPortLocation.map(async (local) => { - await api.get(local.uri).then(({ data }) => { - returningObj.localPortLocation.push({ - led: data.LocationIndicatorActive, - locationNumber: data.Location?.PartLocation?.ServiceLabel, - uri: data['@odata.id'], - }); - }); - }), - ); - } - if (selectedObj.remotePortLocation.length > 0) { - await api.all( - selectedObj.remotePortLocation.map(async (local) => { - await api.get(local.uri).then(({ data }) => { - returningObj.remotePortLocation.push({ - led: data.LocationIndicatorActive, - locationNumber: data.Location?.PartLocation?.ServiceLabel, - uri: data['@odata.id'], - }); - }); - }), - ); - } - if (selectedObj.ioSlots.length > 0) { - await api.all( - selectedObj.ioSlots.map(async (ioSlot) => { - api.get(ioSlot.uri).then(async (ioSlotResponse) => { - const tempSlots = ioSlotResponse.data.Slots; - await api.all( - tempSlots.map((tempSlot) => { - if ( - tempSlot.Location?.PartLocation?.ServiceLabel === - ioSlot.locationNumber - ) { - returningObj.ioSlots.push({ - led: tempSlot.LocationIndicatorActive, - locationNumber: ioSlot.locationNumber, - uri: ioSlot.uri, - }); - } - }), - ); - }); - }), - ); - } - }), - ); + }) + ); + } + }; + + const fetchRemotePorts = async () => { + if (selectedObj.remotePortLocation.length > 0) { + await Promise.all( + selectedObj.remotePortLocation.map(async (local) => { + const { data } = await api.get(local.uri); + returningObj.remotePortLocation.push({ + led: data.LocationIndicatorActive, + locationNumber: data.Location?.PartLocation?.ServiceLabel, + uri: data['@odata.id'], + }); + }) + ); + } + }; + + const fetchIoSlots = async () => { + if (selectedObj.ioSlots.length > 0) { + await Promise.all( + selectedObj.ioSlots.map(async (ioSlot) => { + const ioSlotResponse = await api.get(ioSlot.uri); + const tempSlots = ioSlotResponse.data.Slots; + await Promise.all( + tempSlots.map((tempSlot) => { + if ( + tempSlot.Location?.PartLocation?.ServiceLabel === + ioSlot.locationNumber + ) { + returningObj.ioSlots.push({ + led: tempSlot.LocationIndicatorActive, + locationNumber: ioSlot.locationNumber, + uri: ioSlot.uri, + }); + } + }) + ); + }) + ); + } + }; + + await Promise.all([ + fetchPcieBridge(), + fetchLocalPorts(), + fetchRemotePorts(), + fetchIoSlots(), + ]); + return returningObj; - }, + } }, -}; +}); export default PcieTopologyStore; diff --git a/src/views/HardwareStatus/Inventory/Inventory.vue b/src/views/HardwareStatus/Inventory/Inventory.vue index 05b436d224..97b51ec835 100644 --- a/src/views/HardwareStatus/Inventory/Inventory.vue +++ b/src/views/HardwareStatus/Inventory/Inventory.vue @@ -1,5 +1,5 @@