From aa81e02b285485e64a89f82f5772f0ff12b4a663 Mon Sep 17 00:00:00 2001 From: Vedangi Mittal Date: Tue, 10 Sep 2024 16:01:49 +0530 Subject: [PATCH] Implemented Sessions page - Implemented Sessions page - Jira story: https://jsw.ibm.com/browse/PFEBMC-2397 Signed-off-by: Vedangi Mittal --- src/components/Global/TableToolbar.vue | 2 +- src/router/routes.js | 9 + src/store/index.js | 2 + .../SecurityAndAccess/SessionsStore.js | 29 +- .../SecurityAndAccess/Sessions/Sessions.vue | 439 +++++++++--------- 5 files changed, 251 insertions(+), 230 deletions(-) diff --git a/src/components/Global/TableToolbar.vue b/src/components/Global/TableToolbar.vue index 76a610cb60..e0ee1bad47 100644 --- a/src/components/Global/TableToolbar.vue +++ b/src/components/Global/TableToolbar.vue @@ -13,7 +13,7 @@ :data-test-id="`table-button-${action.value}Selected`" variant="primary" class="d-block" - @click="emit('batch-action', action.value)" + @click="$emit('batch-action', action.value)" > {{ action.label }} diff --git a/src/router/routes.js b/src/router/routes.js index 79466005ce..be6c0d1857 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -19,6 +19,7 @@ import PowerRestorePolicy from '@/views/Settings/PowerRestorePolicy'; import ConcurrentMaintenance from '../views/HardwareStatus/ConcurrentMaintenance/ConcurrentMaintenance.vue'; import IBMiServiceFunctions from '@/views/Logs/IBMiServiceFunctions'; import Notices from '@/views/Notices/Notices.vue'; +import Sessions from '@/views/SecurityAndAccess/Sessions'; const roles = { administrator: 'Administrator', @@ -152,6 +153,14 @@ export const routes = [ title: i18n.global.t('appPageTitle.memory'), }, }, + { + path: '/security-and-access/sessions', + name: 'sessions', + component: Sessions, + meta: { + title: i18n.global.t('appPageTitle.sessions'), + }, + }, { path: '/:pathMatch(.*)*', name: 'page-not-found', diff --git a/src/store/index.js b/src/store/index.js index fd8e8dead4..8d296f97f2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -15,6 +15,7 @@ import PowerPolicyStore from './modules/Settings/PowerPolicyStore'; import ConcurrentMaintenanceStore from './modules/HardwareStatus/ConcurrentMaintenanceStore'; import IBMiServiceFunctionsStore from './modules/Logs/IBMiServiceFunctionsStore'; import AuditLogsStore from './modules/Logs/AuditLogsStore'; +import SessionsStore from './modules/SecurityAndAccess/SessionsStore.js'; // ... (export use other stores) export { @@ -34,4 +35,5 @@ export { ConcurrentMaintenanceStore, IBMiServiceFunctionsStore, AuditLogsStore, + SessionsStore, }; diff --git a/src/store/modules/SecurityAndAccess/SessionsStore.js b/src/store/modules/SecurityAndAccess/SessionsStore.js index 794c75a7f4..b9848be307 100644 --- a/src/store/modules/SecurityAndAccess/SessionsStore.js +++ b/src/store/modules/SecurityAndAccess/SessionsStore.js @@ -1,20 +1,16 @@ import api, { getResponseCount } from '@/store/api'; import i18n from '@/i18n'; +import { defineStore } from 'pinia'; -const SessionsStore = { - namespaced: true, - state: { +export const SessionsStore = defineStore('sessions', { + state: () => ({ allConnections: [], - }, + }), getters: { - allConnections: (state) => state.allConnections, - }, - mutations: { - setAllConnections: (state, allConnections) => - (state.allConnections = allConnections), + allConnectionsGetter: (state) => state.allConnections, }, actions: { - async getSessionsData({ commit }) { + async getSessionsData() { return await api .get('/redfish/v1/SessionService/Sessions') .then((response) => @@ -29,19 +25,20 @@ const SessionsStore = { let filteredIPAddress = sessionUri.data?.ClientOriginIPAddress.split('::ffff:').pop(); return { + isSelected: false, clientID: sessionUri.data?.Context, username: sessionUri.data?.UserName, ipAddress: filteredIPAddress, uri: sessionUri.data['@odata.id'], }; }); - commit('setAllConnections', allConnectionsData); + this.allConnections = allConnectionsData; }) .catch((error) => { console.log('Client Session Data:', error); }); }, - async disconnectSessions({ dispatch }, uris = []) { + async disconnectSessions(uris) { const promises = uris.map((uri) => api.delete(uri).catch((error) => { console.log(error); @@ -51,7 +48,7 @@ const SessionsStore = { return await api .all(promises) .then((response) => { - dispatch('getSessionsData'); + this.getSessionsData(); return response; }) .then( @@ -60,7 +57,7 @@ const SessionsStore = { const toastMessages = []; if (successCount) { - const message = i18n.tc( + const message = i18n.global.t( 'pageSessions.toast.successDelete', successCount, ); @@ -68,7 +65,7 @@ const SessionsStore = { } if (errorCount) { - const message = i18n.tc( + const message = i18n.global.t( 'pageSessions.toast.errorDelete', errorCount, ); @@ -79,5 +76,5 @@ const SessionsStore = { ); }, }, -}; +}); export default SessionsStore; diff --git a/src/views/SecurityAndAccess/Sessions/Sessions.vue b/src/views/SecurityAndAccess/Sessions/Sessions.vue index 4ca2ff9123..7f482c8e7f 100644 --- a/src/views/SecurityAndAccess/Sessions/Sessions.vue +++ b/src/views/SecurityAndAccess/Sessions/Sessions.vue @@ -1,8 +1,8 @@ - - - + + + - - - + + - - - - + + + - - - + + + +

+ {{ + $t('pageSessions.modal.disconnectMessage', { count: count }, count) + }} +

+
+ - -