import { Injectable } from '@angular/core' ; @ Injectable ( { providedIn : 'root' } ) export class ToastService { public toastsright : any [ ] = [ ] ; public toastsleft : any [ ] = [ ] ; public toastsdownleft : any [ ] = [ ] ; public toastsdownright : any [ ] = [ ] ; public toastscenter : any [ ] = [ ] ; param text param options param direction public showToast ( text , options = { } , direction ? ) { if ( ! options . icon ) { options . icon = 'fas fa-info-circle' ; } switch ( direction ) { case 'right' : { this . toastsright . push ( { text , ... options } ) ; break ; } case 'left' : { this . toastsleft . push ( { text , ... options } ) ; break ; } case 'downleft' : { this . toastsdownleft . push ( { text , ... options } ) ; break ; } case 'downright' : { this . toastsdownright . push ( { text , ... options } ) ; break ; } case 'center' : { this . toastscenter . push ( { text , ... options } ) ; break ; } default : { this . toastsright . push ( { text , ... options } ) ; break ; } } } param text param options param direction public error ( text , options = { headerName : 'An Error Occurred' , icon : 'fas fa-exclamation-circle' } , direction ? ) { options . classname += ' border-danger' ; options . iconClass = 'text-danger' ; this . showToast ( text , options , direction ) ; } param text param options param direction public warning ( text , options = { headerName : 'Warning' , icon : 'fas fa-exclamation-triangle' } , direction ? ) { options . classname += ' border-warning' ; options . iconClass = 'text-warning' ; this . showToast ( text , options , direction ) ; } param text param options param direction public success ( text , options = { headerName : 'Success' , icon : 'fas fa-check-circle' } , direction ? ) { options . classname += ' border-success' ; options . iconClass = 'text-success' ; this . showToast ( text , options , direction ) ; } param text param options param direction public info ( text , options = { headerName : 'Information' , icon : 'fas fa-info-circle' } , direction ? ) { options . classname += ' border-info' ; options . iconClass = 'text-info' ; this . showToast ( text , options , direction ) ; } param toast public remove ( toast ) { this . toastscenter = this . toastscenter . filter ( t => t !== toast ) ; this . toastsdownright = this . toastsdownright . filter ( t => t !== toast ) ; this . toastsdownleft = this . toastsdownleft . filter ( t => t !== toast ) ; this . toastsleft = this . toastsleft . filter ( t => t !== toast ) ; this . toastsright = this . toastsright . filter ( t => t !== toast ) ; } }