import {Component, Input} from '@angular/core'; import {ErrorCodes} from './properties/errorCodes'; @Component({ selector: 'errorMessages', template: `
No {{type}} available
An Error Occured
Service temprorarily 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 checkErroCode(code: number) { return function(status: number) { return (status == code); } } public getErrorCode(status: string) { if(status == '401') { return this.errorCodes.FORBIDDEN; } else if(status == "403") { return this.errorCodes.FORBIDDEN; } else if(status == "204") { return this.errorCodes.NONE; } else if(status == '404') { return this.errorCodes.NOT_FOUND; } else if(status == '500') { return this.errorCodes.ERROR; } else { return this.errorCodes.NOT_AVAILABLE; } } }