aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/rest
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/rest')
-rw-r--r--client/src/app/shared/rest/rest-extractor.service.ts16
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 @@
1import { of, throwError as observableThrowError } from 'rxjs' 1import { throwError as observableThrowError } from 'rxjs'
2import { Injectable } from '@angular/core' 2import { Injectable } from '@angular/core'
3import { dateToHuman } from '@app/shared/misc/utils' 3import { dateToHuman } from '@app/shared/misc/utils'
4import { ResultList } from '../../../../../shared' 4import { ResultList } from '../../../../../shared'
5import { Router } from '@angular/router'
5 6
6@Injectable() 7@Injectable()
7export class RestExtractor { 8export 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}