@app/_models#Alert TypeScript Examples

The following examples show how to use @app/_models#Alert. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: alert.component.ts    From angular-10-signup-verification-boilerplate with MIT License 6 votes vote down vote up
removeAlert(alert: Alert) {
        // check if already removed to prevent error on auto close
        if (!this.alerts.includes(alert)) return;

        if (this.fade) {
            // fade out alert
            alert.fade = true;

            // remove alert after faded out
            setTimeout(() => {
                this.alerts = this.alerts.filter(x => x !== alert);
            }, 250);
        } else {
            // remove alert
            this.alerts = this.alerts.filter(x => x !== alert);
        }
    }
Example #2
Source File: alert.component.ts    From angular-11-crud-example with MIT License 6 votes vote down vote up
removeAlert(alert: Alert) {
        // check if already removed to prevent error on auto close
        if (!this.alerts.includes(alert)) return;

        if (this.fade) {
            // fade out alert
            alert.fade = true;

            // remove alert after faded out
            setTimeout(() => {
                this.alerts = this.alerts.filter(x => x !== alert);
            }, 250);
        } else {
            // remove alert
            this.alerts = this.alerts.filter(x => x !== alert);
        }
    }
Example #3
Source File: alert.component.ts    From angular-11-crud-example with MIT License 6 votes vote down vote up
cssClass(alert: Alert) {
        if (alert?.type === undefined) return;

        const classes = ['alert', 'alert-dismissable', 'mt-4', 'container'];
                
        const alertTypeClass = {
            [AlertType.Success]: 'alert-success',
            [AlertType.Error]: 'alert-danger',
            [AlertType.Info]: 'alert-info',
            [AlertType.Warning]: 'alert-warning'
        }

        classes.push(alertTypeClass[alert.type]);

        if (alert.fade) {
            classes.push('fade');
        }

        return classes.join(' ');
    }
Example #4
Source File: alert.component.ts    From angular-10-signup-verification-boilerplate with MIT License 6 votes vote down vote up
cssClasses(alert: Alert) {
        if (!alert) return;

        const classes = ['alert', 'alert-dismissable'];
                
        const alertTypeClass = {
            [AlertType.Success]: 'alert alert-success',
            [AlertType.Error]: 'alert alert-danger',
            [AlertType.Info]: 'alert alert-info',
            [AlertType.Warning]: 'alert alert-warning'
        }

        classes.push(alertTypeClass[alert.type]);

        if (alert.fade) {
            classes.push('fade');
        }

        return classes.join(' ');
    }
Example #5
Source File: alert.component.ts    From angular-10-registration-login-example with MIT License 6 votes vote down vote up
cssClass(alert: Alert) {
        if (!alert) return;

        const classes = ['alert', 'alert-dismissable', 'mt-4', 'container'];
                
        const alertTypeClass = {
            [AlertType.Success]: 'alert alert-success',
            [AlertType.Error]: 'alert alert-danger',
            [AlertType.Info]: 'alert alert-info',
            [AlertType.Warning]: 'alert alert-warning'
        }

        classes.push(alertTypeClass[alert.type]);

        if (alert.fade) {
            classes.push('fade');
        }

        return classes.join(' ');
    }
Example #6
Source File: alert.component.ts    From angular-10-registration-login-example with MIT License 6 votes vote down vote up
removeAlert(alert: Alert) {
        // check if already removed to prevent error on auto close
        if (!this.alerts.includes(alert)) return;

        if (this.fade) {
            // fade out alert
            alert.fade = true;

            // remove alert after faded out
            setTimeout(() => {
                this.alerts = this.alerts.filter(x => x !== alert);
            }, 250);
        } else {
            // remove alert
            this.alerts = this.alerts.filter(x => x !== alert);
        }
    }
Example #7
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
// clear alerts
    clear(id = this.defaultId) {
        this.subject.next(new Alert(id));
    }
Example #8
Source File: alert.component.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
alerts: Alert[] = [];
Example #9
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
// enable subscribing to alerts observable
    onAlert(id = this.defaultId): Observable<Alert> {
        return this.subject.asObservable().pipe(filter(x => x && x.id === id));
    }
Example #10
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
// convenience methods
    success(message: string, options?: Partial<Alert>) {
        this.alert(message, AlertType.Success, options);
    }
Example #11
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
error(message: string, options?: Partial<Alert>) {
        this.alert(message, AlertType.Error, options);
    }
Example #12
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
info(message: string, options?: Partial<Alert>) {
        this.alert(message, AlertType.Info, options);
    }
Example #13
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
warn(message: string, options?: Partial<Alert>) {
        this.alert(message, AlertType.Warning, options);
    }
Example #14
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
// main alert method    
    alert(message: string, type: AlertType, options: Partial<Alert> = {}) {
        const id = options.id || this.defaultId;
        const alert = new Alert(id, type, message, options.autoClose, options.keepAfterRouteChange);
        this.subject.next(alert);
    }
Example #15
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
// main alert method    
    alert(alert: Alert) {
        alert.id = alert.id || this.defaultId;
        alert.autoClose = (alert.autoClose === undefined ? true : alert.autoClose);
        this.subject.next(alert);
    }
Example #16
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
// clear alerts
    clear(id = this.defaultId) {
        this.subject.next(new Alert({ id }));
    }
Example #17
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
private subject = new Subject<Alert>();
Example #18
Source File: alert.service.ts    From angular-11-crud-example with MIT License 5 votes vote down vote up
private subject = new Subject<Alert>();
Example #19
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
// enable subscribing to alerts observable
    onAlert(id = this.defaultId): Observable<Alert> {
        return this.subject.asObservable().pipe(filter(x => x && x.id === id));
    }
Example #20
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
// convenience methods
    success(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Success, message }));
    }
Example #21
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
error(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Error, message }));
    }
Example #22
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
info(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Info, message }));
    }
Example #23
Source File: alert.service.ts    From angular-master-details-crud-example with MIT License 5 votes vote down vote up
warn(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Warning, message }));
    }
Example #24
Source File: alert.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
private subject = new Subject<Alert>();
Example #25
Source File: alert.component.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
alerts: Alert[] = [];
Example #26
Source File: alert.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
// enable subscribing to alerts observable
    onAlert(id = this.defaultId): Observable<Alert> {
        return this.subject.asObservable().pipe(filter(x => x && x.id === id));
    }
Example #27
Source File: alert.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
// convenience methods
    success(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Success, message }));
    }
Example #28
Source File: alert.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
error(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Error, message }));
    }
Example #29
Source File: alert.service.ts    From angular-10-registration-login-example with MIT License 5 votes vote down vote up
info(message: string, options?: any) {
        this.alert(new Alert({ ...options, type: AlertType.Info, message }));
    }