tnx-shared 5.0.61 → 5.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,7 +135,8 @@ ComCtxConstants.ROOT = {
135
135
  MENU_CHANGED: 'MENU_CHANGED',
136
136
  ADVANCE_SEARCH_INIT_WITHOUT_UPDATE_ROUTER: 'ADVANCE_SEARCH_INIT_WITHOUT_UPDATE_ROUTER',
137
137
  SHOW_WAIT_BOX: 'SHOW_WAIT_BOX',
138
- SHOW_REJECT_CONFIRM: 'SHOW_REJECT_CONFIRM'
138
+ SHOW_REJECT_CONFIRM: 'SHOW_REJECT_CONFIRM',
139
+ NEED_CLEAR_PERMISSION_CACHE: 'NEED_CLEAR_PERMISSION_CACHE'
139
140
  };
140
141
  ComCtxConstants.ROOT_USMART = {
141
142
  SHOW_CONFIG_DATA_DEFAULT: 'SHOW_CONFIG_DATA_DEFAULT',
@@ -7614,6 +7615,7 @@ class UserService extends BaseService {
7614
7615
  }
7615
7616
  else {
7616
7617
  this._applicationContext.getRootContext().replaySubscribeOnce(ComCtxConstants.ROOT.USER_READY, rs => {
7618
+ const firstTimeLogin = rs;
7617
7619
  const accessToken = this._oauthService.getAccessToken();
7618
7620
  const decoded = JWT.default(accessToken);
7619
7621
  // Chuyển đổi sang dùng instanceId nếu đăng nhập bằng identityv4 nhưng phải sử dụng base userOrgv5
@@ -7655,7 +7657,12 @@ class UserService extends BaseService {
7655
7657
  localStorage.setItem(this.CURRENT_USER_KEY, JSON.stringify(user));
7656
7658
  }
7657
7659
  this._applicationContext.getRootContext().data.currentUser = user;
7658
- this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
7660
+ if (firstTimeLogin) {
7661
+ this._applicationContext.getRootContext().fireEvent(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE);
7662
+ }
7663
+ else {
7664
+ this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
7665
+ }
7659
7666
  }, err => {
7660
7667
  });
7661
7668
  });
@@ -8175,9 +8182,12 @@ class PermissionService extends BaseService {
8175
8182
  this.delayCheckPermissions = [];
8176
8183
  this.ignoreAdmin = false;
8177
8184
  this.appCode = null;
8185
+ if (_moduleConfigService.getConfig().environment.authenticationSettings.coreVersion == 'v4') {
8186
+ this.serviceUri = `${_moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint}/permission`;
8187
+ }
8178
8188
  this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
8179
- this.ignoreAdmin = this._moduleConfigService.getConfig().environment.isIgnoreAdmin;
8180
8189
  this.appCode = this._moduleConfigService.getConfig().appCode;
8190
+ this.ignoreAdmin = this._moduleConfigService.getConfig().environment.isIgnoreAdmin;
8181
8191
  }
