adminizer 4.2.0-build.56 → 4.2.0-build.58

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.
@@ -45,7 +45,7 @@ export class AccessRightsHelper {
45
45
  }
46
46
  hasPermission(tokenId, user) {
47
47
  if (!tokenId) {
48
- Adminizer.log.error(`AccessRightsHelper > hasPermission no tokenId: ${tokenId}`);
48
+ Adminizer.log.warn(`AccessRightsHelper > hasPermission no tokenId: ${tokenId}`);
49
49
  return false;
50
50
  }
51
51
  tokenId = tokenId.toLowerCase();
@@ -1,6 +1,7 @@
1
1
  import inertiaActionsHelper from "./inertiaActionsHelper";
2
2
  import chalk from "chalk";
3
3
  import { isObject } from "./JsUtils";
4
+ import { MediaManagerHandler } from "../lib/media-manager/MediaManagerHandler";
4
5
  export default function inertiaAddHelper(req, entity, fields, record, view = false) {
5
6
  const actionType = 'add';
6
7
  let props = {
@@ -104,8 +105,14 @@ export default function inertiaAddHelper(req, entity, fields, record, view = fal
104
105
  options = getControlsOptions(fieldConfig, req, fieldType, 'leaflet');
105
106
  }
106
107
  if (type === 'mediamanager') {
107
- fieldType = 'mediamanager';
108
- options = field.config.options;
108
+ let mediaManager = MediaManagerHandler.get('default');
109
+ if (!mediaManager) {
110
+ options = {};
111
+ }
112
+ else {
113
+ fieldType = 'mediamanager';
114
+ options = field.config.options;
115
+ }
109
116
  }
110
117
  props.fields.push({
111
118
  label: label,
@@ -14,7 +14,7 @@ export class MediaManagerHandler {
14
14
  }
15
15
  if (!instance) {
16
16
  Adminizer.log.debug(`MediaManager list ${JSON.stringify(this.managers, null, 2)}`);
17
- throw `MediaManager with id ${id} not found`;
17
+ Adminizer.log.debug(`MediaManager with id ${id} not found`);
18
18
  }
19
19
  Adminizer.log.debug(`ins`, instance);
20
20
  return instance;
@@ -1,5 +1,5 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default abstract class ActionBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export declare abstract class ActionBase extends BaseWidget {
3
3
  readonly widgetType = "action";
4
4
  /** Widget background css color */
5
5
  abstract readonly backgroundCSS: string | null;
@@ -1,4 +1,4 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default class ActionBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export class ActionBase extends BaseWidget {
3
3
  widgetType = "action";
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { MaterialIcon } from "../../../interfaces/MaaterialIcons";
2
- export default abstract class CustomBase {
2
+ export declare abstract class CustomBase {
3
3
  /** Widget unique id */
4
4
  abstract readonly id: string;
5
5
  /** Widget Name */
@@ -1,4 +1,4 @@
1
- export default class CustomBase {
1
+ export class CustomBase {
2
2
  /** Widget background css color */
3
3
  backgroundCSS;
4
4
  widgetType = 'custom';
@@ -1,5 +1,5 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default abstract class InfoBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export declare abstract class InfoBase extends BaseWidget {
3
3
  readonly widgetType = "info";
4
4
  /** Widget background css color */
5
5
  readonly backgroundCSS: string;
@@ -1,5 +1,5 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default class InfoBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export class InfoBase extends BaseWidget {
3
3
  widgetType = "info";
4
4
  /** Widget background css color */
5
5
  backgroundCSS;
@@ -1,4 +1,4 @@
1
- import BaseWidget from "./abstractWidgetBase";
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
2
  import { MaterialIcon } from "../../../interfaces/MaaterialIcons";
3
3
  export interface Links {
4
4
  name: string;
@@ -8,7 +8,7 @@ export interface Links {
8
8
  linkType: 'self' | 'blank';
9
9
  backgroundCSS: string | null;
10
10
  }
11
- export default abstract class LinkBase extends BaseWidget {
11
+ export declare abstract class LinkBase extends BaseWidget {
12
12
  readonly widgetType = "link";
13
13
  readonly abstract links: Links[];
14
14
  /** Get info */
@@ -1,4 +1,4 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default class LinkBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export class LinkBase extends BaseWidget {
3
3
  widgetType = "link";
4
4
  }
@@ -1,5 +1,5 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default abstract class SwitchBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export declare abstract class SwitchBase extends BaseWidget {
3
3
  readonly widgetType = "switcher";
4
4
  /** Widget background css color */
5
5
  abstract readonly backgroundCSS: string | null;
@@ -1,4 +1,4 @@
1
- import BaseWidget from "./abstractWidgetBase";
2
- export default class SwitchBase extends BaseWidget {
1
+ import { BaseWidget } from "./abstractWidgetBase";
2
+ export class SwitchBase extends BaseWidget {
3
3
  widgetType = "switcher";
4
4
  }
@@ -1,5 +1,5 @@
1
1
  import { MaterialIcon } from "../../../interfaces/MaaterialIcons";
2
- export default abstract class BaseWidget {
2
+ export declare abstract class BaseWidget {
3
3
  /** Widget unique id */
4
4
  abstract readonly id: string;
5
5
  /** Widget Name */
@@ -1,2 +1,2 @@
1
- export default class BaseWidget {
1
+ export class BaseWidget {
2
2
  }
@@ -1,13 +1,13 @@
1
- import SwitcherBase from "./abstractSwitch";
2
- import InfoBase from "./abstractInfo";
3
- import ActionBase from "./abstractAction";
4
- import LinkBase from "./abstractLink";
5
- import CustomBase from "./abstractCustom";
1
+ import { SwitchBase } from "./abstractSwitch";
2
+ import { InfoBase } from "./abstractInfo";
3
+ import { ActionBase } from "./abstractAction";
4
+ import { LinkBase } from "./abstractLink";
5
+ import { CustomBase } from "./abstractCustom";
6
6
  import { AdminpanelIcon } from "../../../interfaces/adminpanelConfig";
7
7
  import { Adminizer } from "../../Adminizer";
8
8
  import { UserAP } from "models/UserAP";
9
9
  import { I18n } from "../I18n";
10
- export type WidgetType = (SwitcherBase | InfoBase | ActionBase | LinkBase | CustomBase);
10
+ export type WidgetType = (SwitchBase | InfoBase | ActionBase | LinkBase | CustomBase);
11
11
  export interface WidgetConfig {
12
12
  id: string;
13
13
  type: string;
@@ -1,8 +1,8 @@
1
- import SwitcherBase from "./abstractSwitch";
2
- import InfoBase from "./abstractInfo";
3
- import ActionBase from "./abstractAction";
4
- import LinkBase from "./abstractLink";
5
- import CustomBase from "./abstractCustom";
1
+ import { SwitchBase } from "./abstractSwitch";
2
+ import { InfoBase } from "./abstractInfo";
3
+ import { ActionBase } from "./abstractAction";
4
+ import { LinkBase } from "./abstractLink";
5
+ import { CustomBase } from "./abstractCustom";
6
6
  import * as process from "node:process";
7
7
  export class WidgetHandler {
8
8
  widgets = [];
@@ -40,7 +40,7 @@ export class WidgetHandler {
40
40
  if (this.widgets.length) {
41
41
  let id_key = 0;
42
42
  for (const widget of this.widgets) {
43
- if (widget instanceof SwitcherBase) {
43
+ if (widget instanceof SwitchBase) {
44
44
  if (this.adminizer.accessRightsHelper.hasPermission(`widget-${widget.id}`, user)) {
45
45
  widgets.push({
46
46
  id: `${widget.id}__${id_key}`,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "adminizer",
3
3
  "type": "module",
4
- "version": "4.2.0-build.56",
4
+ "version": "4.2.0-build.58",
5
5
  "main": "index.js",
6
6
  "exports": {
7
7
  ".": "./index.js",
@@ -3,6 +3,8 @@ import { MediaManagerHandler } from "../lib/media-manager/MediaManagerHandler";
3
3
  import serveStatic from "serve-static";
4
4
  import path from "path";
5
5
  export default function bindMediaManager(adminizer) {
6
+ if (!adminizer.config.mediamanager)
7
+ return;
6
8
  adminizer.emitter.on("adminizer:loaded", async () => {
7
9
  try {
8
10
  let mediaManager = new DefaultMediaManager(adminizer, 'default', 'media-manager', adminizer.config.mediamanager.fileStoragePath);