summaryrefslogtreecommitdiff
path: root/src/store/modules/SecurityAndAccess/SessionsStore.js
diff options
context:
space:
mode:
authorSandeepa Singh <sandeepa.singh@ibm.com>2021-07-26 12:35:39 +0300
committerDerick Montague <derick.montague@ibm.com>2021-08-10 22:20:42 +0300
commitb440616c23b61166ae6d87839a70eec31bdca235 (patch)
treed72769d4aa425e96e47419515b85a8631d8e99d7 /src/store/modules/SecurityAndAccess/SessionsStore.js
parentf67f769f2304bca64d2b9758e22c21203960eef9 (diff)
downloadwebui-vue-b440616c23b61166ae6d87839a70eec31bdca235.tar.xz
IA update: Update access and control section
This is the fifth commit of the information architecture changes and has the following changes: - The icon for access and control has been updated - Access and control section has been updated to security and access section - Security settings page has been updated to policies page and moved to security and access section - Client sessions page has been updated to sessions page - Local user management page has been updated to user management page - SSL certificates page has been updated to certificates page Signed-off-by: Sandeepa Singh <sandeepa.singh@ibm.com> Change-Id: Ie93cee9002742ecf7d33615636f4f159f4395fc4
Diffstat (limited to 'src/store/modules/SecurityAndAccess/SessionsStore.js')
-rw-r--r--src/store/modules/SecurityAndAccess/SessionsStore.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/store/modules/SecurityAndAccess/SessionsStore.js b/src/store/modules/SecurityAndAccess/SessionsStore.js
new file mode 100644
index 00000000..54607ab6
--- /dev/null
+++ b/src/store/modules/SecurityAndAccess/SessionsStore.js
@@ -0,0 +1,80 @@
+import api, { getResponseCount } from '@/store/api';
+import i18n from '@/i18n';
+
+const SessionsStore = {
+ namespaced: true,
+ state: {
+ allConnections: [],
+ },
+ getters: {
+ allConnections: (state) => state.allConnections,
+ },
+ mutations: {
+ setAllConnections: (state, allConnections) =>
+ (state.allConnections = allConnections),
+ },
+ actions: {
+ async getSessionsData({ commit }) {
+ return await api
+ .get('/redfish/v1/SessionService/Sessions')
+ .then((response) =>
+ response.data.Members.map((sessionLogs) => sessionLogs['@odata.id'])
+ )
+ .then((sessionUris) =>
+ api.all(sessionUris.map((sessionUri) => api.get(sessionUri)))
+ )
+ .then((sessionUris) => {
+ const allConnectionsData = sessionUris.map((sessionUri) => {
+ return {
+ clientID: sessionUri.data?.Oem?.OpenBMC.ClientID,
+ username: sessionUri.data?.UserName,
+ ipAddress: sessionUri.data?.ClientOriginIPAddress,
+ uri: sessionUri.data['@odata.id'],
+ };
+ });
+ commit('setAllConnections', allConnectionsData);
+ })
+ .catch((error) => {
+ console.log('Client Session Data:', error);
+ });
+ },
+ async disconnectSessions({ dispatch }, uris = []) {
+ const promises = uris.map((uri) =>
+ api.delete(uri).catch((error) => {
+ console.log(error);
+ return error;
+ })
+ );
+ return await api
+ .all(promises)
+ .then((response) => {
+ dispatch('getSessionsData');
+ return response;
+ })
+ .then(
+ api.spread((...responses) => {
+ const { successCount, errorCount } = getResponseCount(responses);
+ const toastMessages = [];
+
+ if (successCount) {
+ const message = i18n.tc(
+ 'pageSessions.toast.successDelete',
+ successCount
+ );
+ toastMessages.push({ type: 'success', message });
+ }
+
+ if (errorCount) {
+ const message = i18n.tc(
+ 'pageSessions.toast.errorDelete',
+ errorCount
+ );
+ toastMessages.push({ type: 'error', message });
+ }
+ return toastMessages;
+ })
+ );
+ },
+ },
+};
+export default SessionsStore;