import {Component, Input} from '@angular/core'; import {ErrorCodes} from './properties/errorCodes'; import {properties} from "../../../environments/environment"; @Component({ selector: 'errorMessages', template: `
No {{type}} available
An Error Occurred
Service temporarily unavailable. Please try again later.
No {{type}} found
Requested page out of bounds
Changes could not be saved
You are not allowed to access this page
` }) export class ErrorMessagesComponent { @Input() status: Array; @Input() type: string; @Input() tab_error_class: boolean = false; public errorCodes:ErrorCodes; constructor () { this.errorCodes = new ErrorCodes(); } ngOnInit() { if(!this.status) { this.status = [this.errorCodes.LOADING]; } } ngOnDestroy() {} public checkErrorCode(code: number) { return function(status: number) { return (status == code); } } public getErrorCode(status: any) { if(status == '401' || status == 401) { return this.errorCodes.FORBIDDEN; } else if(status == "403" || status == 403) { return this.errorCodes.FORBIDDEN; } else if(status == "204" || status == 204) { return this.errorCodes.NONE; } else if(status == '404' || status == 404) { return this.errorCodes.NOT_FOUND; } else if(status == '500'|| status == 500) { return this.errorCodes.ERROR; } else { return this.errorCodes.NOT_AVAILABLE; } } }