adminizer 4.1.0-commit.ad1476a → 4.1.1
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/Readme.md +46 -0
- package/assets/{VanillaJSONEditor-FUe77pIA.js → VanillaJSONEditor-DfRefswH.js} +104 -104
- package/assets/add-CJ1-zeA1.js +1 -0
- package/assets/add-form-CbNl0wdS.js +1 -0
- package/assets/add-group-form-Bt_Dx9wm.js +1 -0
- package/assets/add-group-pIFJV5qL.js +1 -0
- package/assets/add-user-D2US8hL_.js +1 -0
- package/assets/add-user-form-Bt8Jy6S2.js +1 -0
- package/assets/{app-DMmad2-f.css → app-B6cCPfWk.css} +1 -1
- package/assets/app-layout-B86jl9bH.js +1 -0
- package/assets/app-shell-CiGyzQ0C.js +1 -0
- package/assets/app-sidebar-Bz-SRwBg.js +1 -0
- package/assets/app-sidebar-header-7CNCx7Rs.js +11 -0
- package/assets/app.js +45 -37
- package/assets/breadcrumbs-_jhtTcOi.js +1 -0
- package/assets/catalog-CON6moaA.js +16 -0
- package/assets/catalog-Cc6Mk9sX.css +1 -0
- package/assets/checkbox-CQdZw5mb.js +1 -0
- package/assets/dashboard-BOltB2Hq.css +1 -0
- package/assets/dashboard-es9ZT8qk.js +3 -0
- package/assets/{date-picker-B__dVVqj.js → date-picker-Dz-d-YWX.js} +2 -2
- package/assets/debounce-qdyXyOeG.js +1 -0
- package/assets/del-modal-D0mrZvki.js +11 -0
- package/assets/dialog-stack-BiMbfm58.js +1 -0
- package/assets/dropdown-menu-BSBcRiXx.js +1 -0
- package/assets/{field-renderer-CapylJU9.js → field-renderer-B6hFAeiU.js} +3 -3
- package/assets/form-Buslty7y.js +1 -0
- package/assets/form-aqiRmPix.js +1 -0
- package/assets/{geo-json-CwteYDGB.js → geo-json-BKmYmu3d.js} +2 -2
- package/assets/{handsontable-BCnjOpBr.js → handsontable-B8xVeMAQ.js} +5 -5
- package/assets/home-Dr72Jk-w.js +2 -0
- package/assets/icon-B-a7xg54.js +1 -0
- package/assets/index-B68_akQe.js +1 -0
- package/assets/index-B7-xTDyy.js +1 -0
- package/assets/index-BJFFlCSo.js +1 -0
- package/assets/{index-DTRTjOmh.js → index-BOuMo_nl.js} +3 -3
- package/assets/index-BzOcGsBq.js +1 -0
- package/assets/index-CFbQ2Rv0.js +1 -0
- package/assets/{index-D5ir9iUV.js → index-Cq31rrfZ.js} +1 -1
- package/assets/{index-BcE9FUM6.js → index-D5UDXTFs.js} +1 -1
- package/assets/index-oxIQWAdI.js +41 -0
- package/assets/init-user-5H689LP0.js +1 -0
- package/assets/input-CSJjrf2i.js +1 -0
- package/assets/input-error-CK92Shhm.js +1 -0
- package/assets/label-Muj0-Efy.js +1 -0
- package/assets/list-Cvh7zbyG.js +1 -0
- package/assets/list-table-Bs_vbQiV.js +52 -0
- package/assets/login-DliJrjMQ.js +6 -0
- package/assets/manifest.json +589 -666
- package/assets/material-icon-BRS58Qpk.js +1 -0
- package/assets/module-CjG21VCT.js +1 -0
- package/assets/{monaco-editor-DqAqwxw4.js → monaco-editor-9fDiyfuW.js} +2 -2
- package/assets/{multi-select-oabtVhUP.js → multi-select-CMQIJ0JT.js} +2 -2
- package/assets/nav-footer-IGMn9NiE.js +1 -0
- package/assets/nav-main-DBE4rMiZ.js +1 -0
- package/assets/nav-user-CjyLRyq-.js +1 -0
- package/assets/pagination-render-DUAq2klc.js +1 -0
- package/assets/popover-C_cww-4_.js +1 -0
- package/assets/register-UzQn3J0g.js +1 -0
- package/assets/{select-D1N8zRPY.js → select-DzBno-dc.js} +2 -2
- package/assets/{sidebar-4D-sX2l4.js → sidebar-Dc4iqfu-.js} +2 -2
- package/assets/skeleton-Dkmj2o2Z.js +1 -0
- package/assets/sonner-De1t71Gj.js +1 -0
- package/assets/{toast-editor-FbrFd1ft.js → toast-editor-1Pul3oMs.js} +2 -2
- package/assets/tooltip-CwPrC-HD.js +1 -0
- package/assets/use-appearance-J8J2w43p.js +1 -0
- package/assets/use-window-size-DLSEoR6e.js +1 -0
- package/assets/{user-info-DBYoAJYJ.js → user-info-8RyDk7qh.js} +2 -2
- package/assets/user-menu-content-CpxTLH56.js +6 -0
- package/assets/welcome-BYKI6yO-.js +1 -0
- package/controllers/add.js +10 -10
- package/controllers/addGroup.js +2 -4
- package/controllers/addUser.js +4 -6
- package/controllers/catalog/Catalog.d.ts +1 -1
- package/controllers/catalog/Catalog.js +42 -37
- package/controllers/catalog/FrontentCatalogAdapter.d.ts +36 -26
- package/controllers/catalog/FrontentCatalogAdapter.js +71 -73
- package/controllers/ckeditorUpload.js +2 -3
- package/controllers/dashboard.js +16 -2
- package/controllers/edit.js +10 -14
- 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 +6 -6
- package/controllers/login.js +43 -18
- package/controllers/media-manager/mediaManagerAdapter.js +1 -2
- package/controllers/media-manager/mediaManagerApi.js +2 -2
- package/controllers/navigation/edit.js +2 -2
- package/controllers/register.js +1 -4
- package/controllers/remove.js +3 -3
- package/controllers/timezones.js +1 -1
- package/controllers/view.js +3 -3
- 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/JsUtils.d.ts +1 -0
- package/helpers/JsUtils.js +3 -0
- package/helpers/accessRightsHelper.d.ts +6 -2
- package/helpers/accessRightsHelper.js +28 -5
- package/helpers/configHelper.js +2 -1
- package/helpers/controllerHelper.js +39 -18
- package/helpers/fieldsHelper.d.ts +4 -3
- package/helpers/fieldsHelper.js +5 -1
- package/helpers/inertiaActionsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +3 -4
- package/helpers/inertiaAddHelper.js +27 -7
- 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.d.ts +1 -1
- package/helpers/inertiaMenuHelper.js +2 -2
- package/helpers/inertiaUserHelper.d.ts +7 -1
- package/helpers/inertiaUserHelper.js +5 -1
- package/helpers/menuHelper.d.ts +8 -3
- package/helpers/menuHelper.js +26 -17
- package/index.d.ts +6 -3
- package/index.js +9 -3
- package/interfaces/adminpanelConfig.d.ts +41 -32
- package/interfaces/global.d.ts +10 -28
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.d.ts +11 -3
- package/lib/Adminizer.js +49 -17
- package/lib/media-manager/AbstractMediaManager.d.ts +2 -2
- package/lib/media-manager/AbstractMediaManager.js +1 -1
- package/lib/media-manager/Items.js +0 -3
- package/lib/requestProcessor.js +10 -3
- package/lib/v4/DataAccessor.d.ts +5 -2
- package/lib/v4/DataAccessor.js +44 -19
- package/lib/v4/I18n.js +2 -0
- package/lib/v4/POWCaptcha.js +0 -1
- package/lib/v4/PolicyManager.js +0 -1
- package/lib/{catalog → v4/catalog}/AbstractCatalog.d.ts +89 -60
- package/lib/{catalog → v4/catalog}/AbstractCatalog.js +59 -55
- package/lib/v4/catalog/Navigation.d.ts +43 -0
- package/lib/v4/catalog/Navigation.js +457 -0
- package/lib/{controls → v4/controls}/AbstractControls.d.ts +1 -1
- package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/markdown/ToastUiEditor.d.ts +1 -1
- package/lib/{controls → v4/controls}/table/Handsontable.d.ts +1 -1
- package/lib/{controls → v4/controls}/wysiwyg/CKeditor.d.ts +1 -1
- package/lib/{datatable → v4/datatable}/NodeTable.d.ts +3 -3
- package/lib/{datatable → v4/datatable}/NodeTable.js +8 -8
- package/lib/v4/helper/jwt.d.ts +10 -0
- package/lib/v4/helper/jwt.js +18 -0
- package/lib/{inertia → v4/inertia}/inertiaAdapter.js +0 -1
- package/lib/v4/model/AbstractModel.d.ts +5 -1
- package/lib/v4/model/AbstractModel.js +2 -3
- package/lib/v4/model/ModelHandler.js +1 -4
- package/lib/v4/model/adapter/sequelize.d.ts +11 -2
- package/lib/v4/model/adapter/sequelize.js +451 -118
- package/lib/v4/model/adapter/waterline.js +5 -3
- package/lib/{widgets → v4/widgets}/abstractAction.d.ts +1 -1
- package/lib/v4/widgets/abstractCustom.d.ts +28 -0
- package/lib/v4/widgets/abstractCustom.js +9 -0
- package/lib/{widgets → v4/widgets}/abstractInfo.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractInfo.js +1 -1
- package/lib/{widgets → v4/widgets}/abstractLink.d.ts +2 -1
- package/lib/{widgets → v4/widgets}/abstractSwitch.d.ts +1 -1
- package/lib/{widgets → v4/widgets}/abstractWidgetBase.d.ts +2 -2
- package/lib/{widgets → v4/widgets}/widgetHandler.d.ts +29 -5
- package/lib/{widgets → v4/widgets}/widgetHandler.js +25 -25
- package/models/GroupAP.d.ts +8 -0
- package/models/NavigationAP.d.ts +7 -3
- package/models/NavigationAP.js +5 -6
- package/models/UserAP.d.ts +24 -2
- package/models/UserAP.js +2 -2
- package/package.json +29 -11
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +14 -17
- package/system/bindAccessRights.js +0 -4
- package/system/bindAuthorization.js +4 -5
- package/system/bindControls.js +6 -6
- package/system/bindDev.js +1 -0
- package/system/bindInertia.js +17 -12
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +9 -6
- package/system/bindNavigation.d.ts +2 -0
- package/system/bindNavigation.js +42 -42
- package/system/bindReqFunctions.js +15 -0
- package/system/defaults.js +13 -6
- package/translations/ar.json +70 -1
- package/translations/cn.json +70 -1
- package/translations/de.json +71 -3
- package/translations/en.json +70 -102
- package/translations/es.json +70 -1
- package/translations/fr.json +70 -1
- package/translations/hi.json +70 -1
- package/translations/jp.json +70 -1
- package/translations/ko.json +70 -1
- package/translations/pt.json +70 -1
- package/translations/ru.json +71 -94
- package/translations/ua.json +70 -1
- package/translations/uz.json +72 -0
- package/translations/vi.json +70 -1
- 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-group-form-dzadPSfL.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-layout-D1m9Kvxq.js +0 -1
- package/assets/app-shell-BWMRMkHM.js +0 -1
- package/assets/app-sidebar-BCtaEFGb.js +0 -1
- package/assets/app-sidebar-header-DLAFi13E.js +0 -11
- package/assets/breadcrumbs-CQNon4Vl.js +0 -1
- package/assets/button-CQ9t1kLz.js +0 -1
- package/assets/checkbox-W0nGAXIj.js +0 -1
- package/assets/compiler-runtime-tM4jBQ-T.js +0 -9
- package/assets/dashboard-BR602KhL.js +0 -1
- package/assets/dropdown-menu-SEBnEIiL.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/icon-Bz9BMaD0.js +0 -1
- package/assets/index-BC0yfOHo.js +0 -1
- package/assets/index-BbXEMx9n.js +0 -1
- package/assets/index-C0SL3SHw.js +0 -41
- package/assets/index-Cdb9ACvz.js +0 -1
- package/assets/index-DEk3sC8d.js +0 -1
- package/assets/index-DrWfGwtf.js +0 -1
- package/assets/index-K81GbF6O.js +0 -1
- package/assets/init-user-D9mW-g14.js +0 -1
- package/assets/input-DF7Ue23C.js +0 -1
- package/assets/input-error-BBygona6.js +0 -1
- package/assets/label-Z506NKsW.js +0 -1
- package/assets/list-Qyd7ecQH.js +0 -1
- package/assets/list-table-DB1sEQLF.js +0 -62
- package/assets/login-DrGaTWhY.js +0 -6
- package/assets/material-icon-CItZiB53.js +0 -1
- package/assets/module-DBaykv8l.js +0 -1
- package/assets/nav-footer-CM-yHiRs.js +0 -1
- package/assets/nav-main-Q3xofGRT.js +0 -1
- package/assets/nav-user-Ds8i0Pa2.js +0 -1
- package/assets/pagination-render-B57pOpFy.js +0 -1
- package/assets/popover-I249Gg2O.js +0 -1
- package/assets/register-C9FQIDtS.js +0 -1
- package/assets/sonner-Dzckw3U3.js +0 -1
- package/assets/tooltip-D2ehgLlB.js +0 -1
- package/assets/use-appearance-Co6mO0dV.js +0 -1
- package/assets/use-window-size-B8l6Bpkf.js +0 -1
- package/assets/user-menu-content-qkvdkUVd.js +0 -6
- package/assets/utils-DjqsqOe8.js +0 -1
- package/assets/welcome-D2adQ8EU.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -1
- package/controllers/processInstallStep.js +0 -132
- package/lib/catalog/Navigation.d.ts +0 -0
- package/lib/catalog/Navigation.js +0 -532
- package/lib/installStepper/InstallStepAbstract.d.ts +0 -52
- package/lib/installStepper/InstallStepAbstract.js +0 -69
- package/lib/installStepper/finalizeStep.d.ts +0 -21
- package/lib/installStepper/finalizeStep.js +0 -48
- package/lib/installStepper/installStepper.d.ts +0 -40
- package/lib/installStepper/installStepper.js +0 -195
- package/lib/widgets/abstractCustom.d.ts +0 -13
- package/lib/widgets/abstractCustom.js +0 -3
- package/models/MediaManagerAP.d.ts +0 -46
- package/models/MediaManagerAP.js +0 -45
- package/models/MediaManagerAssociationsAP.d.ts +0 -28
- package/models/MediaManagerAssociationsAP.js +0 -27
- package/models/MediaManagerMetaAP.d.ts +0 -22
- package/models/MediaManagerMetaAP.js +0 -21
- package/system/bindInstallStepper.d.ts +0 -2
- package/system/bindInstallStepper.js +0 -23
- /package/lib/{catalog → v4/catalog}/CatalogHandler.d.ts +0 -0
- /package/lib/{catalog → v4/catalog}/CatalogHandler.js +0 -0
- /package/lib/{controls → v4/controls}/AbstractControls.js +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.d.ts +0 -0
- /package/lib/{controls → v4/controls}/ControlsHandler.js +0 -0
- /package/lib/{controls → v4/controls}/codeEditor/MonacoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/geojsoneditor/GeoEditor.js +0 -0
- /package/lib/{controls → v4/controls}/jsoneditor/JsonEditor.js +0 -0
- /package/lib/{controls → v4/controls}/markdown/ToastUiEditor.js +0 -0
- /package/lib/{controls → v4/controls}/table/Handsontable.js +0 -0
- /package/lib/{controls → v4/controls}/wysiwyg/CKeditor.js +0 -0
- /package/lib/{inertia → v4/inertia}/flash.d.ts +0 -0
- /package/lib/{inertia → v4/inertia}/flash.js +0 -0
- /package/lib/{inertia → v4/inertia}/inertiaAdapter.d.ts +0 -0
- /package/lib/{widgets → v4/widgets}/abstractAction.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractLink.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractSwitch.js +0 -0
- /package/lib/{widgets → v4/widgets}/abstractWidgetBase.js +0 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { AbstractCatalog, AbstractGroup, AbstractItem } from "./AbstractCatalog";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
import { Adminizer } from "../../Adminizer";
|
|
4
|
+
class StorageService {
|
|
5
|
+
storageMap = new Map();
|
|
6
|
+
id;
|
|
7
|
+
model;
|
|
8
|
+
adminizer;
|
|
9
|
+
constructor(adminizer, id, model) {
|
|
10
|
+
this.adminizer = adminizer;
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.model = model.toLowerCase();
|
|
13
|
+
this.initModel();
|
|
14
|
+
}
|
|
15
|
+
async initModel() {
|
|
16
|
+
// Direct call by model adapter
|
|
17
|
+
const navigation = await this.adminizer.modelHandler.model.get(this.model)["_findOne"]({ label: this.id });
|
|
18
|
+
if (navigation) {
|
|
19
|
+
Adminizer.log.info(`Found existing navigation: ${this.id}`);
|
|
20
|
+
await this.populateFromTree(navigation.tree);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const newNavigation = { label: this.id, tree: [] };
|
|
24
|
+
// Direct call by model adapter
|
|
25
|
+
await this.adminizer.modelHandler.model.get(this.model)["_create"](newNavigation);
|
|
26
|
+
Adminizer.log.info(`Created a new navigation: ${this.id}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getId() {
|
|
30
|
+
return this.id;
|
|
31
|
+
}
|
|
32
|
+
async buildTree() {
|
|
33
|
+
const rootElements = await this.findElementsByParentId(0, null);
|
|
34
|
+
const buildSubTree = async (elements) => {
|
|
35
|
+
const tree = [];
|
|
36
|
+
for (const element of elements) {
|
|
37
|
+
const children = await this.findElementsByParentId(element.id, null);
|
|
38
|
+
tree.push({
|
|
39
|
+
...element,
|
|
40
|
+
children: await buildSubTree(children)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return tree;
|
|
44
|
+
};
|
|
45
|
+
let tree = await buildSubTree(rootElements);
|
|
46
|
+
function sortTree(items) {
|
|
47
|
+
items.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
48
|
+
for (let i = 0; i < items.length; i++) {
|
|
49
|
+
const item = items[i];
|
|
50
|
+
if (item.children) {
|
|
51
|
+
sortTree(item.children);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
sortTree(tree);
|
|
56
|
+
return tree;
|
|
57
|
+
}
|
|
58
|
+
async populateFromTree(tree) {
|
|
59
|
+
const traverseTree = async (node, parentId = 0) => {
|
|
60
|
+
const { children, ...itemData } = node;
|
|
61
|
+
const item = { ...itemData, parentId };
|
|
62
|
+
await this.setElement(item.id, item, true);
|
|
63
|
+
if (children && children.length > 0) {
|
|
64
|
+
for (const child of children) {
|
|
65
|
+
await traverseTree(child, item.id);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
for (const node of tree) {
|
|
70
|
+
await traverseTree(node);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async setElement(id, item, init = false) {
|
|
74
|
+
this.storageMap.set(item.id, item);
|
|
75
|
+
if (!init)
|
|
76
|
+
await this.saveToDB();
|
|
77
|
+
// This like fetch in DB
|
|
78
|
+
return this.findElementById(item.id);
|
|
79
|
+
}
|
|
80
|
+
async removeElementById(id) {
|
|
81
|
+
this.storageMap.delete(id);
|
|
82
|
+
setTimeout(async () => {
|
|
83
|
+
await this.saveToDB();
|
|
84
|
+
}, 500);
|
|
85
|
+
}
|
|
86
|
+
async findElementById(id) {
|
|
87
|
+
return this.storageMap.get(id);
|
|
88
|
+
}
|
|
89
|
+
async findElementByModelId(modelId) {
|
|
90
|
+
const elements = [];
|
|
91
|
+
for (const item of this.storageMap.values()) {
|
|
92
|
+
if (item.modelId === modelId) {
|
|
93
|
+
elements.push(item);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return elements;
|
|
97
|
+
}
|
|
98
|
+
async saveToDB() {
|
|
99
|
+
let tree = await this.buildTree();
|
|
100
|
+
try {
|
|
101
|
+
// Direct call by model adapter
|
|
102
|
+
await this.adminizer.modelHandler.model.get(this.model)["_update"]({ label: this.id }, { tree: tree });
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
console.log(e);
|
|
106
|
+
throw 'navigation model update error';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async findElementsByParentId(parentId, type) {
|
|
110
|
+
const elements = [];
|
|
111
|
+
for (const item of this.storageMap.values()) {
|
|
112
|
+
if (type === null && item.parentId === parentId) {
|
|
113
|
+
elements.push(item);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (item.parentId === parentId && item.type === type) {
|
|
117
|
+
elements.push(item);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return elements;
|
|
121
|
+
}
|
|
122
|
+
async getAllElements() {
|
|
123
|
+
return Array.from(this.storageMap.values());
|
|
124
|
+
}
|
|
125
|
+
async search(s, type) {
|
|
126
|
+
const lowerCaseQuery = s.toLowerCase(); // Convert query to lowercase for case-insensitive search
|
|
127
|
+
const matchedElements = [];
|
|
128
|
+
for (const item of this.storageMap.values()) {
|
|
129
|
+
// Check if item type matches the specified type
|
|
130
|
+
if (item.type === type) {
|
|
131
|
+
// Search by name
|
|
132
|
+
if (item.name.toLowerCase().includes(lowerCaseQuery)) {
|
|
133
|
+
matchedElements.push(item);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return matchedElements;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export class StorageServices {
|
|
141
|
+
static storages = [];
|
|
142
|
+
static add(storage) {
|
|
143
|
+
this.storages.push(storage);
|
|
144
|
+
}
|
|
145
|
+
static get(id) {
|
|
146
|
+
return this.storages.find(storage => storage.getId() === id);
|
|
147
|
+
}
|
|
148
|
+
static getAll() {
|
|
149
|
+
return this.storages;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export class Navigation extends AbstractCatalog {
|
|
153
|
+
name = 'Navigation';
|
|
154
|
+
slug = 'navigation';
|
|
155
|
+
icon = "box";
|
|
156
|
+
actionHandlers = [];
|
|
157
|
+
idList = [];
|
|
158
|
+
constructor(adminizer, config) {
|
|
159
|
+
let items = [];
|
|
160
|
+
for (const configElement of config.items) {
|
|
161
|
+
items.push(new NavigationItem(adminizer, configElement.title, configElement.model, config.model, configElement.urlPath));
|
|
162
|
+
}
|
|
163
|
+
items.push(new NavigationGroup(adminizer, config.groupField));
|
|
164
|
+
items.push(new LinkItem(adminizer));
|
|
165
|
+
for (const section of config.sections) {
|
|
166
|
+
StorageServices.add(new StorageService(adminizer, section, config.model));
|
|
167
|
+
}
|
|
168
|
+
super(adminizer, items);
|
|
169
|
+
this.movingGroupsRootOnly = config.movingGroupsRootOnly;
|
|
170
|
+
this.idList = config.sections ?? [];
|
|
171
|
+
}
|
|
172
|
+
async getIdList() {
|
|
173
|
+
return this.idList;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class NavigationItem extends AbstractItem {
|
|
177
|
+
allowedRoot = true;
|
|
178
|
+
icon;
|
|
179
|
+
name;
|
|
180
|
+
type;
|
|
181
|
+
model;
|
|
182
|
+
navigationModel;
|
|
183
|
+
actionHandlers = [];
|
|
184
|
+
urlPath;
|
|
185
|
+
adminizer;
|
|
186
|
+
constructor(adminizer, name, model, navigationModel, urlPath) {
|
|
187
|
+
super();
|
|
188
|
+
this.name = name;
|
|
189
|
+
this.navigationModel = navigationModel;
|
|
190
|
+
this.model = model;
|
|
191
|
+
this.type = model.toLowerCase();
|
|
192
|
+
this.urlPath = urlPath;
|
|
193
|
+
let configModel = adminizer.config.models[this.model];
|
|
194
|
+
this.icon = configModel?.icon ?? 'file_present';
|
|
195
|
+
this.adminizer = adminizer;
|
|
196
|
+
}
|
|
197
|
+
async create(data, catalogId) {
|
|
198
|
+
let storage = StorageServices.get(catalogId);
|
|
199
|
+
let storageData = null;
|
|
200
|
+
if (data._method === 'select') {
|
|
201
|
+
// Direct call by model adapter
|
|
202
|
+
let record = await this.adminizer.modelHandler.model.get(this.model)["_findOne"]({ id: data.record });
|
|
203
|
+
storageData = await this.dataPreparation({
|
|
204
|
+
record: record,
|
|
205
|
+
parentId: data.parentId,
|
|
206
|
+
targetBlank: data.targetBlank
|
|
207
|
+
}, catalogId);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
storageData = await this.dataPreparation(data, catalogId);
|
|
211
|
+
}
|
|
212
|
+
return await storage.setElement(data.id, storageData);
|
|
213
|
+
}
|
|
214
|
+
async dataPreparation(data, catalogId, sortOrder) {
|
|
215
|
+
let storage = StorageServices.get(catalogId);
|
|
216
|
+
let urlPath = eval('`' + this.urlPath + '`');
|
|
217
|
+
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
218
|
+
return {
|
|
219
|
+
id: uuid(),
|
|
220
|
+
modelId: data.record.id,
|
|
221
|
+
targetBlank: data.targetBlank ?? data.record.targetBlank,
|
|
222
|
+
name: data.record.name ?? data.record.title ?? data.record.id,
|
|
223
|
+
parentId: parentId,
|
|
224
|
+
sortOrder: sortOrder ?? (await storage.findElementsByParentId(parentId, null)).length,
|
|
225
|
+
icon: this.icon,
|
|
226
|
+
type: this.type,
|
|
227
|
+
urlPath: urlPath
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async updateModelItems(modelId, data, catalogId) {
|
|
231
|
+
let storage = StorageServices.get(catalogId);
|
|
232
|
+
let items = await storage.findElementByModelId(modelId);
|
|
233
|
+
let urlPath = eval('`' + this.urlPath + '`');
|
|
234
|
+
let response = [];
|
|
235
|
+
for (const item of items) {
|
|
236
|
+
item.name = data.record.name ?? data.record.title ?? data.record.id;
|
|
237
|
+
item.urlPath = urlPath;
|
|
238
|
+
if (item.id === data.record.treeId) {
|
|
239
|
+
item.targetBlank = data.record.targetBlank;
|
|
240
|
+
}
|
|
241
|
+
response.push(await storage.setElement(item.id, item));
|
|
242
|
+
}
|
|
243
|
+
return response[0];
|
|
244
|
+
}
|
|
245
|
+
async update(itemId, data, catalogId) {
|
|
246
|
+
let storage = StorageServices.get(catalogId);
|
|
247
|
+
return await storage.setElement(itemId, data);
|
|
248
|
+
}
|
|
249
|
+
async deleteItem(itemId, catalogId) {
|
|
250
|
+
let storage = StorageServices.get(catalogId);
|
|
251
|
+
return await storage.removeElementById(itemId);
|
|
252
|
+
}
|
|
253
|
+
async find(itemId, catalogId) {
|
|
254
|
+
let storage = StorageServices.get(catalogId);
|
|
255
|
+
return await storage.findElementById(itemId);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @deprecated reason: migration for intertia
|
|
259
|
+
* // TODO: need passing custom React module
|
|
260
|
+
*/
|
|
261
|
+
async getAddTemplate(req) {
|
|
262
|
+
let type = 'model';
|
|
263
|
+
// Direct call by model adapter
|
|
264
|
+
let itemsDB = await this.adminizer.modelHandler.model.get(this.model)["_find"]({});
|
|
265
|
+
let items = itemsDB.map((item) => {
|
|
266
|
+
return {
|
|
267
|
+
id: item.id,
|
|
268
|
+
name: item.name ?? item.title ?? item.id
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
return {
|
|
272
|
+
type: type,
|
|
273
|
+
data: {
|
|
274
|
+
items: items,
|
|
275
|
+
model: this.model,
|
|
276
|
+
labels: {
|
|
277
|
+
selectTitle: `${req.i18n.__('Select')} ${req.i18n.__(this.name + 's')}`,
|
|
278
|
+
createTitle: `${req.i18n.__('create new')} ${req.i18n.__(this.name + 's')}`,
|
|
279
|
+
OR: req.i18n.__('OR'),
|
|
280
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async getChilds(parentId, catalogId) {
|
|
286
|
+
let storage = StorageServices.get(catalogId);
|
|
287
|
+
return await storage.findElementsByParentId(parentId, this.type);
|
|
288
|
+
}
|
|
289
|
+
async getEditTemplate(id, catalogId, req, modelId) {
|
|
290
|
+
return Promise.resolve({
|
|
291
|
+
type: 'model',
|
|
292
|
+
data: {
|
|
293
|
+
item: await this.find(id, catalogId)
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
async search(s, catalogId) {
|
|
298
|
+
let storage = StorageServices.get(catalogId);
|
|
299
|
+
return await storage.search(s, this.type);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
class NavigationGroup extends AbstractGroup {
|
|
303
|
+
allowedRoot = true;
|
|
304
|
+
name = "Group";
|
|
305
|
+
groupField;
|
|
306
|
+
adminizer;
|
|
307
|
+
constructor(adminizer, groupField) {
|
|
308
|
+
super();
|
|
309
|
+
this.groupField = groupField;
|
|
310
|
+
this.adminizer = adminizer;
|
|
311
|
+
}
|
|
312
|
+
async create(data, catalogId) {
|
|
313
|
+
let storage = StorageServices.get(catalogId);
|
|
314
|
+
let storageData = await this.dataPreparation(data, catalogId);
|
|
315
|
+
delete data.name;
|
|
316
|
+
delete data.parentId;
|
|
317
|
+
storageData = { ...storageData, ...data };
|
|
318
|
+
return await storage.setElement(storageData.id, storageData);
|
|
319
|
+
}
|
|
320
|
+
async dataPreparation(data, catalogId, sortOrder) {
|
|
321
|
+
let storage = StorageServices.get(catalogId);
|
|
322
|
+
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
323
|
+
return {
|
|
324
|
+
id: uuid(),
|
|
325
|
+
name: data.name,
|
|
326
|
+
targetBlank: data.targetBlank,
|
|
327
|
+
parentId: parentId,
|
|
328
|
+
sortOrder: sortOrder ?? (await storage.findElementsByParentId(parentId, null)).length,
|
|
329
|
+
icon: this.icon,
|
|
330
|
+
type: this.type
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
async deleteItem(itemId, catalogId) {
|
|
334
|
+
let storage = StorageServices.get(catalogId);
|
|
335
|
+
return await storage.removeElementById(itemId);
|
|
336
|
+
}
|
|
337
|
+
async find(itemId, catalogId) {
|
|
338
|
+
let storage = StorageServices.get(catalogId);
|
|
339
|
+
return await storage.findElementById(itemId);
|
|
340
|
+
}
|
|
341
|
+
async update(itemId, data, catalogId) {
|
|
342
|
+
let storage = StorageServices.get(catalogId);
|
|
343
|
+
return await storage.setElement(itemId, data);
|
|
344
|
+
}
|
|
345
|
+
async updateModelItems(modelId, data, catalogId) {
|
|
346
|
+
let storage = StorageServices.get(catalogId);
|
|
347
|
+
return await storage.setElement(modelId, data);
|
|
348
|
+
}
|
|
349
|
+
getAddTemplate(req) {
|
|
350
|
+
let type = 'navigation.group';
|
|
351
|
+
let resItems = [];
|
|
352
|
+
if (this.groupField.length) {
|
|
353
|
+
resItems = this.groupField.map((field) => {
|
|
354
|
+
return {
|
|
355
|
+
name: field.name,
|
|
356
|
+
required: field.required
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return Promise.resolve({
|
|
361
|
+
type: type,
|
|
362
|
+
data: {
|
|
363
|
+
items: resItems,
|
|
364
|
+
labels: {
|
|
365
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
366
|
+
title: req.i18n.__('Title'),
|
|
367
|
+
save: req.i18n.__('Save')
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async getEditTemplate(id, catalogId, req, modelId) {
|
|
373
|
+
let item = await this.find(id, catalogId);
|
|
374
|
+
let type = 'navigation.group';
|
|
375
|
+
let resItems = [];
|
|
376
|
+
if (this.groupField.length) {
|
|
377
|
+
resItems = this.groupField.map((field) => {
|
|
378
|
+
return {
|
|
379
|
+
name: field.name,
|
|
380
|
+
required: field.required
|
|
381
|
+
};
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
return Promise.resolve({
|
|
385
|
+
type: type,
|
|
386
|
+
data: {
|
|
387
|
+
items: resItems,
|
|
388
|
+
item: item,
|
|
389
|
+
labels: {
|
|
390
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
391
|
+
title: req.i18n.__('Title'),
|
|
392
|
+
save: req.i18n.__('Save')
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
async getChilds(parentId, catalogId) {
|
|
398
|
+
let storage = StorageServices.get(catalogId);
|
|
399
|
+
return await storage.findElementsByParentId(parentId, this.type);
|
|
400
|
+
}
|
|
401
|
+
async search(s, catalogId) {
|
|
402
|
+
let storage = StorageServices.get(catalogId);
|
|
403
|
+
return await storage.search(s, this.type);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
class LinkItem extends NavigationGroup {
|
|
407
|
+
allowedRoot = true;
|
|
408
|
+
icon = 'insert_link';
|
|
409
|
+
name = 'Link';
|
|
410
|
+
type = 'link';
|
|
411
|
+
isGroup = false;
|
|
412
|
+
constructor(adminizer) {
|
|
413
|
+
super(adminizer, []);
|
|
414
|
+
}
|
|
415
|
+
getAddTemplate(req) {
|
|
416
|
+
let type = 'navigation.link';
|
|
417
|
+
let resItems = [
|
|
418
|
+
{
|
|
419
|
+
name: req.i18n.__('Link'),
|
|
420
|
+
required: true
|
|
421
|
+
}
|
|
422
|
+
];
|
|
423
|
+
return Promise.resolve({
|
|
424
|
+
type: type,
|
|
425
|
+
data: {
|
|
426
|
+
items: resItems,
|
|
427
|
+
labels: {
|
|
428
|
+
title: req.i18n.__('Title'),
|
|
429
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
430
|
+
save: req.i18n.__('Save')
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
async getEditTemplate(id, catalogId, req) {
|
|
436
|
+
let item = await this.find(id, catalogId);
|
|
437
|
+
let type = 'navigation.group';
|
|
438
|
+
let resItems = [
|
|
439
|
+
{
|
|
440
|
+
name: req.i18n.__('Link'),
|
|
441
|
+
required: true
|
|
442
|
+
}
|
|
443
|
+
];
|
|
444
|
+
return Promise.resolve({
|
|
445
|
+
type: type,
|
|
446
|
+
data: {
|
|
447
|
+
items: resItems,
|
|
448
|
+
item: item,
|
|
449
|
+
labels: {
|
|
450
|
+
openInNewWindow: req.i18n.__('Open in a new window'),
|
|
451
|
+
title: req.i18n.__('Title'),
|
|
452
|
+
save: req.i18n.__('Save')
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class MonacoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class GeoEditor extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../../Adminizer";
|
|
4
4
|
export declare class JsonEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Path, Config } from "../AbstractControls";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
|
-
import { Adminizer } from "
|
|
3
|
+
import { Adminizer } from "../../../Adminizer";
|
|
4
4
|
export declare class ToastUiEditor extends AbstractControls {
|
|
5
5
|
readonly config: Partial<EditorOptions>;
|
|
6
6
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class Handsontable extends AbstractControls {
|
|
4
4
|
readonly config: Config;
|
|
5
5
|
readonly name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractControls, ControlType, Config, Path } from "../AbstractControls";
|
|
2
|
-
import { Adminizer } from "
|
|
2
|
+
import { Adminizer } from "../../../Adminizer";
|
|
3
3
|
export declare class CKeditor extends AbstractControls {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly type: ControlType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Fields } from '
|
|
2
|
-
import { AbstractModel } from '../
|
|
3
|
-
import { DataAccessor } from "../
|
|
1
|
+
import { Fields } from '../../../helpers/fieldsHelper';
|
|
2
|
+
import { AbstractModel } from '../model/AbstractModel';
|
|
3
|
+
import { DataAccessor } from "../DataAccessor";
|
|
4
4
|
interface Request {
|
|
5
5
|
start: string;
|
|
6
6
|
length: string;
|
|
@@ -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
|
}
|
|
@@ -132,10 +131,9 @@ export class NodeTable {
|
|
|
132
131
|
async output(callback, dataAccessor) {
|
|
133
132
|
try {
|
|
134
133
|
const queryOptions = await this.buildQuery();
|
|
135
|
-
const totalRecords = await this.model.count({});
|
|
136
|
-
const filteredRecords = await this.model.count(queryOptions.where);
|
|
134
|
+
const totalRecords = await this.model.count({}, dataAccessor);
|
|
135
|
+
const filteredRecords = await this.model.count(queryOptions.where, dataAccessor);
|
|
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,
|
|
@@ -162,6 +160,9 @@ export class NodeTable {
|
|
|
162
160
|
Object.keys(this.fields).forEach((key) => {
|
|
163
161
|
let fieldConfigConfig = this.fields[key].config;
|
|
164
162
|
let fieldName = key;
|
|
163
|
+
let displayField = this.fields[key].modelConfig?.titleField ?? typeof row["title"] !== "undefined" ? 'title'
|
|
164
|
+
: typeof row["name"] !== "undefined" ? 'name'
|
|
165
|
+
: typeof row[this.fields[key].modelConfig?.identifierField] !== "undefined" ? this.fields[key].modelConfig?.identifierField : this.fields[key].modelConfig?.identifierField;
|
|
165
166
|
if (fieldConfigConfig.displayModifier) {
|
|
166
167
|
row[fieldName] = fieldConfigConfig.displayModifier(elem[key]);
|
|
167
168
|
}
|
|
@@ -171,7 +172,7 @@ export class NodeTable {
|
|
|
171
172
|
row[fieldName] = null;
|
|
172
173
|
}
|
|
173
174
|
else {
|
|
174
|
-
row[fieldName] = elem[key][
|
|
175
|
+
row[fieldName] = elem[key][displayField];
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
else if (this.fields[key].model.type === "association-many" || this.fields[key].model.type === "association") {
|
|
@@ -181,8 +182,8 @@ export class NodeTable {
|
|
|
181
182
|
else {
|
|
182
183
|
let displayValues = [];
|
|
183
184
|
elem[key].forEach((item) => {
|
|
184
|
-
if (item[
|
|
185
|
-
displayValues.push(item[
|
|
185
|
+
if (item[displayField]) {
|
|
186
|
+
displayValues.push(item[displayField]);
|
|
186
187
|
}
|
|
187
188
|
else {
|
|
188
189
|
displayValues.push(item[fieldConfigConfig.identifierField]);
|
|
@@ -201,7 +202,6 @@ export class NodeTable {
|
|
|
201
202
|
});
|
|
202
203
|
out.push(row);
|
|
203
204
|
});
|
|
204
|
-
console.log(out);
|
|
205
205
|
return out;
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
|
@@ -10,6 +10,10 @@ export interface Attribute {
|
|
|
10
10
|
collection?: string;
|
|
11
11
|
via?: string;
|
|
12
12
|
allowNull?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* This is a field that indicates that it refers to keep the bond key 1: 1
|
|
15
|
+
*/
|
|
16
|
+
primaryKeyForAssociation?: boolean;
|
|
13
17
|
}
|
|
14
18
|
export interface ModelAttributes {
|
|
15
19
|
[key: string]: Attribute;
|
|
@@ -49,7 +53,7 @@ export declare abstract class AbstractModel<T> {
|
|
|
49
53
|
update(criteria: Partial<T>, data: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T>[]>;
|
|
50
54
|
destroyOne(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T> | null>;
|
|
51
55
|
destroy(criteria: Partial<T>, dataAccessor: DataAccessor): Promise<Partial<T>[]>;
|
|
52
|
-
count(criteria: Partial<T> | undefined): Promise<number>;
|
|
56
|
+
count(criteria: Partial<T> | undefined, dataAccessor: DataAccessor): Promise<number>;
|
|
53
57
|
}
|
|
54
58
|
export declare abstract class AbstractAdapter {
|
|
55
59
|
abstract Model: any;
|
|
@@ -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) {
|
|
@@ -48,7 +46,8 @@ export class AbstractModel {
|
|
|
48
46
|
let records = await this._destroy(criteria);
|
|
49
47
|
return records.map(record => dataAccessor.process(record));
|
|
50
48
|
}
|
|
51
|
-
async count(criteria) {
|
|
49
|
+
async count(criteria, dataAccessor) {
|
|
50
|
+
criteria = await dataAccessor.sanitizeUserRelationAccess(criteria);
|
|
52
51
|
return this._count(criteria);
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -3,13 +3,10 @@ export class ModelHandler {
|
|
|
3
3
|
models = new Map();
|
|
4
4
|
add(modelName, modelInstance) {
|
|
5
5
|
const modelname = modelName.toLowerCase();
|
|
6
|
-
if (this.models.has(modelname)) {
|
|
7
|
-
throw new Error(`Model "${modelname}" is already registered.`);
|
|
8
|
-
}
|
|
9
6
|
this.models.set(modelname, modelInstance);
|
|
10
7
|
Adminizer.log.debug(`Model with name [${modelname}] was registered`);
|
|
11
|
-
console.log(`Model with name [${modelname}] was registered`);
|
|
12
8
|
}
|
|
9
|
+
// TODO: 'hot reload' need add method for delete model
|
|
13
10
|
/** Improved model getter, so you can write both model.get("UserAP") and model.get("userap") */
|
|
14
11
|
get model() {
|
|
15
12
|
return {
|