adminizer 4.3.0-build.117 → 4.3.0-build.119
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/controllers/catalog/Catalog.js +15 -16
- package/interfaces/adminpanelConfig.d.ts +0 -1
- package/lib/Adminizer.d.ts +2 -0
- package/lib/Adminizer.js +2 -2
- package/lib/catalog/AbstractCatalog.d.ts +2 -0
- package/lib/catalog/AbstractCatalog.js +2 -1
- package/lib/catalog/Navigation.d.ts +6 -4
- package/lib/catalog/Navigation.js +37 -29
- package/package.json +1 -1
|
@@ -46,22 +46,21 @@ export async function catalogController(req, res) {
|
|
|
46
46
|
return res.json(await frontendCatalog.getAddTemplate(item, req));
|
|
47
47
|
case 'getEditTemplate':
|
|
48
48
|
return res.json(await frontendCatalog.getEditTemplate(item, data.id, req, data.modelId));
|
|
49
|
-
case 'getCatalog':
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
49
|
+
case 'getCatalog': {
|
|
50
|
+
const __catalog = await frontendCatalog.getCatalog();
|
|
51
|
+
return res.json({
|
|
52
|
+
items: frontendCatalog.getitemTypes(),
|
|
53
|
+
catalog: {
|
|
54
|
+
nodes: __catalog,
|
|
55
|
+
movingGroupsRootOnly: _catalog.movingGroupsRootOnly ?? false,
|
|
56
|
+
catalogName: _catalog.name,
|
|
57
|
+
catalogId: _catalog.id,
|
|
58
|
+
catalogSlug: _catalog.slug,
|
|
59
|
+
idList: idList
|
|
60
|
+
},
|
|
61
|
+
toolsActions: await frontendCatalog.getActions([], 'tools')
|
|
62
|
+
});
|
|
63
|
+
}
|
|
65
64
|
case 'createItem':
|
|
66
65
|
return res.json({ 'data': await frontendCatalog.createItem(data.data, req) });
|
|
67
66
|
case 'getChilds':
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { CatalogHandler } from "./catalog/CatalogHandler";
|
|
|
15
15
|
import { NotificationHandler } from './notifications/NotificationHandler';
|
|
16
16
|
import { INotification } from "../interfaces/types";
|
|
17
17
|
import { MediaManagerHandler } from "./media-manager/MediaManagerHandler";
|
|
18
|
+
import { StorageServices } from "./catalog/Navigation";
|
|
18
19
|
export declare class Adminizer {
|
|
19
20
|
/**
|
|
20
21
|
* If you convey this default Middleware, it will add it to the very top of the router,
|
|
@@ -36,6 +37,7 @@ export declare class Adminizer {
|
|
|
36
37
|
controlsHandler: ControlsHandler;
|
|
37
38
|
catalogHandler: CatalogHandler;
|
|
38
39
|
mediaManagerHandler: MediaManagerHandler;
|
|
40
|
+
storageServices: StorageServices;
|
|
39
41
|
jwtSecret: string;
|
|
40
42
|
static logger: winston.Logger;
|
|
41
43
|
constructor(ormAdapters: AbstractAdapter[]);
|
package/lib/Adminizer.js
CHANGED
|
@@ -54,6 +54,7 @@ export class Adminizer {
|
|
|
54
54
|
controlsHandler;
|
|
55
55
|
catalogHandler;
|
|
56
56
|
mediaManagerHandler;
|
|
57
|
+
storageServices;
|
|
57
58
|
// Constants
|
|
58
59
|
jwtSecret = process.env.JWT_SECRET ?? uuid();
|
|
59
60
|
static logger = winston.createLogger({
|
|
@@ -208,8 +209,7 @@ export class Adminizer {
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
await bindDashboardWidgets(this);
|
|
211
|
-
|
|
212
|
-
bindNavigation(this);
|
|
212
|
+
await bindNavigation(this);
|
|
213
213
|
bindMediaManager(this);
|
|
214
214
|
await bindAccessRights(this);
|
|
215
215
|
if (I18n.appendLocale) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Adminizer } from "../Adminizer";
|
|
2
|
+
import { StorageServices } from "./Navigation";
|
|
2
3
|
/**
|
|
3
4
|
* Interface `Item` describes the data that the UI will operate on
|
|
4
5
|
* This is a common interface for all data that is linked to the catalog
|
|
@@ -24,6 +25,7 @@ export type _Item_ = {
|
|
|
24
25
|
* General Item structure that will be available for all elements, including groups
|
|
25
26
|
*/
|
|
26
27
|
export declare abstract class BaseItem<T extends Item> {
|
|
28
|
+
storageServices?: StorageServices;
|
|
27
29
|
abstract readonly type: string;
|
|
28
30
|
/**
|
|
29
31
|
* Used for infer T
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* General Item structure that will be available for all elements, including groups
|
|
3
3
|
*/
|
|
4
4
|
export class BaseItem {
|
|
5
|
+
storageServices;
|
|
5
6
|
/**
|
|
6
7
|
* Array of all global contexts, which will appear for all elements
|
|
7
8
|
*/
|
|
@@ -253,7 +254,7 @@ export class AbstractCatalog {
|
|
|
253
254
|
* Method for getting group elements
|
|
254
255
|
*/
|
|
255
256
|
getitemTypes() {
|
|
256
|
-
return this.itemTypes.map(({ adminizer, ...rest }) => rest);
|
|
257
|
+
return this.itemTypes.map(({ adminizer, storageServices, ...rest }) => rest);
|
|
257
258
|
}
|
|
258
259
|
;
|
|
259
260
|
async search(s, hasExtras = true, req) {
|
|
@@ -27,10 +27,11 @@ export declare class StorageService {
|
|
|
27
27
|
search(s: string, type: string): Promise<NavItem[]>;
|
|
28
28
|
}
|
|
29
29
|
export declare class StorageServices {
|
|
30
|
-
protected
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
protected storages: StorageService[];
|
|
31
|
+
constructor();
|
|
32
|
+
add(storage: StorageService): void;
|
|
33
|
+
get(id: string): StorageService;
|
|
34
|
+
getAll(): StorageService[];
|
|
34
35
|
}
|
|
35
36
|
export declare class Navigation extends AbstractCatalog {
|
|
36
37
|
readonly name: string;
|
|
@@ -38,6 +39,7 @@ export declare class Navigation extends AbstractCatalog {
|
|
|
38
39
|
readonly icon: string;
|
|
39
40
|
readonly actionHandlers: ActionHandler[];
|
|
40
41
|
idList: string[];
|
|
42
|
+
storageServices: StorageServices;
|
|
41
43
|
constructor(adminizer: Adminizer, config: NavigationConfig);
|
|
42
44
|
getIdList(): Promise<string[]>;
|
|
43
45
|
}
|
|
@@ -138,14 +138,16 @@ export class StorageService {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
export class StorageServices {
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
storages = [];
|
|
142
|
+
constructor() {
|
|
143
|
+
}
|
|
144
|
+
add(storage) {
|
|
143
145
|
this.storages.push(storage);
|
|
144
146
|
}
|
|
145
|
-
|
|
147
|
+
get(id) {
|
|
146
148
|
return this.storages.find(storage => storage.getId() === id);
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
getAll() {
|
|
149
151
|
return this.storages;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
@@ -155,17 +157,21 @@ export class Navigation extends AbstractCatalog {
|
|
|
155
157
|
icon = "box";
|
|
156
158
|
actionHandlers = [];
|
|
157
159
|
idList = [];
|
|
160
|
+
storageServices;
|
|
158
161
|
constructor(adminizer, config) {
|
|
159
162
|
let items = [];
|
|
163
|
+
const storageServices = new StorageServices();
|
|
160
164
|
for (const configElement of config.items) {
|
|
161
|
-
items.push(new NavigationItem(adminizer, configElement.title, configElement.model, config.model, configElement.urlPath));
|
|
165
|
+
items.push(new NavigationItem(adminizer, configElement.title, configElement.model, config.model, configElement.urlPath, storageServices));
|
|
162
166
|
}
|
|
163
|
-
items.push(new NavigationGroup(adminizer, config.groupField));
|
|
164
|
-
items.push(new LinkItem(adminizer));
|
|
167
|
+
items.push(new NavigationGroup(adminizer, config.groupField, storageServices));
|
|
168
|
+
items.push(new LinkItem(adminizer, storageServices));
|
|
169
|
+
super(adminizer, items);
|
|
170
|
+
this.storageServices = storageServices;
|
|
171
|
+
adminizer.storageServices = storageServices;
|
|
165
172
|
for (const section of config.sections) {
|
|
166
|
-
|
|
173
|
+
this.storageServices.add(new StorageService(adminizer, section, config.model));
|
|
167
174
|
}
|
|
168
|
-
super(adminizer, items);
|
|
169
175
|
this.movingGroupsRootOnly = config.movingGroupsRootOnly;
|
|
170
176
|
this.idList = config.sections ?? [];
|
|
171
177
|
}
|
|
@@ -183,7 +189,7 @@ class NavigationItem extends AbstractItem {
|
|
|
183
189
|
actionHandlers = [];
|
|
184
190
|
urlPath;
|
|
185
191
|
adminizer;
|
|
186
|
-
constructor(adminizer, name, model, navigationModel, urlPath) {
|
|
192
|
+
constructor(adminizer, name, model, navigationModel, urlPath, storageServices) {
|
|
187
193
|
super();
|
|
188
194
|
this.name = name;
|
|
189
195
|
this.navigationModel = navigationModel;
|
|
@@ -193,9 +199,10 @@ class NavigationItem extends AbstractItem {
|
|
|
193
199
|
let configModel = adminizer.config.models[this.model];
|
|
194
200
|
this.icon = configModel?.icon ?? 'file_present';
|
|
195
201
|
this.adminizer = adminizer;
|
|
202
|
+
this.storageServices = storageServices;
|
|
196
203
|
}
|
|
197
204
|
async create(data, catalogId) {
|
|
198
|
-
let storage =
|
|
205
|
+
let storage = this.storageServices.get(catalogId);
|
|
199
206
|
let storageData = null;
|
|
200
207
|
if (data._method === 'select') {
|
|
201
208
|
// Direct call by model adapter
|
|
@@ -213,7 +220,7 @@ class NavigationItem extends AbstractItem {
|
|
|
213
220
|
return await storage.setElement(data.id, storageData);
|
|
214
221
|
}
|
|
215
222
|
async dataPreparation(data, catalogId, sortOrder) {
|
|
216
|
-
let storage =
|
|
223
|
+
let storage = this.storageServices.get(catalogId);
|
|
217
224
|
let urlPath = eval('`' + this.urlPath + '`');
|
|
218
225
|
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
219
226
|
return {
|
|
@@ -231,7 +238,7 @@ class NavigationItem extends AbstractItem {
|
|
|
231
238
|
};
|
|
232
239
|
}
|
|
233
240
|
async updateModelItems(modelId, data, catalogId) {
|
|
234
|
-
let storage =
|
|
241
|
+
let storage = this.storageServices.get(catalogId);
|
|
235
242
|
let items = await storage.findElementByModelId(modelId);
|
|
236
243
|
let urlPath = eval('`' + this.urlPath + '`');
|
|
237
244
|
let response = [];
|
|
@@ -247,15 +254,15 @@ class NavigationItem extends AbstractItem {
|
|
|
247
254
|
return response[0];
|
|
248
255
|
}
|
|
249
256
|
async update(itemId, data, catalogId) {
|
|
250
|
-
let storage =
|
|
257
|
+
let storage = this.storageServices.get(catalogId);
|
|
251
258
|
return await storage.setElement(itemId, data);
|
|
252
259
|
}
|
|
253
260
|
async deleteItem(itemId, catalogId) {
|
|
254
|
-
let storage =
|
|
261
|
+
let storage = this.storageServices.get(catalogId);
|
|
255
262
|
return await storage.removeElementById(itemId);
|
|
256
263
|
}
|
|
257
264
|
async find(itemId, catalogId) {
|
|
258
|
-
let storage =
|
|
265
|
+
let storage = this.storageServices.get(catalogId);
|
|
259
266
|
return await storage.findElementById(itemId);
|
|
260
267
|
}
|
|
261
268
|
/**
|
|
@@ -288,7 +295,7 @@ class NavigationItem extends AbstractItem {
|
|
|
288
295
|
};
|
|
289
296
|
}
|
|
290
297
|
async getChilds(parentId, catalogId) {
|
|
291
|
-
let storage =
|
|
298
|
+
let storage = this.storageServices.get(catalogId);
|
|
292
299
|
return await storage.findElementsByParentId(parentId, this.type);
|
|
293
300
|
}
|
|
294
301
|
async getEditTemplate(id, catalogId, req, modelId) {
|
|
@@ -300,7 +307,7 @@ class NavigationItem extends AbstractItem {
|
|
|
300
307
|
});
|
|
301
308
|
}
|
|
302
309
|
async search(s, catalogId) {
|
|
303
|
-
let storage =
|
|
310
|
+
let storage = this.storageServices.get(catalogId);
|
|
304
311
|
return await storage.search(s, this.type);
|
|
305
312
|
}
|
|
306
313
|
}
|
|
@@ -309,13 +316,14 @@ class NavigationGroup extends AbstractGroup {
|
|
|
309
316
|
name = "Group";
|
|
310
317
|
groupField;
|
|
311
318
|
adminizer;
|
|
312
|
-
constructor(adminizer, groupField) {
|
|
319
|
+
constructor(adminizer, groupField, storageServices) {
|
|
313
320
|
super();
|
|
314
321
|
this.groupField = groupField;
|
|
315
322
|
this.adminizer = adminizer;
|
|
323
|
+
this.storageServices = storageServices;
|
|
316
324
|
}
|
|
317
325
|
async create(data, catalogId) {
|
|
318
|
-
let storage =
|
|
326
|
+
let storage = this.storageServices.get(catalogId);
|
|
319
327
|
let storageData = await this.dataPreparation(data, catalogId);
|
|
320
328
|
delete data.name;
|
|
321
329
|
delete data.parentId;
|
|
@@ -323,7 +331,7 @@ class NavigationGroup extends AbstractGroup {
|
|
|
323
331
|
return await storage.setElement(storageData.id, storageData);
|
|
324
332
|
}
|
|
325
333
|
async dataPreparation(data, catalogId, sortOrder) {
|
|
326
|
-
let storage =
|
|
334
|
+
let storage = this.storageServices.get(catalogId);
|
|
327
335
|
let parentId = data.parentId ? data.parentId : 0; // changed from null to 0
|
|
328
336
|
return {
|
|
329
337
|
id: uuid(),
|
|
@@ -338,19 +346,19 @@ class NavigationGroup extends AbstractGroup {
|
|
|
338
346
|
};
|
|
339
347
|
}
|
|
340
348
|
async deleteItem(itemId, catalogId) {
|
|
341
|
-
let storage =
|
|
349
|
+
let storage = this.storageServices.get(catalogId);
|
|
342
350
|
return await storage.removeElementById(itemId);
|
|
343
351
|
}
|
|
344
352
|
async find(itemId, catalogId) {
|
|
345
|
-
let storage =
|
|
353
|
+
let storage = this.storageServices.get(catalogId);
|
|
346
354
|
return await storage.findElementById(itemId);
|
|
347
355
|
}
|
|
348
356
|
async update(itemId, data, catalogId) {
|
|
349
|
-
let storage =
|
|
357
|
+
let storage = this.storageServices.get(catalogId);
|
|
350
358
|
return await storage.setElement(itemId, data);
|
|
351
359
|
}
|
|
352
360
|
async updateModelItems(modelId, data, catalogId) {
|
|
353
|
-
let storage =
|
|
361
|
+
let storage = this.storageServices.get(catalogId);
|
|
354
362
|
return await storage.setElement(modelId, data);
|
|
355
363
|
}
|
|
356
364
|
getAddTemplate(req) {
|
|
@@ -404,11 +412,11 @@ class NavigationGroup extends AbstractGroup {
|
|
|
404
412
|
});
|
|
405
413
|
}
|
|
406
414
|
async getChilds(parentId, catalogId) {
|
|
407
|
-
let storage =
|
|
415
|
+
let storage = this.storageServices.get(catalogId);
|
|
408
416
|
return await storage.findElementsByParentId(parentId, this.type);
|
|
409
417
|
}
|
|
410
418
|
async search(s, catalogId) {
|
|
411
|
-
let storage =
|
|
419
|
+
let storage = this.storageServices.get(catalogId);
|
|
412
420
|
return await storage.search(s, this.type);
|
|
413
421
|
}
|
|
414
422
|
}
|
|
@@ -418,8 +426,8 @@ class LinkItem extends NavigationGroup {
|
|
|
418
426
|
name = 'Link';
|
|
419
427
|
type = 'link';
|
|
420
428
|
isGroup = false;
|
|
421
|
-
constructor(adminizer) {
|
|
422
|
-
super(adminizer, []);
|
|
429
|
+
constructor(adminizer, storageServices) {
|
|
430
|
+
super(adminizer, [], storageServices);
|
|
423
431
|
}
|
|
424
432
|
getAddTemplate(req) {
|
|
425
433
|
let type = 'navigation.link';
|