Browse Source

refactor: change backend connection error message detail

pull/3734/head
mehmet-erim 7 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"> <div
<button *ngIf="!hideCloseIcon" id="abp-close-button" type="button" class="close mr-2" (click)="destroy()"> #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> <span aria-hidden="true">&times;</span>
</button> </button>
@ -11,7 +22,11 @@
{{ details | abpLocalization }} {{ details | abpLocalization }}
</div> </div>
<div class="error-actions"> <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> ><span class="glyphicon glyphicon-home"></span>
{{ { key: '::Menu:Home', defaultValue: 'Home' } | abpLocalization }} {{ { key: '::Menu:Home', defaultValue: 'Home' } | abpLocalization }}
</a> </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; backgroundColor: string;
isHomeShow = true;
@ViewChild('container', { static: false }) @ViewChild('container', { static: false })
containerRef: ElementRef<HTMLDivElement>; containerRef: ElementRef<HTMLDivElement>;
@ -51,16 +53,21 @@ export class HttpErrorWrapperComponent implements AfterViewInit, OnDestroy, OnIn
ngOnInit() { ngOnInit() {
this.backgroundColor = this.backgroundColor =
snq(() => window.getComputedStyle(document.body).getPropertyValue('background-color')) || '#fff'; snq(() => window.getComputedStyle(document.body).getPropertyValue('background-color')) ||
'#fff';
} }
ngAfterViewInit() { ngAfterViewInit() {
if (this.customComponent) { 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.errorStatus = this.status;
customComponentRef.instance.destroy$ = this.destroy$; customComponentRef.instance.destroy$ = this.destroy$;
this.appRef.attachView(customComponentRef.hostView); 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(); 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', key: 'AbpAccount::DefaultErrorMessage',
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title,
}, },
details: err.message,
isHomeShow: false,
}); });
} }
break; break;

Loading…
Cancel
Save