[#1] Add error notification when an error attempts when post saving.
This commit is contained in:
@@ -4,6 +4,7 @@ import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/c
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { AuthService } from '../services/auth.service';
|
||||
import { NotificationsComponent } from '../notifications/notifications.component';
|
||||
|
||||
@Injectable()
|
||||
export class UnauthorizedInterceptor implements HttpInterceptor {
|
||||
@@ -17,6 +18,7 @@ export class UnauthorizedInterceptor implements HttpInterceptor {
|
||||
if (err.status === 401) {
|
||||
this.authService.setAnonymous();
|
||||
this.router.navigate(['/login']);
|
||||
window.setTimeout(() => NotificationsComponent.error('Veuillez vous authentifier pour réaliser cette action.'), 500);
|
||||
}
|
||||
|
||||
const error = (err.error && err.error.message) || err.statusText;
|
||||
|
||||
@@ -160,10 +160,16 @@ export class CreateUpdatePostComponent implements OnInit {
|
||||
if (this.model.key) {
|
||||
this.createUpdatePostService.updatePost(this.model).subscribe(post => {
|
||||
NotificationsComponent.success('Modification enregistrée');
|
||||
}, error => {
|
||||
console.log(error);
|
||||
NotificationsComponent.error('Une erreur est survenue lors de l\'enregistrement des modifications.');
|
||||
});
|
||||
} else {
|
||||
this.createUpdatePostService.addPost(this.model).subscribe(post => {
|
||||
this.router.navigate([`/posts/update/${post.key}`]);
|
||||
}, error => {
|
||||
console.log(error);
|
||||
NotificationsComponent.error('Une erreur est survenue lors de la création du post.');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user