Browse Source

refactor: change backend connection error message detail

pull/3734/head
mehmet-erim 6 years ago
parent
commit
63ce39af0f
  1. 21
      npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.html
  2. 13
      npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.ts
  3. 2
      npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

21
npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.html

@ -1,5 +1,16 @@
<div #container id="abp-http-error-container" class="error" [style.backgroundColor]="backgroundColor">
<button *ngIf="!hideCloseIcon" id="abp-close-button" type="button" class="close mr-2" (click)="destroy()">
<div
#container
id="abp-http-error-container"
class="error"
[style.backgroundColor]="backgroundColor"
>
<button
*ngIf="!hideCloseIcon"
id="abp-close-button"
type="button"
class="close mr-2"
(click)="destroy()"
>
<span aria-hidden="true">&times;</span>
</button>
@ -11,7 +22,11 @@
{{ details | abpLocalization }}
</div>
<div class="error-actions">
<a (click)="destroy()" routerLink="/" class="btn btn-primary btn-md mt-2"
<a
*ngIf="isHomeShow"
(click)="destroy()"
routerLink="/"
class="btn btn-primary btn-md mt-2"
><span class="glyphicon glyphicon-home"></span>
{{ { key: '::Menu:Home', defaultValue: 'Home' } | abpLocalization }}
</a>

13
npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.ts

@ -42,6 +42,8 @@ export class HttpErrorWrapperComponent implements AfterViewInit, OnDestroy, OnIn
backgroundColor: string;
isHomeShow = true;
@ViewChild('container', { static: false })
containerRef: ElementRef<HTMLDivElement>;
@ -51,16 +53,21 @@ export class HttpErrorWrapperComponent implements AfterViewInit, OnDestroy, OnIn
ngOnInit() {
this.backgroundColor =
snq(() => window.getComputedStyle(document.body).getPropertyValue('background-color')) || '#fff';
snq(() => window.getComputedStyle(document.body).getPropertyValue('background-color')) ||
'#fff';
}
ngAfterViewInit() {
if (this.customComponent) {
const customComponentRef = this.cfRes.resolveComponentFactory(this.customComponent).create(this.injector);
const customComponentRef = this.cfRes
.resolveComponentFactory(this.customComponent)
.create(this.injector);
customComponentRef.instance.errorStatus = this.status;
customComponentRef.instance.destroy$ = this.destroy$;
this.appRef.attachView(customComponentRef.hostView);
this.containerRef.nativeElement.appendChild((customComponentRef.hostView as EmbeddedViewRef<any>).rootNodes[0]);
this.containerRef.nativeElement.appendChild(
(customComponentRef.hostView as EmbeddedViewRef<any>).rootNodes[0],
);
customComponentRef.changeDetectorRef.detectChanges();
}

2
npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

@ -138,6 +138,8 @@ export class ErrorHandler {
key: 'AbpAccount::DefaultErrorMessage',
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title,
},
details: err.message,
isHomeShow: false,
});
}
break;

Loading…
Cancel
Save