diff options
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r-- | client/src/app/shared/rest/rest-extractor.service.ts | 16 |
1 files changed, 15 insertions, 1 deletions
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 @@ | |||
1 | import { of, throwError as observableThrowError } from 'rxjs' | 1 | import { throwError as observableThrowError } from 'rxjs' |
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { dateToHuman } from '@app/shared/misc/utils' | 3 | import { dateToHuman } from '@app/shared/misc/utils' |
4 | import { ResultList } from '../../../../../shared' | 4 | import { ResultList } from '../../../../../shared' |
5 | import { Router } from '@angular/router' | ||
5 | 6 | ||
6 | @Injectable() | 7 | @Injectable() |
7 | export class RestExtractor { | 8 | export class RestExtractor { |
8 | 9 | ||
10 | constructor (private router: Router) { | ||
11 | // empty | ||
12 | } | ||
13 | |||
9 | extractDataBool () { | 14 | extractDataBool () { |
10 | return true | 15 | return true |
11 | } | 16 | } |
@@ -87,4 +92,13 @@ export class RestExtractor { | |||
87 | 92 | ||
88 | return observableThrowError(errorObj) | 93 | return observableThrowError(errorObj) |
89 | } | 94 | } |
95 | |||
96 | redirectTo404IfNotFound (obj: { status: number }, status = [ 404 ]) { | ||
97 | if (obj && obj.status && status.indexOf(obj.status) !== -1) { | ||
98 | // Do not use redirectService to avoid circular dependencies | ||
99 | this.router.navigate([ '/404' ], { skipLocationChange: true }) | ||
100 | } | ||
101 | |||
102 | return observableThrowError(obj) | ||
103 | } | ||
90 | } | 104 | } |