strapi-plugin-magic-sessionmanager 4.7.2 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/README.md +380 -663
- package/dist/admin/Analytics-B6d-39Qh.js +420 -0
- package/dist/admin/Analytics-DxOWXHn8.mjs +418 -0
- package/dist/admin/App-ZsSGj7n8.mjs +1894 -0
- package/dist/admin/App-mRFV50K6.js +1896 -0
- package/dist/admin/License-BE6UQ_V3.mjs +443 -0
- package/dist/admin/License-DXt2oi6u.js +443 -0
- package/dist/admin/OnlineUsersWidget-CFvM3Vbp.js +273 -0
- package/dist/admin/OnlineUsersWidget-_tJ6aeWl.mjs +254 -0
- package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
- package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
- package/dist/admin/Settings-BUc12TP5.js +3570 -0
- package/dist/admin/Settings-dtW7cjTX.mjs +3568 -0
- package/dist/admin/de-BFKoGEVT.js +544 -0
- package/dist/admin/de-j0oZH9Pz.mjs +544 -0
- package/dist/admin/en-UY4Tb5tE.mjs +544 -0
- package/dist/admin/en-s7Ksdkcg.js +544 -0
- package/dist/admin/es-07OGMe_5.js +544 -0
- package/dist/admin/es-DGBcZwQy.mjs +544 -0
- package/dist/admin/fr-B6-DWhGO.mjs +544 -0
- package/dist/admin/fr-ETj_2UBY.js +544 -0
- package/dist/admin/index-C_SyRULc.mjs +1750 -0
- package/dist/admin/index-D4kEnXSp.js +1751 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/maskSensitiveValue-BWcSjow7.js +9 -0
- package/dist/admin/maskSensitiveValue-lLRhN_S7.mjs +10 -0
- package/dist/admin/pt-C7PwrQtV.js +544 -0
- package/dist/admin/pt-YMRLm9gx.mjs +544 -0
- package/dist/server/index.js +3555 -6350
- package/dist/server/index.mjs +3555 -6350
- package/package.json +30 -19
- package/pics/analytics.png +0 -0
- package/pics/dashboard-dark.png +0 -0
- package/pics/dashboard.png +0 -0
- package/pics/dashboardsessionmodal.png +0 -0
- package/pics/mobile-dashboard.png +0 -0
- package/pics/mobile-session.png +0 -0
- package/pics/sessioninfopanel.png +0 -0
- package/pics/settings1.png +0 -0
- package/pics/settings2.png +0 -0
- package/pics/widget.png +0 -0
- package/scripts/geoip-updater.cjs +266 -36
- package/scripts/update-geoip-db.mjs +3 -0
- package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
- package/dist/admin/Analytics-D03ZNNMR.js +0 -499
- package/dist/admin/App-B2VCS3cz.js +0 -1481
- package/dist/admin/App-qxKnK7G2.mjs +0 -1479
- package/dist/admin/License-ClW7sZLR.mjs +0 -318
- package/dist/admin/License-fixnQ7wF.js +0 -320
- package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
- package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
- package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
- package/dist/admin/Settings-gv2BF54w.js +0 -2040
- package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
- package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
- package/dist/admin/de-BnqGCokx.js +0 -316
- package/dist/admin/de-JBE-iylO.mjs +0 -316
- package/dist/admin/en-BRmVwd8-.js +0 -316
- package/dist/admin/en-kQWtdEai.mjs +0 -316
- package/dist/admin/es-CH691xcL.js +0 -301
- package/dist/admin/es-DOQvBxih.mjs +0 -301
- package/dist/admin/fr-CLExO0w_.js +0 -301
- package/dist/admin/fr-CmfCpepX.mjs +0 -301
- package/dist/admin/index-B_lFjUAg.mjs +0 -551
- package/dist/admin/index-Duc7cR_d.js +0 -552
- package/dist/admin/pt-BJ_F0yNi.js +0 -301
- package/dist/admin/pt-BSzZdyAH.mjs +0 -301
- package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
- package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
|
@@ -1,552 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const react = require("react");
|
|
3
|
-
const admin = require("@strapi/strapi/admin");
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const reactIntl = require("react-intl");
|
|
6
|
-
const styled = require("styled-components");
|
|
7
|
-
const designSystem = require("@strapi/design-system");
|
|
8
|
-
const icons = require("@strapi/icons");
|
|
9
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
-
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
11
|
-
const strapi = { "name": "magic-sessionmanager", "displayName": "Magic Sessionmanager" };
|
|
12
|
-
const pluginPkg = {
|
|
13
|
-
strapi
|
|
14
|
-
};
|
|
15
|
-
const pluginId = "magic-sessionmanager";
|
|
16
|
-
const PLUGIN_ID = pluginId;
|
|
17
|
-
const Initializer = ({ setPlugin }) => {
|
|
18
|
-
const ref = react.useRef(setPlugin);
|
|
19
|
-
const { get } = admin.useFetchClient();
|
|
20
|
-
react.useEffect(() => {
|
|
21
|
-
if (ref.current) {
|
|
22
|
-
ref.current(pluginId);
|
|
23
|
-
}
|
|
24
|
-
}, []);
|
|
25
|
-
react.useEffect(() => {
|
|
26
|
-
const HEARTBEAT_INTERVAL = 4 * 60 * 1e3;
|
|
27
|
-
const heartbeat = async () => {
|
|
28
|
-
try {
|
|
29
|
-
await get(`/${pluginId}/license/status`);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const initialTimeout = setTimeout(heartbeat, 60 * 1e3);
|
|
34
|
-
const interval = setInterval(heartbeat, HEARTBEAT_INTERVAL);
|
|
35
|
-
return () => {
|
|
36
|
-
clearTimeout(initialTimeout);
|
|
37
|
-
clearInterval(interval);
|
|
38
|
-
};
|
|
39
|
-
}, [get]);
|
|
40
|
-
return null;
|
|
41
|
-
};
|
|
42
|
-
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 32 32", fill: "currentColor", width: "24", height: "24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M26 5H6a3 3 0 0 0-3 3v14a3 3 0 0 0 3 3h20a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3M20 27h-8a1 1 0 0 0 0 2h8a1 1 0 0 0 0-2" }) });
|
|
43
|
-
const parseUserAgent = (userAgent) => {
|
|
44
|
-
if (!userAgent) {
|
|
45
|
-
return {
|
|
46
|
-
device: "Unknown",
|
|
47
|
-
deviceIcon: "question",
|
|
48
|
-
browser: "Unknown",
|
|
49
|
-
os: "Unknown"
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const ua = userAgent.toLowerCase();
|
|
53
|
-
let device = "Desktop";
|
|
54
|
-
let deviceIcon = "desktop";
|
|
55
|
-
if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {
|
|
56
|
-
device = "Tablet";
|
|
57
|
-
deviceIcon = "tablet";
|
|
58
|
-
} else if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent)) {
|
|
59
|
-
device = "Mobile";
|
|
60
|
-
deviceIcon = "mobile";
|
|
61
|
-
}
|
|
62
|
-
let browser = "Unknown";
|
|
63
|
-
if (ua.includes("edg/")) {
|
|
64
|
-
browser = "Edge";
|
|
65
|
-
} else if (ua.includes("chrome/") && !ua.includes("edg/")) {
|
|
66
|
-
browser = "Chrome";
|
|
67
|
-
} else if (ua.includes("firefox/")) {
|
|
68
|
-
browser = "Firefox";
|
|
69
|
-
} else if (ua.includes("safari/") && !ua.includes("chrome/")) {
|
|
70
|
-
browser = "Safari";
|
|
71
|
-
} else if (ua.includes("opera/") || ua.includes("opr/")) {
|
|
72
|
-
browser = "Opera";
|
|
73
|
-
} else if (ua.includes("curl/")) {
|
|
74
|
-
browser = "cURL";
|
|
75
|
-
deviceIcon = "gear";
|
|
76
|
-
device = "API Client";
|
|
77
|
-
} else if (ua.includes("postman")) {
|
|
78
|
-
browser = "Postman";
|
|
79
|
-
deviceIcon = "code";
|
|
80
|
-
device = "API Client";
|
|
81
|
-
} else if (ua.includes("insomnia")) {
|
|
82
|
-
browser = "Insomnia";
|
|
83
|
-
deviceIcon = "code";
|
|
84
|
-
device = "API Client";
|
|
85
|
-
}
|
|
86
|
-
let os = "Unknown";
|
|
87
|
-
if (ua.includes("android")) {
|
|
88
|
-
os = "Android";
|
|
89
|
-
} else if (ua.includes("iphone") || ua.includes("ipad")) {
|
|
90
|
-
os = "iOS";
|
|
91
|
-
} else if (ua.includes("windows")) {
|
|
92
|
-
os = "Windows";
|
|
93
|
-
} else if (ua.includes("mac os x") || ua.includes("macintosh")) {
|
|
94
|
-
os = "macOS";
|
|
95
|
-
} else if (ua.includes("linux")) {
|
|
96
|
-
os = "Linux";
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
device,
|
|
100
|
-
deviceIcon,
|
|
101
|
-
browser,
|
|
102
|
-
os
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
106
|
-
const PanelContainer = styled__default.default(designSystem.Box)`
|
|
107
|
-
width: 100%;
|
|
108
|
-
`;
|
|
109
|
-
const StatusCard = styled__default.default(designSystem.Box)`
|
|
110
|
-
padding: 20px;
|
|
111
|
-
border-radius: 12px;
|
|
112
|
-
border: 1px solid ${(props) => props.$isOnline ? "rgba(34, 197, 94, 0.3)" : "rgba(128, 128, 128, 0.2)"};
|
|
113
|
-
background: ${(props) => props.$isOnline ? "linear-gradient(135deg, rgba(22, 163, 74, 0.06) 0%, rgba(22, 163, 74, 0.12) 100%)" : "linear-gradient(135deg, rgba(128, 128, 128, 0.04) 0%, rgba(128, 128, 128, 0.08) 100%)"};
|
|
114
|
-
transition: all 0.2s ease;
|
|
115
|
-
`;
|
|
116
|
-
const BlockedWarning = styled__default.default(designSystem.Box)`
|
|
117
|
-
padding: 16px;
|
|
118
|
-
border-radius: 10px;
|
|
119
|
-
background: linear-gradient(135deg, rgba(220, 38, 38, 0.06) 0%, rgba(220, 38, 38, 0.12) 100%);
|
|
120
|
-
border: 1px solid rgba(239, 68, 68, 0.4);
|
|
121
|
-
`;
|
|
122
|
-
const SessionCard = styled__default.default(designSystem.Box)`
|
|
123
|
-
padding: 16px;
|
|
124
|
-
background: ${(p) => p.theme.colors.neutral0};
|
|
125
|
-
border-radius: 10px;
|
|
126
|
-
border: 1px solid rgba(128, 128, 128, 0.2);
|
|
127
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
|
128
|
-
transition: all 0.2s ease;
|
|
129
|
-
|
|
130
|
-
&:hover {
|
|
131
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
132
|
-
border-color: var(--colors-primary600, #0EA5E9);
|
|
133
|
-
}
|
|
134
|
-
`;
|
|
135
|
-
const EmptyState = styled__default.default(designSystem.Box)`
|
|
136
|
-
padding: 32px;
|
|
137
|
-
background: var(--colors-neutral100);
|
|
138
|
-
border-radius: 12px;
|
|
139
|
-
border: 2px dashed rgba(128, 128, 128, 0.2);
|
|
140
|
-
text-align: center;
|
|
141
|
-
`;
|
|
142
|
-
const EmptyIcon = styled__default.default(designSystem.Box)`
|
|
143
|
-
width: 48px;
|
|
144
|
-
height: 48px;
|
|
145
|
-
margin: 0 auto 12px;
|
|
146
|
-
display: flex;
|
|
147
|
-
align-items: center;
|
|
148
|
-
justify-content: center;
|
|
149
|
-
background: rgba(128, 128, 128, 0.2);
|
|
150
|
-
border-radius: 50%;
|
|
151
|
-
color: var(--colors-neutral500);
|
|
152
|
-
`;
|
|
153
|
-
const SectionLabel = styled__default.default(designSystem.Typography)`
|
|
154
|
-
text-transform: uppercase;
|
|
155
|
-
letter-spacing: 0.5px;
|
|
156
|
-
font-size: 11px !important;
|
|
157
|
-
font-weight: 700 !important;
|
|
158
|
-
color: var(--colors-neutral600);
|
|
159
|
-
margin-bottom: 12px;
|
|
160
|
-
display: block;
|
|
161
|
-
`;
|
|
162
|
-
const ActionButton = styled__default.default.button`
|
|
163
|
-
width: 100%;
|
|
164
|
-
padding: 12px 16px;
|
|
165
|
-
border-radius: 8px;
|
|
166
|
-
font-size: 14px;
|
|
167
|
-
font-weight: 600;
|
|
168
|
-
cursor: pointer;
|
|
169
|
-
display: flex;
|
|
170
|
-
align-items: center;
|
|
171
|
-
justify-content: center;
|
|
172
|
-
gap: 8px;
|
|
173
|
-
transition: all 0.2s ease;
|
|
174
|
-
|
|
175
|
-
${(props) => props.$variant === "danger" && `
|
|
176
|
-
background: ${(p) => p.theme.colors.neutral0};
|
|
177
|
-
color: var(--colors-danger600, #DC2626);
|
|
178
|
-
border: 2px solid var(--colors-danger600, #DC2626);
|
|
179
|
-
|
|
180
|
-
&:hover:not(:disabled) {
|
|
181
|
-
background: var(--colors-danger600, #DC2626);
|
|
182
|
-
color: white;
|
|
183
|
-
}
|
|
184
|
-
`}
|
|
185
|
-
|
|
186
|
-
${(props) => props.$variant === "success" && `
|
|
187
|
-
background: ${(p) => p.theme.colors.neutral0};
|
|
188
|
-
color: var(--colors-success600, #16A34A);
|
|
189
|
-
border: 2px solid var(--colors-success600, #16A34A);
|
|
190
|
-
|
|
191
|
-
&:hover:not(:disabled) {
|
|
192
|
-
background: var(--colors-success600, #16A34A);
|
|
193
|
-
color: white;
|
|
194
|
-
}
|
|
195
|
-
`}
|
|
196
|
-
|
|
197
|
-
&:disabled {
|
|
198
|
-
opacity: 0.5;
|
|
199
|
-
cursor: not-allowed;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
svg {
|
|
203
|
-
width: 16px;
|
|
204
|
-
height: 16px;
|
|
205
|
-
}
|
|
206
|
-
`;
|
|
207
|
-
const IconWrapper = styled__default.default(designSystem.Box)`
|
|
208
|
-
width: 32px;
|
|
209
|
-
height: 32px;
|
|
210
|
-
display: flex;
|
|
211
|
-
align-items: center;
|
|
212
|
-
justify-content: center;
|
|
213
|
-
background: var(--colors-neutral100);
|
|
214
|
-
border-radius: 8px;
|
|
215
|
-
flex-shrink: 0;
|
|
216
|
-
|
|
217
|
-
svg {
|
|
218
|
-
width: 16px;
|
|
219
|
-
height: 16px;
|
|
220
|
-
color: var(--colors-neutral600);
|
|
221
|
-
}
|
|
222
|
-
`;
|
|
223
|
-
const SessionInfoPanel = ({ documentId, model, document }) => {
|
|
224
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
225
|
-
const [sessions, setSessions] = react.useState([]);
|
|
226
|
-
const [loading, setLoading] = react.useState(true);
|
|
227
|
-
const [isBlocked, setIsBlocked] = react.useState(false);
|
|
228
|
-
const [actionLoading, setActionLoading] = react.useState(false);
|
|
229
|
-
const { get, post: postRequest } = admin.useFetchClient();
|
|
230
|
-
const { toggleNotification } = admin.useNotification();
|
|
231
|
-
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
232
|
-
const userId = document?.documentId || documentId;
|
|
233
|
-
react.useEffect(() => {
|
|
234
|
-
if (model !== "plugin::users-permissions.user" || !userId) {
|
|
235
|
-
setLoading(false);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const fetchData = async () => {
|
|
239
|
-
try {
|
|
240
|
-
const { data } = await get(`/magic-sessionmanager/user/${userId}/sessions`);
|
|
241
|
-
const activeSessions = (data.data || []).filter((s) => s.isTrulyActive);
|
|
242
|
-
setSessions(activeSessions);
|
|
243
|
-
setIsBlocked(document?.blocked || false);
|
|
244
|
-
} catch (err) {
|
|
245
|
-
console.error("[SessionInfoPanel] Error:", err);
|
|
246
|
-
} finally {
|
|
247
|
-
setLoading(false);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
fetchData();
|
|
251
|
-
}, [userId, model, document, get]);
|
|
252
|
-
const handleLogoutAll = async () => {
|
|
253
|
-
if (!userId) return;
|
|
254
|
-
setActionLoading(true);
|
|
255
|
-
try {
|
|
256
|
-
const response = await postRequest(`/magic-sessionmanager/user/${userId}/terminate-all`);
|
|
257
|
-
if (response.data?.success) {
|
|
258
|
-
toggleNotification({
|
|
259
|
-
type: "success",
|
|
260
|
-
message: t("notifications.success.terminatedAll", "All sessions terminated successfully")
|
|
261
|
-
});
|
|
262
|
-
setSessions([]);
|
|
263
|
-
}
|
|
264
|
-
} catch (error) {
|
|
265
|
-
toggleNotification({
|
|
266
|
-
type: "warning",
|
|
267
|
-
message: t("notifications.error.terminateAll", "Failed to terminate sessions")
|
|
268
|
-
});
|
|
269
|
-
console.error("[SessionInfoPanel] Logout all error:", error);
|
|
270
|
-
} finally {
|
|
271
|
-
setActionLoading(false);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
const handleToggleBlock = async () => {
|
|
275
|
-
if (!userId) return;
|
|
276
|
-
setActionLoading(true);
|
|
277
|
-
try {
|
|
278
|
-
const response = await postRequest(`/magic-sessionmanager/user/${userId}/toggle-block`);
|
|
279
|
-
if (response.data?.success) {
|
|
280
|
-
const newBlockedStatus = response.data.blocked;
|
|
281
|
-
setIsBlocked(newBlockedStatus);
|
|
282
|
-
toggleNotification({
|
|
283
|
-
type: "success",
|
|
284
|
-
message: newBlockedStatus ? t("notifications.success.blocked", "User blocked successfully") : t("notifications.success.unblocked", "User unblocked successfully")
|
|
285
|
-
});
|
|
286
|
-
if (newBlockedStatus) {
|
|
287
|
-
setSessions([]);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
} catch (error) {
|
|
291
|
-
toggleNotification({
|
|
292
|
-
type: "warning",
|
|
293
|
-
message: t("notifications.error.block", "Failed to update user status")
|
|
294
|
-
});
|
|
295
|
-
console.error("[SessionInfoPanel] Toggle block error:", error);
|
|
296
|
-
} finally {
|
|
297
|
-
setActionLoading(false);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
const getDeviceIcon = (deviceType) => {
|
|
301
|
-
if (deviceType === "Mobile" || deviceType === "Tablet") return icons.Phone;
|
|
302
|
-
if (deviceType === "Desktop" || deviceType === "Laptop") return icons.Monitor;
|
|
303
|
-
return icons.Server;
|
|
304
|
-
};
|
|
305
|
-
if (model !== "plugin::users-permissions.user") {
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
if (loading) {
|
|
309
|
-
return {
|
|
310
|
-
title: t("panel.title", "Session Info"),
|
|
311
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("panel.loading", "Loading...") }) })
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
const isOnline = sessions.length > 0;
|
|
315
|
-
return {
|
|
316
|
-
title: t("panel.title", "Session Info"),
|
|
317
|
-
content: /* @__PURE__ */ jsxRuntime.jsx(PanelContainer, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 4, alignItems: "stretch", children: [
|
|
318
|
-
/* @__PURE__ */ jsxRuntime.jsx(StatusCard, { $isOnline: isOnline, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, alignItems: "center", children: [
|
|
319
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
320
|
-
designSystem.Badge,
|
|
321
|
-
{
|
|
322
|
-
backgroundColor: isOnline ? "success600" : "neutral600",
|
|
323
|
-
textColor: "neutral0",
|
|
324
|
-
size: "M",
|
|
325
|
-
style: { fontSize: "12px", padding: "6px 14px", fontWeight: "700" },
|
|
326
|
-
children: isOnline ? t("panel.status.active", "ONLINE") : t("panel.status.offline", "OFFLINE")
|
|
327
|
-
}
|
|
328
|
-
),
|
|
329
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
330
|
-
designSystem.Typography,
|
|
331
|
-
{
|
|
332
|
-
variant: "omega",
|
|
333
|
-
fontWeight: "semiBold",
|
|
334
|
-
textColor: isOnline ? "success700" : "neutral700",
|
|
335
|
-
children: [
|
|
336
|
-
sessions.length,
|
|
337
|
-
" ",
|
|
338
|
-
t("panel.sessions.label", "active session"),
|
|
339
|
-
sessions.length !== 1 ? "s" : ""
|
|
340
|
-
]
|
|
341
|
-
}
|
|
342
|
-
)
|
|
343
|
-
] }) }),
|
|
344
|
-
isBlocked && /* @__PURE__ */ jsxRuntime.jsxs(BlockedWarning, { children: [
|
|
345
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "danger700", children: t("panel.blocked.title", "User is blocked") }),
|
|
346
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", style: { marginTop: "4px" }, children: t("panel.blocked.description", "Authentication disabled") })
|
|
347
|
-
] }),
|
|
348
|
-
sessions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
|
|
349
|
-
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: t("panel.sessions.title", "Active Sessions") }),
|
|
350
|
-
sessions.slice(0, 5).map((session) => {
|
|
351
|
-
const deviceInfo = parseUserAgent(session.userAgent);
|
|
352
|
-
const DeviceIcon = getDeviceIcon(deviceInfo.device);
|
|
353
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SessionCard, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
|
|
354
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
355
|
-
/* @__PURE__ */ jsxRuntime.jsx(IconWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(DeviceIcon, {}) }),
|
|
356
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: deviceInfo.device })
|
|
357
|
-
] }),
|
|
358
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "success600", textColor: "neutral0", size: "S", children: t("panel.sessions.active", "Active") }),
|
|
359
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: [
|
|
360
|
-
deviceInfo.browser,
|
|
361
|
-
" on ",
|
|
362
|
-
deviceInfo.os
|
|
363
|
-
] }),
|
|
364
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
|
|
365
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
366
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Server, { width: "14px", height: "14px", style: { color: "var(--colors-neutral500)" } }),
|
|
367
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: session.ipAddress })
|
|
368
|
-
] }),
|
|
369
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
|
|
370
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Clock, { width: "14px", height: "14px", style: { color: "var(--colors-neutral500)" } }),
|
|
371
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: new Date(session.loginTime).toLocaleString("en-US", {
|
|
372
|
-
month: "short",
|
|
373
|
-
day: "numeric",
|
|
374
|
-
hour: "2-digit",
|
|
375
|
-
minute: "2-digit"
|
|
376
|
-
}) })
|
|
377
|
-
] }),
|
|
378
|
-
session.minutesSinceActive !== void 0 && session.minutesSinceActive < 60 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "success600", fontWeight: "semiBold", children: session.minutesSinceActive === 0 ? t("panel.sessions.activeNow", "Active now") : t("panel.sessions.activeAgo", "Active {minutes} min ago", { minutes: session.minutesSinceActive }) })
|
|
379
|
-
] }) }, session.id);
|
|
380
|
-
}),
|
|
381
|
-
sessions.length > 5 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, background: "primary100", hasRadius: true, style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "primary600", fontWeight: "semiBold", children: [
|
|
382
|
-
"+",
|
|
383
|
-
sessions.length - 5,
|
|
384
|
-
" ",
|
|
385
|
-
t("panel.sessions.more", "more session"),
|
|
386
|
-
sessions.length - 5 !== 1 ? "s" : ""
|
|
387
|
-
] }) })
|
|
388
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(EmptyState, { children: [
|
|
389
|
-
/* @__PURE__ */ jsxRuntime.jsx(EmptyIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(icons.User, { width: "24px", height: "24px" }) }),
|
|
390
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral700", style: { display: "block" }, children: t("panel.empty.title", "No active sessions") }),
|
|
391
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral500", style: { display: "block", marginTop: "4px" }, children: t("panel.empty.description", "User has not logged in yet") })
|
|
392
|
-
] }),
|
|
393
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Divider, {}),
|
|
394
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
|
|
395
|
-
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { children: t("panel.actions.title", "Actions") }),
|
|
396
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
397
|
-
ActionButton,
|
|
398
|
-
{
|
|
399
|
-
$variant: "danger",
|
|
400
|
-
onClick: handleLogoutAll,
|
|
401
|
-
disabled: actionLoading || sessions.length === 0,
|
|
402
|
-
type: "button",
|
|
403
|
-
children: [
|
|
404
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
|
405
|
-
t("panel.actions.terminateAll", "Terminate All Sessions")
|
|
406
|
-
]
|
|
407
|
-
}
|
|
408
|
-
),
|
|
409
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
410
|
-
ActionButton,
|
|
411
|
-
{
|
|
412
|
-
$variant: isBlocked ? "success" : "danger",
|
|
413
|
-
onClick: handleToggleBlock,
|
|
414
|
-
disabled: actionLoading,
|
|
415
|
-
type: "button",
|
|
416
|
-
children: [
|
|
417
|
-
isBlocked ? /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) : /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}),
|
|
418
|
-
isBlocked ? t("panel.actions.unblockUser", "Unblock User") : t("panel.actions.blockUser", "Block User")
|
|
419
|
-
]
|
|
420
|
-
}
|
|
421
|
-
)
|
|
422
|
-
] })
|
|
423
|
-
] }) })
|
|
424
|
-
};
|
|
425
|
-
};
|
|
426
|
-
const prefixPluginTranslations = (data, pluginId2) => {
|
|
427
|
-
const prefixed = {};
|
|
428
|
-
Object.keys(data).forEach((key) => {
|
|
429
|
-
prefixed[`${pluginId2}.${key}`] = data[key];
|
|
430
|
-
});
|
|
431
|
-
return prefixed;
|
|
432
|
-
};
|
|
433
|
-
const name = pluginPkg.strapi.name;
|
|
434
|
-
const index = {
|
|
435
|
-
register(app) {
|
|
436
|
-
const pluginPermissions = [{ action: `plugin::${pluginId}.access`, subject: null }];
|
|
437
|
-
app.addMenuLink({
|
|
438
|
-
to: `plugins/${pluginId}`,
|
|
439
|
-
icon: PluginIcon,
|
|
440
|
-
intlLabel: {
|
|
441
|
-
id: `${pluginId}.plugin.name`,
|
|
442
|
-
defaultMessage: pluginPkg.strapi.displayName
|
|
443
|
-
},
|
|
444
|
-
Component: () => Promise.resolve().then(() => require("./App-B2VCS3cz.js")),
|
|
445
|
-
permissions: pluginPermissions
|
|
446
|
-
});
|
|
447
|
-
app.createSettingSection(
|
|
448
|
-
{
|
|
449
|
-
intlLabel: { id: `${pluginId}.settings.section`, defaultMessage: "Sessions" },
|
|
450
|
-
id: pluginId,
|
|
451
|
-
to: pluginId
|
|
452
|
-
},
|
|
453
|
-
[
|
|
454
|
-
{
|
|
455
|
-
intlLabel: {
|
|
456
|
-
id: `${pluginId}.settings.general`,
|
|
457
|
-
defaultMessage: "General"
|
|
458
|
-
},
|
|
459
|
-
id: "general",
|
|
460
|
-
to: `${pluginId}/general`,
|
|
461
|
-
Component: () => Promise.resolve().then(() => require("./Settings-gv2BF54w.js")),
|
|
462
|
-
permissions: pluginPermissions
|
|
463
|
-
},
|
|
464
|
-
{
|
|
465
|
-
intlLabel: {
|
|
466
|
-
id: `${pluginId}.settings.analytics`,
|
|
467
|
-
defaultMessage: "Analytics"
|
|
468
|
-
},
|
|
469
|
-
id: "analytics",
|
|
470
|
-
to: `${pluginId}/analytics`,
|
|
471
|
-
Component: () => Promise.resolve().then(() => require("./Analytics-D03ZNNMR.js")),
|
|
472
|
-
permissions: pluginPermissions
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
intlLabel: {
|
|
476
|
-
id: `${pluginId}.settings.license`,
|
|
477
|
-
defaultMessage: "Activation"
|
|
478
|
-
},
|
|
479
|
-
id: "license",
|
|
480
|
-
to: `${pluginId}/license`,
|
|
481
|
-
Component: () => Promise.resolve().then(() => require("./License-fixnQ7wF.js")),
|
|
482
|
-
permissions: pluginPermissions
|
|
483
|
-
}
|
|
484
|
-
]
|
|
485
|
-
);
|
|
486
|
-
app.registerPlugin({
|
|
487
|
-
id: pluginId,
|
|
488
|
-
initializer: Initializer,
|
|
489
|
-
isReady: true,
|
|
490
|
-
name
|
|
491
|
-
});
|
|
492
|
-
if ("widgets" in app) {
|
|
493
|
-
app.widgets.register({
|
|
494
|
-
icon: PluginIcon,
|
|
495
|
-
title: {
|
|
496
|
-
id: `${pluginId}.widget.online-users.title`,
|
|
497
|
-
defaultMessage: "Online Users"
|
|
498
|
-
},
|
|
499
|
-
component: async () => {
|
|
500
|
-
const component = await Promise.resolve().then(() => require("./OnlineUsersWidget-qb9utPBy.js"));
|
|
501
|
-
return component.default;
|
|
502
|
-
},
|
|
503
|
-
id: "online-users-widget",
|
|
504
|
-
pluginId
|
|
505
|
-
});
|
|
506
|
-
console.log(`[${pluginId}] [SUCCESS] Online Users Widget registered`);
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
bootstrap(app) {
|
|
510
|
-
console.log(`[${pluginId}] Bootstrapping plugin...`);
|
|
511
|
-
try {
|
|
512
|
-
const contentManagerPlugin = app.getPlugin("content-manager");
|
|
513
|
-
if (contentManagerPlugin && contentManagerPlugin.apis) {
|
|
514
|
-
console.log(`[${pluginId}] Injecting SessionInfoPanel into edit view sidebar...`);
|
|
515
|
-
contentManagerPlugin.apis.addEditViewSidePanel([SessionInfoPanel]);
|
|
516
|
-
console.log(`[${pluginId}] [SUCCESS] SessionInfoPanel injected successfully`);
|
|
517
|
-
} else {
|
|
518
|
-
console.warn(`[${pluginId}] Content Manager plugin or APIs not available`);
|
|
519
|
-
}
|
|
520
|
-
} catch (error) {
|
|
521
|
-
console.error(`[${pluginId}] Error injecting SessionInfoPanel:`, error);
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
async registerTrads({ locales }) {
|
|
525
|
-
const importedTrads = {
|
|
526
|
-
en: () => Promise.resolve().then(() => require("./en-BRmVwd8-.js")),
|
|
527
|
-
de: () => Promise.resolve().then(() => require("./de-BnqGCokx.js")),
|
|
528
|
-
es: () => Promise.resolve().then(() => require("./es-CH691xcL.js")),
|
|
529
|
-
fr: () => Promise.resolve().then(() => require("./fr-CLExO0w_.js")),
|
|
530
|
-
pt: () => Promise.resolve().then(() => require("./pt-BJ_F0yNi.js"))
|
|
531
|
-
};
|
|
532
|
-
const translatedLanguages = Object.keys(importedTrads).filter(
|
|
533
|
-
(lang) => locales.includes(lang)
|
|
534
|
-
);
|
|
535
|
-
const translations = await Promise.all(
|
|
536
|
-
translatedLanguages.map(
|
|
537
|
-
(language) => importedTrads[language]().then(({ default: data }) => ({
|
|
538
|
-
data: prefixPluginTranslations(data, pluginId),
|
|
539
|
-
locale: language
|
|
540
|
-
})).catch(() => ({
|
|
541
|
-
data: {},
|
|
542
|
-
locale: language
|
|
543
|
-
}))
|
|
544
|
-
)
|
|
545
|
-
);
|
|
546
|
-
return Promise.resolve(translations);
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
exports.getTranslation = getTranslation;
|
|
550
|
-
exports.index = index;
|
|
551
|
-
exports.parseUserAgent = parseUserAgent;
|
|
552
|
-
exports.pluginId = pluginId;
|