aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/routing
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/core/routing')
-rw-r--r--client/src/app/core/routing/can-deactivate-guard.service.ts30
-rw-r--r--client/src/app/core/routing/index.ts9
-rw-r--r--client/src/app/core/routing/login-guard.service.ts1
-rw-r--r--client/src/app/core/routing/menu-guard.service.ts4
-rw-r--r--client/src/app/core/routing/preload-selected-modules-list.ts1
-rw-r--r--client/src/app/core/routing/server-config-resolver.service.ts2
-rw-r--r--client/src/app/core/routing/unlogged-guard.service.ts3
-rw-r--r--client/src/app/core/routing/user-right-guard.service.ts9
8 files changed, 43 insertions, 16 deletions
diff --git a/client/src/app/core/routing/can-deactivate-guard.service.ts b/client/src/app/core/routing/can-deactivate-guard.service.ts
new file mode 100644
index 000000000..e0405293a
--- /dev/null
+++ b/client/src/app/core/routing/can-deactivate-guard.service.ts
@@ -0,0 +1,30 @@
1import { Observable } from 'rxjs'
2import { Injectable } from '@angular/core'
3import { CanDeactivate } from '@angular/router'
4import { ConfirmService } from '@app/core/confirm'
5import { I18n } from '@ngx-translate/i18n-polyfill'
6
7export type CanComponentDeactivateResult = { text?: string, canDeactivate: Observable<boolean> | boolean }
8
9export interface CanComponentDeactivate {
10 canDeactivate: () => CanComponentDeactivateResult
11}
12
13@Injectable()
14export class CanDeactivateGuard implements CanDeactivate<CanComponentDeactivate> {
15 constructor (
16 private confirmService: ConfirmService,
17 private i18n: I18n
18 ) { }
19
20 canDeactivate (component: CanComponentDeactivate) {
21 const result = component.canDeactivate()
22 const text = result.text || this.i18n('All unsaved data will be lost, are you sure you want to leave this page?')
23
24 return result.canDeactivate || this.confirmService.confirm(
25 text,
26 this.i18n('Warning')
27 )
28 }
29
30}
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts
index 58b83bb2a..239c27caf 100644
--- a/client/src/app/core/routing/index.ts
+++ b/client/src/app/core/routing/index.ts
@@ -1,5 +1,10 @@
1export * from './can-deactivate-guard.service'
2export * from './custom-reuse-strategy'
3export * from './disable-for-reuse-hook'
1export * from './login-guard.service' 4export * from './login-guard.service'
2export * from './user-right-guard.service' 5export * from './menu-guard.service'
3export * from './preload-selected-modules-list' 6export * from './preload-selected-modules-list'
4export * from './redirect.service' 7export * from './redirect.service'
5export * from './menu-guard.service' 8export * from './server-config-resolver.service'
9export * from './unlogged-guard.service'
10export * from './user-right-guard.service'
diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts
index 7b1c37ee8..a949be14c 100644
--- a/client/src/app/core/routing/login-guard.service.ts
+++ b/client/src/app/core/routing/login-guard.service.ts
@@ -1,6 +1,5 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router'
3
4import { AuthService } from '../auth/auth.service' 3import { AuthService } from '../auth/auth.service'
5 4
6@Injectable() 5@Injectable()
diff --git a/client/src/app/core/routing/menu-guard.service.ts b/client/src/app/core/routing/menu-guard.service.ts
index 907d145fd..9df285635 100644
--- a/client/src/app/core/routing/menu-guard.service.ts
+++ b/client/src/app/core/routing/menu-guard.service.ts
@@ -1,7 +1,7 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { CanActivate, CanDeactivate } from '@angular/router' 2import { CanActivate, CanDeactivate } from '@angular/router'
3import { MenuService } from '@app/core/menu' 3import { MenuService } from '../menu'
4import { ScreenService } from '@app/shared/misc/screen.service' 4import { ScreenService } from '../wrappers'
5 5
6abstract class MenuGuard implements CanActivate, CanDeactivate<any> { 6abstract class MenuGuard implements CanActivate, CanDeactivate<any> {
7 display = true 7 display = true
diff --git a/client/src/app/core/routing/preload-selected-modules-list.ts b/client/src/app/core/routing/preload-selected-modules-list.ts
index 64af68225..b494a40bc 100644
--- a/client/src/app/core/routing/preload-selected-modules-list.ts
+++ b/client/src/app/core/routing/preload-selected-modules-list.ts
@@ -5,6 +5,7 @@ import { Injectable } from '@angular/core'
5 5
6@Injectable() 6@Injectable()
7export class PreloadSelectedModulesList implements PreloadingStrategy { 7export class PreloadSelectedModulesList implements PreloadingStrategy {
8
8 preload (route: Route, load: Function): Observable<any> { 9 preload (route: Route, load: Function): Observable<any> {
9 if (!route.data || !route.data.preload) return ofObservable(null) 10 if (!route.data || !route.data.preload) return ofObservable(null)
10 11
diff --git a/client/src/app/core/routing/server-config-resolver.service.ts b/client/src/app/core/routing/server-config-resolver.service.ts
index 3b7ed99bf..0ce2023a0 100644
--- a/client/src/app/core/routing/server-config-resolver.service.ts
+++ b/client/src/app/core/routing/server-config-resolver.service.ts
@@ -1,6 +1,6 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { Resolve } from '@angular/router' 2import { Resolve } from '@angular/router'
3import { ServerService } from '@app/core/server' 3import { ServerService } from '../server'
4import { ServerConfig } from '@shared/models' 4import { ServerConfig } from '@shared/models'
5 5
6@Injectable() 6@Injectable()
diff --git a/client/src/app/core/routing/unlogged-guard.service.ts b/client/src/app/core/routing/unlogged-guard.service.ts
index 3132a1a77..0be7911a0 100644
--- a/client/src/app/core/routing/unlogged-guard.service.ts
+++ b/client/src/app/core/routing/unlogged-guard.service.ts
@@ -1,5 +1,5 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' 2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router'
3import { AuthService } from '../auth/auth.service' 3import { AuthService } from '../auth/auth.service'
4import { RedirectService } from './redirect.service' 4import { RedirectService } from './redirect.service'
5 5
@@ -7,7 +7,6 @@ import { RedirectService } from './redirect.service'
7export class UnloggedGuard implements CanActivate, CanActivateChild { 7export class UnloggedGuard implements CanActivate, CanActivateChild {
8 8
9 constructor ( 9 constructor (
10 private router: Router,
11 private auth: AuthService, 10 private auth: AuthService,
12 private redirectService: RedirectService 11 private redirectService: RedirectService
13 ) {} 12 ) {}
diff --git a/client/src/app/core/routing/user-right-guard.service.ts b/client/src/app/core/routing/user-right-guard.service.ts
index 50c3d8c19..a2ce772db 100644
--- a/client/src/app/core/routing/user-right-guard.service.ts
+++ b/client/src/app/core/routing/user-right-guard.service.ts
@@ -1,12 +1,5 @@
1import { Injectable } from '@angular/core' 1import { Injectable } from '@angular/core'
2import { 2import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router'
3 ActivatedRouteSnapshot,
4 CanActivateChild,
5 RouterStateSnapshot,
6 CanActivate,
7 Router
8} from '@angular/router'
9
10import { AuthService } from '../auth/auth.service' 3import { AuthService } from '../auth/auth.service'
11 4
12@Injectable() 5@Injectable()