@mediusinc/mng-commons 3.0.0-rc.8 → 3.0.0-rc.9
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/esm2022/lib/components/action/models/action-execution.model.mjs +1 -1
- package/esm2022/lib/components/form/autocomplete/autocomplete.component.mjs +13 -2
- package/esm2022/lib/components/form/dropdown/dropdown.component.mjs +16 -5
- package/esm2022/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +10 -3
- package/esm2022/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +7 -5
- package/esm2022/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +15 -6
- package/esm2022/lib/components/tableview/table/table.component.mjs +9 -4
- package/esm2022/lib/descriptors/action/action.descriptor.mjs +6 -6
- package/esm2022/lib/descriptors/editor/editor.descriptor.mjs +2 -2
- package/esm2022/lib/descriptors/filter/filter.descriptor.mjs +4 -4
- package/esm2022/lib/descriptors/table/column.descriptor.mjs +2 -2
- package/esm2022/lib/descriptors/tableview/tableview.descriptor.mjs +2 -2
- package/esm2022/lib/error/error.handler.mjs +7 -10
- package/esm2022/lib/models/error.model.mjs +44 -2
- package/esm2022/lib/models/index.mjs +1 -2
- package/esm2022/lib/models/log.model.mjs +1 -1
- package/esm2022/lib/provide-commons.mjs +8 -3
- package/esm2022/lib/router/route-builder.mjs +3 -3
- package/esm2022/lib/router/routes-builder.mjs +2 -2
- package/esm2022/lib/services/action-error-mapper.service.mjs +3 -2
- package/esm2022/lib/services/action-executor.service.mjs +40 -25
- package/esm2022/lib/services/configuration.service.mjs +7 -13
- package/esm2022/lib/services/index.mjs +2 -1
- package/esm2022/lib/services/internal/commons-init.service.mjs +4 -3
- package/esm2022/lib/services/log-publisher-console.service.mjs +40 -0
- package/esm2022/lib/services/logger.service.mjs +57 -50
- package/esm2022/lib/services/tokens/index.mjs +2 -1
- package/esm2022/lib/services/tokens/log-publisher.token.mjs +3 -0
- package/esm2022/lib/services/version.service.mjs +7 -2
- package/esm2022/lib/utils/action-data-provider.util.mjs +7 -7
- package/esm2022/lib/utils/error.util.mjs +247 -0
- package/esm2022/lib/utils/i18n.util.mjs +7 -9
- package/esm2022/lib/utils/index.mjs +2 -1
- package/esm2022/lib/utils/notification.util.mjs +1 -1
- package/esm2022/lib/utils/route.util.mjs +2 -2
- package/esm2022/lib/utils/string.util.mjs +32 -1
- package/esm2022/lib/utils/tableview.util.mjs +2 -2
- package/esm2022/lib/utils/type.util.mjs +2 -2
- package/fesm2022/mediusinc-mng-commons.mjs +657 -270
- package/fesm2022/mediusinc-mng-commons.mjs.map +1 -1
- package/lib/components/action/models/action-execution.model.d.ts +2 -2
- package/lib/components/form/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.d.ts +1 -0
- package/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +1 -0
- package/lib/components/tableview/table/table.component.d.ts +1 -0
- package/lib/descriptors/editor/field.descriptor.d.ts +1 -1
- package/lib/descriptors/table/column.descriptor.d.ts +1 -1
- package/lib/models/error.model.d.ts +44 -9
- package/lib/models/index.d.ts +0 -1
- package/lib/models/log.model.d.ts +14 -8
- package/lib/services/action-error-mapper.service.d.ts +10 -3
- package/lib/services/action-executor.service.d.ts +3 -2
- package/lib/services/index.d.ts +1 -0
- package/lib/services/internal/commons-init.service.d.ts +1 -0
- package/lib/services/log-publisher-console.service.d.ts +4 -0
- package/lib/services/logger.service.d.ts +11 -8
- package/lib/services/tokens/index.d.ts +1 -0
- package/lib/services/tokens/log-publisher.token.d.ts +3 -0
- package/lib/services/version.service.d.ts +1 -0
- package/lib/utils/error.util.d.ts +116 -0
- package/lib/utils/i18n.util.d.ts +3 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/notification.util.d.ts +2 -2
- package/lib/utils/string.util.d.ts +5 -0
- package/package.json +1 -1
- package/esm2022/lib/models/internal-error.model.mjs +0 -30
- package/lib/models/internal-error.model.d.ts +0 -26
|
@@ -324,33 +324,47 @@ const typeMapBase = {
|
|
|
324
324
|
QueryParam: MediusQueryParam
|
|
325
325
|
};
|
|
326
326
|
|
|
327
|
-
class
|
|
328
|
-
constructor(message,
|
|
327
|
+
class AMngErrorBase extends Error {
|
|
328
|
+
constructor(message, options) {
|
|
329
329
|
super(message);
|
|
330
|
-
this.
|
|
331
|
-
this.name = name;
|
|
332
|
-
this.id = options?.id;
|
|
330
|
+
this.name = options?.name ?? 'MngError';
|
|
333
331
|
this.messageCode = options?.messageCode;
|
|
334
|
-
this.
|
|
335
|
-
this.details = options?.details;
|
|
336
|
-
this.status = options?.status;
|
|
337
|
-
this.statusDescription = options?.statusDescription;
|
|
338
|
-
this.url = options?.url;
|
|
332
|
+
this.location = options?.location ?? window?.location?.href;
|
|
339
333
|
this.cause = options?.cause;
|
|
340
334
|
this.stack = options?.stack ?? (options?.cause ? options.cause.stack : new Error(message).stack);
|
|
335
|
+
this.details = options?.details;
|
|
341
336
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
return message;
|
|
337
|
+
}
|
|
338
|
+
class MngInternalError extends AMngErrorBase {
|
|
339
|
+
constructor(message, options) {
|
|
340
|
+
super(message, {
|
|
341
|
+
name: 'MngInternalError',
|
|
342
|
+
...options
|
|
343
|
+
});
|
|
344
|
+
this.type = 'MngInternalError';
|
|
351
345
|
}
|
|
352
|
-
|
|
353
|
-
|
|
346
|
+
}
|
|
347
|
+
class MngHttpError extends AMngErrorBase {
|
|
348
|
+
constructor(message, httpError, options) {
|
|
349
|
+
super(message, {
|
|
350
|
+
name: 'MngHttpError_' + httpError.url,
|
|
351
|
+
cause: httpError,
|
|
352
|
+
...options
|
|
353
|
+
});
|
|
354
|
+
this.type = 'MngHttpError';
|
|
355
|
+
this.httpError = httpError;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
class MngActionError extends AMngErrorBase {
|
|
359
|
+
constructor(message, actionName, options) {
|
|
360
|
+
super(message, {
|
|
361
|
+
name: 'MngActionError_' + actionName,
|
|
362
|
+
...options
|
|
363
|
+
});
|
|
364
|
+
this.type = 'MngActionError';
|
|
365
|
+
this.actionId = actionName;
|
|
366
|
+
this.actionContext = options?.actionContext;
|
|
367
|
+
this.httpError = options?.httpError;
|
|
354
368
|
}
|
|
355
369
|
}
|
|
356
370
|
|
|
@@ -373,11 +387,11 @@ class ActionDataProviderUtil {
|
|
|
373
387
|
const serviceExec = ActionDataProviderUtil.runGetAllService(ctx);
|
|
374
388
|
return isObservable(serviceExec)
|
|
375
389
|
? serviceExec
|
|
376
|
-
: throwError(() => new
|
|
390
|
+
: throwError(() => new MngActionError(`Data provider and service instance could not extract fetch function to execute in action ${ctx.instance.action.actionNameLong} (${ctx.instance.action.model?.typeName}) for item id ${ctx.parameters?.itemId}.`, ctx.contextLongName, { actionContext: ctx }));
|
|
377
391
|
}
|
|
378
392
|
static runFetchOrFail(ctx) {
|
|
379
393
|
return (ActionDataProviderUtil.runFetch(ctx) ??
|
|
380
|
-
throwError(() => new
|
|
394
|
+
throwError(() => new MngActionError(`Data provider and service instance could not extract fetch function to execute in action ${ctx.instance.action.actionNameLong} (${ctx.instance.action.model?.typeName}) for item id ${ctx.parameters?.itemId}.`, ctx.contextLongName, { actionContext: ctx })));
|
|
381
395
|
}
|
|
382
396
|
static runFetch(ctx, fallback) {
|
|
383
397
|
const dataProviderExec = ActionDataProviderUtil.runFetchDataProvider(ctx);
|
|
@@ -389,7 +403,7 @@ class ActionDataProviderUtil {
|
|
|
389
403
|
}
|
|
390
404
|
static runCreateOrFail(ctx) {
|
|
391
405
|
return (ActionDataProviderUtil.runCreate(ctx) ??
|
|
392
|
-
throwError(() => new
|
|
406
|
+
throwError(() => new MngActionError(`Data provider and service instance could not extract create function to execute in action ${ctx.instance.action.actionNameLong} (${ctx.instance.action.model?.typeName}) for item ${ctx.parameters?.item}.`, ctx.contextLongName, { actionContext: ctx })));
|
|
393
407
|
}
|
|
394
408
|
static runCreate(ctx, fallback) {
|
|
395
409
|
const dataProviderExec = ActionDataProviderUtil.runCreateDataProvider(ctx);
|
|
@@ -401,7 +415,7 @@ class ActionDataProviderUtil {
|
|
|
401
415
|
}
|
|
402
416
|
static runUpdateOrFail(ctx) {
|
|
403
417
|
return (ActionDataProviderUtil.runUpdate(ctx) ??
|
|
404
|
-
throwError(() => new
|
|
418
|
+
throwError(() => new MngActionError(`Data provider and service instance could not extract update function to execute in action ${ctx.instance.action.actionNameLong} (${ctx.instance.action.model?.typeName}) for item id ${ctx.parameters?.itemId}.`, ctx.contextLongName, { actionContext: ctx })));
|
|
405
419
|
}
|
|
406
420
|
static runUpdate(ctx, fallback) {
|
|
407
421
|
const dataProviderExec = ActionDataProviderUtil.runUpdateDataProvider(ctx);
|
|
@@ -419,7 +433,7 @@ class ActionDataProviderUtil {
|
|
|
419
433
|
const serviceExec = ActionDataProviderUtil.runDeleteService(ctx);
|
|
420
434
|
return isObservable(serviceExec)
|
|
421
435
|
? serviceExec
|
|
422
|
-
: throwError(() => new
|
|
436
|
+
: throwError(() => new MngActionError(`Data provider and service instance could not extract delete function to execute in action ${ctx.instance.action.actionNameLong} (${ctx.instance.action.model?.typeName}) for item id ${ctx.parameters?.itemId}.`, ctx.contextLongName, { actionContext: ctx }));
|
|
423
437
|
}
|
|
424
438
|
static runGetAllService(ctx) {
|
|
425
439
|
if (typeof ctx.serviceInstance !== 'undefined') {
|
|
@@ -1575,17 +1589,18 @@ class DefaultActionMngErrorMapperService extends MngActionErrorMapperService {
|
|
|
1575
1589
|
mngError = {
|
|
1576
1590
|
type: 'MngActionError',
|
|
1577
1591
|
name: error?.name ?? 'UnknownError',
|
|
1578
|
-
message: error.message ?? 'Unknown error'
|
|
1592
|
+
message: error.message ?? 'Unknown error',
|
|
1593
|
+
cause: error
|
|
1579
1594
|
};
|
|
1580
1595
|
}
|
|
1581
1596
|
return mngError;
|
|
1582
1597
|
}
|
|
1583
1598
|
}
|
|
1584
1599
|
|
|
1585
|
-
/* eslint-disable no-console */
|
|
1586
1600
|
class MngLoggerService {
|
|
1587
1601
|
static { this._instance = new MngLoggerService(); }
|
|
1588
1602
|
static { this._isInit = false; }
|
|
1603
|
+
static { this._publishers = []; }
|
|
1589
1604
|
static { this._entriesBuffer = []; }
|
|
1590
1605
|
static { this._categoryInstances = {}; }
|
|
1591
1606
|
static { this._timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS'; }
|
|
@@ -1603,15 +1618,19 @@ class MngLoggerService {
|
|
|
1603
1618
|
MngLoggerService._timestampFormat = config.timestampFormat;
|
|
1604
1619
|
}
|
|
1605
1620
|
}
|
|
1606
|
-
static init(configurationService) {
|
|
1621
|
+
static init(configurationService, publishers) {
|
|
1607
1622
|
if (MngLoggerService._isInit) {
|
|
1608
1623
|
return;
|
|
1609
1624
|
}
|
|
1610
1625
|
MngLoggerService._configurationService = configurationService;
|
|
1626
|
+
MngLoggerService._publishers = publishers;
|
|
1611
1627
|
MngLoggerService._isInit = true;
|
|
1612
1628
|
MngLoggerService._flushBuffer();
|
|
1613
1629
|
}
|
|
1614
1630
|
static _flushBuffer() {
|
|
1631
|
+
if (!MngLoggerService._isInit) {
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1615
1634
|
MngLoggerService._entriesBuffer.forEach(e => this._instance._log(e));
|
|
1616
1635
|
MngLoggerService._entriesBuffer = [];
|
|
1617
1636
|
}
|
|
@@ -1630,26 +1649,38 @@ class MngLoggerService {
|
|
|
1630
1649
|
MngLoggerService._categoryInstances[category] = logger;
|
|
1631
1650
|
return logger;
|
|
1632
1651
|
}
|
|
1633
|
-
_processLog(
|
|
1634
|
-
const timestamp =
|
|
1635
|
-
const
|
|
1636
|
-
const log = {
|
|
1652
|
+
_processLog(msgOrError, logLevel, category = undefined, data) {
|
|
1653
|
+
const [timestamp, timestampFormatted] = [...this._getTimestamps()];
|
|
1654
|
+
const logEntry = {
|
|
1637
1655
|
level: logLevel,
|
|
1638
|
-
message:
|
|
1656
|
+
message: typeof msgOrError === 'string' ? msgOrError : msgOrError.message,
|
|
1639
1657
|
data: data,
|
|
1640
|
-
category: category,
|
|
1658
|
+
category: this.category ?? category,
|
|
1641
1659
|
timestamp: timestamp,
|
|
1642
1660
|
timestampFormatted: timestampFormatted ?? undefined
|
|
1643
1661
|
};
|
|
1644
|
-
if (
|
|
1645
|
-
//
|
|
1646
|
-
|
|
1662
|
+
if (msgOrError instanceof Error) {
|
|
1663
|
+
// set error from message param
|
|
1664
|
+
logEntry.error = msgOrError;
|
|
1647
1665
|
}
|
|
1648
|
-
else {
|
|
1649
|
-
|
|
1666
|
+
else if (data?.length && data[0] instanceof Error) {
|
|
1667
|
+
// if first data is error, also consider as error
|
|
1668
|
+
logEntry.error = data[0];
|
|
1669
|
+
data = data.splice(1);
|
|
1650
1670
|
}
|
|
1671
|
+
this._log(logEntry);
|
|
1672
|
+
}
|
|
1673
|
+
_getTimestamps() {
|
|
1674
|
+
const timestamp = new Date();
|
|
1675
|
+
const timestampFormatted = this.datePipe.transform(timestamp, MngLoggerService._timestampFormat) ?? DateUtil.toIsoString(timestamp, false, true, true);
|
|
1676
|
+
return [timestamp, timestampFormatted];
|
|
1651
1677
|
}
|
|
1652
1678
|
_log(log) {
|
|
1679
|
+
if (!MngLoggerService._isInit) {
|
|
1680
|
+
// add to buffer
|
|
1681
|
+
MngLoggerService._entriesBuffer.push(log);
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1653
1684
|
const logConfig = (MngLoggerService._configurationService?.getConfigValue)?.('log');
|
|
1654
1685
|
if ((this.category && log.level < (logConfig?.category?.[this.category]?.level ?? logConfig?.level ?? this.defaultLogLevel)) ||
|
|
1655
1686
|
(!this.category && log.level < (logConfig?.level ?? this.defaultLogLevel))) {
|
|
@@ -1658,48 +1689,38 @@ class MngLoggerService {
|
|
|
1658
1689
|
if (logConfig?.timestampFormat) {
|
|
1659
1690
|
log.timestampFormatted = this.datePipe.transform(log.timestamp, logConfig.timestampFormat) ?? undefined;
|
|
1660
1691
|
}
|
|
1661
|
-
|
|
1662
|
-
if (log.category)
|
|
1663
|
-
prefix += ` [${log.category}]`;
|
|
1664
|
-
prefix += ':';
|
|
1665
|
-
switch (log.level) {
|
|
1666
|
-
case LogLevelEnum.Trace:
|
|
1667
|
-
console.trace(prefix, log.message, ...log.data);
|
|
1668
|
-
break;
|
|
1669
|
-
case LogLevelEnum.Debug:
|
|
1670
|
-
console.debug(prefix, log.message, ...log.data);
|
|
1671
|
-
break;
|
|
1672
|
-
case LogLevelEnum.Log:
|
|
1673
|
-
console.log(prefix, log.message, ...log.data);
|
|
1674
|
-
break;
|
|
1675
|
-
case LogLevelEnum.Info:
|
|
1676
|
-
console.info(prefix, log.message, ...log.data);
|
|
1677
|
-
break;
|
|
1678
|
-
case LogLevelEnum.Warning:
|
|
1679
|
-
console.warn(prefix, log.message, ...log.data);
|
|
1680
|
-
break;
|
|
1681
|
-
case LogLevelEnum.Error:
|
|
1682
|
-
console.error(prefix, log.message, ...log.data);
|
|
1683
|
-
break;
|
|
1684
|
-
}
|
|
1692
|
+
MngLoggerService._publishers.forEach(p => p.addEntry(log));
|
|
1685
1693
|
}
|
|
1686
|
-
trace(
|
|
1687
|
-
this._processLog(
|
|
1694
|
+
trace(msgOrError, ...data) {
|
|
1695
|
+
this._processLog(msgOrError, LogLevelEnum.Trace, undefined, data);
|
|
1688
1696
|
}
|
|
1689
|
-
debug(
|
|
1690
|
-
this._processLog(
|
|
1697
|
+
debug(msgOrError, ...data) {
|
|
1698
|
+
this._processLog(msgOrError, LogLevelEnum.Debug, undefined, data);
|
|
1691
1699
|
}
|
|
1692
|
-
log(
|
|
1693
|
-
this._processLog(
|
|
1700
|
+
log(msgOrError, logLevel = LogLevelEnum.Log, category = undefined, ...data) {
|
|
1701
|
+
this._processLog(msgOrError, logLevel, category, data);
|
|
1694
1702
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1703
|
+
logEntry(logEntry) {
|
|
1704
|
+
const [timestamp, timestampFormatted] = [...this._getTimestamps()];
|
|
1705
|
+
const logEntryFinal = {
|
|
1706
|
+
timestamp: timestamp,
|
|
1707
|
+
timestampFormatted: timestampFormatted ?? undefined,
|
|
1708
|
+
category: this.category ?? logEntry.category,
|
|
1709
|
+
message: '',
|
|
1710
|
+
messageDetails: logEntry.messageDetails,
|
|
1711
|
+
level: LogLevelEnum.Log,
|
|
1712
|
+
...logEntry
|
|
1713
|
+
};
|
|
1714
|
+
this._log(logEntryFinal);
|
|
1697
1715
|
}
|
|
1698
|
-
|
|
1699
|
-
this._processLog(
|
|
1716
|
+
info(msgOrError, ...data) {
|
|
1717
|
+
this._processLog(msgOrError, LogLevelEnum.Info, undefined, data);
|
|
1700
1718
|
}
|
|
1701
|
-
|
|
1702
|
-
this._processLog(
|
|
1719
|
+
warn(msgOrError, ...data) {
|
|
1720
|
+
this._processLog(msgOrError, LogLevelEnum.Warning, undefined, data);
|
|
1721
|
+
}
|
|
1722
|
+
error(msgOrError, ...data) {
|
|
1723
|
+
this._processLog(msgOrError, LogLevelEnum.Error, undefined, data);
|
|
1703
1724
|
}
|
|
1704
1725
|
}
|
|
1705
1726
|
|
|
@@ -1712,6 +1733,8 @@ const MNG_COMMONS_INITIALIZER_IT = new InjectionToken('MNG Commons Initializer')
|
|
|
1712
1733
|
|
|
1713
1734
|
const ACTION_EDITOR_DIALOG_COMPONENT_SETTING = new InjectionToken('ACTION_EDITOR_DIALOG_COMPONENT_SETTING');
|
|
1714
1735
|
|
|
1736
|
+
const MNG_LOG_PUBLISHERS = new InjectionToken('MNG_LOG_PUBLISHERS');
|
|
1737
|
+
|
|
1715
1738
|
const MNG_MODULE_CONFIG_IT = new InjectionToken('MngModuleConfig');
|
|
1716
1739
|
|
|
1717
1740
|
class MngCommonsService {
|
|
@@ -2442,7 +2465,7 @@ class MngActionExecutorService {
|
|
|
2442
2465
|
return runResult;
|
|
2443
2466
|
}), catchError(err => {
|
|
2444
2467
|
// transform error to mng action error
|
|
2445
|
-
const actionError = this.toMngActionError(err);
|
|
2468
|
+
const actionError = this.toMngActionError(err, ctx);
|
|
2446
2469
|
// set instance state to error
|
|
2447
2470
|
ctx.instance.state = isMainRunFn ? ActionInstanceStateEnum.RunError : ActionInstanceStateEnum.FetchError;
|
|
2448
2471
|
// mark execution error on context
|
|
@@ -2451,10 +2474,6 @@ class MngActionExecutorService {
|
|
|
2451
2474
|
if (isMainRunFn) {
|
|
2452
2475
|
ctx.instance.error = err;
|
|
2453
2476
|
ctx.instance.isRunLoadingSubject.next(false);
|
|
2454
|
-
// handle error notification
|
|
2455
|
-
if (ctx.instance.action.hasRunNotificationError) {
|
|
2456
|
-
actionError.notification = NotificationUtil.actionNotificationError(this.translate, ctx.instance.action, actionError, ctx.functionName, ctx.parameters.viewContainer ?? undefined, ctx.parameters.item);
|
|
2457
|
-
}
|
|
2458
2477
|
// handle possible error action if run
|
|
2459
2478
|
if (isMainRunFn && ctx.instance.action.onRunErrorAction) {
|
|
2460
2479
|
// cannot start with trigger, because routing might be problematic (lousing previous results etc.)
|
|
@@ -2472,13 +2491,13 @@ class MngActionExecutorService {
|
|
|
2472
2491
|
NotificationUtil.actionNotificationError(this.translate, ctx.instance.action, actionError, 'fetch', ctx.parameters.viewContainer, ctx.parameters.item);
|
|
2473
2492
|
}
|
|
2474
2493
|
}
|
|
2475
|
-
//
|
|
2494
|
+
// list and map only to mark instance state as finished error state
|
|
2476
2495
|
return errorObs.pipe(map(() => {
|
|
2477
2496
|
// deactivate action only if critical (fetch on editor or run on button actions)
|
|
2478
2497
|
if (isErrorCriticalRunFn) {
|
|
2479
2498
|
this.finishAction(ctx.instance);
|
|
2480
2499
|
}
|
|
2481
|
-
// rethrow error to propagate
|
|
2500
|
+
// rethrow error to propagate further
|
|
2482
2501
|
throw actionError;
|
|
2483
2502
|
}));
|
|
2484
2503
|
}));
|
|
@@ -2487,9 +2506,11 @@ class MngActionExecutorService {
|
|
|
2487
2506
|
this.logger.debug(`ActionContext ${ctx.contextLongName} execution next event`, res);
|
|
2488
2507
|
},
|
|
2489
2508
|
error: err => {
|
|
2490
|
-
this.logger.debug(`ActionContext ${ctx.contextLongName} execution error event`, err);
|
|
2491
2509
|
if (err?.type !== 'MngActionError') {
|
|
2492
|
-
this.logger.error(`Non
|
|
2510
|
+
this.logger.error(`Non action error occurred`, err);
|
|
2511
|
+
}
|
|
2512
|
+
else {
|
|
2513
|
+
this.logger.debug(`Action context ${ctx.contextLongName} execution error event`, err);
|
|
2493
2514
|
}
|
|
2494
2515
|
}
|
|
2495
2516
|
});
|
|
@@ -2852,22 +2873,39 @@ class MngActionExecutorService {
|
|
|
2852
2873
|
/**
|
|
2853
2874
|
* Transform error of any type to mng error by using error mapper that could be provided by final project.
|
|
2854
2875
|
* @param error error of any type.
|
|
2876
|
+
* @param context Action context.
|
|
2855
2877
|
*
|
|
2856
2878
|
* @return mapped MngError.
|
|
2857
2879
|
*/
|
|
2858
|
-
toMngActionError(error) {
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2880
|
+
toMngActionError(error, context) {
|
|
2881
|
+
let mngError;
|
|
2882
|
+
if (context) {
|
|
2883
|
+
const options = {
|
|
2884
|
+
cause: error,
|
|
2885
|
+
location: this.router.url
|
|
2886
|
+
};
|
|
2887
|
+
if (error instanceof HttpErrorResponse) {
|
|
2888
|
+
options.httpError = error;
|
|
2889
|
+
}
|
|
2890
|
+
mngError = new MngActionError(error?.message ?? 'Unknown error', context.contextLongName);
|
|
2891
|
+
}
|
|
2892
|
+
else if (error instanceof HttpErrorResponse) {
|
|
2893
|
+
// should not really happen (should always be wrapped in MngActionError), just in case
|
|
2894
|
+
mngError = new MngHttpError(`Http Error occurred in action`, error, {
|
|
2895
|
+
location: this.router.url
|
|
2896
|
+
});
|
|
2897
|
+
}
|
|
2898
|
+
else {
|
|
2899
|
+
// not from action, so unknown source of error
|
|
2900
|
+
mngError = new MngInternalError(error?.message ?? 'Unknown error', {
|
|
2901
|
+
name: error?.name ?? 'UnknownError',
|
|
2902
|
+
location: this.router.url,
|
|
2903
|
+
cause: error
|
|
2904
|
+
});
|
|
2869
2905
|
}
|
|
2870
|
-
|
|
2906
|
+
// just trace it, allow user to set if this is error or not
|
|
2907
|
+
this.logger.trace(mngError);
|
|
2908
|
+
return this.errorMapper.toMngError(error, mngError);
|
|
2871
2909
|
}
|
|
2872
2910
|
/**
|
|
2873
2911
|
* Creates or gets existing action instance.
|
|
@@ -2884,7 +2922,7 @@ class MngActionExecutorService {
|
|
|
2884
2922
|
}
|
|
2885
2923
|
if (!instance) {
|
|
2886
2924
|
if (!action) {
|
|
2887
|
-
throw new MngInternalError('Action descriptor is not provided, instance cannot be created.', '
|
|
2925
|
+
throw new MngInternalError('Action descriptor is not provided, instance cannot be created.', { name: 'ActionExecutorServiceError' });
|
|
2888
2926
|
}
|
|
2889
2927
|
// create new instance if non provided
|
|
2890
2928
|
instance = new ActionInstance(action, instanceInitialStatus);
|
|
@@ -3020,18 +3058,13 @@ class MngConfigurationService {
|
|
|
3020
3058
|
return httpClient.get(noEnvUrl);
|
|
3021
3059
|
}
|
|
3022
3060
|
else {
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
return throwError(() => {
|
|
3026
|
-
return new MngInternalError(message, 'ConfigurationService', {
|
|
3027
|
-
cause: err,
|
|
3028
|
-
status: err.status,
|
|
3029
|
-
statusDescription: err.statusText,
|
|
3030
|
-
url: err.url ?? undefined
|
|
3031
|
-
});
|
|
3032
|
-
});
|
|
3061
|
+
this.logger?.warn(`Configuration file ${url} not loaded`, err);
|
|
3062
|
+
return of(false);
|
|
3033
3063
|
}
|
|
3034
3064
|
}), map(configuration => {
|
|
3065
|
+
if (typeof configuration !== 'object') {
|
|
3066
|
+
return false;
|
|
3067
|
+
}
|
|
3035
3068
|
sourceInfo.configuration = configuration;
|
|
3036
3069
|
sourceInfo.isLoaded = true;
|
|
3037
3070
|
return true;
|
|
@@ -3265,6 +3298,7 @@ class MngVersionService {
|
|
|
3265
3298
|
constructor(http, configurationService) {
|
|
3266
3299
|
this.http = http;
|
|
3267
3300
|
this.configurationService = configurationService;
|
|
3301
|
+
this.logger = inject(MngLoggerService).create('MngVersionService');
|
|
3268
3302
|
this.cache = {};
|
|
3269
3303
|
}
|
|
3270
3304
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -3283,6 +3317,9 @@ class MngVersionService {
|
|
|
3283
3317
|
this.http.get(urlSegments.join('')).subscribe({
|
|
3284
3318
|
next: res => {
|
|
3285
3319
|
this.cache[url].next(res);
|
|
3320
|
+
},
|
|
3321
|
+
error: err => {
|
|
3322
|
+
this.logger.error('Version could not be retreived', err);
|
|
3286
3323
|
}
|
|
3287
3324
|
});
|
|
3288
3325
|
}
|
|
@@ -3386,6 +3423,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImpor
|
|
|
3386
3423
|
args: [{ providedIn: 'root' }]
|
|
3387
3424
|
}] });
|
|
3388
3425
|
|
|
3426
|
+
/* eslint-disable no-console */
|
|
3427
|
+
class MngLogPublisherConsoleService {
|
|
3428
|
+
addEntry(entry) {
|
|
3429
|
+
let prefix = `${entry.timestampFormatted}`;
|
|
3430
|
+
if (entry.category)
|
|
3431
|
+
prefix += ` [${entry.category}]`;
|
|
3432
|
+
prefix += ':';
|
|
3433
|
+
const message = `${entry.message}${entry.messageDetails ? `\n${entry.messageDetails}` : ''}`;
|
|
3434
|
+
const logParams = [prefix, message];
|
|
3435
|
+
if (entry.error) {
|
|
3436
|
+
logParams.push(`\n${ErrorUtil.getErrorName(entry.error)}:`, entry.error);
|
|
3437
|
+
}
|
|
3438
|
+
if (entry.data?.length) {
|
|
3439
|
+
logParams.push(`\nData:\n`, ...entry.data);
|
|
3440
|
+
}
|
|
3441
|
+
switch (entry.level) {
|
|
3442
|
+
case LogLevelEnum.Trace:
|
|
3443
|
+
console.trace(...logParams);
|
|
3444
|
+
break;
|
|
3445
|
+
case LogLevelEnum.Debug:
|
|
3446
|
+
console.debug(...logParams);
|
|
3447
|
+
break;
|
|
3448
|
+
case LogLevelEnum.Log:
|
|
3449
|
+
console.log(...logParams);
|
|
3450
|
+
break;
|
|
3451
|
+
case LogLevelEnum.Info:
|
|
3452
|
+
console.info(...logParams);
|
|
3453
|
+
break;
|
|
3454
|
+
case LogLevelEnum.Warning:
|
|
3455
|
+
console.warn(...logParams);
|
|
3456
|
+
break;
|
|
3457
|
+
case LogLevelEnum.Error:
|
|
3458
|
+
console.error(...logParams);
|
|
3459
|
+
break;
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
|
|
3389
3464
|
class ObjectSerializer {
|
|
3390
3465
|
constructor() {
|
|
3391
3466
|
this._logCategory = 'ObjectSerializer';
|
|
@@ -3963,7 +4038,7 @@ class TableviewUtil {
|
|
|
3963
4038
|
*/
|
|
3964
4039
|
static expandAttributeDefWithTableviewTypes(attributes) {
|
|
3965
4040
|
if (attributes == null) {
|
|
3966
|
-
throw new MngInternalError('AttributeDef is null, problem with ObjectSerializer::findAttributesDefinitionByClassType?', '
|
|
4041
|
+
throw new MngInternalError('AttributeDef is null, problem with ObjectSerializer::findAttributesDefinitionByClassType?', { name: 'TableViewUtilsError' });
|
|
3967
4042
|
}
|
|
3968
4043
|
const objectSerializer = ObjectSerializer.get();
|
|
3969
4044
|
const tableviewAttributeDef = [];
|
|
@@ -4810,14 +4885,14 @@ class FilterLookupDescriptor extends FilterDescriptor {
|
|
|
4810
4885
|
this._defaultValueTo = filterValueTo;
|
|
4811
4886
|
this._defaultFilterMatchMode = filterMatchMode;
|
|
4812
4887
|
if (Array.isArray(filterValue) && !this.multiselect) {
|
|
4813
|
-
throw new MngInternalError('Array default filter can only be used with a multiselect filter.', '
|
|
4888
|
+
throw new MngInternalError('Array default filter can only be used with a multiselect filter.', { name: 'FilterDescriptorError' });
|
|
4814
4889
|
}
|
|
4815
4890
|
if (filterMatchMode && this._matchModes && this._matchModes.indexOf(filterMatchMode) < 0) {
|
|
4816
4891
|
this._defaultFilterMatchMode = undefined;
|
|
4817
4892
|
MngLoggerService.get().debug(`WARNING: Default filter match mode '${filterMatchMode}' could not be assigned for property ${this._property}.`);
|
|
4818
4893
|
}
|
|
4819
4894
|
if ((Array.isArray(filterValue) && !this.multiselect) || (this.multiselect && !Array.isArray(filterValue))) {
|
|
4820
|
-
throw new MngInternalError(`Default value not in correct format for property ${this._property}.`, '
|
|
4895
|
+
throw new MngInternalError(`Default value not in correct format for property ${this._property}.`, { name: 'FilterDescriptorError' });
|
|
4821
4896
|
}
|
|
4822
4897
|
return this;
|
|
4823
4898
|
}
|
|
@@ -4873,7 +4948,7 @@ class FilterLookupEnumDescriptor extends FilterLookupDescriptor {
|
|
|
4873
4948
|
return super.withMultiselect(multiselect);
|
|
4874
4949
|
}
|
|
4875
4950
|
withDefaultFilter() {
|
|
4876
|
-
throw new MngInternalError(`withDefaultFilter on FilterLookupEnumDescriptor should not be used. Use withDefaultFilterEnum instead.`, '
|
|
4951
|
+
throw new MngInternalError(`withDefaultFilter on FilterLookupEnumDescriptor should not be used. Use withDefaultFilterEnum instead.`, { name: 'FilterDescriptorError' });
|
|
4877
4952
|
}
|
|
4878
4953
|
withDefaultFilterEnum(filterValue, filterValueTo, filterMatchMode) {
|
|
4879
4954
|
let defaultOptionValue;
|
|
@@ -5214,7 +5289,7 @@ class ColumnDescriptor {
|
|
|
5214
5289
|
}
|
|
5215
5290
|
withFilterLookupEnum(options) {
|
|
5216
5291
|
if (this._columnType !== ColumnTypeEnum.Enum || !this._enumType) {
|
|
5217
|
-
throw new MngInternalError(`Column ${this._property} is not of type enum or enum type is undefined.`, '
|
|
5292
|
+
throw new MngInternalError(`Column ${this._property} is not of type enum or enum type is undefined.`, { name: 'ColumnDescriptorError' });
|
|
5218
5293
|
}
|
|
5219
5294
|
const filterDescriptor = new FilterLookupEnumDescriptor(this._property, this._enumType, options, this._enumNameAsValue, this._enumTitlePath);
|
|
5220
5295
|
this._filterDescriptor = filterDescriptor;
|
|
@@ -6159,7 +6234,7 @@ class TableviewDescriptor {
|
|
|
6159
6234
|
*/
|
|
6160
6235
|
withModifiedType(property, columnType, fieldType, columnDisplayType) {
|
|
6161
6236
|
if (columnType === ColumnTypeEnum.Enum) {
|
|
6162
|
-
throw new MngInternalError('Do not use with types where args are required', '
|
|
6237
|
+
throw new MngInternalError('Do not use with types where args are required', { name: 'TableViewDescriptorError' });
|
|
6163
6238
|
}
|
|
6164
6239
|
const attributeDef = TableviewUtil.getAttributeDefMap(this._modelType).find(atribute => atribute.name === property);
|
|
6165
6240
|
if (attributeDef != null) {
|
|
@@ -7483,7 +7558,7 @@ class EditorDescriptor {
|
|
|
7483
7558
|
removeField(property) {
|
|
7484
7559
|
const fieldIdx = this._fields.findIndex(f => f.property === property);
|
|
7485
7560
|
if (fieldIdx < 0) {
|
|
7486
|
-
throw new MngInternalError(`Field ${property} does not exist.`, '
|
|
7561
|
+
throw new MngInternalError(`Field ${property} does not exist.`, { name: 'EditorDescriptorError' });
|
|
7487
7562
|
}
|
|
7488
7563
|
for (const group of this._groups) {
|
|
7489
7564
|
const groupFieldIdx = group.fields.findIndex(f => f instanceof AFieldDescriptor && f.property === property);
|
|
@@ -8056,6 +8131,393 @@ class EnumUtil {
|
|
|
8056
8131
|
}
|
|
8057
8132
|
}
|
|
8058
8133
|
|
|
8134
|
+
class ObjectUtil {
|
|
8135
|
+
static deepCopy(obj, options) {
|
|
8136
|
+
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
8137
|
+
return obj;
|
|
8138
|
+
}
|
|
8139
|
+
if (obj instanceof Date) {
|
|
8140
|
+
return new Date(+obj);
|
|
8141
|
+
}
|
|
8142
|
+
let copy;
|
|
8143
|
+
if (options?.mapGettersToProperties) {
|
|
8144
|
+
copy = {};
|
|
8145
|
+
}
|
|
8146
|
+
else {
|
|
8147
|
+
copy = options?.objectPrototype ? Object.create(options.objectPrototype['prototype']) : Object.create(Object.getPrototypeOf(obj));
|
|
8148
|
+
Object.assign(copy, obj);
|
|
8149
|
+
}
|
|
8150
|
+
for (const key of ObjectUtil.getProperties(obj)) {
|
|
8151
|
+
const prop = obj[key];
|
|
8152
|
+
copy[key] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
8153
|
+
}
|
|
8154
|
+
if (options?.mapGettersToProperties) {
|
|
8155
|
+
for (const getterKey of ObjectUtil.getGetters(obj)) {
|
|
8156
|
+
const prop = obj[getterKey];
|
|
8157
|
+
copy[getterKey] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
8158
|
+
}
|
|
8159
|
+
}
|
|
8160
|
+
return copy;
|
|
8161
|
+
}
|
|
8162
|
+
static deepMerge(target, source) {
|
|
8163
|
+
if (!ObjectUtil.isObject(source)) {
|
|
8164
|
+
return target;
|
|
8165
|
+
}
|
|
8166
|
+
for (const key of ObjectUtil.getProperties(source)) {
|
|
8167
|
+
if (ObjectUtil.isObject(source[key])) {
|
|
8168
|
+
if (ObjectUtil.isObject(target[key])) {
|
|
8169
|
+
target[key] = ObjectUtil.deepMerge(target[key], source[key]);
|
|
8170
|
+
}
|
|
8171
|
+
else {
|
|
8172
|
+
target[key] = ObjectUtil.deepCopy(source[key]);
|
|
8173
|
+
}
|
|
8174
|
+
}
|
|
8175
|
+
else if (Array.isArray(source[key])) {
|
|
8176
|
+
if (!Array.isArray(target[key])) {
|
|
8177
|
+
target[key] = source[key].map(i => (ObjectUtil.isObject(i) ? ObjectUtil.deepMerge({}, i) : i));
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
else if (typeof target[key] === 'undefined') {
|
|
8181
|
+
target[key] = source[key];
|
|
8182
|
+
}
|
|
8183
|
+
}
|
|
8184
|
+
return target;
|
|
8185
|
+
}
|
|
8186
|
+
static isObject(obj) {
|
|
8187
|
+
return typeof obj === 'object' && obj !== null && !Array.isArray(obj);
|
|
8188
|
+
}
|
|
8189
|
+
static handleProp(prop, options) {
|
|
8190
|
+
if (Array.isArray(prop)) {
|
|
8191
|
+
return prop.map(i => ObjectUtil.deepCopy(i, options));
|
|
8192
|
+
}
|
|
8193
|
+
else if (typeof prop === 'object' && prop !== null) {
|
|
8194
|
+
return ObjectUtil.deepCopy(prop, options);
|
|
8195
|
+
}
|
|
8196
|
+
else {
|
|
8197
|
+
return prop;
|
|
8198
|
+
}
|
|
8199
|
+
}
|
|
8200
|
+
static getProperties(obj) {
|
|
8201
|
+
return Object.keys(obj);
|
|
8202
|
+
}
|
|
8203
|
+
static getGetters(obj) {
|
|
8204
|
+
const getterSet = new Set();
|
|
8205
|
+
let currObj = obj;
|
|
8206
|
+
while (currObj) {
|
|
8207
|
+
const getters = Object.entries(Object.getOwnPropertyDescriptors(currObj))
|
|
8208
|
+
.filter(([, descriptor]) => typeof descriptor.get === 'function')
|
|
8209
|
+
.filter(([key]) => key !== '__proto__')
|
|
8210
|
+
.map(([key]) => key);
|
|
8211
|
+
for (const getter of getters) {
|
|
8212
|
+
getterSet.add(getter);
|
|
8213
|
+
}
|
|
8214
|
+
currObj = Object.getPrototypeOf(currObj);
|
|
8215
|
+
}
|
|
8216
|
+
return Array.from(getterSet);
|
|
8217
|
+
}
|
|
8218
|
+
}
|
|
8219
|
+
|
|
8220
|
+
class StringUtil {
|
|
8221
|
+
static escapeHtml(value) {
|
|
8222
|
+
return value.replace(/</g, '<').replace(/>/g, '>');
|
|
8223
|
+
}
|
|
8224
|
+
static escapeHtmlAny(value) {
|
|
8225
|
+
if (typeof value === 'string') {
|
|
8226
|
+
return StringUtil.escapeHtml(value);
|
|
8227
|
+
}
|
|
8228
|
+
else if (typeof value === 'object') {
|
|
8229
|
+
const escapedValue = ObjectUtil.deepCopy(value, { mapGettersToProperties: true });
|
|
8230
|
+
for (const key in value) {
|
|
8231
|
+
if (typeof value[key] === 'string') {
|
|
8232
|
+
escapedValue[key] = StringUtil.escapeHtml(value[key]);
|
|
8233
|
+
}
|
|
8234
|
+
else if (typeof value[key] === 'object') {
|
|
8235
|
+
escapedValue[key] = StringUtil.escapeHtmlAny(value[key]);
|
|
8236
|
+
}
|
|
8237
|
+
else {
|
|
8238
|
+
escapedValue[key] = value[key];
|
|
8239
|
+
}
|
|
8240
|
+
}
|
|
8241
|
+
return escapedValue;
|
|
8242
|
+
}
|
|
8243
|
+
return value;
|
|
8244
|
+
}
|
|
8245
|
+
/**
|
|
8246
|
+
* Stringifies a value - primitives with toString, dates with dateUtil, objects with JSON.stringify.
|
|
8247
|
+
* @param value Any value.
|
|
8248
|
+
*/
|
|
8249
|
+
static stringify(value) {
|
|
8250
|
+
if (value === null) {
|
|
8251
|
+
return 'null';
|
|
8252
|
+
}
|
|
8253
|
+
if (typeof value === 'undefined') {
|
|
8254
|
+
return 'undefined';
|
|
8255
|
+
}
|
|
8256
|
+
// eliminate functions, cause they could fall into objects
|
|
8257
|
+
if (typeof value === 'function') {
|
|
8258
|
+
return `Function ${value.name ?? 'anonymous'}()`;
|
|
8259
|
+
}
|
|
8260
|
+
if (typeof value === 'object') {
|
|
8261
|
+
// date is object, but would like it in ISO string representation
|
|
8262
|
+
if (value instanceof Date) {
|
|
8263
|
+
return DateUtil.toIsoString(value, false, true, true) ?? 'null';
|
|
8264
|
+
}
|
|
8265
|
+
try {
|
|
8266
|
+
return JSON.stringify(value);
|
|
8267
|
+
}
|
|
8268
|
+
catch (e) {
|
|
8269
|
+
return value.toString();
|
|
8270
|
+
}
|
|
8271
|
+
}
|
|
8272
|
+
// only primitives should be left to be printed like this (string, number, boolean)
|
|
8273
|
+
return value.toString();
|
|
8274
|
+
}
|
|
8275
|
+
}
|
|
8276
|
+
|
|
8277
|
+
class ErrorUtil {
|
|
8278
|
+
/**
|
|
8279
|
+
* Converts RxJS subscription error to MngError.
|
|
8280
|
+
* @param error Error.
|
|
8281
|
+
* @param name Optional name to write in mngError.
|
|
8282
|
+
* @param details Optional details of error.
|
|
8283
|
+
*/
|
|
8284
|
+
static fromSubscribeError(error, name, details) {
|
|
8285
|
+
const opts = {
|
|
8286
|
+
name,
|
|
8287
|
+
details,
|
|
8288
|
+
location: window?.location?.href
|
|
8289
|
+
};
|
|
8290
|
+
if (error instanceof HttpErrorResponse) {
|
|
8291
|
+
return new MngHttpError(error.message ?? 'Http Error occurred', error, opts);
|
|
8292
|
+
}
|
|
8293
|
+
else {
|
|
8294
|
+
opts.cause = error;
|
|
8295
|
+
return new MngInternalError(error.message ?? 'Internal Error occurred', opts);
|
|
8296
|
+
}
|
|
8297
|
+
}
|
|
8298
|
+
/**
|
|
8299
|
+
* Checks if error is Http error (Angular or Mng).
|
|
8300
|
+
* @param error
|
|
8301
|
+
*/
|
|
8302
|
+
static isHttpErrorResponse(error) {
|
|
8303
|
+
return error instanceof HttpErrorResponse || error instanceof MngHttpError || (error instanceof MngActionError && error.httpError);
|
|
8304
|
+
}
|
|
8305
|
+
/**
|
|
8306
|
+
* Gets HttpErrorResponse from error (Angular or Mng).
|
|
8307
|
+
* @param error Error.
|
|
8308
|
+
*/
|
|
8309
|
+
static getHttpErrorResponse(error) {
|
|
8310
|
+
if (error instanceof HttpErrorResponse) {
|
|
8311
|
+
return error;
|
|
8312
|
+
}
|
|
8313
|
+
else if (error instanceof MngHttpError) {
|
|
8314
|
+
return error.httpError;
|
|
8315
|
+
}
|
|
8316
|
+
else if (error instanceof MngActionError) {
|
|
8317
|
+
return error.httpError ?? null;
|
|
8318
|
+
}
|
|
8319
|
+
else {
|
|
8320
|
+
return null;
|
|
8321
|
+
}
|
|
8322
|
+
}
|
|
8323
|
+
/**
|
|
8324
|
+
* Gets HttpErrorResponse status from error (Angular or Mng).
|
|
8325
|
+
* @param error Error.
|
|
8326
|
+
*/
|
|
8327
|
+
static getHttpErrorResponseStatus(error) {
|
|
8328
|
+
return ErrorUtil.getHttpErrorResponse(error)?.status ?? null;
|
|
8329
|
+
}
|
|
8330
|
+
/**
|
|
8331
|
+
* Get error log level. All is error, except if error is http error with status >=400 and <500.
|
|
8332
|
+
* @param error Error.
|
|
8333
|
+
*/
|
|
8334
|
+
static getErrorLogLevel(error) {
|
|
8335
|
+
if (ErrorUtil.isHttpErrorResponse(error)) {
|
|
8336
|
+
const status = ErrorUtil.getHttpErrorResponseStatus(error);
|
|
8337
|
+
if (status && status >= 400 && status < 500) {
|
|
8338
|
+
return LogLevelEnum.Warning;
|
|
8339
|
+
}
|
|
8340
|
+
}
|
|
8341
|
+
return LogLevelEnum.Error;
|
|
8342
|
+
}
|
|
8343
|
+
/**
|
|
8344
|
+
* Get error name (prototype name or type from mng error if name is not provided).
|
|
8345
|
+
* @param error Error.
|
|
8346
|
+
*/
|
|
8347
|
+
static getErrorName(error) {
|
|
8348
|
+
if (error instanceof AMngErrorBase) {
|
|
8349
|
+
return error.name ?? error.type;
|
|
8350
|
+
}
|
|
8351
|
+
else {
|
|
8352
|
+
return error.name;
|
|
8353
|
+
}
|
|
8354
|
+
}
|
|
8355
|
+
/**
|
|
8356
|
+
* Writes http error to string with all headers and body.
|
|
8357
|
+
* @param error Http response error.
|
|
8358
|
+
* @param opts Options for hiding parts of error:
|
|
8359
|
+
* - hideMessage Hides message of error (message include url, status and status text!).
|
|
8360
|
+
* - hideHeaders Hides headers.
|
|
8361
|
+
* - hideBody Hides JSON representation of body.
|
|
8362
|
+
*/
|
|
8363
|
+
static httpErrorResponseToString(error, opts) {
|
|
8364
|
+
let str = opts?.hideMessage ? '' : `${error.message}\n`; // message should already include url, status, etc.
|
|
8365
|
+
if (!opts?.hideHeaders) {
|
|
8366
|
+
str += `Http Response Headers: ${error.headers.keys().reduce((acc, key) => `${acc}[${key}: ${error.headers.get(key)}]`, '')}`;
|
|
8367
|
+
}
|
|
8368
|
+
if (!opts?.hideBody) {
|
|
8369
|
+
str += `\nHttp Response Body: ${StringUtil.stringify(error.error)}`;
|
|
8370
|
+
}
|
|
8371
|
+
return str;
|
|
8372
|
+
}
|
|
8373
|
+
/**
|
|
8374
|
+
* Error to string.
|
|
8375
|
+
* @param error Error.
|
|
8376
|
+
* @param opts Options for hiding parts of error:
|
|
8377
|
+
* - hideMessage Hides message of error.
|
|
8378
|
+
* - hideName Hides error name.
|
|
8379
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
8380
|
+
* - hideStack Hides stack of an error (if present).
|
|
8381
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
8382
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
8383
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
8384
|
+
*/
|
|
8385
|
+
static errorToString(error, opts) {
|
|
8386
|
+
if (error instanceof AMngErrorBase) {
|
|
8387
|
+
return ErrorUtil.mngErrorToString(error, opts);
|
|
8388
|
+
}
|
|
8389
|
+
else if (error instanceof HttpErrorResponse) {
|
|
8390
|
+
return ErrorUtil.httpErrorResponseToString(error, opts);
|
|
8391
|
+
}
|
|
8392
|
+
const strBlocks = [];
|
|
8393
|
+
if (!opts?.hideMessage) {
|
|
8394
|
+
strBlocks.push(error.message);
|
|
8395
|
+
}
|
|
8396
|
+
if (error.name) {
|
|
8397
|
+
strBlocks.push(`Error name: ${error.name}`);
|
|
8398
|
+
}
|
|
8399
|
+
if (!opts?.hideCause) {
|
|
8400
|
+
strBlocks.push(ErrorUtil.errorCauseToString(error, opts));
|
|
8401
|
+
}
|
|
8402
|
+
if (!opts?.hideStack && error.stack) {
|
|
8403
|
+
strBlocks.push(`Stack trace:\n${error.stack}`);
|
|
8404
|
+
}
|
|
8405
|
+
return strBlocks.filter(s => s.trim().length > 0).join('\n');
|
|
8406
|
+
}
|
|
8407
|
+
/**
|
|
8408
|
+
* Mng error to string.
|
|
8409
|
+
* @param error Mng error.
|
|
8410
|
+
* @param opts Options for hiding parts of error:
|
|
8411
|
+
* - hideMessage Hides message of error.
|
|
8412
|
+
* - hideName Hides error name.
|
|
8413
|
+
* - hideCause Hides cause of an error (if present, see @link(errorCauseToString) for other options).
|
|
8414
|
+
* - hideStack Hides stack of an error (if present).
|
|
8415
|
+
* - hideDetails Hides JSON detail's representation of error (if present).
|
|
8416
|
+
* - hideLocation Hides location (URL) where error was thrown.
|
|
8417
|
+
* - hideHttp Hides http error portion of error if http error response (see @link(httpErrorResponseToString) for other options).
|
|
8418
|
+
* - hideItems Hides all item information (http body, action context data).
|
|
8419
|
+
* - hideActionData See @link(mngActionErrorContextToString) for additional info.
|
|
8420
|
+
* - hideQueryParams See @link(mngActionErrorContextToString) for additional info.
|
|
8421
|
+
*/
|
|
8422
|
+
static mngErrorToString(error, opts) {
|
|
8423
|
+
const strBlocks = [];
|
|
8424
|
+
if (!opts?.hideMessage) {
|
|
8425
|
+
strBlocks.push(`${error.message}${error.messageCode ? ` (code: ${error.messageCode})` : ''}`);
|
|
8426
|
+
}
|
|
8427
|
+
if (!opts?.hideName) {
|
|
8428
|
+
strBlocks.push(`Error name: ${error.name ?? error.type} ${error.name ? `(${error.type})` : ''}`);
|
|
8429
|
+
}
|
|
8430
|
+
if (!opts?.hideLocation && error.location) {
|
|
8431
|
+
strBlocks.push(`Location: ${error.location}`);
|
|
8432
|
+
}
|
|
8433
|
+
let isHttp = false;
|
|
8434
|
+
if (!opts?.hideHttp && error instanceof MngHttpError) {
|
|
8435
|
+
strBlocks.push(ErrorUtil.httpErrorResponseToString(error.httpError, {
|
|
8436
|
+
hideBody: opts?.hideItems || opts?.hideBody,
|
|
8437
|
+
hideHeaders: opts?.hideHeaders,
|
|
8438
|
+
hideMessage: error.message.indexOf(error.httpError.message) >= 0
|
|
8439
|
+
}));
|
|
8440
|
+
isHttp = true;
|
|
8441
|
+
}
|
|
8442
|
+
if (error instanceof MngActionError) {
|
|
8443
|
+
if (error.actionContext) {
|
|
8444
|
+
strBlocks.push(ErrorUtil.mngActionErrorContextToString(error, opts));
|
|
8445
|
+
}
|
|
8446
|
+
if (!opts?.hideHttp && error.httpError) {
|
|
8447
|
+
strBlocks.push(ErrorUtil.httpErrorResponseToString(error.httpError, {
|
|
8448
|
+
hideBody: opts?.hideItems || opts?.hideBody,
|
|
8449
|
+
hideHeaders: opts?.hideHeaders,
|
|
8450
|
+
hideMessage: error.message.indexOf(error.httpError.message) >= 0
|
|
8451
|
+
}));
|
|
8452
|
+
isHttp = true;
|
|
8453
|
+
}
|
|
8454
|
+
}
|
|
8455
|
+
if (!opts?.hideDetails && error.details) {
|
|
8456
|
+
strBlocks.push(`Details: ${StringUtil.stringify(error.details)}`);
|
|
8457
|
+
}
|
|
8458
|
+
if (!opts?.hideCause && (!isHttp || !(error.cause instanceof HttpErrorResponse))) {
|
|
8459
|
+
strBlocks.push(ErrorUtil.errorCauseToString(error, opts));
|
|
8460
|
+
}
|
|
8461
|
+
if (!opts?.hideStack && error.stack) {
|
|
8462
|
+
strBlocks.push(`Stack trace:\n${error.stack}`);
|
|
8463
|
+
}
|
|
8464
|
+
return strBlocks.filter(s => s.trim().length > 0).join('\n');
|
|
8465
|
+
}
|
|
8466
|
+
/**
|
|
8467
|
+
* Writes Mng action error info from context as string.
|
|
8468
|
+
* @param error Mng action error.
|
|
8469
|
+
* @param opts Options for hiding parts of error:
|
|
8470
|
+
* - hideItems Hides all item related information (item, form item, submit item, ...).
|
|
8471
|
+
* - hideActionData Hides action data.
|
|
8472
|
+
* - hideQueryParams Hides query params.
|
|
8473
|
+
*/
|
|
8474
|
+
static mngActionErrorContextToString(error, opts) {
|
|
8475
|
+
let paramsMessage = '';
|
|
8476
|
+
if (error.actionContext?.parameters) {
|
|
8477
|
+
if (error.actionContext?.parameters.itemId) {
|
|
8478
|
+
paramsMessage += `[itemId: ${error.actionContext.parameters.itemId}]`;
|
|
8479
|
+
}
|
|
8480
|
+
if (!opts?.hideItems && error.actionContext?.parameters.item) {
|
|
8481
|
+
paramsMessage += `[item: ${StringUtil.stringify(error.actionContext.parameters.item)}]`;
|
|
8482
|
+
}
|
|
8483
|
+
if (!opts?.hideActionData && error.actionContext?.parameters.actionData) {
|
|
8484
|
+
paramsMessage += Object.entries(error.actionContext?.parameters.actionData).reduce((acc, [key, value]) => `${acc}[actionData ${key}: ${StringUtil.stringify(value)}]`, '');
|
|
8485
|
+
}
|
|
8486
|
+
if (!opts?.hideQueryParams && error.actionContext?.parameters.queryParam) {
|
|
8487
|
+
paramsMessage += `[queryParam: ${StringUtil.stringify(error.actionContext.parameters.queryParam)}]`;
|
|
8488
|
+
}
|
|
8489
|
+
if (!opts?.hideItems && error.actionContext?.parameters.formItem) {
|
|
8490
|
+
paramsMessage += `[formItem: ${StringUtil.stringify(error.actionContext.parameters.formItem)}]`;
|
|
8491
|
+
}
|
|
8492
|
+
if (!opts?.hideItems && error.actionContext?.parameters.submitResult) {
|
|
8493
|
+
paramsMessage += `[formItem: ${StringUtil.stringify(error.actionContext.parameters.submitResult)}]`;
|
|
8494
|
+
}
|
|
8495
|
+
if (error.actionContext?.parameters.locale) {
|
|
8496
|
+
paramsMessage += `[locale: ${StringUtil.stringify(error.actionContext.parameters.locale)}]`;
|
|
8497
|
+
}
|
|
8498
|
+
}
|
|
8499
|
+
return paramsMessage;
|
|
8500
|
+
}
|
|
8501
|
+
/**
|
|
8502
|
+
* Writes cause of an error as string.
|
|
8503
|
+
* @param error Error.
|
|
8504
|
+
* @param opts Options for hiding parts of error:
|
|
8505
|
+
* - causeOnErrorOnly Prints only if cause is instance of error.
|
|
8506
|
+
* - causeAsJson Print error cause as a JSON (by default, if error only message and name will be printed).
|
|
8507
|
+
*/
|
|
8508
|
+
static errorCauseToString(error, opts) {
|
|
8509
|
+
// if already logged as http error, check that cause is not also http error (cause it is usually duplicated)
|
|
8510
|
+
if (error.cause && (!opts?.causeOnErrorOnly || error.cause instanceof Error)) {
|
|
8511
|
+
const stringify = opts?.causeAsJson || !(error.cause instanceof Error);
|
|
8512
|
+
if (!opts?.causeOnErrorOnly || error.cause instanceof Error) {
|
|
8513
|
+
return ('Caused by: ' +
|
|
8514
|
+
(stringify ? StringUtil.stringify(error.cause) : `${error.cause.message}${error.cause.name ? ` (${error.cause.name})` : ''}`));
|
|
8515
|
+
}
|
|
8516
|
+
}
|
|
8517
|
+
return '';
|
|
8518
|
+
}
|
|
8519
|
+
}
|
|
8520
|
+
|
|
8059
8521
|
class TypeUtil {
|
|
8060
8522
|
static { this.reflectTypeNameKey = 'typeName'; }
|
|
8061
8523
|
static { this.reflectTypeIdPropertyKey = 'typeIdProperty'; }
|
|
@@ -8129,7 +8591,7 @@ class TypeUtil {
|
|
|
8129
8591
|
if (enumName) {
|
|
8130
8592
|
return enumName;
|
|
8131
8593
|
}
|
|
8132
|
-
throw new MngInternalError('Could not fined enum name', '
|
|
8594
|
+
throw new MngInternalError('Could not fined enum name', { name: 'TypeUtilsError' });
|
|
8133
8595
|
}
|
|
8134
8596
|
/**
|
|
8135
8597
|
* Gets type's id property from reflect metadata.
|
|
@@ -8404,14 +8866,11 @@ var I18nUtils;
|
|
|
8404
8866
|
const paramsRes = { ...params };
|
|
8405
8867
|
paramsRes.errorStatus = '';
|
|
8406
8868
|
paramsRes.errorMessage = '';
|
|
8407
|
-
if (error
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
|
|
8411
|
-
paramsRes.
|
|
8412
|
-
}
|
|
8413
|
-
if (error.statusDescription) {
|
|
8414
|
-
paramsRes.errorStatusDescription = error.statusDescription;
|
|
8869
|
+
if (ErrorUtil.isHttpErrorResponse(error)) {
|
|
8870
|
+
const httpError = ErrorUtil.getHttpErrorResponse(error);
|
|
8871
|
+
paramsRes.errorStatus = httpError?.status;
|
|
8872
|
+
paramsRes.errorMessage = httpError?.message;
|
|
8873
|
+
paramsRes.errorStatusDescription = httpError?.statusText;
|
|
8415
8874
|
}
|
|
8416
8875
|
paramsRes.error = error;
|
|
8417
8876
|
return paramsRes;
|
|
@@ -8537,119 +8996,6 @@ class NotificationUtil {
|
|
|
8537
8996
|
}
|
|
8538
8997
|
}
|
|
8539
8998
|
|
|
8540
|
-
class ObjectUtil {
|
|
8541
|
-
static deepCopy(obj, options) {
|
|
8542
|
-
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
8543
|
-
return obj;
|
|
8544
|
-
}
|
|
8545
|
-
if (obj instanceof Date) {
|
|
8546
|
-
return new Date(+obj);
|
|
8547
|
-
}
|
|
8548
|
-
let copy;
|
|
8549
|
-
if (options?.mapGettersToProperties) {
|
|
8550
|
-
copy = {};
|
|
8551
|
-
}
|
|
8552
|
-
else {
|
|
8553
|
-
copy = options?.objectPrototype ? Object.create(options.objectPrototype['prototype']) : Object.create(Object.getPrototypeOf(obj));
|
|
8554
|
-
Object.assign(copy, obj);
|
|
8555
|
-
}
|
|
8556
|
-
for (const key of ObjectUtil.getProperties(obj)) {
|
|
8557
|
-
const prop = obj[key];
|
|
8558
|
-
copy[key] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
8559
|
-
}
|
|
8560
|
-
if (options?.mapGettersToProperties) {
|
|
8561
|
-
for (const getterKey of ObjectUtil.getGetters(obj)) {
|
|
8562
|
-
const prop = obj[getterKey];
|
|
8563
|
-
copy[getterKey] = ObjectUtil.handleProp(prop, { mapGettersToProperties: options?.mapGettersToProperties });
|
|
8564
|
-
}
|
|
8565
|
-
}
|
|
8566
|
-
return copy;
|
|
8567
|
-
}
|
|
8568
|
-
static deepMerge(target, source) {
|
|
8569
|
-
if (!ObjectUtil.isObject(source)) {
|
|
8570
|
-
return target;
|
|
8571
|
-
}
|
|
8572
|
-
for (const key of ObjectUtil.getProperties(source)) {
|
|
8573
|
-
if (ObjectUtil.isObject(source[key])) {
|
|
8574
|
-
if (ObjectUtil.isObject(target[key])) {
|
|
8575
|
-
target[key] = ObjectUtil.deepMerge(target[key], source[key]);
|
|
8576
|
-
}
|
|
8577
|
-
else {
|
|
8578
|
-
target[key] = ObjectUtil.deepCopy(source[key]);
|
|
8579
|
-
}
|
|
8580
|
-
}
|
|
8581
|
-
else if (Array.isArray(source[key])) {
|
|
8582
|
-
if (!Array.isArray(target[key])) {
|
|
8583
|
-
target[key] = source[key].map(i => (ObjectUtil.isObject(i) ? ObjectUtil.deepMerge({}, i) : i));
|
|
8584
|
-
}
|
|
8585
|
-
}
|
|
8586
|
-
else if (typeof target[key] === 'undefined') {
|
|
8587
|
-
target[key] = source[key];
|
|
8588
|
-
}
|
|
8589
|
-
}
|
|
8590
|
-
return target;
|
|
8591
|
-
}
|
|
8592
|
-
static isObject(obj) {
|
|
8593
|
-
return typeof obj === 'object' && obj !== null && !Array.isArray(obj);
|
|
8594
|
-
}
|
|
8595
|
-
static handleProp(prop, options) {
|
|
8596
|
-
if (Array.isArray(prop)) {
|
|
8597
|
-
return prop.map(i => ObjectUtil.deepCopy(i, options));
|
|
8598
|
-
}
|
|
8599
|
-
else if (typeof prop === 'object' && prop !== null) {
|
|
8600
|
-
return ObjectUtil.deepCopy(prop, options);
|
|
8601
|
-
}
|
|
8602
|
-
else {
|
|
8603
|
-
return prop;
|
|
8604
|
-
}
|
|
8605
|
-
}
|
|
8606
|
-
static getProperties(obj) {
|
|
8607
|
-
return Object.keys(obj);
|
|
8608
|
-
}
|
|
8609
|
-
static getGetters(obj) {
|
|
8610
|
-
const getterSet = new Set();
|
|
8611
|
-
let currObj = obj;
|
|
8612
|
-
while (currObj) {
|
|
8613
|
-
const getters = Object.entries(Object.getOwnPropertyDescriptors(currObj))
|
|
8614
|
-
.filter(([, descriptor]) => typeof descriptor.get === 'function')
|
|
8615
|
-
.filter(([key]) => key !== '__proto__')
|
|
8616
|
-
.map(([key]) => key);
|
|
8617
|
-
for (const getter of getters) {
|
|
8618
|
-
getterSet.add(getter);
|
|
8619
|
-
}
|
|
8620
|
-
currObj = Object.getPrototypeOf(currObj);
|
|
8621
|
-
}
|
|
8622
|
-
return Array.from(getterSet);
|
|
8623
|
-
}
|
|
8624
|
-
}
|
|
8625
|
-
|
|
8626
|
-
class StringUtil {
|
|
8627
|
-
static escapeHtml(value) {
|
|
8628
|
-
return value.replace(/</g, '<').replace(/>/g, '>');
|
|
8629
|
-
}
|
|
8630
|
-
static escapeHtmlAny(value) {
|
|
8631
|
-
if (typeof value === 'string') {
|
|
8632
|
-
return StringUtil.escapeHtml(value);
|
|
8633
|
-
}
|
|
8634
|
-
else if (typeof value === 'object') {
|
|
8635
|
-
const escapedValue = ObjectUtil.deepCopy(value, { mapGettersToProperties: true });
|
|
8636
|
-
for (const key in value) {
|
|
8637
|
-
if (typeof value[key] === 'string') {
|
|
8638
|
-
escapedValue[key] = StringUtil.escapeHtml(value[key]);
|
|
8639
|
-
}
|
|
8640
|
-
else if (typeof value[key] === 'object') {
|
|
8641
|
-
escapedValue[key] = StringUtil.escapeHtmlAny(value[key]);
|
|
8642
|
-
}
|
|
8643
|
-
else {
|
|
8644
|
-
escapedValue[key] = value[key];
|
|
8645
|
-
}
|
|
8646
|
-
}
|
|
8647
|
-
return escapedValue;
|
|
8648
|
-
}
|
|
8649
|
-
return value;
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
|
|
8653
8999
|
class ExportUtils {
|
|
8654
9000
|
static prepareDataForExport(pageData, delimiter, descriptor, translate) {
|
|
8655
9001
|
const replaceNullValue = (key, value) => (value === null ? '' : value);
|
|
@@ -8892,7 +9238,7 @@ class ActionDescriptor {
|
|
|
8892
9238
|
this._model = model;
|
|
8893
9239
|
this._actionName = actionName;
|
|
8894
9240
|
if ((parentType && !parentProperty) || (!parentProperty && parentProperty)) {
|
|
8895
|
-
throw new MngInternalError(`Provide both the parent type and parent property or none: ${parentType}, ${parentProperty}
|
|
9241
|
+
throw new MngInternalError(`Provide both the parent type and parent property or none: ${this._actionName}, ${parentType}, ${parentProperty}.`);
|
|
8896
9242
|
}
|
|
8897
9243
|
this._parentType = parentType;
|
|
8898
9244
|
this._parentTypeName = parentType ? TypeUtil.findTypeName(parentType) : undefined;
|
|
@@ -8941,7 +9287,7 @@ class ActionDescriptor {
|
|
|
8941
9287
|
}
|
|
8942
9288
|
get runFunction() {
|
|
8943
9289
|
if (!this._runFunction) {
|
|
8944
|
-
throw new MngInternalError(
|
|
9290
|
+
throw new MngInternalError(`Run function is not defined for action ${this._actionNameLong} and cannot be invoked`);
|
|
8945
9291
|
}
|
|
8946
9292
|
return this._runFunction;
|
|
8947
9293
|
}
|
|
@@ -9027,7 +9373,7 @@ class ActionDescriptor {
|
|
|
9027
9373
|
}
|
|
9028
9374
|
withServiceType(serviceType) {
|
|
9029
9375
|
if (!this._model) {
|
|
9030
|
-
throw new MngInternalError(`Cannot set data provider if no model type is provided
|
|
9376
|
+
throw new MngInternalError(`Cannot set data provider for action ${this._actionNameLong} if no model type is provided`);
|
|
9031
9377
|
}
|
|
9032
9378
|
this._dataProvider = new DataProvider(this._model.type, serviceType);
|
|
9033
9379
|
return this;
|
|
@@ -9217,7 +9563,7 @@ class ActionEditorDescriptor extends ActionDescriptor {
|
|
|
9217
9563
|
return this._dataProvider;
|
|
9218
9564
|
}
|
|
9219
9565
|
get runFunction() {
|
|
9220
|
-
throw new MngInternalError(
|
|
9566
|
+
throw new MngInternalError(`Run function cannot be used in editor action for ${this._actionNameLong}. Use submit function instead`);
|
|
9221
9567
|
}
|
|
9222
9568
|
get fetchFunction() {
|
|
9223
9569
|
return this._fetchFunction;
|
|
@@ -9251,7 +9597,7 @@ class ActionEditorDescriptor extends ActionDescriptor {
|
|
|
9251
9597
|
}
|
|
9252
9598
|
withServiceType(serviceType) {
|
|
9253
9599
|
if (!this._model) {
|
|
9254
|
-
throw new MngInternalError(`Cannot set data provider if no model type is provided
|
|
9600
|
+
throw new MngInternalError(`Cannot set data provider for action ${this._actionNameLong} if no model type is provided`);
|
|
9255
9601
|
}
|
|
9256
9602
|
this._dataProvider = new EditorDataProvider(this._model.type, serviceType);
|
|
9257
9603
|
return this;
|
|
@@ -10602,6 +10948,14 @@ class MngAutocompleteComponent {
|
|
|
10602
10948
|
this.searchSubscription = this.getLookup(queryParamBuilder.build(), event.query).subscribe({
|
|
10603
10949
|
next: items => {
|
|
10604
10950
|
this.setSuggestionsFromItems(items, event.query);
|
|
10951
|
+
},
|
|
10952
|
+
error: err => {
|
|
10953
|
+
this.setSuggestionsFromItems([], event.query);
|
|
10954
|
+
const mngError = ErrorUtil.fromSubscribeError(err, 'MngAutocompleteComponentError', {
|
|
10955
|
+
search: event.query,
|
|
10956
|
+
queryParam: queryParamBuilder.build()
|
|
10957
|
+
});
|
|
10958
|
+
this.logger.log(mngError, ErrorUtil.getErrorLogLevel(mngError));
|
|
10605
10959
|
}
|
|
10606
10960
|
});
|
|
10607
10961
|
}
|
|
@@ -10708,7 +11062,9 @@ class MngAutocompleteComponent {
|
|
|
10708
11062
|
this.itemsValueProperty = 'value';
|
|
10709
11063
|
}
|
|
10710
11064
|
else {
|
|
10711
|
-
throw new MngInternalError(`Invalid use with value (${this.itemsLabelPropertyInit}) and label (${this.itemsLabelPropertyInit}) property setup.`,
|
|
11065
|
+
throw new MngInternalError(`Invalid use with value (${this.itemsLabelPropertyInit}) and label (${this.itemsLabelPropertyInit}) property setup.`, {
|
|
11066
|
+
name: 'MngAutocompleteComponentError'
|
|
11067
|
+
});
|
|
10712
11068
|
}
|
|
10713
11069
|
}
|
|
10714
11070
|
}
|
|
@@ -10884,7 +11240,9 @@ class MngDropdownComponent {
|
|
|
10884
11240
|
this.itemsValueProperty = 'value';
|
|
10885
11241
|
}
|
|
10886
11242
|
else {
|
|
10887
|
-
throw new MngInternalError(`Invalid use with value (${this.itemsLabelPropertyInit}) and label (${this.itemsLabelPropertyInit}) property setup.`,
|
|
11243
|
+
throw new MngInternalError(`Invalid use with value (${this.itemsLabelPropertyInit}) and label (${this.itemsLabelPropertyInit}) property setup.`, {
|
|
11244
|
+
name: 'MngDropdownComponentError'
|
|
11245
|
+
});
|
|
10888
11246
|
}
|
|
10889
11247
|
}
|
|
10890
11248
|
this.itemsSubscription = this.dataProvider
|
|
@@ -10917,9 +11275,17 @@ class MngDropdownComponent {
|
|
|
10917
11275
|
return of(items);
|
|
10918
11276
|
}
|
|
10919
11277
|
}))
|
|
10920
|
-
.subscribe(
|
|
10921
|
-
|
|
10922
|
-
|
|
11278
|
+
.subscribe({
|
|
11279
|
+
next: res => {
|
|
11280
|
+
this.itemsSubject.next(res);
|
|
11281
|
+
this.loadingSubject.next(false);
|
|
11282
|
+
},
|
|
11283
|
+
error: err => {
|
|
11284
|
+
const mngError = ErrorUtil.fromSubscribeError(err, 'MngDropdownComponentError', {
|
|
11285
|
+
queryParam: queryParamBuilder.build()
|
|
11286
|
+
});
|
|
11287
|
+
this.logger.log(mngError, ErrorUtil.getErrorLogLevel(mngError));
|
|
11288
|
+
}
|
|
10923
11289
|
});
|
|
10924
11290
|
if (this.selectFirstItem && !this.dropdownFormControl?.value) {
|
|
10925
11291
|
this.items$.pipe(first()).subscribe(res => {
|
|
@@ -12110,6 +12476,7 @@ class MngTableComponent {
|
|
|
12110
12476
|
this.localStorageService = localStorageService;
|
|
12111
12477
|
this.filterDisplayRow = TableFilterDisplayEnum.Row;
|
|
12112
12478
|
this.cmpTypeName = 'MngTableComponent';
|
|
12479
|
+
this.logger = inject(MngLoggerService).create(this.cmpTypeName);
|
|
12113
12480
|
this.useQueryParams = false;
|
|
12114
12481
|
// extra features input
|
|
12115
12482
|
this.selectionMode = 'multiple';
|
|
@@ -12508,6 +12875,10 @@ class MngTableComponent {
|
|
|
12508
12875
|
emptyQueryResult.allDataCount = 0;
|
|
12509
12876
|
this.dataProviderQueryResultSubject.next(emptyQueryResult);
|
|
12510
12877
|
this.dataProviderLoadingSubject.next(false);
|
|
12878
|
+
const mngError = ErrorUtil.fromSubscribeError(err, 'MngTableComponentError', {
|
|
12879
|
+
queryParam: queryParam
|
|
12880
|
+
});
|
|
12881
|
+
this.logger.log(mngError, ErrorUtil.getErrorLogLevel(mngError));
|
|
12511
12882
|
}
|
|
12512
12883
|
});
|
|
12513
12884
|
if (emitEvent) {
|
|
@@ -13127,6 +13498,7 @@ class MngFormlyFieldLookupDialogComponent extends FieldType {
|
|
|
13127
13498
|
constructor(injector) {
|
|
13128
13499
|
super();
|
|
13129
13500
|
this.injector = injector;
|
|
13501
|
+
this.logger = inject(MngLoggerService).create('MngFormlyFieldLookupDialogComponent');
|
|
13130
13502
|
this.fieldLabelFormControl = new FormControl();
|
|
13131
13503
|
this.itemsSubject = new ReplaySubject(1);
|
|
13132
13504
|
this.itemsAsync = this.itemsSubject.asObservable();
|
|
@@ -13217,6 +13589,10 @@ class MngFormlyFieldLookupDialogComponent extends FieldType {
|
|
|
13217
13589
|
eventSubtype: 'LookupError',
|
|
13218
13590
|
queryResult: err
|
|
13219
13591
|
});
|
|
13592
|
+
const mngError = ErrorUtil.fromSubscribeError(err, 'MngFormlyFieldLookupDialogComponentError', {
|
|
13593
|
+
queryParam: queryParamBuilder.build()
|
|
13594
|
+
});
|
|
13595
|
+
this.logger.log(mngError, ErrorUtil.getErrorLogLevel(mngError));
|
|
13220
13596
|
}
|
|
13221
13597
|
});
|
|
13222
13598
|
}
|
|
@@ -13274,7 +13650,7 @@ class MngFormlyFieldLookupDialogComponent extends FieldType {
|
|
|
13274
13650
|
if (typeof value === 'object') {
|
|
13275
13651
|
const labelProperty = this.descriptor.itemsLabelProperty ?? this.descriptor.dialogTableDescriptor?.model.titlePropertyName;
|
|
13276
13652
|
if (!labelProperty) {
|
|
13277
|
-
throw new MngInternalError('Could not determine label property.', '
|
|
13653
|
+
throw new MngInternalError('Could not determine label property.', { name: 'MngFormlyFieldLookupDialogError' });
|
|
13278
13654
|
}
|
|
13279
13655
|
this.fieldLabelFormControl.setValue(value[labelProperty]);
|
|
13280
13656
|
}
|
|
@@ -13336,7 +13712,7 @@ class MngFormlyFieldTableDialogFormComponent extends FieldType {
|
|
|
13336
13712
|
})
|
|
13337
13713
|
.withSubmitFunction(ctx => {
|
|
13338
13714
|
if (!ctx.parameters.item) {
|
|
13339
|
-
return throwError(() => new MngInternalError(`No item was provided in context, add cannot be done.`, '
|
|
13715
|
+
return throwError(() => new MngInternalError(`No item was provided in context, add cannot be done.`, { name: 'FormlyFieldTableDialogFormComponentError' }));
|
|
13340
13716
|
}
|
|
13341
13717
|
this.formState.submittedOn = Date.now();
|
|
13342
13718
|
let value = this.formControl.value;
|
|
@@ -13364,7 +13740,7 @@ class MngFormlyFieldTableDialogFormComponent extends FieldType {
|
|
|
13364
13740
|
})
|
|
13365
13741
|
.withSubmitFunction(ctx => {
|
|
13366
13742
|
if (!ctx.parameters.item) {
|
|
13367
|
-
return throwError(() => new MngInternalError(`No item was provided in context, edit cannot be done.`, '
|
|
13743
|
+
return throwError(() => new MngInternalError(`No item was provided in context, edit cannot be done.`, { name: 'FormlyFieldTableDialogFormComponentError' }));
|
|
13368
13744
|
}
|
|
13369
13745
|
this.formState.submittedOn = Date.now();
|
|
13370
13746
|
const formControlValue = this.formControl.value;
|
|
@@ -13387,7 +13763,7 @@ class MngFormlyFieldTableDialogFormComponent extends FieldType {
|
|
|
13387
13763
|
.withButtonDescriptor(new ActionButtonDescriptor().withStyleClass(new ButtonStyleBuilder(StyleLevelEnum.Danger).withSize(StyleSizeEnum.ExtraSmall)))
|
|
13388
13764
|
.withRunFunction(ctx => {
|
|
13389
13765
|
if (!ctx.parameters.item) {
|
|
13390
|
-
return throwError(() => new MngInternalError(`No item was provided in context, delete cannot be done.`, '
|
|
13766
|
+
return throwError(() => new MngInternalError(`No item was provided in context, delete cannot be done.`, { name: 'FormlyFieldTableDialogFormComponentError' }));
|
|
13391
13767
|
}
|
|
13392
13768
|
let formControlValue = this.formControl.value;
|
|
13393
13769
|
const compareProperty = this.descriptor.tableDescriptor.dataKeyProperty
|
|
@@ -13405,7 +13781,9 @@ class MngFormlyFieldTableDialogFormComponent extends FieldType {
|
|
|
13405
13781
|
this.formControl.markAsDirty();
|
|
13406
13782
|
}
|
|
13407
13783
|
else {
|
|
13408
|
-
return throwError(() => new MngInternalError('Cannot compare items, please provide main table data key property or model id property.',
|
|
13784
|
+
return throwError(() => new MngInternalError('Cannot compare items, please provide main table data key property or model id property.', {
|
|
13785
|
+
name: 'FormlyFieldTableDialogFormComponentError'
|
|
13786
|
+
}));
|
|
13409
13787
|
}
|
|
13410
13788
|
this.formControl.markAsTouched();
|
|
13411
13789
|
return of(ctxItem);
|
|
@@ -13488,6 +13866,7 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
13488
13866
|
constructor(injector) {
|
|
13489
13867
|
super();
|
|
13490
13868
|
this.injector = injector;
|
|
13869
|
+
this.logger = inject(MngLoggerService).create('MngFormlyFieldTableDialogMultiselectComponent');
|
|
13491
13870
|
this.itemsSubject = new ReplaySubject(1);
|
|
13492
13871
|
this.itemsAsync = this.itemsSubject.asObservable();
|
|
13493
13872
|
this.addItemsSubject = new ReplaySubject(1);
|
|
@@ -13574,8 +13953,12 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
13574
13953
|
this.dialogAreItemsLoaded = true;
|
|
13575
13954
|
this.dialogIsLoadingSubject.next(false);
|
|
13576
13955
|
},
|
|
13577
|
-
error:
|
|
13956
|
+
error: err => {
|
|
13578
13957
|
this.dialogIsLoadingSubject.next(false);
|
|
13958
|
+
const mngError = ErrorUtil.fromSubscribeError(err, 'MngFormlyFieldTableDialogMultiselectComponent', {
|
|
13959
|
+
queryParam: queryParamBuilder.build()
|
|
13960
|
+
});
|
|
13961
|
+
this.logger.log(mngError, ErrorUtil.getErrorLogLevel(mngError));
|
|
13579
13962
|
}
|
|
13580
13963
|
});
|
|
13581
13964
|
});
|
|
@@ -13618,7 +14001,9 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
13618
14001
|
? this.descriptor.mainTableDescriptor.dataKeyProperty
|
|
13619
14002
|
: this.descriptor.mainTableDescriptor.model.idPropertyName;
|
|
13620
14003
|
if (!compareProperty) {
|
|
13621
|
-
throw new MngInternalError('Cannot compare items, please provide main table data key property or model id property.',
|
|
14004
|
+
throw new MngInternalError('Cannot compare items, please provide main table data key property or model id property.', {
|
|
14005
|
+
name: 'FormlyFieldTableDialogMultiselectComponentError'
|
|
14006
|
+
});
|
|
13622
14007
|
}
|
|
13623
14008
|
value = value.filter((i) => i[compareProperty] !== item[compareProperty]);
|
|
13624
14009
|
this.formControl.patchValue(value);
|
|
@@ -13631,11 +14016,11 @@ class MngFormlyFieldTableDialogMultiselectComponent extends FieldType {
|
|
|
13631
14016
|
this.searchDebounceSubject.next(query);
|
|
13632
14017
|
}
|
|
13633
14018
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MngFormlyFieldTableDialogMultiselectComponent, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
13634
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: MngFormlyFieldTableDialogMultiselectComponent, isStandalone: true, selector: "mng-formly-table-multiselect-add-field", viewQueries: [{ propertyName: "addTableComponent", first: true, predicate: ["addTableComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<mng-table [descriptor]=\"descriptor.mainTableDescriptor\" [items]=\"itemsAsync\" [viewContainer]=\"viewContainer\">\n <ng-template mngTemplate=\"caption\">\n <div class=\"flex flex-row justify-content-end align-items-center table-header pt-0\">\n <label class=\"mng-datatable-form-label p-0 m-0\" [for]=\"key\"\n >{{ props.label! | translate }} <span *ngIf=\"props.required && props['hideRequiredMarker'] !== true\">*</span></label\n >\n <button\n *ngIf=\"hasAddAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-plus\"\n class=\"p-button-rounded mng-button-xs\"\n (click)=\"openAddDialog()\"\n [disabled]=\"formControl!.disabled\"></button>\n </div>\n </ng-template>\n <ng-template mngTemplate=\"columnAction\" let-item=\"rowItem\">\n <button\n *ngIf=\"hasDeleteAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-trash\"\n class=\"p-button-rounded p-button-danger mng-button-xs\"\n (click)=\"removeItem(item)\"\n [disabled]=\"formControl!.disabled\"></button>\n </ng-template>\n</mng-table>\n\n<p-dialog\n *ngIf=\"hasAddAction\"\n [(visible)]=\"isDialogVisible\"\n [draggable]=\"false\"\n [header]=\"'general.addItem' | translate : {item: props.label! | translate}\"\n [modal]=\"true\"\n appendTo=\"body\"\n styleClass=\"p-fluid mng-dialog mng-dialog-sm mng-formly-field-table-multiselect-dialog\">\n <ng-template pTemplate=\"content\" class=\"table-container\">\n <div class=\"h-full flex flex-column\">\n <div class=\"flex-grow-1 formly-field-table-multiselect-dialog-form-container\">\n <div class=\"mng-formly-field-table-multiselect-dialog-table\">\n <mng-table\n #addTableComponent\n [descriptor]=\"descriptor.
|
|
14019
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.7", type: MngFormlyFieldTableDialogMultiselectComponent, isStandalone: true, selector: "mng-formly-table-multiselect-add-field", viewQueries: [{ propertyName: "addTableComponent", first: true, predicate: ["addTableComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<mng-table [descriptor]=\"descriptor.mainTableDescriptor\" [items]=\"itemsAsync\" [viewContainer]=\"viewContainer\">\n <ng-template mngTemplate=\"caption\">\n <div class=\"flex flex-row justify-content-end align-items-center table-header pt-0\">\n <label class=\"mng-datatable-form-label p-0 m-0\" [for]=\"key\"\n >{{ props.label! | translate }} <span *ngIf=\"props.required && props['hideRequiredMarker'] !== true\">*</span></label\n >\n <button\n *ngIf=\"hasAddAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-plus\"\n class=\"p-button-rounded mng-button-xs\"\n (click)=\"openAddDialog()\"\n [disabled]=\"formControl!.disabled\"></button>\n </div>\n </ng-template>\n <ng-template mngTemplate=\"columnAction\" let-item=\"rowItem\">\n <button\n *ngIf=\"hasDeleteAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-trash\"\n class=\"p-button-rounded p-button-danger mng-button-xs\"\n (click)=\"removeItem(item)\"\n [disabled]=\"formControl!.disabled\"></button>\n </ng-template>\n</mng-table>\n\n<p-dialog\n *ngIf=\"hasAddAction\"\n [(visible)]=\"isDialogVisible\"\n [draggable]=\"false\"\n [header]=\"'general.addItem' | translate : {item: props.label! | translate}\"\n [modal]=\"true\"\n appendTo=\"body\"\n styleClass=\"p-fluid mng-dialog mng-dialog-sm mng-formly-field-table-multiselect-dialog\">\n <ng-template pTemplate=\"content\" class=\"table-container\">\n <div class=\"h-full flex flex-column\">\n <div class=\"flex-grow-1 formly-field-table-multiselect-dialog-form-container\">\n <div class=\"mng-formly-field-table-multiselect-dialog-table\">\n <mng-table\n #addTableComponent\n [descriptor]=\"descriptor.lookupTableDescriptor\"\n [globalFilterFields]=\"descriptor.searchFields\"\n [queryResult]=\"addItemsAsync\"\n [selectionEnabled]=\"true\"\n [loading]=\"dialogIsLoading$\"\n (selectionChange)=\"onSelectionChange($event)\"\n [viewContainer]=\"viewContainer\">\n <ng-template *ngIf=\"descriptor.searchEnabled\" mngTemplate=\"caption\">\n <div class=\"flex\">\n <span class=\"p-input-icon-left ml-auto\" [ngStyle]=\"{width: 'unset'}\">\n <i class=\"pi pi-search\"></i>\n <input pInputText type=\"text\" (input)=\"onSearch($event)\" [placeholder]=\"'general.search' | translate\" />\n </span>\n </div>\n </ng-template>\n </mng-table>\n </div>\n </div>\n\n <div class=\"flex flex-row justify-content-end mng-formly-field-table-multiselect-dialog-footer\">\n <button pButton pRipple type=\"button\" [label]=\"'general.cancel' | translate\" icon=\"pi pi-times\" class=\"p-button-text\" (click)=\"hideDialog()\"></button>\n <button\n pButton\n pRipple\n type=\"button\"\n [label]=\"'general.add' | translate\"\n icon=\"pi pi-check\"\n class=\"p-button-primary\"\n (click)=\"addItems()\"\n [loading]=\"(dialogIsLoading$ | async) ?? false\"\n [disabled]=\"form.disabled\"></button>\n </div>\n </div>\n </ng-template>\n</p-dialog>\n", styles: [".table-footer{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:flex-end;align-items:center;align-content:center;margin-top:2rem}.table-container{overflow:hidden}.table-footer button{width:8rem}.table-footer button:not(:first-child){margin-left:1.5rem}.table-scroll{max-height:75vh;overflow-y:auto}\n"], dependencies: [{ kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "component", type: MngTableComponent, selector: "mng-table", inputs: ["descriptor", "items", "queryResult", "loading", "dataProvider", "useQueryParams", "selectionMode", "selectionEnabled", "actions", "isColumnClickable", "viewContainer", "captionComponent", "columnActionComponent", "columnActionMinWidth", "globalFilterFields"], outputs: ["tableLoad", "cellClick", "selectionChange", "captionComponentInstance", "columnActionComponentInstance"] }, { kind: "ngmodule", type: DialogModule }, { kind: "component", type: i4$4.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "visible", "style", "position"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "directive", type: i1$2.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "directive", type: i6.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading"] }, { kind: "ngmodule", type: RippleModule }, { kind: "directive", type: i6$1.Ripple, selector: "[pRipple]" }, { kind: "directive", type: MngTemplateDirective, selector: "[mngTemplate]", inputs: ["type", "mngTemplate"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i14.InputText, selector: "[pInputText]" }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
13635
14020
|
}
|
|
13636
14021
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.7", ngImport: i0, type: MngFormlyFieldTableDialogMultiselectComponent, decorators: [{
|
|
13637
14022
|
type: Component,
|
|
13638
|
-
args: [{ standalone: true, selector: 'mng-formly-table-multiselect-add-field', imports: [TranslateModule, NgIf, AsyncPipe, MngTableComponent, DialogModule, ButtonModule, RippleModule, MngTemplateDirective, InputTextModule, NgStyle], changeDetection: ChangeDetectionStrategy.OnPush, template: "<mng-table [descriptor]=\"descriptor.mainTableDescriptor\" [items]=\"itemsAsync\" [viewContainer]=\"viewContainer\">\n <ng-template mngTemplate=\"caption\">\n <div class=\"flex flex-row justify-content-end align-items-center table-header pt-0\">\n <label class=\"mng-datatable-form-label p-0 m-0\" [for]=\"key\"\n >{{ props.label! | translate }} <span *ngIf=\"props.required && props['hideRequiredMarker'] !== true\">*</span></label\n >\n <button\n *ngIf=\"hasAddAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-plus\"\n class=\"p-button-rounded mng-button-xs\"\n (click)=\"openAddDialog()\"\n [disabled]=\"formControl!.disabled\"></button>\n </div>\n </ng-template>\n <ng-template mngTemplate=\"columnAction\" let-item=\"rowItem\">\n <button\n *ngIf=\"hasDeleteAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-trash\"\n class=\"p-button-rounded p-button-danger mng-button-xs\"\n (click)=\"removeItem(item)\"\n [disabled]=\"formControl!.disabled\"></button>\n </ng-template>\n</mng-table>\n\n<p-dialog\n *ngIf=\"hasAddAction\"\n [(visible)]=\"isDialogVisible\"\n [draggable]=\"false\"\n [header]=\"'general.addItem' | translate : {item: props.label! | translate}\"\n [modal]=\"true\"\n appendTo=\"body\"\n styleClass=\"p-fluid mng-dialog mng-dialog-sm mng-formly-field-table-multiselect-dialog\">\n <ng-template pTemplate=\"content\" class=\"table-container\">\n <div class=\"h-full flex flex-column\">\n <div class=\"flex-grow-1 formly-field-table-multiselect-dialog-form-container\">\n <div class=\"mng-formly-field-table-multiselect-dialog-table\">\n <mng-table\n #addTableComponent\n [descriptor]=\"descriptor.
|
|
14023
|
+
args: [{ standalone: true, selector: 'mng-formly-table-multiselect-add-field', imports: [TranslateModule, NgIf, AsyncPipe, MngTableComponent, DialogModule, ButtonModule, RippleModule, MngTemplateDirective, InputTextModule, NgStyle], changeDetection: ChangeDetectionStrategy.OnPush, template: "<mng-table [descriptor]=\"descriptor.mainTableDescriptor\" [items]=\"itemsAsync\" [viewContainer]=\"viewContainer\">\n <ng-template mngTemplate=\"caption\">\n <div class=\"flex flex-row justify-content-end align-items-center table-header pt-0\">\n <label class=\"mng-datatable-form-label p-0 m-0\" [for]=\"key\"\n >{{ props.label! | translate }} <span *ngIf=\"props.required && props['hideRequiredMarker'] !== true\">*</span></label\n >\n <button\n *ngIf=\"hasAddAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-plus\"\n class=\"p-button-rounded mng-button-xs\"\n (click)=\"openAddDialog()\"\n [disabled]=\"formControl!.disabled\"></button>\n </div>\n </ng-template>\n <ng-template mngTemplate=\"columnAction\" let-item=\"rowItem\">\n <button\n *ngIf=\"hasDeleteAction && !options?.formState?.disabled\"\n pButton\n pRipple\n type=\"button\"\n icon=\"pi pi-trash\"\n class=\"p-button-rounded p-button-danger mng-button-xs\"\n (click)=\"removeItem(item)\"\n [disabled]=\"formControl!.disabled\"></button>\n </ng-template>\n</mng-table>\n\n<p-dialog\n *ngIf=\"hasAddAction\"\n [(visible)]=\"isDialogVisible\"\n [draggable]=\"false\"\n [header]=\"'general.addItem' | translate : {item: props.label! | translate}\"\n [modal]=\"true\"\n appendTo=\"body\"\n styleClass=\"p-fluid mng-dialog mng-dialog-sm mng-formly-field-table-multiselect-dialog\">\n <ng-template pTemplate=\"content\" class=\"table-container\">\n <div class=\"h-full flex flex-column\">\n <div class=\"flex-grow-1 formly-field-table-multiselect-dialog-form-container\">\n <div class=\"mng-formly-field-table-multiselect-dialog-table\">\n <mng-table\n #addTableComponent\n [descriptor]=\"descriptor.lookupTableDescriptor\"\n [globalFilterFields]=\"descriptor.searchFields\"\n [queryResult]=\"addItemsAsync\"\n [selectionEnabled]=\"true\"\n [loading]=\"dialogIsLoading$\"\n (selectionChange)=\"onSelectionChange($event)\"\n [viewContainer]=\"viewContainer\">\n <ng-template *ngIf=\"descriptor.searchEnabled\" mngTemplate=\"caption\">\n <div class=\"flex\">\n <span class=\"p-input-icon-left ml-auto\" [ngStyle]=\"{width: 'unset'}\">\n <i class=\"pi pi-search\"></i>\n <input pInputText type=\"text\" (input)=\"onSearch($event)\" [placeholder]=\"'general.search' | translate\" />\n </span>\n </div>\n </ng-template>\n </mng-table>\n </div>\n </div>\n\n <div class=\"flex flex-row justify-content-end mng-formly-field-table-multiselect-dialog-footer\">\n <button pButton pRipple type=\"button\" [label]=\"'general.cancel' | translate\" icon=\"pi pi-times\" class=\"p-button-text\" (click)=\"hideDialog()\"></button>\n <button\n pButton\n pRipple\n type=\"button\"\n [label]=\"'general.add' | translate\"\n icon=\"pi pi-check\"\n class=\"p-button-primary\"\n (click)=\"addItems()\"\n [loading]=\"(dialogIsLoading$ | async) ?? false\"\n [disabled]=\"form.disabled\"></button>\n </div>\n </div>\n </ng-template>\n</p-dialog>\n", styles: [".table-footer{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:flex-end;align-items:center;align-content:center;margin-top:2rem}.table-container{overflow:hidden}.table-footer button{width:8rem}.table-footer button:not(:first-child){margin-left:1.5rem}.table-scroll{max-height:75vh;overflow-y:auto}\n"] }]
|
|
13639
14024
|
}], ctorParameters: function () { return [{ type: i0.Injector }]; }, propDecorators: { addTableComponent: [{
|
|
13640
14025
|
type: ViewChild,
|
|
13641
14026
|
args: ['addTableComponent']
|
|
@@ -13851,7 +14236,7 @@ class RouteUtil {
|
|
|
13851
14236
|
}
|
|
13852
14237
|
else if (path[0].startsWith('../')) {
|
|
13853
14238
|
// TODO: process multi upper folder
|
|
13854
|
-
throw new MngInternalError('Not implemented', '
|
|
14239
|
+
throw new MngInternalError('Not implemented', { name: 'RouteUtilsError' });
|
|
13855
14240
|
}
|
|
13856
14241
|
else {
|
|
13857
14242
|
return RouteUtil.removeEmptyPathSegments([...basePath, ...path]);
|
|
@@ -14571,16 +14956,12 @@ class MngErrorHandler {
|
|
|
14571
14956
|
}
|
|
14572
14957
|
static { this.logCategory = 'MngErrorHandler'; }
|
|
14573
14958
|
handleError(error) {
|
|
14574
|
-
if (error instanceof
|
|
14575
|
-
const
|
|
14576
|
-
this.logger.log(
|
|
14577
|
-
}
|
|
14578
|
-
else if (error instanceof HttpErrorResponse) {
|
|
14579
|
-
const isClientError = error.status >= 400 && error.status < 500;
|
|
14580
|
-
this.logger.log(`Http error occurred with status ${error.status} ${error.statusText}: ${error.message}`, isClientError ? LogLevelEnum.Warning : LogLevelEnum.Error, MngErrorHandler.logCategory, error);
|
|
14959
|
+
if (error instanceof AMngErrorBase || error instanceof HttpErrorResponse) {
|
|
14960
|
+
const logLevel = ErrorUtil.getErrorLogLevel(error);
|
|
14961
|
+
this.logger.log(error, logLevel);
|
|
14581
14962
|
}
|
|
14582
14963
|
else {
|
|
14583
|
-
this.logger.
|
|
14964
|
+
this.logger.error('Unexpected error occurred', error);
|
|
14584
14965
|
}
|
|
14585
14966
|
}
|
|
14586
14967
|
}
|
|
@@ -14593,6 +14974,7 @@ class MngCommonsInitService {
|
|
|
14593
14974
|
constructor() {
|
|
14594
14975
|
this.httpClient = inject(HttpClient);
|
|
14595
14976
|
this.logger = inject(MngLoggerService);
|
|
14977
|
+
this.logPublishers = inject(MNG_LOG_PUBLISHERS, { optional: true });
|
|
14596
14978
|
this.config = inject(MngConfigurationService);
|
|
14597
14979
|
this.mngCommons = inject(MngCommonsService);
|
|
14598
14980
|
this.mngRouter = inject(MngRouterService);
|
|
@@ -14632,7 +15014,7 @@ class MngCommonsInitService {
|
|
|
14632
15014
|
}
|
|
14633
15015
|
return this.config.loadJsonConfigurations().pipe(mergeMap(() => {
|
|
14634
15016
|
// init logger
|
|
14635
|
-
MngLoggerService.init(this.config);
|
|
15017
|
+
MngLoggerService.init(this.config, this.logPublishers ?? []);
|
|
14636
15018
|
if (this.commonsInitializers) {
|
|
14637
15019
|
ctxLogger.debug('Project initializers are being initialized');
|
|
14638
15020
|
return combineLatest(this.commonsInitializers.map(ci => ci())).pipe(map(res => res));
|
|
@@ -14987,6 +15369,11 @@ function provideMngCommons(config) {
|
|
|
14987
15369
|
provide: MngLoggerService,
|
|
14988
15370
|
useFactory: () => MngLoggerService.get()
|
|
14989
15371
|
},
|
|
15372
|
+
{
|
|
15373
|
+
provide: MNG_LOG_PUBLISHERS,
|
|
15374
|
+
useClass: MngLogPublisherConsoleService,
|
|
15375
|
+
multi: true
|
|
15376
|
+
},
|
|
14990
15377
|
{
|
|
14991
15378
|
provide: ErrorHandler,
|
|
14992
15379
|
useClass: MngErrorHandler
|
|
@@ -15710,13 +16097,13 @@ class RouteBuilder {
|
|
|
15710
16097
|
}
|
|
15711
16098
|
toParent() {
|
|
15712
16099
|
if (!this.parent) {
|
|
15713
|
-
throw new MngInternalError('Parent was not provided.', 'RouteBuilder error');
|
|
16100
|
+
throw new MngInternalError('Parent was not provided.', { name: 'RouteBuilder error' });
|
|
15714
16101
|
}
|
|
15715
16102
|
return this.parent;
|
|
15716
16103
|
}
|
|
15717
16104
|
toRoot() {
|
|
15718
16105
|
if (!this.root) {
|
|
15719
|
-
throw new MngInternalError('Root was not provided.', '
|
|
16106
|
+
throw new MngInternalError('Root was not provided.', { name: 'RouteBuilderError' });
|
|
15720
16107
|
}
|
|
15721
16108
|
return this.root;
|
|
15722
16109
|
}
|
|
@@ -15898,7 +16285,7 @@ class RoutesBuilder {
|
|
|
15898
16285
|
}
|
|
15899
16286
|
toRoute() {
|
|
15900
16287
|
if (!this.currentRoute) {
|
|
15901
|
-
throw new MngInternalError('No routes were added!', '
|
|
16288
|
+
throw new MngInternalError('No routes were added!', { name: 'RoutesBuilderError' });
|
|
15902
16289
|
}
|
|
15903
16290
|
return this.currentRoute;
|
|
15904
16291
|
}
|
|
@@ -16148,5 +16535,5 @@ function EnumName(typeName) {
|
|
|
16148
16535
|
* Generated bundle index. Do not edit.
|
|
16149
16536
|
*/
|
|
16150
16537
|
|
|
16151
|
-
export { ACTION_EDITOR_DIALOG_COMPONENT_SETTING, AFieldDescriptor, AFieldGroupDescriptor, AGenericFieldDescriptor, AMngApiService, AMngBaseApiService, AMngCrudApiService, AMngFormlyCustomFieldComponent, AMngGetAllApiService, AMngTableviewRouteComponent, APermissions, ActionActivationTriggerEnum, ActionButtonDescriptor, ActionConfirmationDialogDescriptor, ActionContext, ActionContextValidation, ActionDataProviderUtil, ActionDeleteDescriptor, ActionDescriptor, ActionEditorAddDescriptor, ActionEditorDescriptor, ActionEditorDetailsDescriptor, ActionEditorEditDescriptor, ActionEditorSubmitDescriptor, ActionEditorSubmitTypeEnum, ActionError, ActionInstance, ActionInstanceStateEnum, ActionLinkDescriptor, ActionParameters, ActionPositionEnum, ActionSimpleDescriptor, ActionTypeEnum, AuthorizationTypeEnum, AuthorizationUtil, ButtonStyleBuilder, ButtonStyleRoundedEnum, ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, DataProvider, DateUtil, DefaultActionMngErrorMapperService, DynamicTableviewDataProvider, EditorDataProvider, EditorDescriptor, EditorFormlyUtil, EnumName, EnumUtil, EnumeratePipeI18nHelper, ExportUtils, FieldActionDescriptor, FieldGroupDescriptor, FieldGroupTypeEnum, FieldInputDescriptor, FieldInputTypeEnum, FieldLookupDescriptor, FieldLookupEnumDescriptor, FieldLookupTypeEnum, FieldManyEditorActionEnum, FieldManyEditorDescriptor, FieldManyEditorTypeEnum, FieldManyToManyEditorActionEnum, FieldManyToManyEditorDescriptor, FieldManyToManyEditorTypeEnum, FieldSizeEnum, FieldTabGroupDescriptor, FieldValidationDescriptor, FileUtil, FilterDescriptor, FilterLookupDescriptor, FilterLookupEnumDescriptor, FilterLookupTypeEnum, FilterMatchModeEnum, FilterTypeEnum, I18nUtils, IdProperty, JsonPathPipe, LogLevelEnum, LookupDataProvider, MNG_AUTOCOMPLETE_VALUE_ACCESSOR, MNG_BROWSER_STORAGE_IT, MNG_COMMONS_INITIALIZER_IT, MNG_DATE_RANGE_VALUE_ACCESSOR, MNG_DROPDOWN_VALUE_ACCESSOR, MNG_MODULE_CONFIG_IT, MediusFilterMatchType, MediusFilterParam, MediusQueryMode, MediusQueryParam, MediusQueryParamBuilder, MediusQueryResult, MediusRestUtil, MngActionComponent, MngActionEditorComponent, MngActionErrorMapperService, MngActionExecutorService, MngActionRouteComponent, MngAuthorizationService, MngAutocompleteComponent, MngBooleanPipe, MngBreadcrumbComponent, MngClassMapPipe, MngCommonsModule, MngCommonsService, MngComponentDirective, MngConfigurationService, MngDataLanguageDropdownComponent, MngDateRangeComponent, MngDropdownComponent, MngEnumPipe, MngEnumerateAsyncPipe, MngEnumeratePipe, MngErrorHandler, MngErrorPageComponent, MngFooterComponent, MngFormEditorComponent, MngFormEditorSubmitEvent, MngFormEvent, MngFormEventTypeEnum, MngFormFieldEvent, MngFormFieldEventComponentSubtype, MngFormFieldEventDialogSubtype, MngFormFieldEventTypeEnum, MngFormlyFieldActionComponent, MngFormlyFieldAutocompleteComponent, MngFormlyFieldCustomComponent, MngFormlyFieldDropdownComponent, MngFormlyFieldFieldsetComponent, MngFormlyFieldInputComponent, MngFormlyFieldLabelComponent, MngFormlyFieldLookupDialogComponent, MngFormlyFieldNoLabelWrapperComponent, MngFormlyFieldTableDialogFormComponent, MngFormlyFieldTableDialogMultiselectComponent, MngFormlyFieldTabsComponent, MngFormlyFieldWrapperComponent, MngGetterPipe, MngI18nPropertyPipe, MngInternalError, MngLocalStorageService, MngLocaleDefaultRowClassPipe, MngLoggerService, MngMainLayoutComponent, MngMainLayoutComponentService, MngMenuComponent, MngMenuItemComponent, MngNavigationService, MngNotFoundPageComponent, MngParametrizePipe, MngRouterService, MngTableCellClickEvent, MngTableColumnFilterComponent, MngTableColumnValueComponent, MngTableComponent, MngTableLoadEvent, MngTableReloadEvent, MngTableviewComponent, MngTableviewRouteComponent, MngTemplateDirective, MngTemplatePipe, MngTopbarComponent, MngTopbarUserComponent, MngVersionComponent, MngVersionService, MngViewContainerComponentService, ModelDescriptor, ModelUtil, NotificationUtil, ObjectSerializer, ObjectUtil, Permissions, RouteBuilder, RoutesBuilder, StringUtil, StyleLevelEnum, StyleSizeEnum, StylesUtil, TableDataProvider, TableDescriptor, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableFilterDisplayEnum, TablePaginationModeEnum, TableSizeEnum, TableviewActionDefaultCategories, TableviewCrudDataProvider, TableviewDataProvider, TableviewDescriptor, TableviewDynamicDescriptor, TableviewEditorTypeEnum, TableviewRouteBuilder, TableviewRouteBuilderInternal, TitleProperty, TypeName, TypeUtil, enumsMapBase, formlyTypesConfig, formlyWrappersConfig, getEmailValidationMessage, getFormlyValidationMessages, getMaxDateValidationMessage, getMaxLengthValidationMessage, getMaxValidationMessage, getMinDateValidationMessage, getMinLengthValidationMessage, getMinValidationMessage, getRequiredValidationMessage, getTextPatternValidationMessage, mngAuthorizationGuard, mngFormlyConfigProvider, primeNgModules, provideMngCommons, typeMapBase };
|
|
16538
|
+
export { ACTION_EDITOR_DIALOG_COMPONENT_SETTING, AFieldDescriptor, AFieldGroupDescriptor, AGenericFieldDescriptor, AMngApiService, AMngBaseApiService, AMngCrudApiService, AMngErrorBase, AMngFormlyCustomFieldComponent, AMngGetAllApiService, AMngTableviewRouteComponent, APermissions, ActionActivationTriggerEnum, ActionButtonDescriptor, ActionConfirmationDialogDescriptor, ActionContext, ActionContextValidation, ActionDataProviderUtil, ActionDeleteDescriptor, ActionDescriptor, ActionEditorAddDescriptor, ActionEditorDescriptor, ActionEditorDetailsDescriptor, ActionEditorEditDescriptor, ActionEditorSubmitDescriptor, ActionEditorSubmitTypeEnum, ActionError, ActionInstance, ActionInstanceStateEnum, ActionLinkDescriptor, ActionParameters, ActionPositionEnum, ActionSimpleDescriptor, ActionTypeEnum, AuthorizationTypeEnum, AuthorizationUtil, ButtonStyleBuilder, ButtonStyleRoundedEnum, ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, DataProvider, DateUtil, DefaultActionMngErrorMapperService, DynamicTableviewDataProvider, EditorDataProvider, EditorDescriptor, EditorFormlyUtil, EnumName, EnumUtil, EnumeratePipeI18nHelper, ErrorUtil, ExportUtils, FieldActionDescriptor, FieldGroupDescriptor, FieldGroupTypeEnum, FieldInputDescriptor, FieldInputTypeEnum, FieldLookupDescriptor, FieldLookupEnumDescriptor, FieldLookupTypeEnum, FieldManyEditorActionEnum, FieldManyEditorDescriptor, FieldManyEditorTypeEnum, FieldManyToManyEditorActionEnum, FieldManyToManyEditorDescriptor, FieldManyToManyEditorTypeEnum, FieldSizeEnum, FieldTabGroupDescriptor, FieldValidationDescriptor, FileUtil, FilterDescriptor, FilterLookupDescriptor, FilterLookupEnumDescriptor, FilterLookupTypeEnum, FilterMatchModeEnum, FilterTypeEnum, I18nUtils, IdProperty, JsonPathPipe, LogLevelEnum, LookupDataProvider, MNG_AUTOCOMPLETE_VALUE_ACCESSOR, MNG_BROWSER_STORAGE_IT, MNG_COMMONS_INITIALIZER_IT, MNG_DATE_RANGE_VALUE_ACCESSOR, MNG_DROPDOWN_VALUE_ACCESSOR, MNG_LOG_PUBLISHERS, MNG_MODULE_CONFIG_IT, MediusFilterMatchType, MediusFilterParam, MediusQueryMode, MediusQueryParam, MediusQueryParamBuilder, MediusQueryResult, MediusRestUtil, MngActionComponent, MngActionEditorComponent, MngActionError, MngActionErrorMapperService, MngActionExecutorService, MngActionRouteComponent, MngAuthorizationService, MngAutocompleteComponent, MngBooleanPipe, MngBreadcrumbComponent, MngClassMapPipe, MngCommonsModule, MngCommonsService, MngComponentDirective, MngConfigurationService, MngDataLanguageDropdownComponent, MngDateRangeComponent, MngDropdownComponent, MngEnumPipe, MngEnumerateAsyncPipe, MngEnumeratePipe, MngErrorHandler, MngErrorPageComponent, MngFooterComponent, MngFormEditorComponent, MngFormEditorSubmitEvent, MngFormEvent, MngFormEventTypeEnum, MngFormFieldEvent, MngFormFieldEventComponentSubtype, MngFormFieldEventDialogSubtype, MngFormFieldEventTypeEnum, MngFormlyFieldActionComponent, MngFormlyFieldAutocompleteComponent, MngFormlyFieldCustomComponent, MngFormlyFieldDropdownComponent, MngFormlyFieldFieldsetComponent, MngFormlyFieldInputComponent, MngFormlyFieldLabelComponent, MngFormlyFieldLookupDialogComponent, MngFormlyFieldNoLabelWrapperComponent, MngFormlyFieldTableDialogFormComponent, MngFormlyFieldTableDialogMultiselectComponent, MngFormlyFieldTabsComponent, MngFormlyFieldWrapperComponent, MngGetterPipe, MngHttpError, MngI18nPropertyPipe, MngInternalError, MngLocalStorageService, MngLocaleDefaultRowClassPipe, MngLogPublisherConsoleService, MngLoggerService, MngMainLayoutComponent, MngMainLayoutComponentService, MngMenuComponent, MngMenuItemComponent, MngNavigationService, MngNotFoundPageComponent, MngParametrizePipe, MngRouterService, MngTableCellClickEvent, MngTableColumnFilterComponent, MngTableColumnValueComponent, MngTableComponent, MngTableLoadEvent, MngTableReloadEvent, MngTableviewComponent, MngTableviewRouteComponent, MngTemplateDirective, MngTemplatePipe, MngTopbarComponent, MngTopbarUserComponent, MngVersionComponent, MngVersionService, MngViewContainerComponentService, ModelDescriptor, ModelUtil, NotificationUtil, ObjectSerializer, ObjectUtil, Permissions, RouteBuilder, RoutesBuilder, StringUtil, StyleLevelEnum, StyleSizeEnum, StylesUtil, TableDataProvider, TableDescriptor, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableFilterDisplayEnum, TablePaginationModeEnum, TableSizeEnum, TableviewActionDefaultCategories, TableviewCrudDataProvider, TableviewDataProvider, TableviewDescriptor, TableviewDynamicDescriptor, TableviewEditorTypeEnum, TableviewRouteBuilder, TableviewRouteBuilderInternal, TitleProperty, TypeName, TypeUtil, enumsMapBase, formlyTypesConfig, formlyWrappersConfig, getEmailValidationMessage, getFormlyValidationMessages, getMaxDateValidationMessage, getMaxLengthValidationMessage, getMaxValidationMessage, getMinDateValidationMessage, getMinLengthValidationMessage, getMinValidationMessage, getRequiredValidationMessage, getTextPatternValidationMessage, mngAuthorizationGuard, mngFormlyConfigProvider, primeNgModules, provideMngCommons, typeMapBase };
|
|
16152
16539
|
//# sourceMappingURL=mediusinc-mng-commons.mjs.map
|