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))"
|
2018-10-03 16:12:42 +02:00
|
|
|
[class]="(tab_error_class ? '' : 'uk-animation-fade') + ' uk-margin-top uk-width-1-1'" role="alert"><span class="loading-gif uk-align-center" ></span></div>
|
2018-06-08 13:21:42 +02:00
|
|
|
<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))"
|
2018-06-29 15:24:49 +02:00
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">Requested page out of bounds
|
|
|
|
</div>
|
|
|
|
<div *ngIf="status.some(checkErroCode(errorCodes.NOT_SAVED))"
|
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-warning'" role="alert">Changes could not be saved
|
|
|
|
</div>
|
2018-09-24 12:08:33 +02:00
|
|
|
<div *ngIf="status.some(checkErroCode(errorCodes.FORBIDDEN))"
|
2019-01-16 21:43:44 +01:00
|
|
|
[class]="(tab_error_class ? 'uk-margin-top' : 'uk-animation-fade') + ' uk-alert uk-alert-danger'" role="alert">You are not allowed to access this page
|
2018-09-24 12:08:33 +02:00
|
|
|
</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();
|
|
|
|
if(!this.status) {
|
|
|
|
this.status = [this.errorCodes.LOADING];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {}
|
|
|
|
|
|
|
|
public checkErroCode(code: number) {
|
|
|
|
return function(status: number) {
|
|
|
|
return (status == code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|