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-05-11 13:33:50 +02:00
|
|
|
<div *ngIf="status.some(checkErroCode(errorCodes.LOADING))" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert"><img class="loading-gif uk-align-center" ></div>
|
2017-12-19 13:53:46 +01:00
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.NONE))" class="uk-animation-fade uk-alert uk-alert-primary" role="alert">No {{type}} available</div>
|
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.ERROR)) ||
|
|
|
|
(status.some(checkErroCode(errorCodes.ERROR)) && (!status.every(checkErroCode(errorCodes.DONE)) || !status.every(checkErroCode(errorCodes.LOADING))))"
|
|
|
|
class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
|
|
|
|
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))))"
|
|
|
|
class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
|
|
|
|
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))))"
|
|
|
|
class="uk-animation-fade uk-alert uk-alert-warning" role="alert">
|
|
|
|
No {{type}} found
|
|
|
|
</div>
|
|
|
|
<div *ngIf="status.every(checkErroCode(errorCodes.OUT_OF_BOUND))" class="uk-animation-fade uk-alert uk-alert-warning" role="alert">Requested page out of bounds</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ErrorMessagesComponent {
|
|
|
|
@Input() status: Array<number>;
|
|
|
|
@Input() type: string;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|