adminizer 4.3.0-build.79 → 4.3.0-build.81
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/assets/add-ChaPnvFv.js +1 -0
- package/assets/{add-form-C04ZI5LT.js → add-form-DNqlORQQ.js} +1 -1
- package/assets/add-group-D6YsQVrC.js +1 -0
- package/assets/{add-group-form-CyRwxTs3.js → add-group-form-CDi1y4af.js} +1 -1
- package/assets/{add-user-form-yp020h4r.js → add-user-form-BzXHahSY.js} +1 -1
- package/assets/add-user-psdNyGx8.js +1 -0
- package/assets/{app-CpGtjhxF.css → app-PLVuwM-H.css} +1 -1
- package/assets/{app-layout-BmT5KQwc.js → app-layout-AWzEe1aH.js} +1 -1
- package/assets/{app-sidebar-4lm9f_CG.js → app-sidebar-Bd4nWVXq.js} +1 -1
- package/assets/app-sidebar-header-jBFp1qZb.js +1 -0
- package/assets/app.js +3 -3
- package/assets/{catalog-CG_EB2kz.js → catalog-XiWBZptC.js} +1 -1
- package/assets/{dashboard-CsmJfdLb.js → dashboard-DcRJErQB.js} +1 -1
- package/assets/date-picker-A6CYw4SC.js +1 -0
- package/assets/del-modal-0klf0PNC.js +1 -0
- package/assets/{field-renderer-Bp1lfm0v.js → field-renderer-CYB5W2He.js} +3 -3
- package/assets/form-B-he6_tT.js +1 -0
- package/assets/{form-CSTeMDf5.js → form-BGRpsR-M.js} +1 -1
- package/assets/{home-D00XjLjD.js → home-B7aZTHTv.js} +2 -2
- package/assets/icon-k6999vVE.js +1 -0
- package/assets/{init-user-L-oxFTOv.js → init-user-Btm16ElL.js} +1 -1
- package/assets/input-error-Dbp_lp61.js +1 -0
- package/assets/list-_tZumymo.js +1 -0
- package/assets/{list-table-vIvydJV2.js → list-table-OzVUH7i4.js} +4 -4
- package/assets/{login-DLMJ6l_r.js → login-DeqxLVx3.js} +1 -1
- package/assets/manifest.json +74 -74
- package/assets/material-icon-B9BY_7p9.js +1 -0
- package/assets/{media-manager-ASGJ4PcS.js → media-manager-DQ5CA_na.js} +1 -1
- package/assets/{module-mxngd2cA.js → module-Drcr0QjC.js} +1 -1
- package/assets/{nav-footer-DbGCtmmN.js → nav-footer-DWHxIgb7.js} +1 -1
- package/assets/{nav-main-BcWhl71g.js → nav-main-CRT9ezos.js} +1 -1
- package/assets/notification-C7K-zK4k.js +27 -0
- package/assets/{register-C_W_hOmq.js → register-CMhPasDj.js} +1 -1
- package/assets/tabs-GDFuClHU.js +1 -0
- package/assets/{theme-switcher-D1G6OSMc.js → theme-switcher-C35zBCil.js} +1 -1
- package/assets/{welcome-FHRCdke0.js → welcome-CbhDDQlg.js} +1 -1
- package/controllers/add.js +1 -1
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +4 -4
- package/controllers/edit.js +1 -15
- package/controllers/list.js +2 -2
- package/controllers/login.js +2 -2
- package/controllers/navigation/edit.js +1 -1
- package/controllers/notifications/NotificationController.d.ts +5 -5
- package/controllers/notifications/NotificationController.js +77 -78
- package/controllers/remove.js +1 -11
- package/controllers/view.js +1 -1
- package/helpers/configHelper.d.ts +1 -1
- package/helpers/fieldsHelper.d.ts +1 -1
- package/helpers/fieldsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +1 -1
- package/helpers/translationHelper.d.ts +1 -1
- package/helpers/translationHelper.js +1 -1
- package/index.d.ts +14 -13
- package/index.js +14 -13
- package/interfaces/adminpanelConfig.d.ts +1 -1
- package/interfaces/global.d.ts +3 -3
- package/interfaces/types.d.ts +10 -1
- package/lib/Adminizer.d.ts +7 -7
- package/lib/Adminizer.js +7 -7
- package/lib/{v4/DataAccessor.d.ts → DataAccessor.d.ts} +4 -4
- package/lib/{v4/DataAccessor.js → DataAccessor.js} +3 -3
- package/lib/{v4/I18n.js → I18n.js} +2 -2
- package/lib/{v4/PolicyManager.d.ts → PolicyManager.d.ts} +1 -1
- package/lib/{v4/PolicyManager.js → PolicyManager.js} +2 -2
- package/lib/{v4/catalog → catalog}/AbstractCatalog.d.ts +1 -1
- package/lib/{v4/catalog → catalog}/Navigation.d.ts +2 -2
- package/lib/{v4/catalog → catalog}/Navigation.js +1 -1
- package/lib/{v4/controls → controls}/AbstractControls.d.ts +1 -1
- package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{v4/controls → controls}/table/Handsontable.d.ts +1 -1
- package/lib/{v4/controls → controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{v4/datatable → datatable}/NodeTable.d.ts +1 -1
- package/lib/{v4/model → model}/AbstractModel.d.ts +12 -0
- package/lib/model/AbstractModel.js +178 -0
- package/lib/{v4/model → model}/ModelHandler.js +1 -1
- package/lib/{v4/model → model}/adapter/sequelize.d.ts +0 -1
- package/lib/{v4/model → model}/adapter/sequelize.js +7 -4
- package/lib/{v4/notifications → notifications}/AbstractNotificationService.d.ts +14 -7
- package/lib/notifications/AbstractNotificationService.js +233 -0
- package/lib/{v4/notifications → notifications}/GeneralNotificationService.d.ts +1 -1
- package/lib/{v4/notifications → notifications}/GeneralNotificationService.js +4 -2
- package/lib/notifications/NotificationHandler.d.ts +27 -0
- package/lib/notifications/NotificationHandler.js +41 -0
- package/lib/{v4/notifications → notifications}/SystemNotificationService.d.ts +5 -4
- package/lib/notifications/SystemNotificationService.js +173 -0
- package/lib/{v4/widgets → widgets}/abstractCustom.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractLink.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/abstractWidgetBase.d.ts +1 -1
- package/lib/{v4/widgets → widgets}/widgetHandler.d.ts +2 -2
- package/migrations/index.d.ts +3 -0
- package/migrations/index.js +4 -0
- package/migrations/index.ts +5 -0
- package/migrations/umzug/0001.d.ts +7 -0
- package/migrations/umzug/0001.js +119 -0
- package/migrations/umzug/0001.ts +132 -0
- package/migrations/umzug.d.ts +2 -0
- package/migrations/umzug.js +8 -0
- package/migrations/umzug.ts +9 -0
- package/models/NotificationAP.d.ts +8 -0
- package/models/NotificationAP.js +8 -0
- package/models/UserAP.d.ts +1 -1
- package/package.json +5 -4
- package/system/Router.js +4 -8
- package/system/bindControls.js +6 -6
- package/system/bindInertia.js +4 -3
- package/system/bindNavigation.js +1 -1
- package/system/bindNotifications.js +3 -3
- package/system/bindReqFunctions.js +8 -25
- package/system/defaults.js +1 -1
- package/ui/components/ui/table.d.ts +1 -1
- package/ui/components/ui/table.js +2 -2
- package/assets/add-DSapOiv0.js +0 -1
- package/assets/add-group-DWR7SBTO.js +0 -1
- package/assets/add-user-acATGxUL.js +0 -1
- package/assets/app-sidebar-header-CxXmzszq.js +0 -1
- package/assets/date-picker-By3kj-Rx.js +0 -1
- package/assets/del-modal-DlcbcdR5.js +0 -1
- package/assets/form-CxHRGp7p.js +0 -1
- package/assets/icon-ButfCBrt.js +0 -1
- package/assets/input-error-CHsDLcK0.js +0 -1
- package/assets/list-4TOTsjqE.js +0 -1
- package/assets/material-icon-sXk4BK-N.js +0 -1
- package/assets/notification-BEfA5sT6.js +0 -1
- package/assets/tabs-CgZW_LLn.js +0 -1
- package/lib/v4/model/AbstractModel.js +0 -79
- package/lib/v4/notifications/AbstractNotificationService.js +0 -150
- package/lib/v4/notifications/NotificationHandler.d.ts +0 -69
- package/lib/v4/notifications/NotificationHandler.js +0 -127
- package/lib/v4/notifications/SystemNotificationService.js +0 -124
- /package/lib/{v4/I18n.d.ts → I18n.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.d.ts → POWCaptcha.d.ts} +0 -0
- /package/lib/{v4/POWCaptcha.js → POWCaptcha.js} +0 -0
- /package/lib/{v4/catalog → catalog}/AbstractCatalog.js +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{v4/catalog → catalog}/CatalogHandler.js +0 -0
- /package/lib/{v4/controls → controls}/AbstractControls.js +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{v4/controls → controls}/ControlsHandler.js +0 -0
- /package/lib/{v4/controls → controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{v4/controls → controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{v4/controls → controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{v4/controls → controls}/table/Handsontable.js +0 -0
- /package/lib/{v4/controls → controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{v4/datatable → datatable}/NodeTable.js +0 -0
- /package/lib/{v4/helper → helper}/jwt.d.ts +0 -0
- /package/lib/{v4/helper → helper}/jwt.js +0 -0
- /package/lib/{v4/inertia → inertia}/flash.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/flash.js +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{v4/inertia → inertia}/inertiaAdapter.js +0 -0
- /package/lib/{v4/model → model}/ModelHandler.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.d.ts +0 -0
- /package/lib/{v4/model → model}/adapter/waterline.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractAction.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractCustom.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractInfo.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractLink.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.d.ts +0 -0
- /package/lib/{v4/widgets → widgets}/abstractSwitch.js +0 -0
- /package/lib/{v4/widgets → widgets}/abstractWidgetBase.js +0 -0
- /package/lib/{v4/widgets → widgets}/widgetHandler.js +0 -0
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { Adminizer } from '../../lib/Adminizer';
|
|
2
2
|
export class NotificationController {
|
|
3
|
-
static async
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
static async search(req, res) {
|
|
4
|
+
NotificationController.checkNotifPermission(req, res);
|
|
5
|
+
if (req.method.toUpperCase() === 'POST') {
|
|
6
|
+
const { s, notificationClass } = req.body;
|
|
7
|
+
const hasPermission = req.adminizer.accessRightsHelper.hasPermission(`notification-${notificationClass}`, req.user);
|
|
8
|
+
if (!hasPermission) {
|
|
9
|
+
res.status(403).json({ error: 'Forbidden' });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const service = req.adminizer.notificationHandler.getService(notificationClass);
|
|
13
|
+
res.json(await service.search(s, req.user.id));
|
|
6
14
|
}
|
|
15
|
+
}
|
|
16
|
+
static async viewAll(req, res) {
|
|
17
|
+
NotificationController.checkNotifPermission(req, res);
|
|
7
18
|
return req.Inertia.render({
|
|
8
19
|
component: 'notification',
|
|
9
20
|
props: {
|
|
@@ -11,9 +22,24 @@ export class NotificationController {
|
|
|
11
22
|
}
|
|
12
23
|
});
|
|
13
24
|
}
|
|
25
|
+
static async getNotificationClasses(req, res) {
|
|
26
|
+
NotificationController.checkNotifPermission(req, res);
|
|
27
|
+
if (req.adminizer.config.notifications.enabled === false)
|
|
28
|
+
return res.json([]);
|
|
29
|
+
const services = req.adminizer.notificationHandler.getAllServices();
|
|
30
|
+
let activeServices = [];
|
|
31
|
+
for (const service of services) {
|
|
32
|
+
// Получаем только клиентов текущего пользователя
|
|
33
|
+
const userClients = service.getUserClients(req.user.id);
|
|
34
|
+
if (userClients.size > 0) {
|
|
35
|
+
activeServices.push(service.notificationClass);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return res.json(activeServices);
|
|
39
|
+
}
|
|
14
40
|
// Единый SSE endpoint для всех уведомлений
|
|
15
41
|
static async getNotificationsStream(req, res) {
|
|
16
|
-
NotificationController.
|
|
42
|
+
NotificationController.checkNotifPermission(req, res);
|
|
17
43
|
// Устанавливаем заголовки для SSE
|
|
18
44
|
res.setHeader('Content-Type', 'text/event-stream');
|
|
19
45
|
res.setHeader('Cache-Control', 'no-cache');
|
|
@@ -25,10 +51,13 @@ export class NotificationController {
|
|
|
25
51
|
const sendEvent = (event) => {
|
|
26
52
|
// Фильтруем уведомления по правам пользователя
|
|
27
53
|
if (event.type === 'notification') {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
54
|
+
const notificationClass = event.notificationClass;
|
|
55
|
+
// ЕДИНАЯ проверка прав через AccessRightsHelper
|
|
56
|
+
const hasPermission = req.adminizer.accessRightsHelper.hasPermission(`notification-${notificationClass}`, req.user);
|
|
57
|
+
if (!hasPermission) {
|
|
58
|
+
return; // Пользователь не имеет прав на этот класс уведомлений
|
|
31
59
|
}
|
|
60
|
+
// Проверка персональных уведомлений (только для целевого пользователя)
|
|
32
61
|
if (event.userId !== null && event.userId !== req.user.id) {
|
|
33
62
|
return;
|
|
34
63
|
}
|
|
@@ -38,14 +67,15 @@ export class NotificationController {
|
|
|
38
67
|
};
|
|
39
68
|
// Подключаем клиента ко всем сервисам
|
|
40
69
|
const services = req.adminizer.notificationHandler.getAllServices();
|
|
41
|
-
services.
|
|
42
|
-
|
|
70
|
+
const allowedServices = services.filter(service => req.adminizer.accessRightsHelper.hasPermission(`notification-${service.notificationClass}`, req.user));
|
|
71
|
+
allowedServices.forEach(service => {
|
|
72
|
+
service.addClient(clientId, sendEvent, req.user);
|
|
43
73
|
// Для системного сервиса добавляем клиента в CRUD каналы
|
|
44
|
-
if (service.notificationClass === 'system'
|
|
74
|
+
if (service.notificationClass === 'system') {
|
|
45
75
|
const systemService = service;
|
|
46
|
-
// Добавляем клиента в основные CRUD каналы
|
|
76
|
+
// Добавляем клиента в основные CRUD каналы с указанием userId
|
|
47
77
|
['created', 'updated', 'deleted', 'system'].forEach(channel => {
|
|
48
|
-
systemService.addClientToChannel(clientId, channel);
|
|
78
|
+
systemService.addClientToChannel(clientId, channel, req.user.id);
|
|
49
79
|
});
|
|
50
80
|
}
|
|
51
81
|
});
|
|
@@ -57,24 +87,6 @@ export class NotificationController {
|
|
|
57
87
|
clientId: clientId
|
|
58
88
|
}
|
|
59
89
|
});
|
|
60
|
-
// Отправляем историю уведомлений (с учетом прав доступа)
|
|
61
|
-
// try {
|
|
62
|
-
// const notifications = await req.adminizer.notificationHandler.getUserNotifications(
|
|
63
|
-
// req.user,
|
|
64
|
-
// 4,
|
|
65
|
-
// true
|
|
66
|
-
// );
|
|
67
|
-
// notifications.forEach(notification => {
|
|
68
|
-
// sendEvent({
|
|
69
|
-
// type: 'notification',
|
|
70
|
-
// data: notification,
|
|
71
|
-
// notificationClass: notification.notificationClass,
|
|
72
|
-
// userId: notification.userId ?? null
|
|
73
|
-
// });
|
|
74
|
-
// });
|
|
75
|
-
// } catch (error) {
|
|
76
|
-
// Adminizer.log.error('Error sending notification history:', error);
|
|
77
|
-
// }
|
|
78
90
|
// Обработка закрытия соединения
|
|
79
91
|
req.on('close', () => {
|
|
80
92
|
// Отключаем клиента от всех сервисов
|
|
@@ -84,7 +96,7 @@ export class NotificationController {
|
|
|
84
96
|
if (service.notificationClass === 'system') {
|
|
85
97
|
const systemService = service;
|
|
86
98
|
if (systemService.removeClientFromAllChannels) {
|
|
87
|
-
systemService.removeClientFromAllChannels(clientId);
|
|
99
|
+
systemService.removeClientFromAllChannels(clientId, req.user.id);
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
});
|
|
@@ -107,16 +119,18 @@ export class NotificationController {
|
|
|
107
119
|
}
|
|
108
120
|
// API для получения уведомлений по классу
|
|
109
121
|
static async getNotificationsByClass(req, res) {
|
|
110
|
-
NotificationController.
|
|
122
|
+
NotificationController.checkNotifPermission(req, res);
|
|
111
123
|
try {
|
|
112
124
|
const { notificationClass } = req.params;
|
|
113
|
-
const { limit =
|
|
114
|
-
// Проверяем права доступа
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
const { limit = 20, skip = 0, unreadOnly = false } = req.query;
|
|
126
|
+
// Проверяем права доступа
|
|
127
|
+
const hasPermission = req.adminizer.accessRightsHelper.hasPermission(`notification-${notificationClass}`, req.user);
|
|
128
|
+
if (!hasPermission) {
|
|
129
|
+
res.status(403).json({ error: 'Forbidden' });
|
|
117
130
|
return;
|
|
118
131
|
}
|
|
119
|
-
const
|
|
132
|
+
const service = req.adminizer.notificationHandler.getService(notificationClass);
|
|
133
|
+
const notifications = await service.getNotifications(req.user?.id, Number(limit), Number(skip), unreadOnly === 'true');
|
|
120
134
|
res.json(notifications);
|
|
121
135
|
}
|
|
122
136
|
catch (error) {
|
|
@@ -126,21 +140,20 @@ export class NotificationController {
|
|
|
126
140
|
}
|
|
127
141
|
// API для получения всех уведомлений пользователя
|
|
128
142
|
static async getUserNotifications(req, res) {
|
|
129
|
-
NotificationController.
|
|
143
|
+
NotificationController.checkNotifPermission(req, res);
|
|
144
|
+
const { limit = 4, skip = 0, unreadOnly = false } = req.query;
|
|
130
145
|
try {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const notifications = await req.adminizer.notificationHandler.getUserNotifications(req.user, 50, false);
|
|
143
|
-
res.json(notifications);
|
|
146
|
+
// Фильтруем сервисы по правам доступа
|
|
147
|
+
const services = req.adminizer.notificationHandler.getAllServices();
|
|
148
|
+
const allowedServices = services.filter(service => req.adminizer.accessRightsHelper.hasPermission(`notification-${service.notificationClass}`, req.user));
|
|
149
|
+
const allNotifications = [];
|
|
150
|
+
for (const service of allowedServices) {
|
|
151
|
+
const notifications = await service.getNotifications(req.user.id, Number(limit), Number(skip), unreadOnly === 'true');
|
|
152
|
+
allNotifications.push(...notifications);
|
|
153
|
+
}
|
|
154
|
+
// Сортируем по дате создания
|
|
155
|
+
const sortedNotifications = allNotifications.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).slice(0, Number(limit));
|
|
156
|
+
res.json(sortedNotifications);
|
|
144
157
|
}
|
|
145
158
|
catch (error) {
|
|
146
159
|
Adminizer.log.error('Error getting user notifications:', error);
|
|
@@ -149,15 +162,11 @@ export class NotificationController {
|
|
|
149
162
|
}
|
|
150
163
|
// API для пометки как прочитанного
|
|
151
164
|
static async markAsRead(req, res) {
|
|
152
|
-
NotificationController.
|
|
165
|
+
NotificationController.checkNotifPermission(req, res);
|
|
153
166
|
try {
|
|
154
167
|
const { notificationClass, id } = req.params;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
res.status(403).json({ error: 'Forbidden: Admin access required' });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
await req.adminizer.notificationHandler.markAsRead(notificationClass, id, req.user.id);
|
|
168
|
+
const service = req.adminizer.notificationHandler.getService(notificationClass);
|
|
169
|
+
await service.markAsRead(req.user.id, id);
|
|
161
170
|
res.json({ success: true });
|
|
162
171
|
}
|
|
163
172
|
catch (error) {
|
|
@@ -165,36 +174,26 @@ export class NotificationController {
|
|
|
165
174
|
res.status(500).json({ error: 'Internal server error' });
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
NotificationController.checkPermission(req, res);
|
|
171
|
-
// Проверяем права админа
|
|
172
|
-
if (!NotificationController.isAdmin(req.user)) {
|
|
173
|
-
res.status(403).json({ error: 'Forbidden: Admin access required' });
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
177
|
+
static async markAllAsRead(req, res) {
|
|
178
|
+
NotificationController.checkNotifPermission(req, res);
|
|
176
179
|
try {
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
+
const services = req.adminizer.notificationHandler.getAllServices();
|
|
181
|
+
for (const service of services) {
|
|
182
|
+
await service.markAllAsRead(req.user.id);
|
|
183
|
+
}
|
|
184
|
+
res.json({ success: true });
|
|
180
185
|
}
|
|
181
186
|
catch (error) {
|
|
182
|
-
Adminizer.log.error('Error
|
|
187
|
+
Adminizer.log.error('Error marking all notifications as read:', error);
|
|
183
188
|
res.status(500).json({ error: 'Internal server error' });
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
|
-
|
|
187
|
-
static isAdmin(user) {
|
|
188
|
-
if (!user)
|
|
189
|
-
return false;
|
|
190
|
-
return user.isAdministrator === true;
|
|
191
|
-
}
|
|
192
|
-
static checkPermission(req, res) {
|
|
191
|
+
static checkNotifPermission(req, res) {
|
|
193
192
|
if (!req.adminizer?.notificationHandler) {
|
|
194
193
|
res.status(500).json({ error: 'Notification system not initialized' });
|
|
195
194
|
return;
|
|
196
195
|
}
|
|
197
|
-
// Проверяем аутентификацию
|
|
196
|
+
// // Проверяем аутентификацию
|
|
198
197
|
if (req.adminizer.config.auth.enable && !req.user) {
|
|
199
198
|
res.status(401).json({ error: 'Unauthorized' });
|
|
200
199
|
return;
|
package/controllers/remove.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
2
|
import { deleteRelationsMediaManager } from "../lib/media-manager/helpers/MediaManagerHelper";
|
|
3
|
-
import { DataAccessor } from "../lib/
|
|
3
|
+
import { DataAccessor } from "../lib/DataAccessor";
|
|
4
4
|
import { Adminizer } from "../lib/Adminizer";
|
|
5
|
-
import { formatChanges, sanitizeForDiff } from "../helpers/diffHelpers";
|
|
6
|
-
import { diff } from "deep-object-diff";
|
|
7
5
|
export default async function remove(req, res) {
|
|
8
6
|
// Checking id of the record
|
|
9
7
|
if (!req.params.id) {
|
|
@@ -70,14 +68,6 @@ export default async function remove(req, res) {
|
|
|
70
68
|
Adminizer.log.error('adminpanel > error', e);
|
|
71
69
|
}
|
|
72
70
|
if (destroyedRecord) {
|
|
73
|
-
const cleanRecordBeforeDelete = sanitizeForDiff(destroyedRecord[0]);
|
|
74
|
-
const changesDiff = diff(cleanRecordBeforeDelete, {});
|
|
75
|
-
const formattedChanges = formatChanges(changesDiff, cleanRecordBeforeDelete, {});
|
|
76
|
-
// log system event notification с diff
|
|
77
|
-
await req.adminizer.logSystemDeletedEvent(req.i18n.__('Deleted'), `user ${req.user.login} ${req.i18n.__('delete')} ${entity.name} ${destroyedRecord[0].id}`, {
|
|
78
|
-
changes: formattedChanges,
|
|
79
|
-
summary: `${req.i18n.__('Deleted')} ${formattedChanges.length} ${req.i18n.__('fields')}`
|
|
80
|
-
});
|
|
81
71
|
req.flash.setFlashMessage('success', req.i18n.__('Record was removed successfully !'));
|
|
82
72
|
}
|
|
83
73
|
else {
|
package/controllers/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
|
-
import { DataAccessor } from "../lib/
|
|
2
|
+
import { DataAccessor } from "../lib/DataAccessor";
|
|
3
3
|
import { Adminizer } from "../lib/Adminizer";
|
|
4
4
|
import { inertiaUserHelper } from "../helpers/inertiaUserHelper";
|
|
5
5
|
import { inertiaGroupHelper } from "../helpers/inertiaGroupHelper";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdminpanelConfig, BaseFieldConfig } from "../interfaces/adminpanelConfig";
|
|
2
|
-
import { Attribute } from "../lib/
|
|
2
|
+
import { Attribute } from "../lib/model/AbstractModel";
|
|
3
3
|
import { Adminizer } from "../lib/Adminizer";
|
|
4
4
|
export declare class ConfigHelper {
|
|
5
5
|
adminizer: Adminizer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ActionType, BaseFieldConfig, FieldsTypes, ModelConfig } from "../interfaces/adminpanelConfig";
|
|
2
|
-
import { Attribute } from "../lib/
|
|
2
|
+
import { Attribute } from "../lib/model/AbstractModel";
|
|
3
3
|
export type Field = {
|
|
4
4
|
config: BaseFieldConfig & {
|
|
5
5
|
/** @deprecated record should not be in config anymore */
|
package/helpers/fieldsHelper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Entity, PropsField } from "../interfaces/types";
|
|
2
2
|
import { Actions } from "./inertiaActionsHelper";
|
|
3
3
|
import { Fields, Field } from "./fieldsHelper";
|
|
4
|
-
import { AbstractControls, ControlType } from "../lib/
|
|
4
|
+
import { AbstractControls, ControlType } from "../lib/controls/AbstractControls";
|
|
5
5
|
export type PropsFieldType = 'text' | 'number' | 'range' | 'week' | 'month' | 'email' | 'color' | 'time' | 'date' | 'datetime-local' | 'password' | 'select' | 'select-many' | 'association-many' | 'association' | 'textarea' | 'mediamanager' | 'checkbox' | ControlType;
|
|
6
6
|
interface FieldProps extends Record<string | number | symbol, unknown> {
|
|
7
7
|
edit: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Adminizer } from "../lib/Adminizer";
|
|
2
|
-
import { I18n } from "../lib/
|
|
2
|
+
import { I18n } from "../lib/I18n";
|
|
3
3
|
export declare class TranslationHelper {
|
|
4
4
|
static loadTranslations(adminizer: Adminizer, translationsPath: string): void;
|
|
5
5
|
static translateProperties(i18n: I18n, object: any, fields: string[]): any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import { Adminizer } from "../lib/Adminizer";
|
|
4
|
-
import { I18n } from "../lib/
|
|
4
|
+
import { I18n } from "../lib/I18n";
|
|
5
5
|
export class TranslationHelper {
|
|
6
6
|
static loadTranslations(adminizer, translationsPath) {
|
|
7
7
|
let translationsConfig = adminizer.config.translation;
|
package/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export * from "./helpers/configHelper";
|
|
2
2
|
export * from "./helpers/accessRightsHelper";
|
|
3
|
-
export * from "./lib/
|
|
4
|
-
export * from "./lib/
|
|
5
|
-
export * from "./lib/
|
|
6
|
-
export * from "./lib/
|
|
7
|
-
export * from "./lib/
|
|
8
|
-
export * from "./lib/
|
|
9
|
-
export * from "./lib/
|
|
10
|
-
export * from "./lib/
|
|
11
|
-
export * from "./lib/
|
|
12
|
-
export * from "./lib/
|
|
3
|
+
export * from "./lib/widgets/abstractAction";
|
|
4
|
+
export * from "./lib/widgets/abstractInfo";
|
|
5
|
+
export * from "./lib/widgets/abstractCustom";
|
|
6
|
+
export * from "./lib/widgets/abstractLink";
|
|
7
|
+
export * from "./lib/widgets/abstractWidgetBase";
|
|
8
|
+
export * from "./lib/widgets/abstractSwitch";
|
|
9
|
+
export * from "./lib/widgets/widgetHandler";
|
|
10
|
+
export * from "./lib/catalog/AbstractCatalog";
|
|
11
|
+
export * from "./lib/catalog/Navigation";
|
|
12
|
+
export * from "./lib/catalog/CatalogHandler";
|
|
13
13
|
export * from "./lib/media-manager/MediaManagerHandler";
|
|
14
14
|
export * from "./interfaces/adminpanelConfig";
|
|
15
15
|
export * from "./interfaces/types";
|
|
16
16
|
export * from "./interfaces/MaaterialIcons";
|
|
17
|
-
export * from "./lib/
|
|
18
|
-
export * from "./lib/
|
|
19
|
-
export * from "./lib/
|
|
17
|
+
export * from "./lib/model/AbstractModel";
|
|
18
|
+
export * from "./lib/model/adapter/waterline";
|
|
19
|
+
export * from "./lib/model/adapter/sequelize";
|
|
20
20
|
export * from "./lib/Adminizer";
|
|
21
21
|
export * from "./models/GroupAP";
|
|
22
22
|
export * from "./models/UserAP";
|
|
@@ -24,3 +24,4 @@ export * from "./models/MediaManagerAP";
|
|
|
24
24
|
export * from "./models/MediaManagerAssociationsAP";
|
|
25
25
|
export * from "./models/MediaManagerMetaAP";
|
|
26
26
|
export * from "./models/NavigationAP";
|
|
27
|
+
export * from "./migrations";
|
package/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
export * from "./helpers/configHelper";
|
|
2
2
|
export * from "./helpers/accessRightsHelper";
|
|
3
|
-
export * from "./lib/
|
|
4
|
-
export * from "./lib/
|
|
5
|
-
export * from "./lib/
|
|
6
|
-
export * from "./lib/
|
|
7
|
-
export * from "./lib/
|
|
8
|
-
export * from "./lib/
|
|
9
|
-
export * from "./lib/
|
|
10
|
-
export * from "./lib/
|
|
11
|
-
export * from "./lib/
|
|
12
|
-
export * from "./lib/
|
|
3
|
+
export * from "./lib/widgets/abstractAction";
|
|
4
|
+
export * from "./lib/widgets/abstractInfo";
|
|
5
|
+
export * from "./lib/widgets/abstractCustom";
|
|
6
|
+
export * from "./lib/widgets/abstractLink";
|
|
7
|
+
export * from "./lib/widgets/abstractWidgetBase";
|
|
8
|
+
export * from "./lib/widgets/abstractSwitch";
|
|
9
|
+
export * from "./lib/widgets/widgetHandler";
|
|
10
|
+
export * from "./lib/catalog/AbstractCatalog";
|
|
11
|
+
export * from "./lib/catalog/Navigation";
|
|
12
|
+
export * from "./lib/catalog/CatalogHandler";
|
|
13
13
|
export * from "./lib/media-manager/MediaManagerHandler";
|
|
14
14
|
export * from "./interfaces/adminpanelConfig";
|
|
15
15
|
export * from "./interfaces/types";
|
|
16
16
|
export * from "./interfaces/MaaterialIcons";
|
|
17
|
-
export * from "./lib/
|
|
18
|
-
export * from "./lib/
|
|
19
|
-
export * from "./lib/
|
|
17
|
+
export * from "./lib/model/AbstractModel";
|
|
18
|
+
export * from "./lib/model/adapter/waterline";
|
|
19
|
+
export * from "./lib/model/adapter/sequelize";
|
|
20
20
|
export * from "./lib/Adminizer";
|
|
21
21
|
export * from "./models/GroupAP";
|
|
22
22
|
export * from "./models/UserAP";
|
|
@@ -24,3 +24,4 @@ export * from "./models/MediaManagerAP";
|
|
|
24
24
|
export * from "./models/MediaManagerAssociationsAP";
|
|
25
25
|
export * from "./models/MediaManagerMetaAP";
|
|
26
26
|
export * from "./models/NavigationAP";
|
|
27
|
+
export * from "./migrations";
|
package/interfaces/global.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Adminizer } from "../lib/Adminizer";
|
|
2
2
|
import { NextFunction, Request, Response } from "express";
|
|
3
3
|
import multer from "multer";
|
|
4
|
-
import { I18n } from "../lib/
|
|
5
|
-
import { Inertia } from "../lib/
|
|
6
|
-
import { Flash } from "../lib/
|
|
4
|
+
import { I18n } from "../lib/I18n";
|
|
5
|
+
import { Inertia } from "../lib/inertia/inertiaAdapter";
|
|
6
|
+
import { Flash } from "../lib/inertia/flash";
|
|
7
7
|
import { UserAP } from "models/UserAP";
|
|
8
8
|
declare global {
|
|
9
9
|
/** @deprecated use import from TS model decalration */
|
package/interfaces/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractModel } from "../lib/
|
|
1
|
+
import { AbstractModel } from "../lib/model/AbstractModel";
|
|
2
2
|
import { ModelConfig } from "./adminpanelConfig";
|
|
3
3
|
export type EntityType = "form" | "model";
|
|
4
4
|
export interface Entity {
|
|
@@ -57,3 +57,12 @@ export interface INotificationEvent {
|
|
|
57
57
|
channel?: string;
|
|
58
58
|
userId?: number;
|
|
59
59
|
}
|
|
60
|
+
export type Migration = {
|
|
61
|
+
name: string;
|
|
62
|
+
up: (args: {
|
|
63
|
+
context: any;
|
|
64
|
+
}) => Promise<unknown> | unknown;
|
|
65
|
+
down: (args: {
|
|
66
|
+
context: any;
|
|
67
|
+
}) => Promise<unknown> | unknown;
|
|
68
|
+
};
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ import express, { Express } from "express";
|
|
|
2
2
|
import winston from "winston";
|
|
3
3
|
import EventEmitter from 'events';
|
|
4
4
|
import { AdminpanelConfig } from "../interfaces/adminpanelConfig";
|
|
5
|
-
import PolicyManager from "./
|
|
6
|
-
import { ModelHandler } from "./
|
|
7
|
-
import { WidgetHandler } from "./
|
|
5
|
+
import PolicyManager from "./PolicyManager";
|
|
6
|
+
import { ModelHandler } from "./model/ModelHandler";
|
|
7
|
+
import { WidgetHandler } from "./widgets/widgetHandler";
|
|
8
8
|
import { AccessRightsHelper } from "../helpers/accessRightsHelper";
|
|
9
9
|
import { ConfigHelper } from "../helpers/configHelper";
|
|
10
|
-
import { AbstractAdapter } from "./
|
|
10
|
+
import { AbstractAdapter } from "./model/AbstractModel";
|
|
11
11
|
import type { ViteDevServer } from 'vite';
|
|
12
12
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
13
|
-
import { ControlsHandler } from "./
|
|
14
|
-
import { CatalogHandler } from "./
|
|
15
|
-
import { NotificationHandler } from './
|
|
13
|
+
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
14
|
+
import { CatalogHandler } from "./catalog/CatalogHandler";
|
|
15
|
+
import { NotificationHandler } from './notifications/NotificationHandler';
|
|
16
16
|
import { INotification } from "../interfaces/types";
|
|
17
17
|
export declare class Adminizer {
|
|
18
18
|
/**
|
package/lib/Adminizer.js
CHANGED
|
@@ -3,7 +3,7 @@ import cookieParser from 'cookie-parser';
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import winston from "winston";
|
|
5
5
|
import EventEmitter from 'events';
|
|
6
|
-
import PolicyManager from "./
|
|
6
|
+
import PolicyManager from "./PolicyManager";
|
|
7
7
|
import Router from "./../system/Router";
|
|
8
8
|
import bindAssets from "../system/bindAssets";
|
|
9
9
|
import bindDev from "../system/bindDev";
|
|
@@ -15,19 +15,19 @@ import bindAuthorization from "../system/bindAuthorization";
|
|
|
15
15
|
import bindModels from "../system/bindModels";
|
|
16
16
|
import bindForms from "../system/bindForms";
|
|
17
17
|
import bindTranslations from "../system/bindTranslations";
|
|
18
|
-
import { ModelHandler } from "./
|
|
19
|
-
import { WidgetHandler } from "./
|
|
18
|
+
import { ModelHandler } from "./model/ModelHandler";
|
|
19
|
+
import { WidgetHandler } from "./widgets/widgetHandler";
|
|
20
20
|
import { AccessRightsHelper } from "../helpers/accessRightsHelper";
|
|
21
21
|
import bindReqFunctions from "../system/bindReqFunctions";
|
|
22
22
|
import { ConfigHelper } from "../helpers/configHelper";
|
|
23
|
-
import { I18n } from "./
|
|
23
|
+
import { I18n } from "./I18n";
|
|
24
24
|
import { getDefaultConfig } from "../system/defaults";
|
|
25
25
|
import bindExpressUtils from "../system/bindExpressUtils";
|
|
26
26
|
import { bindInertia } from "../system/bindInertia";
|
|
27
27
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
28
28
|
import { bindControls } from "../system/bindControls";
|
|
29
|
-
import { ControlsHandler } from "./
|
|
30
|
-
import { CatalogHandler } from "./
|
|
29
|
+
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
30
|
+
import { CatalogHandler } from "./catalog/CatalogHandler";
|
|
31
31
|
import { v4 as uuid } from "uuid";
|
|
32
32
|
import { bindNotifications } from "../system/bindNotifications";
|
|
33
33
|
export class Adminizer {
|
|
@@ -199,7 +199,7 @@ export class Adminizer {
|
|
|
199
199
|
bindInertia(this);
|
|
200
200
|
await bindAuthorization(this);
|
|
201
201
|
// Bind notifications
|
|
202
|
-
if (this.config.
|
|
202
|
+
if (this.config.notifications.enabled)
|
|
203
203
|
await bindNotifications(this);
|
|
204
204
|
await Router.bind(this); // must be after binding policies and req/res functions
|
|
205
205
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The class manages the interaction between the user and the database entry, taking into account user permissions and the main config file settings.
|
|
3
3
|
*/
|
|
4
|
-
import { Entity } from "
|
|
5
|
-
import { ActionType } from "
|
|
6
|
-
import { Fields } from "
|
|
7
|
-
import { Adminizer } from "
|
|
4
|
+
import { Entity } from "../interfaces/types";
|
|
5
|
+
import { ActionType } from "../interfaces/adminpanelConfig";
|
|
6
|
+
import { Fields } from "../helpers/fieldsHelper";
|
|
7
|
+
import { Adminizer } from "./Adminizer";
|
|
8
8
|
import { UserAP } from "models/UserAP";
|
|
9
9
|
export declare class DataAccessor {
|
|
10
10
|
readonly adminizer: Adminizer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ControllerHelper } from "
|
|
2
|
-
import { Adminizer } from "
|
|
3
|
-
import { isObject } from "
|
|
1
|
+
import { ControllerHelper } from "../helpers/controllerHelper";
|
|
2
|
+
import { Adminizer } from "./Adminizer";
|
|
3
|
+
import { isObject } from "../helpers/JsUtils";
|
|
4
4
|
export class DataAccessor {
|
|
5
5
|
adminizer;
|
|
6
6
|
user;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { vsprintf } from "sprintf-js";
|
|
4
|
-
import { Adminizer } from "
|
|
4
|
+
import { Adminizer } from "./Adminizer";
|
|
5
5
|
export class I18n {
|
|
6
6
|
devMode;
|
|
7
7
|
static locales = {};
|
|
@@ -18,7 +18,7 @@ export class I18n {
|
|
|
18
18
|
constructor(options = {}) {
|
|
19
19
|
this.devMode = process.env.NODE_ENV !== "production";
|
|
20
20
|
this.defaultLocale = options.defaultLocale || "en";
|
|
21
|
-
this.directory = options.directory || path.join(import.meta.filename, '
|
|
21
|
+
this.directory = options.directory || path.join(import.meta.filename, '../../translations');
|
|
22
22
|
this.extension = options.extension || ".json";
|
|
23
23
|
this.cookieName = options.cookieName || "lang";
|
|
24
24
|
this.sessionVarName = options.sessionVarName || "locale";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "./Adminizer";
|
|
4
4
|
import { pathToFileURL } from "url";
|
|
5
5
|
class PolicyManager {
|
|
6
6
|
_adminizer;
|
|
@@ -9,7 +9,7 @@ class PolicyManager {
|
|
|
9
9
|
}
|
|
10
10
|
async loadPolicies() {
|
|
11
11
|
try {
|
|
12
|
-
const policiesDirPath = path.join(import.meta.dirname, "
|
|
12
|
+
const policiesDirPath = path.join(import.meta.dirname, "../policies");
|
|
13
13
|
const policiesDir = fs.readdirSync(policiesDirPath);
|
|
14
14
|
for (const policyFile of policiesDir) {
|
|
15
15
|
if (path.extname(policyFile).toLowerCase() === ".js") {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractCatalog, ActionHandler, Item } from "./AbstractCatalog";
|
|
2
|
-
import { NavigationConfig } from "
|
|
3
|
-
import { Adminizer } from "
|
|
2
|
+
import { NavigationConfig } from "../../interfaces/adminpanelConfig";
|
|
3
|
+
import { Adminizer } from "../Adminizer";
|
|
4
4
|
export interface NavItem extends Item {
|
|
5
5
|
urlPath?: string;
|
|
6
6
|
modelId?: string | number;
|