2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
2018-02-15 11:36:12 +01:00
|
|
|
import {ErrorCodes} from './properties/errorCodes';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'errorMessages',
|
|
|
|
template: `
|
2018-06-08 13:21:42 +02:00
|
|
|
<div *ngIf="status.some(checkErroCode(errorCodes.LOADING))"
|
|
|
|
[class]="(tab_error_class ? '' : 'uk-animation-fade') + ' uk-margin-top uk-width-1-1'" role="alert"><img class="loading-gif uk-align-center" ></div>
|
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.NONE))"
|
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-primary'" role="alert">No {{type}} available</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.ERROR)) ||
|
|
|
|
(status.some(checkErroCode(errorCodes.ERROR)) && (!status.every(checkErroCode(errorCodes.DONE)) || !status.every(checkErroCode(errorCodes.LOADING))))"
|
2018-06-08 13:21:42 +02:00
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">
|
2017-12-19 13:53:46 +01:00
|
|
|
An Error Occured
|
|
|
|
</div>
|
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.NOT_AVAILABLE)) ||
|
|
|
|
(status.some(checkErroCode(errorCodes.NOT_AVAILABLE)) && (!status.every(checkErroCode(errorCodes.DONE)) || !status.every(checkErroCode(errorCodes.LOADING))))"
|
2018-06-08 13:21:42 +02:00
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">
|
2017-12-19 13:53:46 +01:00
|
|
|
Service temprorarily unavailable. Please try again later.
|
|
|
|
</div>
|
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.NOT_FOUND)) ||
|
|
|
|
(status.some(checkErroCode(errorCodes.NOT_FOUND)) && (!status.every(checkErroCode(errorCodes.DONE)) || !status.every(checkErroCode(errorCodes.LOADING))))"
|
2018-06-08 13:21:42 +02:00
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">
|
2017-12-19 13:53:46 +01:00
|
|
|
No {{type}} found
|
|
|
|
</div>
|
2018-06-08 13:21:42 +02:00
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.OUT_OF_BOUND))"
|
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">Requested page out of bounds</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ErrorMessagesComponent {
|
|
|
|
@Input() status: Array<number>;
|
|
|
|
@Input() type: string;
|
2018-06-08 13:21:42 +02:00
|
|
|
@Input() tab_error_class: boolean = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
public errorCodes:ErrorCodes;
|
|
|
|
|
|
|
|
constructor () {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.errorCodes = new ErrorCodes();
|
|
|
|
console.info("ngOnInit");
|
|
|
|
if(!this.status) {
|
|
|
|
this.status = [this.errorCodes.LOADING];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {}
|
|
|
|
|
|
|
|
public checkErroCode(code: number) {
|
|
|
|
return function(status: number) {
|
|
|
|
return (status == code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|