Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into dev

pull/1775/head
TheDiaval 7 years ago
parent
commit
162b5d85ea
  1. 43
      npm/ng-packs/packages/setting-management/src/lib/services/setting-management.service.ts

43
npm/ng-packs/packages/setting-management/src/lib/services/setting-management.service.ts

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

Loading…
Cancel
Save