Skip to content

Commit

Permalink
feat(admin-ui): Dashboard with monthly active users/clients. (#1983)
Browse files Browse the repository at this point in the history
* fix: agama projects are not deploying properly

* feat: dashboard with monthly active users

* fix: show MAU when lock is configured
  • Loading branch information
mjatin-dev authored Feb 3, 2025
1 parent f0d0c32 commit b0908ea
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 92 deletions.
79 changes: 79 additions & 0 deletions admin-ui/app/components/SVG/menu/JansLockClients.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from "react";
import PropTypes from "prop-types";

const JansLockClients = ({ className, style }) => {
return (
<div className={className} style={style}>
<svg
version="1.0"
xmlns="http://www.w3.org/2000/svg"
width="30pt"
height="30pt"
viewBox="0 0 900.000000 900.000000"
preserveAspectRatio="xMidYMid meet"
>
<g
transform="translate(0.000000,900.000000) scale(0.100000,-0.100000)"
fill="#000000"
stroke="none"
>
<path
d="M2128 8430 c-90 -14 -233 -66 -311 -113 -193 -114 -347 -329 -394
-551 -22 -104 -13 -317 17 -411 46 -143 123 -268 231 -371 110 -104 201 -156
346 -200 115 -35 306 -40 423 -10 98 24 245 93 317 149 219 169 333 402 333
680 0 172 -45 318 -141 461 -84 126 -245 259 -373 309 -139 54 -322 77 -448
57z"
/>
<path
d="M4373 8429 c-84 -12 -223 -63 -304 -110 -89 -51 -208 -164 -267 -253
-98 -146 -142 -294 -142 -474 0 -126 17 -211 60 -316 103 -247 303 -423 567
-498 112 -32 314 -32 426 0 264 75 464 251 567 498 43 105 60 190 60 316 0
125 -18 220 -62 325 -148 356 -521 567 -905 512z"
/>
<path
d="M6630 8429 c-342 -50 -635 -323 -706 -658 -18 -87 -18 -262 1 -351
54 -255 227 -472 468 -585 136 -63 216 -80 372 -79 110 1 144 5 218 28 145 44
236 96 346 200 112 108 199 251 238 396 26 94 25 351 -1 435 -49 160 -130 290
-248 399 -183 170 -443 252 -688 215z"
/>
<path
d="M1015 6455 c-194 -43 -334 -144 -401 -290 -55 -121 -55 -118 -52
-1280 l3 -1070 23 -69 c55 -163 167 -274 333 -332 41 -14 100 -29 132 -31 32
-3 60 -10 64 -16 3 -6 7 -639 7 -1406 l1 -1396 843 -3 842 -2 0 1124 0 1124
-72 12 c-207 35 -359 136 -430 286 -61 130 -59 62 -56 1692 l3 1487 27 88 c16
48 28 89 28 92 0 3 -278 5 -617 4 -473 0 -632 -4 -678 -14z"
/>
<path
d="M3255 6454 c-169 -35 -321 -144 -382 -274 -60 -128 -58 -78 -58
-1265 0 -1030 1 -1093 18 -1150 38 -123 93 -203 185 -272 68 -51 202 -102 289
-110 35 -3 63 -11 64 -17 1 -6 2 -639 3 -1406 l1 -1395 754 -3 754 -2 74 -56
c112 -84 253 -171 393 -240 953 -474 2103 -296 2873 445 411 396 670 904 754
1476 25 170 24 515 0 690 -59 414 -212 792 -460 1140 l-72 100 -5 940 c-6
1047 -1 980 -77 1135 -45 93 -126 176 -215 219 -120 59 -140 61 -830 61 -346
0 -628 -2 -628 -5 0 -3 12 -44 27 -92 l28 -88 3 -615 3 -615 -280 0 -280 0 -3
470 c-4 520 -4 520 -72 660 -63 128 -158 211 -295 258 l-66 22 -1215 2 c-1031
1 -1226 -1 -1285 -13z m3540 -1983 c798 -134 1437 -751 1599 -1543 56 -271 56
-528 1 -792 -105 -505 -417 -966 -842 -1244 -365 -239 -807 -356 -1216 -323
-317 26 -605 114 -862 266 -503 296 -851 801 -946 1370 -161 972 420 1915
1358 2206 285 88 612 110 908 60z"
/>
<path
d="M6315 3930 c-236 -37 -446 -166 -565 -347 -107 -163 -157 -345 -167
-605 l-6 -168 -119 0 -118 0 0 -700 0 -700 1125 0 1125 0 0 700 0 699 -117 3
-118 3 3 71 c2 39 -2 124 -8 190 -29 294 -136 528 -306 668 -150 123 -323 185
-539 191 -71 2 -157 0 -190 -5z m279 -571 c88 -22 154 -108 181 -236 8 -38 15
-123 15 -190 l0 -123 -320 0 -319 0 -7 37 c-10 52 2 221 21 294 31 118 86 189
166 214 54 17 204 19 263 4z"
/>
</g>
</svg>
</div>
);
};

export default JansLockClients;

JansLockClients.propTypes = {
style: PropTypes.object,
className: PropTypes.string,
};
58 changes: 58 additions & 0 deletions admin-ui/app/components/SVG/menu/JansLockUsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from "react";
import PropTypes from "prop-types";

const JansLockUsers = ({ className, style }) => {
return (
<div className={className} style={style}>
<svg
version="1.0"
xmlns="http://www.w3.org/2000/svg"
width="30pt"
height="30pt"
viewBox="0 0 512.000000 512.000000"
preserveAspectRatio="xMidYMid meet"
>
<g
transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"
fill="#000000"
stroke="none"
>
<path
d="M2250 5049 c-545 -62 -886 -381 -950 -892 -32 -258 14 -685 105 -961
133 -408 379 -674 705 -765 161 -44 418 -45 575 -1 415 117 697 503 789 1085
41 255 46 596 12 747 -76 334 -261 562 -562 692 -194 84 -450 120 -674 95z"
/>
<path
d="M3847 2734 c-148 -27 -290 -87 -397 -169 -85 -65 -193 -185 -241
-266 -23 -41 -44 -75 -45 -77 -1 -2 -64 49 -140 113 l-137 116 -241 -240 -241
-241 -60 61 c-33 33 -144 141 -246 239 l-185 179 -141 -117 -140 -118 -323
-149 c-323 -149 -389 -187 -442 -257 -15 -20 -216 -352 -447 -737 l-419 -701
1436 -2 1437 -3 6 -46 c17 -114 111 -216 229 -248 34 -9 260 -11 910 -9 859 3
865 3 911 24 67 31 124 87 156 152 l28 57 3 679 c3 752 3 743 -61 828 -18 24
-55 58 -82 76 -28 18 -53 43 -56 55 -4 12 -16 63 -28 112 -22 95 -79 224 -132
301 -80 116 -224 241 -354 307 -113 56 -296 98 -423 96 -31 0 -92 -7 -135 -15z
m318 -321 c100 -25 192 -79 275 -162 135 -136 180 -259 180 -493 l0 -138 100
0 100 0 0 -625 0 -625 -810 0 -810 0 0 625 0 625 100 0 100 0 0 138 c0 234 45
358 180 492 160 161 365 218 585 163z"
/>
<path
d="M3915 2167 c-68 -23 -118 -54 -161 -99 -79 -82 -104 -165 -104 -345
l0 -103 360 0 360 0 0 103 c0 181 -24 259 -106 347 -83 88 -241 132 -349 97z"
/>
<path
d="M3931 1142 c-89 -45 -124 -148 -81 -237 12 -25 31 -50 41 -56 17 -9
19 -22 19 -149 l0 -140 100 0 100 0 0 140 c0 127 2 140 19 149 26 14 61 90 61
132 0 42 -29 107 -61 136 -50 46 -137 57 -198 25z"
/>
</g>
</svg>
</div>
);
};

export default JansLockUsers;

JansLockUsers.propTypes = {
style: PropTypes.object,
className: PropTypes.string,
};
42 changes: 22 additions & 20 deletions admin-ui/app/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"currentMonth": "Current Month",
"currentYear": "Current Year",
"choose": "Choose",
"deploy":"Deploy",
"deploy": "Deploy",
"edit": "Edit",
"next": "Next",
"no": "No",
Expand Down Expand Up @@ -55,7 +55,7 @@
"add_source_ldap_server": "Add source LDAP server",
"remove_source_server": "Remove source server",
"copy_to_clipboard": "Copy To Clipboard",
"export_csv":"Export CSV"
"export_csv": "Export CSV"
},
"dashboard": {
"summary_title": "Actives Users & Access Token Stats",
Expand All @@ -80,14 +80,16 @@
"start_date": "Start Date",
"end_date": "End Date",
"system_status": "System Status",
"config_api":"Config API",
"config_api_status":"Config API Status",
"key_cloak":"Keycloak",
"jans_lock":"Jans Lock",
"jans_link":"Jans Link",
"access_denied":"Access Denied",
"access_denied_message":"You do not have permission to access this page",
"access_contact_admin":"Please contact your administrator for more information"
"config_api": "Config API",
"config_api_status": "Config API Status",
"key_cloak": "Keycloak",
"jans_lock": "Jans Lock",
"jans_link": "Jans Link",
"access_denied": "Access Denied",
"access_denied_message": "You do not have permission to access this page",
"access_contact_admin": "Please contact your administrator for more information",
"mau_users": "Max. MAU for LTM (Lock)",
"mau_clients": "Max. MAC for LTM (Lock)"
},
"fields": {
"access_token_signing_alg": "JWS alg for signing",
Expand Down Expand Up @@ -133,7 +135,7 @@
"jans_assertion_consumer_service_post_url": "Jans Assertion Consumer Service POST URL",
"jans_id": "Jans ID",
"jans_state": "Jans State",
"jans_sess_state":"Jans Session State",
"jans_sess_state": "Jans Session State",
"jans_user_dn": "Jans User DN",
"permission_granted_map": "Permission Granted Map",
"jans_sess_attr": "Jans Session Attributes",
Expand Down Expand Up @@ -658,9 +660,9 @@
"source_backend_ldap_servers": "Source Backend LDAP Servers",
"inum_db_server": "Inum DB Server",
"static_configuration": "Static Configuration",
"dynamic_configuration": "Dynamic Configuration",
"upload_agama_project":"Upload Agama project",
"add_community_project":"Add a Community Project"
"dynamic_configuration": "Dynamic Configuration",
"upload_agama_project": "Upload Agama project",
"add_community_project": "Add a Community Project"
},
"messages": {
"add_permission": "Add Permission",
Expand Down Expand Up @@ -809,7 +811,7 @@
"search_reference": "Search by reference",
"search_scope": "Search by scope",
"search_token": "Search by token code",
"search_date":"Search by creation date",
"search_date": "Search by creation date",
"sector_uri": "Enter the sector URI",
"sender_email": "Enter the sender email",
"sender_name": "Enter the sender name",
Expand Down Expand Up @@ -889,8 +891,8 @@
"scopes": "Scopes",
"scripts": "Custom Scripts",
"schemaName": "Schema Name",
"select_project_deploy":"Select a project to deploy",
"add_new_agama_project":"Add a new Agama Project",
"select_project_deploy": "Select a project to deploy",
"add_new_agama_project": "Add a new Agama Project",
"user_management": "User Management",
"fido_management": "FIDO Configuration",
"saml_management": "SAML",
Expand Down Expand Up @@ -919,7 +921,7 @@
"edit_alias": "Edit Mapping",
"export_csv": "Export CSV",
"filters": "Filters",
"expiration_date" : "Expiration Date",
"expiration_date": "Expiration Date",
"authentication_date": "Authentication Date",
"creation_date": "Creation Date"
},
Expand Down Expand Up @@ -1591,8 +1593,8 @@
"type": "Type",
"domain": "Domain"
},
"sessions":{
"expirationDate" : "Expiration Date",
"sessions": {
"expirationDate": "Expiration Date",
"jansId": "Jans Id",
"jansState": "Jans State",
"jansSessState": "Jans Session State",
Expand Down
16 changes: 9 additions & 7 deletions admin-ui/app/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
"key_cloak": "Keycloak",
"jans_lock": "Jans Lock",
"jans_link": "Lien Jans",
"access_denied":"Accès refusé",
"access_denied_message":"Vous n'êtes pas autorisé à accéder à cette page",
"access_contact_admin":"Veuillez contacter l'administrateur pour obtenir de l'aide"
"access_denied": "Accès refusé",
"access_denied_message": "Vous n'êtes pas autorisé à accéder à cette page",
"access_contact_admin": "Veuillez contacter l'administrateur pour obtenir de l'aide",
"mau_users": "Max. MAU pour LTM (Verrouillage)",
"mau_clients": "Max. MAC pour LTM (Verrouillage)"
},
"menus": {
"adminui": "Administratrice",
Expand Down Expand Up @@ -182,7 +184,7 @@
"jans_assertion_consumer_service_post_url": "URL POST du service consommateur d'assertions Jans",
"jans_id": "ID Jans",
"jans_state": "État Jans",
"jans_sess_state":"État de la session Jans",
"jans_sess_state": "État de la session Jans",
"jans_user_dn": "DN de l'utilisateur Jans",
"permission_granted_map": "Carte des autorisations accordées",
"jans_sess_attr": "Attributs de la session Jans",
Expand Down Expand Up @@ -812,7 +814,7 @@
"jans_ink": "Jans Link",
"change_backend_bind_password": "Modifier le mot de passe de liaison du backend",
"add_agama_project": "Ajouter un projet Agama",
"export_csv":"Exporter CSV"
"export_csv": "Exporter CSV"
},
"links": {
"support": "https://support.gluu.org/"
Expand Down Expand Up @@ -1521,8 +1523,8 @@
"type": "Type",
"domain": "Domaine"
},
"sessions":{
"expirationDate" : "Date d'expiration",
"sessions": {
"expirationDate": "Date d'expiration",
"jansId": "ID Jans",
"jansState": "État Jans",
"jansSessState": "État de la session Jans",
Expand Down
4 changes: 3 additions & 1 deletion admin-ui/app/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"jans_link": "Link Jans",
"access_denied":"Acesso negado",
"access_denied_message":"Entre em contato com o administrador para obter ajuda",
"access_contact_admin":"Se você acha que isso é um erro, entre em contato com o administrador"
"access_contact_admin":"Se você acha que isso é um erro, entre em contato com o administrador",
"mau_users": "Máx. MAU para LTM (Bloqueio)",
"mau_clients": "Máx. MAC para LTM (Bloqueio)"
},
"menus": {
"adminui": "Admin",
Expand Down
14 changes: 14 additions & 0 deletions admin-ui/app/redux/api/LockApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { handleResponse } from "Utils/ApiUtils";

export default class LockApi {
constructor(api) {
this.api = api;
}
getLockMau = (opt) => {
return new Promise((resolve, reject) => {
this.api.getLockStat(opt, (error, data) => {
handleResponse(error, reject, resolve, data);
});
});
};
}
28 changes: 28 additions & 0 deletions admin-ui/app/redux/features/lockSlice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createSlice } from "@reduxjs/toolkit";
import reducerRegistry from "Redux/reducers/ReducerRegistry";

const initialState = {
lockDetail: {},
loading: false,
};

const lockSlice = createSlice({
name: "lock",
initialState,
reducers: {
getLockStatus: (state) => {
state.loading = true;
},
getLockStatusResponse: (state, action) => {
state.loading = false;
if (action.payload?.data) {
state.lockDetail = action.payload.data;
}
},
},
});

export const { getLockStatus, getLockStatusResponse } = lockSlice.actions;

export default lockSlice.reducer;
reducerRegistry.register("lockReducer", lockSlice.reducer);
1 change: 0 additions & 1 deletion admin-ui/app/redux/sagas/AuthSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function* putConfigWorker({ payload }) {
return
}
} catch (error) {
console.log('Problems udpating configuration.', error)
yield put(updateToast(true, 'error'))
if (isFourZeroOneError(error)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
Expand Down
41 changes: 41 additions & 0 deletions admin-ui/app/redux/sagas/LockSaga.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { call, all, put, fork, select, takeLatest } from "redux-saga/effects";
import { isFourZeroOneError } from "Utils/TokenController";

import { getAPIAccessToken } from "../features/authSlice";
import { getClient } from "../api/base";
import { initAudit } from "../sagas/SagaUtils";
import LockApi from "../api/LockApi";
import { getLockStatusResponse } from "../features/lockSlice";
const JansConfigApi = require("jans_config_api");

function* newFunction() {
const token = yield select((state) => state.authReducer.token.access_token);
const issuer = yield select((state) => state.authReducer.issuer);
const api = new JansConfigApi.StatisticsApi(
getClient(JansConfigApi, token, issuer)
);
return new LockApi(api);
}

export function* getLockMau({ payload }) {
const audit = yield* initAudit();
try {
const lockapi = yield* newFunction();
const data = yield call(lockapi.getLockMau,payload);
yield put(getLockStatusResponse({ data }));
} catch (e) {
yield put(getLockStatusResponse(null));
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt);
yield put(getAPIAccessToken(jwt));
}
}
}

export function* watchGetLockMau() {
yield takeLatest("lock/getLockStatus", getLockMau);
}

export default function* rootSaga() {
yield all([fork(watchGetLockMau)]);
}
Loading

0 comments on commit b0908ea

Please sign in to comment.