8182
8192
  /**
8183
8193
  * Truyền vào danh sách permision cần check
@@ -8312,6 +8322,10 @@ class PermissionService extends BaseService {
8312
8322
  }
8313
8323
  });
8314
8324
  }
8325
+ clearPermissionCache(lstModule) {
8326
+ const url = `${this.serviceUri}/ClearPermissionCache`;
8327
+ return this.defaultPost(url, lstModule);
8328
+ }
8315
8329
  }
8316
8330
  PermissionService.ɵprov = ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(ɵɵinject(HttpClient), ɵɵinject(INJECTOR), ɵɵinject(ModuleConfigService), ɵɵinject(UserService), ɵɵinject(OAuthService), ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
8317
8331
  PermissionService.decorators = [
@@ -21433,10 +21447,13 @@ class MenuService {
21433
21447
  }
21434
21448
  });
21435
21449
  }
21436
- renderMenuByAppCode(appCode) {
21450
+ renderMenuByAppCode(scopeName, appCode) {
21437
21451
  return __awaiter(this, void 0, void 0, function* () {
21438
21452
  this._menuItems = [];
21439
- const menuUrl = `assets/menus/${appCode.toLocaleLowerCase()}.json`;
21453
+ let menuUrl = `assets/menus/${appCode.toLocaleLowerCase()}.json`;
21454
+ if (scopeName) {
21455
+ menuUrl = `assets/menus/${scopeName.toLocaleLowerCase()}/${appCode.toLocaleLowerCase()}.json`;
21456
+ }
21440
21457
  fetch(menuUrl).then((rs) => __awaiter(this, void 0, void 0, function* () {
21441
21458
  const menu = JSON.parse(yield rs.text());
21442
21459
  this.setMenuItems(menu);
@@ -21595,7 +21612,7 @@ class AppMenuComponent {
21595
21612
  // Nếu là môi trường triển khai thì cộng thêm tiền tố phân hệ vào router link để có thể chuột phải mở tab mới
21596
21613
  funcSetNewTabLink = link => `/${appCodeLowerCase}${link}`;
21597
21614
  }
21598
- this._menuService.renderMenuByAppCode(appCode);
21615
+ this._menuService.renderMenuByAppCode(this.environment.scopeName, appCode);
21599
21616
  this.model = this._menuService.getMenuItems();
21600
21617
  this._router.events.pipe(filter(event => event instanceof NavigationEnd))
21601
21618
  .subscribe(event => {
@@ -23951,7 +23968,7 @@ ReportQueueComponent.propDecorators = {
23951
23968
  };
23952
23969
 
23953
23970
  class CommonAppComponentComponent {
23954
- constructor(_globalService, _commonService, renderer, translate, _oauthService, _authenService, _userService, _router, _title, _signalRService, _storageUpdatedService, _customRouteService, _applicationContext, _componentContextService, _activatedRoute, _deviceDetectorService, _cd, _tnClientService, _coreConfigService, _notifierService, _entityMetadataService, _moduleConfigService, _translateService, _messageService, _confirmService, _menuService, _primengConfig, _storageService) {
23971
+ constructor(_globalService, _commonService, renderer, translate, _oauthService, _authenService, _userService, _router, _title, _signalRService, _storageUpdatedService, _customRouteService, _applicationContext, _componentContextService, _activatedRoute, _deviceDetectorService, _cd, _tnClientService, _coreConfigService, _notifierService, _entityMetadataService, _moduleConfigService, _translateService, _messageService, _confirmService, _menuService, _primengConfig, _storageService, _permissionService) {
23955
23972
  this._globalService = _globalService;
23956
23973
  this._commonService = _commonService;
23957
23974
  this.renderer = renderer;
@@ -23980,6 +23997,7 @@ class CommonAppComponentComponent {
23980
23997
  this._menuService = _menuService;
23981
23998
  this._primengConfig = _primengConfig;
23982
23999
  this._storageService = _storageService;
24000
+ this._permissionService = _permissionService;
23983
24001
  this.showQuickNote = true;
23984
24002
  this.allowAnonymous = false;
23985
24003
  this._unsubscribeAll = new Subject();
@@ -24132,6 +24150,15 @@ class CommonAppComponentComponent {
24132
24150
  root.data.allowAnonymous = this.allowAnonymous;
24133
24151
  // get current User
24134
24152
  this._userService.populateCurrentUser();
24153
+ this._componentContextService.subscribe(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE, () => __awaiter(this, void 0, void 0, function* () {
24154
+ if (this.environment.authenticationSettings.coreVersion == 'v4') {
24155
+ const clear = yield this.clearPermissionCacheByModule();
24156
+ if (!clear.success) {
24157
+ this._notifierService.showWarning('Có vấn đề trong lúc clear cache quyền');
24158
+ }
24159
+ }
24160
+ this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED);
24161
+ }));
24135
24162
  this._componentContextService.subscribe(ComCtxConstants.ROOT.KEY_DOWN_ARROWLEFT, (e) => {
24136
24163
  if (document.activeElement === this.cancelButton.nativeElement) {
24137
24164
  this.okButton.nativeElement.focus();
@@ -24636,6 +24663,17 @@ class CommonAppComponentComponent {
24636
24663
  }
24637
24664
  }
24638
24665
  }
24666
+ clearPermissionCacheByModule() {
24667
+ let appSwitcher = this._moduleConfigService.getConfig().environment.appMetadata.appSwitcher;
24668
+ if (!appSwitcher || !appSwitcher.length) {
24669
+ appSwitcher = [];
24670
+ }
24671
+ let lstModule = appSwitcher.map(x => x.code);
24672
+ if (!lstModule) {
24673
+ lstModule = [];
24674
+ }
24675
+ return this._permissionService.clearPermissionCache(lstModule);
24676
+ }
24639
24677
  }
24640
24678
  CommonAppComponentComponent.decorators = [
24641
24679
  { type: Component, args: [{
@@ -24673,7 +24711,8 @@ CommonAppComponentComponent.ctorParameters = () => [
24673
24711
  { type: ConfirmationService },
24674
24712
  { type: MenuService },
24675
24713
  { type: PrimeNGConfig },
24676
- { type: StorageService }
24714
+ { type: StorageService },
24715
+ { type: PermissionService }
24677
24716
  ];
24678
24717
  CommonAppComponentComponent.propDecorators = {
24679
24718
  okButton: [{ type: ViewChild, args: ['okButton',] }],