|
|
|
@ -2,9 +2,11 @@ import { SettingTab } from '@abp/ng.theme.shared'; |
|
|
|
import { Injectable } from '@angular/core'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { Navigate } from '@ngxs/router-plugin'; |
|
|
|
import { Store } from '@ngxs/store'; |
|
|
|
import { Store, Actions, ofActionSuccessful } from '@ngxs/store'; |
|
|
|
import { Subject } from 'rxjs'; |
|
|
|
import { ConfigState } from '@abp/ng.core'; |
|
|
|
import { ConfigState, GetAppConfiguration } from '@abp/ng.core'; |
|
|
|
import { OAuthService } from 'angular-oauth2-oidc'; |
|
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' }) |
|
|
|
export class SettingManagementService { |
|
|
|
@ -14,10 +16,27 @@ export class SettingManagementService { |
|
|
|
|
|
|
|
private destroy$ = new Subject(); |
|
|
|
|
|
|
|
constructor(private router: Router, private store: Store) { |
|
|
|
setTimeout(() => { |
|
|
|
this.setSettings(); |
|
|
|
}, 0); |
|
|
|
constructor( |
|
|
|
private actions: Actions, |
|
|
|
private router: Router, |
|
|
|
private store: Store, |
|
|
|
private oAuthService: OAuthService, |
|
|
|
) { |
|
|
|
if (this.oAuthService.hasValidAccessToken()) { |
|
|
|
setTimeout(() => { |
|
|
|
this.setSettings(); |
|
|
|
}, 0); |
|
|
|
} else { |
|
|
|
this.actions |
|
|
|
.pipe(ofActionSuccessful(GetAppConfiguration)) |
|
|
|
.pipe(takeUntil(this.destroy$)) |
|
|
|
.subscribe(() => { |
|
|
|
if (this.oAuthService.hasValidAccessToken()) { |
|
|
|
this.setSettings(); |
|
|
|
this.destroy$.next(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ngOnDestroy() { |
|
|
|
@ -25,13 +44,11 @@ export class SettingManagementService { |
|
|
|
} |
|
|
|
|
|
|
|
setSettings() { |
|
|
|
setTimeout(() => { |
|
|
|
const route = this.router.config.find(r => r.path === 'setting-management'); |
|
|
|
this.settings = (route.data.settings as SettingTab[]) |
|
|
|
.filter(setting => this.store.selectSnapshot(ConfigState.getGrantedPolicy(setting.requiredPolicy))) |
|
|
|
.sort((a, b) => a.order - b.order); |
|
|
|
this.checkSelected(); |
|
|
|
}, 0); |
|
|
|
const route = this.router.config.find(r => r.path === 'setting-management'); |
|
|
|
this.settings = (route.data.settings as SettingTab[]) |
|
|
|
.filter(setting => this.store.selectSnapshot(ConfigState.getGrantedPolicy(setting.requiredPolicy))) |
|
|
|
.sort((a, b) => a.order - b.order); |
|
|
|
this.checkSelected(); |
|
|
|
} |
|
|
|
|
|
|
|
checkSelected() { |
|
|
|
|