adminizer 4.1.0-commit.3bf605e → 4.1.0-commit.d8a06d3
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/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-D-Lx670g.js} +1 -1
- package/assets/add-BP_u3Tjl.js +1 -0
- package/assets/add-form-nffmiYTh.js +1 -0
- package/assets/add-group-D4vcHlm-.js +1 -0
- package/assets/{add-group-form-dzadPSfL.js → add-group-form-gNJW11-q.js} +1 -1
- package/assets/add-user-DWh3Nas0.js +1 -0
- package/assets/add-user-form-BJ0FsZYJ.js +1 -0
- package/assets/{app-DMmad2-f.css → app-WTooYWC3.css} +1 -1
- package/assets/{app-layout-D1m9Kvxq.js → app-layout-DYsRFUuP.js} +1 -1
- package/assets/{app-shell-BWMRMkHM.js → app-shell-Dd9Eknik.js} +1 -1
- package/assets/app-sidebar-BOmu6-Sl.js +1 -0
- package/assets/{app-sidebar-header-DLAFi13E.js → app-sidebar-header-CoXSzWxk.js} +1 -1
- package/assets/app.js +2 -2
- package/assets/{breadcrumbs-CQNon4Vl.js → breadcrumbs-BmAq4fHT.js} +1 -1
- package/assets/{button-CQ9t1kLz.js → button-C9B_5Jf_.js} +1 -1
- package/assets/{checkbox-W0nGAXIj.js → checkbox-Fg27sL_1.js} +1 -1
- package/assets/{compiler-runtime-tM4jBQ-T.js → compiler-runtime-hB6dAw2d.js} +1 -1
- package/assets/dashboard-BACj996r.js +3 -0
- package/assets/dashboard-BOltB2Hq.css +1 -0
- package/assets/{date-picker-B__dVVqj.js → date-picker-DI1cCO7K.js} +1 -1
- package/assets/{dropdown-menu-SEBnEIiL.js → dropdown-menu-Bhj17ENm.js} +1 -1
- package/assets/{field-renderer-CapylJU9.js → field-renderer-DVHZF6HS.js} +3 -3
- package/assets/form-BgWdwvz1.js +1 -0
- package/assets/form-DgtErfln.js +1 -0
- package/assets/{geo-json-CwteYDGB.js → geo-json-BjiyTtMu.js} +1 -1
- package/assets/{handsontable-BCnjOpBr.js → handsontable-4mjU_b0n.js} +1 -1
- package/assets/home-CHntBHJa.js +2 -0
- package/assets/{icon-Bz9BMaD0.js → icon-Dt0vBgDO.js} +1 -1
- package/assets/index-B8BS9wMC.js +1 -0
- package/assets/{index-DEk3sC8d.js → index-BKCgnGj_.js} +1 -1
- package/assets/{index-C0SL3SHw.js → index-BykbU6Ee.js} +1 -1
- package/assets/index-CaJgc5EZ.js +1 -0
- package/assets/{index-BcE9FUM6.js → index-Cgp8OfuI.js} +1 -1
- package/assets/{index-DTRTjOmh.js → index-Cw5o84pO.js} +1 -1
- package/assets/{init-user-D9mW-g14.js → init-user-JfCKJ5Ce.js} +1 -1
- package/assets/{input-DF7Ue23C.js → input-CvRbIbk4.js} +1 -1
- package/assets/{input-error-BBygona6.js → input-error-DMK7cAt7.js} +1 -1
- package/assets/{label-Z506NKsW.js → label-CSLFe9Bz.js} +1 -1
- package/assets/list-B2Oa5O_Q.js +1 -0
- package/assets/{list-table-DB1sEQLF.js → list-table-DA9MhywL.js} +5 -5
- package/assets/{login-DrGaTWhY.js → login-DQwGtdis.js} +1 -1
- package/assets/manifest.json +491 -470
- package/assets/{material-icon-CItZiB53.js → material-icon-BJg8o_fs.js} +1 -1
- package/assets/module-DWXp59Vg.js +1 -0
- package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-CJs0_GlD.js} +1 -1
- package/assets/{multi-select-oabtVhUP.js → multi-select-BvRpAW8r.js} +1 -1
- package/assets/{nav-footer-CM-yHiRs.js → nav-footer-Bs4dmN1d.js} +1 -1
- package/assets/{nav-main-Q3xofGRT.js → nav-main-Bq3IMk4C.js} +1 -1
- package/assets/{nav-user-Ds8i0Pa2.js → nav-user-CbB22J5O.js} +1 -1
- package/assets/{pagination-render-B57pOpFy.js → pagination-render-DuXDDbC_.js} +1 -1
- package/assets/{popover-I249Gg2O.js → popover-DtoGI2b1.js} +1 -1
- package/assets/{register-C9FQIDtS.js → register-BSogVF0h.js} +1 -1
- package/assets/{select-D1N8zRPY.js → select-BWepUw-9.js} +1 -1
- package/assets/{sidebar-4D-sX2l4.js → sidebar-CAHsHdjM.js} +2 -2
- package/assets/skeleton-COOcAA8f.js +1 -0
- package/assets/{sonner-Dzckw3U3.js → sonner-BI0IFOQN.js} +1 -1
- package/assets/{toast-editor-FbrFd1ft.js → toast-editor-CMK7QtF1.js} +1 -1
- package/assets/{tooltip-D2ehgLlB.js → tooltip-DHwpLKOI.js} +1 -1
- package/assets/{use-appearance-Co6mO0dV.js → use-appearance-DRfIqTgw.js} +1 -1
- package/assets/{use-window-size-B8l6Bpkf.js → use-window-size-h0Sh_NvX.js} +1 -1
- package/assets/{user-info-DBYoAJYJ.js → user-info-DFrmpJ4y.js} +1 -1
- package/assets/{user-menu-content-qkvdkUVd.js → user-menu-content-DPXQdERj.js} +1 -1
- package/assets/welcome-B4WCIXKf.js +1 -0
- package/controllers/add.js +2 -2
- package/controllers/addGroup.js +2 -4
- package/controllers/addUser.js +4 -6
- package/controllers/catalog/Catalog.js +2 -2
- package/controllers/catalog/FrontentCatalogAdapter.js +1 -2
- package/controllers/ckeditorUpload.js +2 -3
- package/controllers/dashboard.js +16 -2
- package/controllers/edit.js +2 -3
- package/controllers/editGroup.js +2 -4
- package/controllers/editUser.js +3 -5
- package/controllers/form.js +2 -3
- package/controllers/getAllWidgets.js +3 -3
- package/controllers/initUser.js +1 -2
- package/controllers/list.js +4 -4
- package/controllers/login.js +31 -15
- package/controllers/media-manager/mediaManagerAdapter.js +1 -2
- package/controllers/media-manager/mediaManagerApi.js +2 -2
- package/controllers/navigation/edit.js +1 -1
- package/controllers/processInstallFinalize.js +2 -2
- package/controllers/processInstallStep.d.ts +0 -1
- package/controllers/processInstallStep.js +122 -132
- package/controllers/register.js +1 -4
- package/controllers/remove.js +2 -2
- package/controllers/timezones.js +1 -1
- package/controllers/view.js +2 -2
- package/controllers/welcome.js +1 -1
- package/controllers/widgets/Action.js +2 -2
- package/controllers/widgets/Custom.js +2 -2
- package/controllers/widgets/Info.js +2 -2
- package/controllers/widgets/switch.js +2 -2
- package/controllers/widgetsDB.js +5 -5
- package/helpers/accessRightsHelper.d.ts +3 -2
- package/helpers/accessRightsHelper.js +1 -1
- package/helpers/configHelper.js +2 -1
- package/helpers/fieldsHelper.d.ts +1 -1
- package/helpers/inertiaActionsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +1 -1
- package/helpers/inertiaAddHelper.js +2 -0
- package/helpers/inertiaFromHelper.js +2 -0
- package/helpers/inertiaGroupHelper.d.ts +4 -2
- package/helpers/inertiaGroupHelper.js +1 -1
- package/helpers/inertiaListHelper.js +5 -5
- package/helpers/inertiaMenuHelper.js +1 -1
- package/helpers/inertiaUserHelper.d.ts +7 -1
- package/helpers/inertiaUserHelper.js +5 -1
- package/index.d.ts +7 -0
- package/index.js +7 -0
- package/interfaces/adminpanelConfig.d.ts +6 -2
- package/interfaces/global.d.ts +5 -26
- package/lib/Adminizer.d.ts +2 -0
- package/lib/Adminizer.js +17 -1
- package/lib/catalog/AbstractCatalog.js +0 -1
- package/lib/catalog/Navigation.js +6 -6
- package/lib/datatable/NodeTable.js +0 -3
- package/lib/inertia/inertiaAdapter.js +0 -1
- package/lib/installStepper/installStepper.js +5 -5
- package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
- package/lib/media-manager/AbstractMediaManager.js +1 -1
- package/lib/v4/DataAccessor.d.ts +2 -1
- package/lib/v4/DataAccessor.js +2 -2
- package/lib/v4/POWCaptcha.js +0 -1
- package/lib/v4/PolicyManager.js +0 -1
- package/lib/v4/helper/jwt.d.ts +10 -0
- package/lib/v4/helper/jwt.js +18 -0
- package/lib/v4/model/AbstractModel.js +0 -2
- package/lib/v4/model/ModelHandler.js +0 -1
- package/lib/v4/model/adapter/sequelize.d.ts +3 -2
- package/lib/v4/model/adapter/sequelize.js +250 -58
- package/lib/v4/model/adapter/waterline.js +0 -1
- package/lib/widgets/abstractAction.d.ts +1 -1
- package/lib/widgets/abstractCustom.d.ts +27 -12
- package/lib/widgets/abstractCustom.js +8 -2
- package/lib/widgets/abstractInfo.d.ts +1 -1
- package/lib/widgets/abstractInfo.js +1 -1
- package/lib/widgets/abstractLink.d.ts +1 -0
- package/lib/widgets/abstractSwitch.d.ts +1 -1
- package/lib/widgets/abstractWidgetBase.d.ts +1 -1
- package/lib/widgets/widgetHandler.d.ts +20 -3
- package/lib/widgets/widgetHandler.js +25 -25
- package/models/GroupAP.d.ts +8 -0
- package/models/MediaManagerAP.d.ts +16 -0
- package/models/MediaManagerAssociationsAP.d.ts +10 -0
- package/models/MediaManagerMetaAP.d.ts +8 -0
- package/models/NavigationAP.d.ts +5 -0
- package/models/UserAP.d.ts +25 -2
- package/models/UserAP.js +2 -2
- package/package.json +17 -10
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +14 -14
- package/system/bindAuthorization.js +4 -5
- package/system/bindInertia.js +9 -9
- package/system/bindInstallStepper.js +1 -1
- package/system/bindReqFunctions.js +16 -0
- package/translations/ru.json +17 -8
- package/assets/add-ZITr43GJ.js +0 -1
- package/assets/add-form-CYOfr0Ef.js +0 -1
- package/assets/add-group-B332wN8K.js +0 -1
- package/assets/add-user-TC-mYdsB.js +0 -1
- package/assets/add-user-form-y2f_1_lM.js +0 -1
- package/assets/app-sidebar-BCtaEFGb.js +0 -1
- package/assets/dashboard-BR602KhL.js +0 -1
- package/assets/form-DOUNk3o2.js +0 -1
- package/assets/form-lOKv4Qbw.js +0 -1
- package/assets/home-Ch6QfTIt.js +0 -2
- package/assets/index-Cdb9ACvz.js +0 -1
- package/assets/index-K81GbF6O.js +0 -1
- package/assets/list-Qyd7ecQH.js +0 -1
- package/assets/module-DBaykv8l.js +0 -1
- package/assets/welcome-D2adQ8EU.js +0 -1
|
@@ -53,6 +53,6 @@ export class AccessRightsHelper {
|
|
|
53
53
|
Adminizer.log.error("Adminpanel > Token is not valid");
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
return user.groups.some((group) => group.tokens
|
|
56
|
+
return user.groups.some((group) => group.tokens?.includes(tokenId));
|
|
57
57
|
}
|
|
58
58
|
}
|
package/helpers/configHelper.js
CHANGED
|
@@ -77,7 +77,7 @@ export class ConfigHelper {
|
|
|
77
77
|
}
|
|
78
78
|
// Boolean notation: `true` means field is visible; `false` means field is hidden.
|
|
79
79
|
if (typeof config === "boolean") {
|
|
80
|
-
return config ? { title: key } : false;
|
|
80
|
+
return config ? { title: key } : { visible: false };
|
|
81
81
|
}
|
|
82
82
|
// String notation: Interpreted as the field title.
|
|
83
83
|
if (typeof config === "string") {
|
|
@@ -86,6 +86,7 @@ export class ConfigHelper {
|
|
|
86
86
|
// Object notation: Allows full customization of the field.
|
|
87
87
|
if (typeof config === "object" && config !== null) {
|
|
88
88
|
config.title = config.title || key;
|
|
89
|
+
config.visible = config.visible === undefined ? true : Boolean(config.visible);
|
|
89
90
|
// For association types, determine display field by checking model attributes.
|
|
90
91
|
if (["association", "association-many"].includes(config.type)) {
|
|
91
92
|
let associatedModelAttributes = {};
|
|
@@ -4,7 +4,7 @@ export default function inertiaActionsHelper(actionType, entity, req) {
|
|
|
4
4
|
const actions = req.adminizer.menuHelper.getGlobalActions(entity.config, actionType);
|
|
5
5
|
if (actions && actions.length > 0) {
|
|
6
6
|
actions.forEach(function (action) {
|
|
7
|
-
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.
|
|
7
|
+
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user)) {
|
|
8
8
|
resActions.push({
|
|
9
9
|
link: action.link,
|
|
10
10
|
id: action.id,
|
|
@@ -436,7 +436,7 @@ export declare function getControlsOptions(fieldConfig: BaseFieldConfig, req: Re
|
|
|
436
436
|
};
|
|
437
437
|
path: {};
|
|
438
438
|
};
|
|
439
|
-
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "
|
|
439
|
+
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "date" | "time" | "number" | "color" | "month" | "week" | "range" | "text" | "select" | "datetime-local";
|
|
440
440
|
export declare function getControl(req: ReqType, type: ControlType, name: string | undefined, defaultControlName: string): AbstractControls;
|
|
441
441
|
export declare function setSelectMany(isIn: string[], value: string[] | undefined): {
|
|
442
442
|
initOptions: {
|
|
@@ -25,6 +25,8 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
|
|
|
25
25
|
continue;
|
|
26
26
|
let field = fields[key];
|
|
27
27
|
let fieldConfig = field.config;
|
|
28
|
+
if (!!fieldConfig.visible === false)
|
|
29
|
+
continue;
|
|
28
30
|
const type = (fieldConfig.type || fieldConfig.type).toLowerCase();
|
|
29
31
|
//@ts-ignore TODO: fix model validations
|
|
30
32
|
const isIn = typeof fieldConfig.isIn === 'object' ? fieldConfig.isIn : (field.model && typeof { ...field.model.validations }.isIn === 'object' ? { ...field.model.validations }.isIn : []);
|
|
@@ -9,6 +9,8 @@ export default function inertiaFormHelper(req, postLink, formData) {
|
|
|
9
9
|
};
|
|
10
10
|
for (const key of Object.keys(formData)) {
|
|
11
11
|
let field = formData[key];
|
|
12
|
+
if (field.visible === false)
|
|
13
|
+
continue;
|
|
12
14
|
const type = (field.type || field.type).toLowerCase();
|
|
13
15
|
const isIn = field.isIn ?? [];
|
|
14
16
|
let label = field.title ?? '';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { AccessRightsToken, Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface groupedTokens {
|
|
3
5
|
header: string;
|
|
@@ -20,7 +22,7 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
20
22
|
users: PropsField[];
|
|
21
23
|
groupedTokens: groupedTokens[];
|
|
22
24
|
}
|
|
23
|
-
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users:
|
|
25
|
+
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users: UserAP[], groupedTokens: {
|
|
24
26
|
[key: string]: AccessRightsToken[];
|
|
25
|
-
}, group?:
|
|
27
|
+
}, group?: GroupAP, view?: boolean): listProps;
|
|
26
28
|
export {};
|
|
@@ -55,7 +55,7 @@ export function inertiaGroupHelper(entity, req, users, groupedTokens, group, vie
|
|
|
55
55
|
label: token.name,
|
|
56
56
|
tooltip: token.description,
|
|
57
57
|
name: `token-checkbox-${token.id}`,
|
|
58
|
-
value: group ? (group.tokens && group.tokens
|
|
58
|
+
value: group ? (group.tokens && group.tokens?.includes(token.id)) : false,
|
|
59
59
|
type: 'checkbox'
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -24,22 +24,22 @@ export function inertiaListHelper(entity, req, fields) {
|
|
|
24
24
|
searchBtn: req.i18n.__('Search'),
|
|
25
25
|
resetBtn: req.i18n.__('Reset'),
|
|
26
26
|
};
|
|
27
|
-
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.
|
|
27
|
+
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
28
28
|
props.crudActions.createTitle = req.i18n.__('create');
|
|
29
29
|
}
|
|
30
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
30
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
31
31
|
props.crudActions.editTitle = req.i18n.__('Edit');
|
|
32
32
|
}
|
|
33
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.
|
|
33
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.user)) {
|
|
34
34
|
props.crudActions.viewsTitle = req.i18n.__('View');
|
|
35
35
|
}
|
|
36
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.
|
|
36
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.user)) {
|
|
37
37
|
props.crudActions.deleteTitle = req.i18n.__('Delete');
|
|
38
38
|
}
|
|
39
39
|
props.actions = inertiaActionsHelper(actionType, entity, req);
|
|
40
40
|
if (req.adminizer.menuHelper.hasInlineActions(entity.config, 'list')) {
|
|
41
41
|
for (const inlineAction of req.adminizer.menuHelper.getInlineActions(entity.config, 'list')) {
|
|
42
|
-
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.
|
|
42
|
+
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.user)) {
|
|
43
43
|
props.inlineActions.push({
|
|
44
44
|
icon: inlineAction.icon,
|
|
45
45
|
id: inlineAction.id,
|
|
@@ -13,7 +13,7 @@ export class InertiaMenuHelper {
|
|
|
13
13
|
}) : [];
|
|
14
14
|
if (menuItem.accessRightsToken)
|
|
15
15
|
menuItemTokens.push(menuItem.accessRightsToken);
|
|
16
|
-
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.
|
|
16
|
+
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.user)) {
|
|
17
17
|
menu.push(menuItem);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface listProps extends Record<string | number | symbol, unknown> {
|
|
3
5
|
edit: boolean;
|
|
@@ -16,6 +18,10 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
16
18
|
fields: PropsField[];
|
|
17
19
|
groups: PropsField[];
|
|
18
20
|
locales: Record<string, string>[];
|
|
21
|
+
userPretend: {
|
|
22
|
+
label: string;
|
|
23
|
+
postLink: string;
|
|
24
|
+
};
|
|
19
25
|
}
|
|
20
|
-
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups:
|
|
26
|
+
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups: GroupAP[], user?: UserAP, view?: boolean): listProps;
|
|
21
27
|
export {};
|
|
@@ -6,6 +6,10 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
|
|
|
6
6
|
title: req.i18n.__('Back'),
|
|
7
7
|
link: entity.uri
|
|
8
8
|
},
|
|
9
|
+
userPretend: {
|
|
10
|
+
label: req.i18n.__('Pretend to be a user'),
|
|
11
|
+
postLink: `${req.adminizer.config.routePrefix}/model/userap/login`
|
|
12
|
+
},
|
|
9
13
|
passwordError: req.i18n.__('Values in "password" and "repeatPassword" fields should be the same'),
|
|
10
14
|
btnSave: {
|
|
11
15
|
title: req.i18n.__('Save')
|
|
@@ -58,7 +62,7 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
|
|
|
58
62
|
value: user?.locale ?? ''
|
|
59
63
|
});
|
|
60
64
|
}
|
|
61
|
-
if (req.
|
|
65
|
+
if (req.user.isAdministrator) {
|
|
62
66
|
props.fields.push({
|
|
63
67
|
label: req.i18n.__('Profile expires'),
|
|
64
68
|
type: 'date',
|
package/index.d.ts
CHANGED
|
@@ -8,4 +8,11 @@ export * from "./interfaces/adminpanelConfig";
|
|
|
8
8
|
export * from "./lib/v4/model/AbstractModel";
|
|
9
9
|
export * from "./lib/v4/model/adapter/waterline";
|
|
10
10
|
export * from "./lib/v4/model/adapter/typeorm";
|
|
11
|
+
export * from "./lib/v4/model/adapter/sequelize";
|
|
11
12
|
export * from "./lib/Adminizer";
|
|
13
|
+
export * from "./models/GroupAP";
|
|
14
|
+
export * from "./models/UserAP";
|
|
15
|
+
export * from "./models/MediaManagerAP";
|
|
16
|
+
export * from "./models/MediaManagerAssociationsAP";
|
|
17
|
+
export * from "./models/MediaManagerMetaAP";
|
|
18
|
+
export * from "./models/NavigationAP";
|
package/index.js
CHANGED
|
@@ -8,4 +8,11 @@ export * from "./interfaces/adminpanelConfig";
|
|
|
8
8
|
export * from "./lib/v4/model/AbstractModel";
|
|
9
9
|
export * from "./lib/v4/model/adapter/waterline";
|
|
10
10
|
export * from "./lib/v4/model/adapter/typeorm";
|
|
11
|
+
export * from "./lib/v4/model/adapter/sequelize";
|
|
11
12
|
export * from "./lib/Adminizer";
|
|
13
|
+
export * from "./models/GroupAP";
|
|
14
|
+
export * from "./models/UserAP";
|
|
15
|
+
export * from "./models/MediaManagerAP";
|
|
16
|
+
export * from "./models/MediaManagerAssociationsAP";
|
|
17
|
+
export * from "./models/MediaManagerMetaAP";
|
|
18
|
+
export * from "./models/NavigationAP";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MaterialIcon } from "./MaaterialIcons";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
3
|
import { GridSettings as HandsontableSettings } from "handsontable/settings";
|
|
4
|
+
import { GroupAP } from "models/GroupAP";
|
|
5
|
+
import { UserAP } from "models/UserAP";
|
|
4
6
|
export type AdminpanelIcon = MaterialIcon;
|
|
5
7
|
export type FieldsTypes = "string" | "password" | "date" | "datetime" | "time" | "integer" | "number" | "float" | "color" | "email" | "month" | "week" | "range" | "boolean" | "binary" | "text" | "longtext" | "mediumtext" | "ckeditor" | "wysiwyg" | "texteditor" | "word" | 'tui' | 'tuieditor' | 'toast-ui' | "jsoneditor" | "json" | "array" | "object" | "ace" | "code" | "html" | "xml" | "aceeditor" | "menu" | "schedule" | "worktime" | "association" | "association-many" | "select" | "select-many" | "table" | "geojson" | "mediamanager" |
|
|
6
8
|
/**
|
|
@@ -268,8 +270,8 @@ export interface ModelConfig {
|
|
|
268
270
|
} | string;
|
|
269
271
|
userAccessRelationCallback?: (userWithGroups: UserWithGroups, record: any) => boolean;
|
|
270
272
|
}
|
|
271
|
-
type UserWithGroups =
|
|
272
|
-
groups:
|
|
273
|
+
type UserWithGroups = UserAP & {
|
|
274
|
+
groups: GroupAP[];
|
|
273
275
|
};
|
|
274
276
|
export interface FieldsForms {
|
|
275
277
|
[key: string]: FormFieldConfig;
|
|
@@ -316,6 +318,8 @@ export interface BaseFieldConfig {
|
|
|
316
318
|
disabled?: boolean;
|
|
317
319
|
/** Show as required element HTML */
|
|
318
320
|
required?: boolean;
|
|
321
|
+
/** show or hode element, default `true` */
|
|
322
|
+
visible?: boolean;
|
|
319
323
|
}
|
|
320
324
|
export interface TuiEditorFieldConfig extends BaseFieldConfig {
|
|
321
325
|
type: 'tui' | 'tuieditor' | 'toast-ui';
|
package/interfaces/global.d.ts
CHANGED
|
@@ -4,15 +4,10 @@ import multer from "multer";
|
|
|
4
4
|
import { I18n } from "../lib/v4/I18n";
|
|
5
5
|
import { Inertia } from "../lib/inertia/inertiaAdapter";
|
|
6
6
|
import { Flash } from "../lib/inertia/flash";
|
|
7
|
+
import { UserAP } from "models/UserAP";
|
|
7
8
|
declare global {
|
|
9
|
+
/** @deprecated use import from TS model decalration */
|
|
8
10
|
type ModelsAP = {
|
|
9
|
-
GroupAP: {
|
|
10
|
-
id?: number;
|
|
11
|
-
name: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
tokens?: string[];
|
|
14
|
-
users?: ModelsAP["UserAP"][];
|
|
15
|
-
};
|
|
16
11
|
MediaManagerAP: {
|
|
17
12
|
id?: string;
|
|
18
13
|
parent?: ModelsAP["MediaManagerAP"];
|
|
@@ -48,36 +43,20 @@ declare global {
|
|
|
48
43
|
label: string;
|
|
49
44
|
tree: any;
|
|
50
45
|
};
|
|
51
|
-
UserAP: {
|
|
52
|
-
id?: number;
|
|
53
|
-
login?: string;
|
|
54
|
-
fullName?: string;
|
|
55
|
-
email?: string;
|
|
56
|
-
passwordHashed?: string;
|
|
57
|
-
password?: string;
|
|
58
|
-
timezone?: string;
|
|
59
|
-
expires?: string;
|
|
60
|
-
locale?: string;
|
|
61
|
-
isDeleted?: boolean;
|
|
62
|
-
isActive?: boolean;
|
|
63
|
-
isAdministrator?: boolean;
|
|
64
|
-
groups?: ModelsAP["GroupAP"][];
|
|
65
|
-
widgets?: any;
|
|
66
|
-
isConfirmed?: boolean;
|
|
67
|
-
};
|
|
68
46
|
};
|
|
69
47
|
type reqSession = {
|
|
70
48
|
flashMessages: Record<string, string[]>;
|
|
71
49
|
xInertiaCurrentComponent: string | undefined;
|
|
72
|
-
UserAP:
|
|
50
|
+
UserAP: UserAP;
|
|
73
51
|
messages: {
|
|
74
52
|
adminError: string[];
|
|
75
53
|
adminSuccess: string[];
|
|
76
54
|
};
|
|
77
|
-
|
|
55
|
+
userPretended?: UserAP;
|
|
78
56
|
};
|
|
79
57
|
type FlashMessages = 'info' | 'error' | 'success' | string;
|
|
80
58
|
type ReqType = Request & {
|
|
59
|
+
user: UserAP;
|
|
81
60
|
Inertia: Inertia;
|
|
82
61
|
flash: Flash<FlashMessages>;
|
|
83
62
|
session: reqSession;
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -24,8 +24,10 @@ export declare class Adminizer {
|
|
|
24
24
|
widgetHandler: WidgetHandler;
|
|
25
25
|
vite: ViteDevServer;
|
|
26
26
|
controlsHandler: ControlsHandler;
|
|
27
|
+
jwtSecret: string;
|
|
27
28
|
static logger: winston.Logger;
|
|
28
29
|
constructor(ormAdapters: AbstractAdapter[]);
|
|
30
|
+
getMiddleware(): (req: any, res: any) => void;
|
|
29
31
|
/**
|
|
30
32
|
* Vite middleware
|
|
31
33
|
* @protected
|
package/lib/Adminizer.js
CHANGED
|
@@ -29,6 +29,7 @@ import { bindInertia } from "../system/bindInertia";
|
|
|
29
29
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
30
30
|
import { bindControls } from "../system/bindControls";
|
|
31
31
|
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
32
|
+
import { v4 as uuid } from "uuid";
|
|
32
33
|
export class Adminizer {
|
|
33
34
|
app;
|
|
34
35
|
config;
|
|
@@ -42,6 +43,7 @@ export class Adminizer {
|
|
|
42
43
|
widgetHandler;
|
|
43
44
|
vite;
|
|
44
45
|
controlsHandler;
|
|
46
|
+
jwtSecret = process.env.JWT_SECRET ?? uuid();
|
|
45
47
|
static logger = winston.createLogger({
|
|
46
48
|
level: "info",
|
|
47
49
|
format: winston.format.combine(winston.format.timestamp(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
@@ -58,6 +60,21 @@ export class Adminizer {
|
|
|
58
60
|
this._emitter = new EventEmitter();
|
|
59
61
|
this.ormAdapters = ormAdapters;
|
|
60
62
|
}
|
|
63
|
+
getMiddleware() {
|
|
64
|
+
return (req, res) => {
|
|
65
|
+
this.app(req, res, (err) => {
|
|
66
|
+
if (err) {
|
|
67
|
+
console.error("Error in Adminizer", err);
|
|
68
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
69
|
+
res.end('Internal Server Error');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
73
|
+
res.end('Route Not Found in Adminizer');
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
61
78
|
/**
|
|
62
79
|
* Vite middleware
|
|
63
80
|
* @protected
|
|
@@ -105,7 +122,6 @@ export class Adminizer {
|
|
|
105
122
|
set: configForms.set ?? defaultForms.set
|
|
106
123
|
}
|
|
107
124
|
};
|
|
108
|
-
// console.log("CONFIG", this.config)
|
|
109
125
|
this.modelHandler = new ModelHandler();
|
|
110
126
|
await bindModels(this);
|
|
111
127
|
await bindForms(this);
|
|
@@ -207,7 +207,6 @@ export class AbstractCatalog {
|
|
|
207
207
|
else {
|
|
208
208
|
action = this.actionHandlers.find((it) => it.id === actionId);
|
|
209
209
|
}
|
|
210
|
-
// console.log(this.actionHandlers)
|
|
211
210
|
if (!action)
|
|
212
211
|
throw `Action with id \`${actionId}\` not found`;
|
|
213
212
|
return await action.handler(items, config);
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
// let items = await this.adminizer.modelHandler.model.get(this.model)["_find"]({})
|
|
327
327
|
//
|
|
328
328
|
// // This dirty hack is here because the field of view is disappearing
|
|
329
|
-
// req.i18n.setLocale(req.
|
|
329
|
+
// req.i18n.setLocale(req.user.locale);
|
|
330
330
|
// const __ = (s: string) => {
|
|
331
331
|
// return req.i18n.__(s)
|
|
332
332
|
// }
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
// let type: 'html' = 'html'
|
|
355
355
|
//
|
|
356
356
|
// // This dirty hack is here because the field of view is disappearing
|
|
357
|
-
// req.i18n.setLocale(req.
|
|
357
|
+
// req.i18n.setLocale(req.user.locale);
|
|
358
358
|
// const __ = (s: string) => {
|
|
359
359
|
// return req.i18n.__(s)
|
|
360
360
|
// }
|
|
@@ -433,7 +433,7 @@
|
|
|
433
433
|
// let type: 'html' = 'html'
|
|
434
434
|
//
|
|
435
435
|
// // This dirty hack is here because the field of view is disappearing
|
|
436
|
-
// req.i18n.setLocale(req.
|
|
436
|
+
// req.i18n.setLocale(req.user.locale);
|
|
437
437
|
// const __ = (s: string) => {
|
|
438
438
|
// return req.i18n.__(s)
|
|
439
439
|
// }
|
|
@@ -460,7 +460,7 @@
|
|
|
460
460
|
// let item = await this.find(id, catalogId)
|
|
461
461
|
//
|
|
462
462
|
// // This dirty hack is here because the field of view is disappearing
|
|
463
|
-
// req.i18n.setLocale(req.
|
|
463
|
+
// req.i18n.setLocale(req.user.locale);
|
|
464
464
|
// const __ = (s: string) => {
|
|
465
465
|
// return req.i18n.__(s)
|
|
466
466
|
// }
|
|
@@ -496,7 +496,7 @@
|
|
|
496
496
|
//
|
|
497
497
|
// getAddHTML(req: ReqType): Promise<{ type: "link" | "html" | "jsonForm"; data: string }> {
|
|
498
498
|
// let type: 'html' = 'html'
|
|
499
|
-
// req.i18n.setLocale(req.
|
|
499
|
+
// req.i18n.setLocale(req.user.locale);
|
|
500
500
|
//
|
|
501
501
|
// const __ = (s: string) => {
|
|
502
502
|
// return req.i18n.__(s)
|
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
// let type: 'html' = 'html'
|
|
515
515
|
// let item = await this.find(id, catalogId)
|
|
516
516
|
//
|
|
517
|
-
// req.i18n.setLocale(req.
|
|
517
|
+
// req.i18n.setLocale(req.user.locale);
|
|
518
518
|
// const __ = (s: string) => {
|
|
519
519
|
// return req.i18n.__(s)
|
|
520
520
|
// }
|
|
@@ -98,7 +98,6 @@ export class NodeTable {
|
|
|
98
98
|
columnQuery = { [fieldsArray[parseInt(columnName)]]: { contains: searchStr } };
|
|
99
99
|
break;
|
|
100
100
|
default:
|
|
101
|
-
// Пропускаем json, ref и ассоциации
|
|
102
101
|
break;
|
|
103
102
|
}
|
|
104
103
|
}
|
|
@@ -135,7 +134,6 @@ export class NodeTable {
|
|
|
135
134
|
const totalRecords = await this.model.count({});
|
|
136
135
|
const filteredRecords = await this.model.count(queryOptions.where);
|
|
137
136
|
const data = await this.model.find(queryOptions, dataAccessor);
|
|
138
|
-
console.log(data, "data");
|
|
139
137
|
const output = {
|
|
140
138
|
draw: this.request.draw !== "" ? this.request.draw : 0,
|
|
141
139
|
recordsTotal: totalRecords,
|
|
@@ -201,7 +199,6 @@ export class NodeTable {
|
|
|
201
199
|
});
|
|
202
200
|
out.push(row);
|
|
203
201
|
});
|
|
204
|
-
console.log(out);
|
|
205
202
|
return out;
|
|
206
203
|
}
|
|
207
204
|
}
|
|
@@ -21,7 +21,6 @@ const inertiaExpressAdapter = function ({ version, html, flashMessages, enableRe
|
|
|
21
21
|
if (!['GET', 'HEAD', 'OPTIONS'].includes(req.method)) {
|
|
22
22
|
const csrfCookie = req.cookies['XSRF-TOKEN'];
|
|
23
23
|
const csrfHeader = req.headers[csrf.headerName || 'x-xsrf-token'];
|
|
24
|
-
// console.log('headers:', req.headers['x-xsrf-token']);
|
|
25
24
|
if (!csrfCookie || !csrfHeader || csrfCookie !== csrfHeader) {
|
|
26
25
|
res.status(403).send({ message: 'Invalid CSRF token' });
|
|
27
26
|
return;
|
|
@@ -91,21 +91,21 @@ export class InstallStepper {
|
|
|
91
91
|
let leftSteps = this.steps.filter(step => !step.isProcessed && !step.isSkipped);
|
|
92
92
|
// set locale
|
|
93
93
|
if (typeof req.adminizer.config.translation !== "boolean") {
|
|
94
|
-
if (!req.
|
|
95
|
-
req.
|
|
94
|
+
if (!req.user.locale || !req.adminizer.config.translation.locales.includes(req.user.locale)) {
|
|
95
|
+
req.user.locale = req.adminizer.config.translation.defaultLocale || "en";
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
req.
|
|
99
|
+
req.user.locale = "en";
|
|
100
100
|
}
|
|
101
|
-
this.context.locale = req.
|
|
101
|
+
this.context.locale = req.user.locale;
|
|
102
102
|
// translate step
|
|
103
103
|
stepToRender = TranslationHelper.translateProperties(req.i18n, stepToRender, ["title", "description", "name"]);
|
|
104
104
|
return {
|
|
105
105
|
totalStepCount: this.steps.length,
|
|
106
106
|
leftStepsCount: leftSteps.length,
|
|
107
107
|
currentStep: stepToRender,
|
|
108
|
-
locale: req.
|
|
108
|
+
locale: req.user.locale
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
async skipStep(stepId) {
|
|
@@ -143,10 +143,10 @@ export declare abstract class AbstractMediaManager {
|
|
|
143
143
|
uloadAllowedTypes: string[];
|
|
144
144
|
dir: string;
|
|
145
145
|
/**
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
*/
|
|
148
148
|
allowSearch: boolean;
|
|
149
|
-
|
|
149
|
+
/**⚠️ above the settings that need to be implemented*/
|
|
150
150
|
/**
|
|
151
151
|
* id for mediamanager instance
|
|
152
152
|
*/
|
package/lib/v4/DataAccessor.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
import { Entity } from "../../interfaces/types";
|
|
5
5
|
import { ActionType } from "../../interfaces/adminpanelConfig";
|
|
6
6
|
import { Fields } from "../../helpers/fieldsHelper";
|
|
7
|
+
import { UserAP } from "models/UserAP";
|
|
7
8
|
export declare class DataAccessor {
|
|
8
9
|
private readonly adminizer;
|
|
9
|
-
user:
|
|
10
|
+
user: UserAP;
|
|
10
11
|
entity: Entity;
|
|
11
12
|
action: ActionType;
|
|
12
13
|
private fields;
|
package/lib/v4/DataAccessor.js
CHANGED
|
@@ -8,7 +8,7 @@ export class DataAccessor {
|
|
|
8
8
|
fields = null;
|
|
9
9
|
constructor(req, entity, action) {
|
|
10
10
|
this.adminizer = req.adminizer;
|
|
11
|
-
this.user = req.
|
|
11
|
+
this.user = req.user;
|
|
12
12
|
this.entity = entity;
|
|
13
13
|
this.action = action;
|
|
14
14
|
}
|
|
@@ -26,7 +26,7 @@ export class DataAccessor {
|
|
|
26
26
|
}
|
|
27
27
|
// get action and field configs
|
|
28
28
|
const actionConfig = ControllerHelper.findActionConfig(this.entity, this.action);
|
|
29
|
-
const fieldsConfig = this.entity.config
|
|
29
|
+
const fieldsConfig = this.entity.config?.fields || {};
|
|
30
30
|
const modelAttributes = this.entity.model.attributes;
|
|
31
31
|
const result = {};
|
|
32
32
|
Object.entries(modelAttributes).forEach(([key, modelField]) => {
|
package/lib/v4/POWCaptcha.js
CHANGED
|
@@ -54,7 +54,6 @@ export class POWCaptcha {
|
|
|
54
54
|
if (!task || task.label !== label)
|
|
55
55
|
return false;
|
|
56
56
|
// Verify the solution (should be equal to puzzleOptions.message)
|
|
57
|
-
// console.log("QUESTION", `${taskId}:${label}`)
|
|
58
57
|
if (`${taskId}:${label}` === captchaSolution) {
|
|
59
58
|
this.deleteTask(taskId);
|
|
60
59
|
return true;
|
package/lib/v4/PolicyManager.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function signUser(user: JwtPayload, JWT_SECRET: string): string;
|
|
2
|
+
interface JwtPayload {
|
|
3
|
+
id: number;
|
|
4
|
+
login: string;
|
|
5
|
+
isAdministrator?: boolean;
|
|
6
|
+
iat?: number;
|
|
7
|
+
exp?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function verifyUser(token: string, JWT_SECRET: string): JwtPayload | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import jwt from 'jsonwebtoken';
|
|
2
|
+
export function signUser(user, JWT_SECRET) {
|
|
3
|
+
return jwt.sign(user, JWT_SECRET, {
|
|
4
|
+
expiresIn: '15d',
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export function verifyUser(token, JWT_SECRET) {
|
|
8
|
+
try {
|
|
9
|
+
const decoded = jwt.verify(token, JWT_SECRET);
|
|
10
|
+
if (typeof decoded === 'object' && decoded !== null && 'id' in decoded && 'login' in decoded) {
|
|
11
|
+
return decoded;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -17,13 +17,11 @@ export class AbstractModel {
|
|
|
17
17
|
async findOne(criteria, dataAccessor) {
|
|
18
18
|
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
19
19
|
let record = await this._findOne(criteria);
|
|
20
|
-
console.log(record, "record");
|
|
21
20
|
return record ? dataAccessor.process(record) : null;
|
|
22
21
|
}
|
|
23
22
|
async find(criteria, dataAccessor) {
|
|
24
23
|
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
25
24
|
let records = await this._find(criteria);
|
|
26
|
-
console.log(records, "records");
|
|
27
25
|
return records.map(record => dataAccessor.process(record));
|
|
28
26
|
}
|
|
29
27
|
async updateOne(criteria, data, dataAccessor) {
|
|
@@ -8,7 +8,6 @@ export class ModelHandler {
|
|
|
8
8
|
}
|
|
9
9
|
this.models.set(modelname, modelInstance);
|
|
10
10
|
Adminizer.log.debug(`Model with name [${modelname}] was registered`);
|
|
11
|
-
console.log(`Model with name [${modelname}] was registered`);
|
|
12
11
|
}
|
|
13
12
|
/** Improved model getter, so you can write both model.get("UserAP") and model.get("userap") */
|
|
14
13
|
get model() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Sequelize, ModelStatic } from "sequelize";
|
|
2
|
-
import { AbstractAdapter, AbstractModel, FindOptions } from "../AbstractModel";
|
|
2
|
+
import { AbstractAdapter, AbstractModel, Attribute, FindOptions } from "../AbstractModel";
|
|
3
|
+
export declare function mapSequelizeToWaterline(model: ModelStatic<any>): Record<string, Attribute>;
|
|
3
4
|
export declare class SequelizeModel<T> extends AbstractModel<T> {
|
|
4
5
|
private model;
|
|
5
6
|
constructor(modelName: string, model: ModelStatic<any>);
|
|
@@ -21,6 +22,6 @@ export declare class SequelizeAdapter extends AbstractAdapter {
|
|
|
21
22
|
get models(): Record<string, any>;
|
|
22
23
|
getModel(modelName: string): any;
|
|
23
24
|
getAttributes(modelName: string): any;
|
|
24
|
-
/**
|
|
25
|
+
/**Registration of system models*/
|
|
25
26
|
static registerSystemModels(sequelize: Sequelize): Promise<void>;
|
|
26
27
|
}
|