feat: replace custom notify to ngx-toastr
#https://github.com/scttcper/ngx-toastr
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
import {catchError, distinctUntilChanged, filter, first, mergeMap, Observable, retryWhen, switchMap, timer} from "rxjs";
|
||||
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
||||
import {NotifyColor, OpenNotifyService} from "@service/open-notify.service";
|
||||
import {environment} from "@environment";
|
||||
import {Router} from "@angular/router";
|
||||
import {Injectable} from "@angular/core";
|
||||
import {RequestBuilder, RequestData} from "@api/RequestBuilder";
|
||||
import {TokenRefreshService} from "@service/token-refresh.service";
|
||||
import {AuthToken} from "@service/auth.service";
|
||||
import {ToastrService} from "ngx-toastr";
|
||||
|
||||
export function retryWithInterval<T>(): (source: Observable<T>) => Observable<T> {
|
||||
return (source: Observable<T>) =>
|
||||
@ -37,7 +37,7 @@ export enum AvailableVersion {
|
||||
|
||||
@Injectable()
|
||||
export default abstract class ApiService {
|
||||
constructor(private http: HttpClient, private notify: OpenNotifyService, private router: Router, protected tokenRefreshService: TokenRefreshService) {
|
||||
constructor(private http: HttpClient, private notify: ToastrService, private router: Router, protected tokenRefreshService: TokenRefreshService) {
|
||||
}
|
||||
|
||||
private apiUrl = environment.apiUrl;
|
||||
@ -154,6 +154,7 @@ export default abstract class ApiService {
|
||||
}
|
||||
|
||||
let message: string;
|
||||
let description: string | undefined = undefined;
|
||||
if (error.error instanceof ErrorEvent) {
|
||||
message = `Произошла ошибка: ${error.error.message}`;
|
||||
} else {
|
||||
@ -185,9 +186,9 @@ export default abstract class ApiService {
|
||||
break;
|
||||
}
|
||||
if (error.error?.Error) {
|
||||
message += ` ${error.error.Error}`;
|
||||
description = `${error.error.Error}`;
|
||||
}
|
||||
}
|
||||
this.notify.open(message, NotifyColor.Danger);
|
||||
this.notify.error(description, message);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user