tnx-shared 5.0.61 → 5.0.62

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.
@@ -395,7 +395,8 @@
395
395
  MENU_CHANGED: 'MENU_CHANGED',
396
396
  ADVANCE_SEARCH_INIT_WITHOUT_UPDATE_ROUTER: 'ADVANCE_SEARCH_INIT_WITHOUT_UPDATE_ROUTER',
397
397
  SHOW_WAIT_BOX: 'SHOW_WAIT_BOX',
398
- SHOW_REJECT_CONFIRM: 'SHOW_REJECT_CONFIRM'
398
+ SHOW_REJECT_CONFIRM: 'SHOW_REJECT_CONFIRM',
399
+ NEED_CLEAR_PERMISSION_CACHE: 'NEED_CLEAR_PERMISSION_CACHE'
399
400
  };
400
401
  ComCtxConstants.ROOT_USMART = {
401
402
  SHOW_CONFIG_DATA_DEFAULT: 'SHOW_CONFIG_DATA_DEFAULT',
@@ -8940,6 +8941,7 @@
8940
8941
  }
8941
8942
  else {
8942
8943
  this._applicationContext.getRootContext().replaySubscribeOnce(ComCtxConstants.ROOT.USER_READY, function (rs) {
8944
+ var firstTimeLogin = rs;
8943
8945
  var accessToken = _this._oauthService.getAccessToken();
8944
8946
  var decoded = JWT.default(accessToken);
8945
8947
  // Chuyển đổi sang dùng instanceId nếu đăng nhập bằng identityv4 nhưng phải sử dụng base userOrgv5
@@ -8981,7 +8983,12 @@
8981
8983
  localStorage.setItem(_this.CURRENT_USER_KEY, JSON.stringify(user));
8982
8984
  }
8983
8985
  _this._applicationContext.getRootContext().data.currentUser = user;
8984
- _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
8986
+ if (firstTimeLogin) {
8987
+ _this._applicationContext.getRootContext().fireEvent(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE);
8988
+ }
8989
+ else {
8990
+ _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
8991
+ }
8985
8992
  }, function (err) {
8986
8993
  });
8987
8994
  });
@@ -9532,7 +9539,7 @@
9532
9539
  var PermissionService = /** @class */ (function (_super) {
9533
9540
  __extends(PermissionService, _super);
9534
9541
  function PermissionService(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
9535
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/permission") || this;
9542
+ var _this = _super.call(this, http, injector, (_moduleConfigService.getConfig().environment.authenticationSettings.coreVersion == 'v4' ? _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint : _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion) + "/permission") || this;
9536
9543
  _this._moduleConfigService = _moduleConfigService;
9537
9544
  _this._userService = _userService;
9538
9545
  _this._oauthService = _oauthService;
@@ -9765,6 +9772,10 @@
9765
9772
  }
9766
9773
  });
9767
9774
  };
9775
+ PermissionService.prototype.clearPermissionCache = function (lstModule) {
9776
+ var url = this.serviceUri + "/ClearPermissionCache";
9777
+ return this.defaultPost(url, lstModule);
9778
+ };
9768
9779
  return PermissionService;
9769
9780
  }(BaseService));
9770
9781
  PermissionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService), i0.ɵɵinject(UserService), i0.ɵɵinject(i4.OAuthService), i0.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
@@ -20728,13 +20739,16 @@
20728
20739
  });
20729
20740
  });
20730
20741
  };
