@abp/ng.theme.shared 7.4.0-rc.2 → 7.4.0-rc.4
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/http-error-wrapper/http-error-wrapper.component.mjs +8 -5
- package/esm2022/lib/handlers/error.handler.mjs +8 -11
- package/esm2022/lib/models/common.mjs +1 -1
- package/esm2022/lib/services/create-error-component.service.mjs +15 -11
- package/esm2022/lib/services/router-error-handler.service.mjs +2 -2
- package/esm2022/lib/services/status-code-error-handler.service.mjs +36 -36
- package/fesm2022/abp-ng.theme.shared.mjs +58 -56
- package/fesm2022/abp-ng.theme.shared.mjs.map +1 -1
- package/lib/components/http-error-wrapper/http-error-wrapper.component.d.ts +7 -4
- package/lib/handlers/error.handler.d.ts +13 -10
- package/lib/models/common.d.ts +2 -2
- package/lib/services/create-error-component.service.d.ts +11 -9
- package/lib/services/router-error-handler.service.d.ts +6 -4
- package/lib/services/status-code-error-handler.service.d.ts +11 -9
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { animation, style, animate, keyframes, trigger, state, transition, useAnimation, query } from '@angular/animations';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output, ViewChild, InjectionToken, Inject, ViewEncapsulation, Injectable, Optional, ContentChild, Directive, HostListener, forwardRef, HostBinding, NgModule,
|
|
3
|
+
import { Component, Input, ChangeDetectionStrategy, EventEmitter, Output, ViewChild, InjectionToken, Inject, inject, ViewEncapsulation, Injectable, Optional, ContentChild, Directive, HostListener, forwardRef, HostBinding, NgModule, RendererFactory2, ComponentFactoryResolver, Injector, ApplicationRef, APP_INITIALIZER, LOCALE_ID } from '@angular/core';
|
|
4
4
|
import * as i1 from '@angular/common';
|
|
5
|
-
import { CommonModule, NgIf,
|
|
5
|
+
import { DOCUMENT, CommonModule, NgIf, formatDate, DatePipe } from '@angular/common';
|
|
6
6
|
import * as i1$1 from '@angular/router';
|
|
7
7
|
import { ResolveEnd } from '@angular/router';
|
|
8
8
|
import * as i2 from '@abp/ng.core';
|
|
@@ -361,6 +361,8 @@ class HttpErrorWrapperComponent {
|
|
|
361
361
|
}
|
|
362
362
|
constructor(subscription) {
|
|
363
363
|
this.subscription = subscription;
|
|
364
|
+
this.document = inject(DOCUMENT);
|
|
365
|
+
this.window = this.document.defaultView;
|
|
364
366
|
this.status = 0;
|
|
365
367
|
this.title = 'Oops!';
|
|
366
368
|
this.details = 'Sorry, an error has occured.';
|
|
@@ -370,7 +372,7 @@ class HttpErrorWrapperComponent {
|
|
|
370
372
|
}
|
|
371
373
|
ngOnInit() {
|
|
372
374
|
this.backgroundColor =
|
|
373
|
-
window.getComputedStyle(document.body)?.getPropertyValue('background-color') || '#fff';
|
|
375
|
+
this.window.getComputedStyle(this.document.body)?.getPropertyValue('background-color') || '#fff';
|
|
374
376
|
}
|
|
375
377
|
ngAfterViewInit() {
|
|
376
378
|
if (this.customComponent) {
|
|
@@ -385,7 +387,7 @@ class HttpErrorWrapperComponent {
|
|
|
385
387
|
}
|
|
386
388
|
customComponentRef.changeDetectorRef.detectChanges();
|
|
387
389
|
}
|
|
388
|
-
const keyup$ = fromEvent(document, 'keyup').pipe(debounceTime(150), filter((key) => key && key.key === 'Escape'));
|
|
390
|
+
const keyup$ = fromEvent(this.document, 'keyup').pipe(debounceTime(150), filter((key) => key && key.key === 'Escape'));
|
|
389
391
|
this.subscription.addOne(keyup$, () => this.destroy());
|
|
390
392
|
}
|
|
391
393
|
ngOnDestroy() {
|
|
@@ -2235,15 +2237,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.6", ngImpor
|
|
|
2235
2237
|
}] });
|
|
2236
2238
|
|
|
2237
2239
|
class CreateErrorComponentService {
|
|
2238
|
-
getErrorHostElement() {
|
|
2239
|
-
return document.body;
|
|
2240
|
-
}
|
|
2241
|
-
canCreateCustomError(status) {
|
|
2242
|
-
return !!(this.httpErrorConfig?.errorScreen?.component &&
|
|
2243
|
-
this.httpErrorConfig?.errorScreen?.forWhichErrors &&
|
|
2244
|
-
this.httpErrorConfig?.errorScreen?.forWhichErrors.indexOf(status) > -1);
|
|
2245
|
-
}
|
|
2246
2240
|
constructor() {
|
|
2241
|
+
this.document = inject(DOCUMENT);
|
|
2247
2242
|
this.rendererFactory = inject(RendererFactory2);
|
|
2248
2243
|
this.cfRes = inject(ComponentFactoryResolver);
|
|
2249
2244
|
this.routerEvents = inject(RouterEvents);
|
|
@@ -2261,8 +2256,18 @@ class CreateErrorComponentService {
|
|
|
2261
2256
|
this.componentRef = null;
|
|
2262
2257
|
});
|
|
2263
2258
|
}
|
|
2259
|
+
getErrorHostElement() {
|
|
2260
|
+
return this.document.body;
|
|
2261
|
+
}
|
|
2264
2262
|
isCloseIconHidden() {
|
|
2265
|
-
return !!this.httpErrorConfig
|
|
2263
|
+
return !!this.httpErrorConfig?.errorScreen?.hideCloseIcon;
|
|
2264
|
+
}
|
|
2265
|
+
canCreateCustomError(status) {
|
|
2266
|
+
const { component, forWhichErrors } = this.httpErrorConfig?.errorScreen || {};
|
|
2267
|
+
if (!component || !forWhichErrors) {
|
|
2268
|
+
return false;
|
|
2269
|
+
}
|
|
2270
|
+
return forWhichErrors.indexOf(status) > -1;
|
|
2266
2271
|
}
|
|
2267
2272
|
execute(instance) {
|
|
2268
2273
|
const renderer = this.rendererFactory.createRenderer(null, null);
|
|
@@ -2393,11 +2398,39 @@ class StatusCodeErrorHandlerService {
|
|
|
2393
2398
|
this.confirmationService = inject(ConfirmationService);
|
|
2394
2399
|
this.createErrorComponentService = inject(CreateErrorComponentService);
|
|
2395
2400
|
this.authService = inject(AuthService);
|
|
2396
|
-
this.priority = CUSTOM_HTTP_ERROR_HANDLER_PRIORITY.normal;
|
|
2397
2401
|
this.handledStatusCodes = [401, 403, 404, 500];
|
|
2402
|
+
this.priority = CUSTOM_HTTP_ERROR_HANDLER_PRIORITY.normal;
|
|
2403
|
+
}
|
|
2404
|
+
navigateToLogin() {
|
|
2405
|
+
this.authService.navigateToLogin();
|
|
2406
|
+
}
|
|
2407
|
+
showConfirmation(message, title) {
|
|
2408
|
+
return this.confirmationService.error(message, title, {
|
|
2409
|
+
hideCancelBtn: true,
|
|
2410
|
+
yesText: 'AbpAccount::Close',
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
showPage() {
|
|
2414
|
+
const key = `defaultError${this.status}`;
|
|
2415
|
+
const shouldRemoveDetail = [401, 404].indexOf(this.status) > -1;
|
|
2416
|
+
const instance = {
|
|
2417
|
+
title: {
|
|
2418
|
+
key: DEFAULT_ERROR_LOCALIZATIONS[key]?.title,
|
|
2419
|
+
defaultValue: DEFAULT_ERROR_MESSAGES[key]?.title,
|
|
2420
|
+
},
|
|
2421
|
+
details: {
|
|
2422
|
+
key: DEFAULT_ERROR_LOCALIZATIONS[key]?.details,
|
|
2423
|
+
defaultValue: DEFAULT_ERROR_MESSAGES[key]?.details,
|
|
2424
|
+
},
|
|
2425
|
+
status: this.status,
|
|
2426
|
+
};
|
|
2427
|
+
if (shouldRemoveDetail) {
|
|
2428
|
+
delete instance.details;
|
|
2429
|
+
}
|
|
2430
|
+
this.createErrorComponentService.execute(instance);
|
|
2398
2431
|
}
|
|
2399
2432
|
canHandle({ status }) {
|
|
2400
|
-
this.status = status;
|
|
2433
|
+
this.status = status || 0;
|
|
2401
2434
|
return this.handledStatusCodes.indexOf(status) > -1;
|
|
2402
2435
|
}
|
|
2403
2436
|
execute() {
|
|
@@ -2418,11 +2451,11 @@ class StatusCodeErrorHandlerService {
|
|
|
2418
2451
|
this.showPage();
|
|
2419
2452
|
break;
|
|
2420
2453
|
}
|
|
2421
|
-
this.
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2454
|
+
if (this.status === 401) {
|
|
2455
|
+
this.authService.navigateToLogin();
|
|
2456
|
+
break;
|
|
2457
|
+
}
|
|
2458
|
+
this.showConfirmation(title, message).subscribe();
|
|
2426
2459
|
break;
|
|
2427
2460
|
case 403:
|
|
2428
2461
|
case 500:
|
|
@@ -2430,34 +2463,6 @@ class StatusCodeErrorHandlerService {
|
|
|
2430
2463
|
break;
|
|
2431
2464
|
}
|
|
2432
2465
|
}
|
|
2433
|
-
navigateToLogin() {
|
|
2434
|
-
this.authService.navigateToLogin();
|
|
2435
|
-
}
|
|
2436
|
-
showConfirmation(message, title) {
|
|
2437
|
-
return this.confirmationService.error(message, title, {
|
|
2438
|
-
hideCancelBtn: true,
|
|
2439
|
-
yesText: 'AbpAccount::Close',
|
|
2440
|
-
});
|
|
2441
|
-
}
|
|
2442
|
-
showPage() {
|
|
2443
|
-
const key = `defaultError${this.status}`;
|
|
2444
|
-
const instance = {
|
|
2445
|
-
title: {
|
|
2446
|
-
key: DEFAULT_ERROR_LOCALIZATIONS[key]?.title,
|
|
2447
|
-
defaultValue: DEFAULT_ERROR_MESSAGES[key]?.title,
|
|
2448
|
-
},
|
|
2449
|
-
details: {
|
|
2450
|
-
key: DEFAULT_ERROR_LOCALIZATIONS[key]?.details,
|
|
2451
|
-
defaultValue: DEFAULT_ERROR_MESSAGES[key]?.details,
|
|
2452
|
-
},
|
|
2453
|
-
status: this.status,
|
|
2454
|
-
};
|
|
2455
|
-
const shouldRemoveDetail = [401, 404].indexOf(this.status) > -1;
|
|
2456
|
-
if (shouldRemoveDetail) {
|
|
2457
|
-
delete instance.details;
|
|
2458
|
-
}
|
|
2459
|
-
this.createErrorComponentService.execute(instance);
|
|
2460
|
-
}
|
|
2461
2466
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: StatusCodeErrorHandlerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2462
2467
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.6", ngImport: i0, type: StatusCodeErrorHandlerService, providedIn: 'root' }); }
|
|
2463
2468
|
}
|
|
@@ -2504,7 +2509,7 @@ class RouterErrorHandlerService {
|
|
|
2504
2509
|
this.httpErrorConfig = inject(HTTP_ERROR_CONFIG);
|
|
2505
2510
|
this.createErrorComponentService = inject(CreateErrorComponentService);
|
|
2506
2511
|
this.filterRouteErrors = (navigationError) => {
|
|
2507
|
-
if (!this.httpErrorConfig
|
|
2512
|
+
if (!this.httpErrorConfig?.skipHandledErrorCodes) {
|
|
2508
2513
|
return true;
|
|
2509
2514
|
}
|
|
2510
2515
|
return (navigationError.error?.message?.indexOf('Cannot match') > -1 &&
|
|
@@ -2548,8 +2553,7 @@ class ErrorHandler {
|
|
|
2548
2553
|
this.executeErrorHandler = (error) => {
|
|
2549
2554
|
const errHandler = this.httpErrorHandler(this.injector, error);
|
|
2550
2555
|
const isObservable = errHandler instanceof Observable;
|
|
2551
|
-
|
|
2552
|
-
return response.pipe(catchError(err => {
|
|
2556
|
+
return (isObservable ? errHandler : of(null)).pipe(catchError(err => {
|
|
2553
2557
|
this.handleError(err);
|
|
2554
2558
|
return of(null);
|
|
2555
2559
|
}));
|
|
@@ -2557,10 +2561,10 @@ class ErrorHandler {
|
|
|
2557
2561
|
this.filterRestErrors = ({ status }) => {
|
|
2558
2562
|
if (typeof status !== 'number')
|
|
2559
2563
|
return false;
|
|
2560
|
-
if (!this.httpErrorConfig.skipHandledErrorCodes) {
|
|
2564
|
+
if (!this.httpErrorConfig || !this.httpErrorConfig.skipHandledErrorCodes) {
|
|
2561
2565
|
return true;
|
|
2562
2566
|
}
|
|
2563
|
-
return this.httpErrorConfig.skipHandledErrorCodes
|
|
2567
|
+
return this.httpErrorConfig.skipHandledErrorCodes?.findIndex(code => code === status) < 0;
|
|
2564
2568
|
};
|
|
2565
2569
|
this.listenToRestError();
|
|
2566
2570
|
this.listenToRouterError();
|
|
@@ -2571,9 +2575,7 @@ class ErrorHandler {
|
|
|
2571
2575
|
listenToRestError() {
|
|
2572
2576
|
this.httpErrorReporter.reporter$
|
|
2573
2577
|
.pipe(filter(this.filterRestErrors), switchMap(this.executeErrorHandler))
|
|
2574
|
-
.subscribe(err =>
|
|
2575
|
-
this.handleError(err);
|
|
2576
|
-
});
|
|
2578
|
+
.subscribe(err => this.handleError(err));
|
|
2577
2579
|
}
|
|
2578
2580
|
sortHttpErrorHandlers(a, b) {
|
|
2579
2581
|
return (b.priority || 0) - (a.priority || 0);
|