adminizer 4.1.0-build.13 → 4.1.0-build.14
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-BGC0iJ01.js → VanillaJSONEditor-D-Lx670g.js} +2 -2
- 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-BUM07NJS.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-BYldMVaW.css → app-C3OdwOHy.css} +1 -1
- package/assets/{app-layout-YPlKN2l5.js → app-layout-DYsRFUuP.js} +1 -1
- package/assets/{app-shell-D6Uf68EA.js → app-shell-Dd9Eknik.js} +1 -1
- package/assets/app-sidebar-BOmu6-Sl.js +1 -0
- package/assets/{app-sidebar-header-BTKq0Dr0.js → app-sidebar-header-CoXSzWxk.js} +1 -1
- package/assets/app.js +14 -14
- package/assets/{breadcrumbs-B4LOvzuL.js → breadcrumbs-BmAq4fHT.js} +1 -1
- package/assets/{button-CTOOfwvn.js → button-C9B_5Jf_.js} +1 -1
- package/assets/checkbox-Fg27sL_1.js +1 -0
- package/assets/{compiler-runtime-tM4jBQ-T.js → compiler-runtime-hB6dAw2d.js} +1 -1
- package/assets/dashboard-BOltB2Hq.css +1 -0
- package/assets/dashboard-Ddh74NBQ.js +3 -0
- package/assets/{date-picker-DdGpxs8q.js → date-picker-DI1cCO7K.js} +1 -1
- package/assets/{dropdown-menu-CsGmdVIn.js → dropdown-menu-Bhj17ENm.js} +1 -1
- package/assets/{field-renderer-Q3ajtfjk.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-CFYMCghL.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-Mx04mBJl.js → index-BC0yfOHo.js} +1 -1
- package/assets/{index-m5itSoCR.js → index-BKCgnGj_.js} +1 -1
- package/assets/{index-C5OL14ES.js → index-BbXEMx9n.js} +1 -1
- package/assets/{index-DnbQEoxZ.js → index-BykbU6Ee.js} +1 -1
- package/assets/index-CaJgc5EZ.js +1 -0
- package/assets/{index-Cb_qrizV.js → index-Cgp8OfuI.js} +1 -1
- package/assets/{index-CGjCQBqR.js → index-Cw5o84pO.js} +1 -1
- package/assets/index-DrWfGwtf.js +1 -0
- package/assets/{init-user-CotD_o5_.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-C2tlefOv.js → label-CSLFe9Bz.js} +1 -1
- package/assets/list-B2Oa5O_Q.js +1 -0
- package/assets/{list-table-Cz8Wgfsa.js → list-table-DA9MhywL.js} +2 -2
- package/assets/{login-B7br6gt5.js → login-DQwGtdis.js} +1 -1
- package/assets/manifest.json +588 -568
- 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-CDlcaNFy.js → multi-select-BvRpAW8r.js} +1 -1
- package/assets/{nav-footer-CXKG3O4K.js → nav-footer-Bs4dmN1d.js} +1 -1
- package/assets/{nav-main-ByHRr3yf.js → nav-main-Bq3IMk4C.js} +1 -1
- package/assets/{nav-user-BVRKiqm-.js → nav-user-CbB22J5O.js} +1 -1
- package/assets/{pagination-render-CihJ7J2u.js → pagination-render-DuXDDbC_.js} +1 -1
- package/assets/{popover-_WN_Lj46.js → popover-DtoGI2b1.js} +1 -1
- package/assets/{register-CpRFo88B.js → register-BSogVF0h.js} +1 -1
- package/assets/{select-DYffGc49.js → select-BWepUw-9.js} +1 -1
- package/assets/{sidebar-B9HagQ6H.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-ZLOtXFu5.js → toast-editor-CMK7QtF1.js} +82 -82
- package/assets/{tooltip-CWVAD5oF.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-DA4KTAOF.js → user-info-DFrmpJ4y.js} +1 -1
- package/assets/{user-menu-content-Biwi4u9j.js → user-menu-content-DPXQdERj.js} +1 -1
- package/assets/welcome-B4WCIXKf.js +1 -0
- package/controllers/dashboard.js +15 -1
- package/controllers/getAllWidgets.js +1 -1
- package/controllers/widgetsDB.js +2 -2
- package/helpers/accessRightsHelper.js +2 -2
- package/helpers/controllerHelper.js +1 -1
- package/helpers/inertiaAddHelper.js +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/interfaces/adminpanelConfig.d.ts +0 -17
- package/interfaces/global.d.ts +3 -0
- package/interfaces/types.d.ts +1 -1
- package/lib/Adminizer.js +9 -5
- package/lib/catalog/Navigation.js +0 -1
- package/lib/media-manager/Items.js +0 -3
- package/lib/v4/DataAccessor.js +4 -3
- package/lib/v4/model/adapter/sequelize.js +8 -1
- package/lib/v4/model/adapter/waterline.js +5 -2
- 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 +26 -3
- package/lib/widgets/widgetHandler.js +25 -25
- package/models/UserAP.d.ts +5 -2
- package/package.json +14 -8
- package/system/Router.js +6 -14
- package/system/bindAccessRights.js +0 -4
- package/system/bindDev.js +1 -0
- package/system/bindMediaManager.js +0 -1
- package/system/bindModels.js +7 -2
- package/system/bindNavigation.js +0 -1
- package/translations/ru.json +17 -8
- package/assets/add-EOP63mij.js +0 -1
- package/assets/add-form-DofA75xF.js +0 -1
- package/assets/add-group-CbKcu8bN.js +0 -1
- package/assets/add-user-FQ_0_L3C.js +0 -1
- package/assets/add-user-form-D1f_2noB.js +0 -1
- package/assets/app-sidebar-mh83eSsH.js +0 -1
- package/assets/checkbox-D9ub-v0l.js +0 -1
- package/assets/dashboard-BiLSHuF2.js +0 -1
- package/assets/form-D2gvtdQt.js +0 -1
- package/assets/form-EPWwr8yD.js +0 -1
- package/assets/home-Co9WBSjN.js +0 -2
- package/assets/index-DEzdKGnS.js +0 -1
- package/assets/index-DUXJYtOc.js +0 -1
- package/assets/index-Dllsp4Rk.js +0 -1
- package/assets/list-BrJBbAVm.js +0 -1
- package/assets/module-BA_EenoK.js +0 -1
- package/assets/welcome-C1kRbbWq.js +0 -1
- package/controllers/processInstallFinalize.d.ts +0 -1
- package/controllers/processInstallFinalize.js +0 -16
- package/controllers/processInstallStep.d.ts +0 -0
- package/controllers/processInstallStep.js +0 -122
- 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/system/bindInstallStepper.d.ts +0 -2
- package/system/bindInstallStepper.js +0 -23
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import FinalizeStep from "./finalizeStep";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import { TranslationHelper } from "../../helpers/translationHelper";
|
|
4
|
-
import { Adminizer } from "../Adminizer";
|
|
5
|
-
export class InstallStepper {
|
|
6
|
-
id;
|
|
7
|
-
steps = [];
|
|
8
|
-
context = {};
|
|
9
|
-
canBeClosed;
|
|
10
|
-
// TODO remove static fields for multi adminizer server
|
|
11
|
-
static instances = [];
|
|
12
|
-
constructor(id, canBeClosed = false) {
|
|
13
|
-
this.id = id;
|
|
14
|
-
this.canBeClosed = canBeClosed;
|
|
15
|
-
}
|
|
16
|
-
static addStepper(stepper) {
|
|
17
|
-
if (this.instances.find(item => item.id === stepper.id)) {
|
|
18
|
-
Adminizer.log.debug(`Stepper with id ${stepper.id} was deleted due to creating new one`);
|
|
19
|
-
this.deleteStepper(stepper.id);
|
|
20
|
-
}
|
|
21
|
-
this.instances.push(stepper);
|
|
22
|
-
}
|
|
23
|
-
static getStepper(stepperId) {
|
|
24
|
-
return this.instances.find(item => item.id === stepperId);
|
|
25
|
-
}
|
|
26
|
-
static deleteStepper(stepperId) {
|
|
27
|
-
let stepper = this.getStepper(stepperId);
|
|
28
|
-
if (!stepper.canBeClosed) {
|
|
29
|
-
Adminizer.log.error(`Can not delete stepper: Stepper with id ${stepperId} can not be closed.`);
|
|
30
|
-
throw `Can not delete stepper: Stepper with id ${stepperId} can not be closed`;
|
|
31
|
-
}
|
|
32
|
-
const index = this.instances.findIndex(item => item.id === stepperId);
|
|
33
|
-
if (index !== -1) {
|
|
34
|
-
this.instances.splice(index, 1);
|
|
35
|
-
Adminizer.log.info(`Stepper with id ${stepperId} has been deleted.`);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
Adminizer.log.error(`Can not delete stepper: Stepper with id ${stepperId} not found.`);
|
|
39
|
-
throw `Can not delete stepper: Stepper with id ${stepperId} not found.`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static getInstance() {
|
|
43
|
-
if (!this.instances.length) {
|
|
44
|
-
let newStepper = new InstallStepper("project", false);
|
|
45
|
-
this.instances.push(newStepper);
|
|
46
|
-
}
|
|
47
|
-
return this.instances.find(item => item.id === "project");
|
|
48
|
-
}
|
|
49
|
-
getSteps() {
|
|
50
|
-
return this.steps;
|
|
51
|
-
}
|
|
52
|
-
async processStep(stepId, data) {
|
|
53
|
-
try {
|
|
54
|
-
/** As we sort steps by sortOrder, we should check that previous steps were processed */
|
|
55
|
-
const stepIndex = this.steps.findIndex(item => item.id === stepId);
|
|
56
|
-
Adminizer.log.debug("STEP INDEX", stepIndex);
|
|
57
|
-
for (let i = 0; i < stepIndex; i++) {
|
|
58
|
-
if (this.steps[i].canBeSkipped && this.steps[i].isSkipped) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
let checkResult = await this.steps[i].check();
|
|
62
|
-
if (checkResult === false) {
|
|
63
|
-
throw `Previous step was not processed`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
let step = this.getStepById(stepId);
|
|
67
|
-
// get context copy and write down information in it on process without damaging source object
|
|
68
|
-
let contextCopy = { ...this.context };
|
|
69
|
-
await step.process(data, contextCopy);
|
|
70
|
-
Object.assign(this.context, contextCopy);
|
|
71
|
-
step.isProcessed = true;
|
|
72
|
-
Adminizer.log.debug(`STEP ${stepId} was processed`);
|
|
73
|
-
// call finalize method only if has description
|
|
74
|
-
if (step.finallyToRun) {
|
|
75
|
-
contextCopy = { ...this.context };
|
|
76
|
-
step.toFinally(data, this.context);
|
|
77
|
-
Object.assign(this.context, contextCopy);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
catch (e) {
|
|
81
|
-
Adminizer.log.error(`Error processing step: ${e}`);
|
|
82
|
-
throw new Error(e);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
getStepById(stepId) {
|
|
86
|
-
return this.steps.find(item => item.id === stepId);
|
|
87
|
-
}
|
|
88
|
-
/** Prepares steps array for user interface render */
|
|
89
|
-
render(req) {
|
|
90
|
-
let stepToRender = this.getNextUnprocessedStep();
|
|
91
|
-
let leftSteps = this.steps.filter(step => !step.isProcessed && !step.isSkipped);
|
|
92
|
-
// set locale
|
|
93
|
-
if (typeof req.adminizer.config.translation !== "boolean") {
|
|
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
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
req.user.locale = "en";
|
|
100
|
-
}
|
|
101
|
-
this.context.locale = req.user.locale;
|
|
102
|
-
// translate step
|
|
103
|
-
stepToRender = TranslationHelper.translateProperties(req.i18n, stepToRender, ["title", "description", "name"]);
|
|
104
|
-
return {
|
|
105
|
-
totalStepCount: this.steps.length,
|
|
106
|
-
leftStepsCount: leftSteps.length,
|
|
107
|
-
currentStep: stepToRender,
|
|
108
|
-
locale: req.user.locale
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
async skipStep(stepId) {
|
|
112
|
-
try {
|
|
113
|
-
let step = this.getStepById(stepId);
|
|
114
|
-
await step.skipIt();
|
|
115
|
-
step.isSkipped = true;
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
Adminizer.log.error(`Error skipping step: ${e}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/** Add step (replace if it already exists) */
|
|
122
|
-
addStep(step) {
|
|
123
|
-
if (step.renderer === "ejs") {
|
|
124
|
-
if (!step.ejsPath || !fs.existsSync(step.ejsPath)) {
|
|
125
|
-
throw `Step [${step.title}] error: ejs path does not exists`;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const stepIndex = this.steps.findIndex(item => item.id === step.id);
|
|
129
|
-
if (stepIndex !== -1) {
|
|
130
|
-
Adminizer.log.warn(`Attention! The step has been replaced\`${step.id}\``);
|
|
131
|
-
this.steps[stepIndex] = step;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.steps.push(step);
|
|
135
|
-
}
|
|
136
|
-
// sort by group, then by renderer and then by sortOrder
|
|
137
|
-
this.steps.sort((a, b) => {
|
|
138
|
-
if (a.groupSortOrder !== b.groupSortOrder) {
|
|
139
|
-
return a.groupSortOrder - b.groupSortOrder;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (a.renderer !== b.renderer) {
|
|
143
|
-
return a.renderer === 'ejs' ? -1 : 1;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
return a.sortOrder - b.sortOrder;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
hasUnprocessedSteps() {
|
|
152
|
-
return this.steps.some(step => !step.isProcessed && !step.isSkipped);
|
|
153
|
-
}
|
|
154
|
-
getNextUnprocessedStep() {
|
|
155
|
-
let nextStep = this.steps.find(step => !step.isProcessed && !step.isSkipped);
|
|
156
|
-
if (!nextStep && this.hasUnfinalizedSteps()) {
|
|
157
|
-
if (this.getStepById("finalize")) {
|
|
158
|
-
nextStep = this.getStepById("finalize");
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
let timer = setInterval(() => {
|
|
162
|
-
// clear steps if all of them was processed and finalized
|
|
163
|
-
if (!this.hasUnprocessedSteps() && !this.hasUnfinalizedSteps()) {
|
|
164
|
-
this.steps = [];
|
|
165
|
-
Adminizer.log.debug("CLEARING STEPS", this.steps);
|
|
166
|
-
clearInterval(timer);
|
|
167
|
-
}
|
|
168
|
-
}, 5000);
|
|
169
|
-
nextStep = new FinalizeStep();
|
|
170
|
-
this.addStep(nextStep);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return nextStep;
|
|
174
|
-
}
|
|
175
|
-
hasUnfinalizedSteps() {
|
|
176
|
-
return this.steps.some(step => step.finallyPromise?.status === "pending");
|
|
177
|
-
}
|
|
178
|
-
getFinalizeStatus() {
|
|
179
|
-
let stepsWithFinalize = this.steps.filter(step => step.finallyPromise !== null);
|
|
180
|
-
let generalStatus = "fulfilled";
|
|
181
|
-
let stepFinalizeStatuses = stepsWithFinalize.map(item => {
|
|
182
|
-
let info = null;
|
|
183
|
-
// if one of them is pending, general status is pending
|
|
184
|
-
if (item.finallyPromise.status === "pending") {
|
|
185
|
-
generalStatus = "pending";
|
|
186
|
-
}
|
|
187
|
-
if (item.finallyPromise.status === "rejected") {
|
|
188
|
-
generalStatus = "rejected";
|
|
189
|
-
info = `Error: ${item.finallyPromise.info}`;
|
|
190
|
-
}
|
|
191
|
-
return { id: item.id, status: item.finallyPromise.status, description: item.finallyDescription, info: info };
|
|
192
|
-
});
|
|
193
|
-
return { status: generalStatus, finalizeList: stepFinalizeStatuses ?? [] };
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { InstallStepper } from "../lib/installStepper/installStepper";
|
|
2
|
-
import { Adminizer } from "../lib/Adminizer";
|
|
3
|
-
let installStepper = InstallStepper.getInstance();
|
|
4
|
-
export default function bindInstallStepper(adminizer) {
|
|
5
|
-
let installStepperPolicy = function (req, res, proceed) {
|
|
6
|
-
if (!req.user) {
|
|
7
|
-
return proceed();
|
|
8
|
-
}
|
|
9
|
-
let goingToProcessInstallStep = req._parsedUrl.pathname === `/install/${installStepper.id}`;
|
|
10
|
-
let goingToProcessInstallFinalize = req._parsedUrl.pathname === `/install/${installStepper.id}/finalize`;
|
|
11
|
-
if (installStepper.hasUnprocessedSteps() && !goingToProcessInstallStep && !goingToProcessInstallFinalize) {
|
|
12
|
-
return res.redirect(`${adminizer.config.routePrefix}/install/${installStepper.id}`);
|
|
13
|
-
}
|
|
14
|
-
return proceed();
|
|
15
|
-
};
|
|
16
|
-
if (Array.isArray(adminizer.config.policies) && typeof adminizer.config.policies[0] !== "string") {
|
|
17
|
-
adminizer.config.policies.push(installStepperPolicy);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
Adminizer.log.error("Can not bind install stepper. Policies is not array");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
;
|