20731
- MenuService.prototype.renderMenuByAppCode = function (appCode) {
20742
+ MenuService.prototype.renderMenuByAppCode = function (scopeName, appCode) {
20732
20743
  return __awaiter(this, void 0, void 0, function () {
20733
20744
  var menuUrl;
20734
20745
  var _this = this;
20735
20746
  return __generator(this, function (_a) {
20736
20747
  this._menuItems = [];
20737
20748
  menuUrl = "assets/menus/" + appCode.toLocaleLowerCase() + ".json";
20749
+ if (scopeName) {
20750
+ menuUrl = "assets/menus/" + scopeName.toLocaleLowerCase() + "/" + appCode.toLocaleLowerCase() + ".json";
20751
+ }
20738
20752
  fetch(menuUrl).then(function (rs) { return __awaiter(_this, void 0, void 0, function () {
20739
20753
  var menu, _a, _b;
20740
20754
  return __generator(this, function (_c) {
@@ -20888,7 +20902,7 @@
20888
20902
  // 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
20889
20903
  funcSetNewTabLink = function (link) { return "/" + appCodeLowerCase + link; };
20890
20904
  }
20891
- this._menuService.renderMenuByAppCode(appCode);
20905
+ this._menuService.renderMenuByAppCode(this.environment.scopeName, appCode);
20892
20906
  this.model = this._menuService.getMenuItems();
20893
20907
  this._router.events.pipe(operators.filter(function (event) { return event instanceof i3.NavigationEnd; }))
20894
20908
  .subscribe(function (event) {
@@ -23449,7 +23463,7 @@
23449
23463
  };
23450
23464
 
23451
23465
  var CommonAppComponentComponent = /** @class */ (function () {
23452
- function CommonAppComponentComponent(_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) {
23466
+ function CommonAppComponentComponent(_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) {
23453
23467
  var _this = this;
23454
23468
  this._globalService = _globalService;
23455
23469
  this._commonService = _commonService;
@@ -23479,6 +23493,7 @@
23479
23493
  this._menuService = _menuService;
23480
23494
  this._primengConfig = _primengConfig;
23481
23495
  this._storageService = _storageService;
23496
+ this._permissionService = _permissionService;
23482
23497
  this.showQuickNote = true;
23483
23498
  this.allowAnonymous = false;
23484
23499
  this._unsubscribeAll = new rxjs.Subject();
@@ -23632,6 +23647,25 @@
23632
23647
  root.data.allowAnonymous = this.allowAnonymous;
23633
23648
  // get current User
23634
23649
  this._userService.populateCurrentUser();
23650
+ this._componentContextService.subscribe(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE, function () { return __awaiter(_this, void 0, void 0, function () {
23651
+ var clear;
23652
+ return __generator(this, function (_a) {
23653
+ switch (_a.label) {
23654
+ case 0:
23655
+ if (!(this.environment.authenticationSettings.coreVersion == 'v4')) return [3 /*break*/, 2];
23656
+ return [4 /*yield*/, this.clearPermissionCacheByModule()];
23657
+ case 1:
23658
+ clear = _a.sent();
23659
+ if (!clear.success) {
23660
+ this._notifierService.showWarning('Có vấn đề trong lúc clear cache quyền');
23661
+ }
23662
+ _a.label = 2;
23663
+ case 2:
23664
+ this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED);
23665
+ return [2 /*return*/];
23666
+ }
23667
+ });
23668
+ }); });
23635
23669
  this._componentContextService.subscribe(ComCtxConstants.ROOT.KEY_DOWN_ARROWLEFT, function (e) {
23636
23670
  if (document.activeElement === _this.cancelButton.nativeElement) {
23637
23671
  _this.okButton.nativeElement.focus();
@@ -24147,6 +24181,17 @@
24147
24181
  }
24148
24182
  }
24149
24183
  };
24184
+ CommonAppComponentComponent.prototype.clearPermissionCacheByModule = function () {
24185
+ var appSwitcher = this._moduleConfigService.getConfig().environment.appMetadata.appSwitcher;
24186
+ if (!appSwitcher || !appSwitcher.length) {
24187
+ appSwitcher = [];
24188
+ }
24189
+ var lstModule = appSwitcher.map(function (x) { return x.code; });
24190
+ if (!lstModule) {
24191
+ lstModule = [];
24192
+ }
24193
+ return this._permissionService.clearPermissionCache(lstModule);
24194
+ };
24150
24195
  return CommonAppComponentComponent;
24151
24196
  }());
24152
24197
  CommonAppComponentComponent.decorators = [
@@ -24185,7 +24230,8 @@
24185
24230
  { type: i1.ConfirmationService },
24186
24231
  { type: MenuService },
24187
24232
  { type: i1.PrimeNGConfig },
24188
- { type: StorageService }
24233
+ { type: StorageService },
24234
+ { type: PermissionService }
24189
24235
  ]; };
24190
24236
  CommonAppComponentComponent.propDecorators = {
24191
24237
  okButton: [{ type: i0.ViewChild, args: ['okButton',] }],