From a51bad1accfade25916db0dadaeb879a182cf19b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 31 May 2018 11:35:01 +0200 Subject: Add 404 page --- client/src/app/shared/rest/rest-extractor.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/rest/rest-extractor.service.ts') diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts index db087d407..39e601e20 100644 --- a/client/src/app/shared/rest/rest-extractor.service.ts +++ b/client/src/app/shared/rest/rest-extractor.service.ts @@ -1,11 +1,16 @@ -import { of, throwError as observableThrowError } from 'rxjs' +import { throwError as observableThrowError } from 'rxjs' import { Injectable } from '@angular/core' import { dateToHuman } from '@app/shared/misc/utils' import { ResultList } from '../../../../../shared' +import { Router } from '@angular/router' @Injectable() export class RestExtractor { + constructor (private router: Router) { + // empty + } + extractDataBool () { return true } @@ -87,4 +92,13 @@ export class RestExtractor { return observableThrowError(errorObj) } + + redirectTo404IfNotFound (obj: { status: number }, status = [ 404 ]) { + if (obj && obj.status && status.indexOf(obj.status) !== -1) { + // Do not use redirectService to avoid circular dependencies + this.router.navigate([ '/404' ], { skipLocationChange: true }) + } + + return observableThrowError(obj) + } } -- cgit v1.2.3