tnx-shared 5.1.154 → 5.1.155

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.
@@ -345,6 +345,7 @@
345
345
  USER_READY: 'USER_READY',
346
346
  USER_LOADED: 'USER_LOADED',
347
347
  USER_INFO_CHANGED: 'USER_INFO_CHANGED',
348
+ NEED_CLEAR_PERMISSION_CACHE: 'CLEAR_PERMISSION_CACHE',
348
349
  ADVANCE_SEARCH_TOGGLE_BOX: 'ADVANCE_SEARCH_TOGGLE_BOX',
349
350
  ADVANCE_SEARCH_HIDE_BOX: 'ADVANCE_SEARCH_HIDE_BOX',
350
351
  ADVANCE_SEARCH_INIT: 'ADVANCE_SEARCH_INIT',
@@ -9224,6 +9225,11 @@
9224
9225
  }
9225
9226
  return false;
9226
9227
  };
9228
+ UserService.prototype.getFullCanBoLabel = function (item) {
9229
+ var label = this.getUserName(item);
9230
+ label = (item.maChucVu ? item.maChucVu + ". " : '') + ("" + label) + (item.tenDonVi ? " - " + item.tenDonVi : '');
9231
+ return label;
9232
+ };
9227
9233
  UserService.prototype.getAllWithInfo = function (filters) {
9228
9234
  return this.getDataCustomRoute('WithInfo', filters);
9229
9235
  };
@@ -9280,6 +9286,7 @@
9280
9286
  }
9281
9287
  else {
9282
9288
  this._applicationContext.getRootContext().replaySubscribeOnce(ComCtxConstants.ROOT.USER_READY, function (rs) {
9289
+ var firstTimeLogin = rs !== null && rs !== void 0 ? rs : false;
9283
9290
  var accessToken = _this._oauthService.getAccessToken();
9284
9291
  var decoded = JWT.default(accessToken);
9285
9292
  // Chuyển đổi sang dùng instanceId nếu đăng nhập bằng identityv4 nhưng phải sử dụng base userOrgv5
@@ -9307,6 +9314,7 @@
9307
9314
  user.role = rs1.role;
9308
9315
  user.gender = rs1.gender;
9309
9316
  user.positionCode = rs1.positionCode;
9317
+ 1;
9310
9318
  user.instanceid = decoded.instanceid;
9311
9319
  user.idCanBo = decoded.idCanBo;
9312
9320
  user.originId = decoded.sub;
@@ -9321,7 +9329,12 @@
9321
9329
  localStorage.setItem(_this.CURRENT_USER_KEY, JSON.stringify(user));
9322
9330
  }
9323
9331
  _this._applicationContext.getRootContext().data.currentUser = user;
9324
- _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
9332
+ if (firstTimeLogin) {
9333
+ _this._applicationContext.getRootContext().fireEvent(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE);
9334
+ }
9335
+ else {
9336
+ _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
9337
+ }
9325
9338
  }, function (err) {
9326
9339
  });
9327
9340
  });
@@ -30611,60 +30624,56 @@
30611
30624
  this._componentContextService.data.personalize = {};
30612
30625
  }
30613
30626
  this._componentContextService.replaySubscribe(ComCtxConstants.ROOT.USER_LOADED, function (rs) { return __awaiter(_this, void 0, void 0, function () {
30614
- var lstAppCodes, oldUrl;
30627
+ var oldUrl;
30615
30628
  var _this = this;
30616
30629
  return __generator(this, function (_a) {
30617
- switch (_a.label) {
30618
- case 0:
30619
- this._entityMetadataService.setupSyncCacheEntityMetadata();
30620
- this._router.config
30621
- .forEach(function (route) { return _this.addGuard(route); });
30622
- if (!this.firstTimeLogin) return [3 /*break*/, 2];
30623
- lstAppCodes = this.environment.appMetadata.appSwitcher.map(function (app) { return app.code; });
30624
- return [4 /*yield*/, this._permissionService.cleanPermissionCache(lstAppCodes)];
30625
- case 1:
30626
- _a.sent();
30627
- // Thêm vào để đánh dấu lần dầu login => để xử lý
30628
- // UserA đag ở màn hình 1 => đăng xuất => đăng nhập vào tài khoản UserB không có quyền màn hình 1 => redirect về "/"
30629
- this._storageService.removeItem('current_user_info');
30630
- this._storageService.setItem('firstTimeLogin', true);
30631
- oldUrl = this._storageService.getItem('currentUrl');
30632
- if (oldUrl && oldUrl != top.location.href + '') {
30633
- this._storageService.removeItem('currentUrl');
30634
- top.location.href = "" + oldUrl;
30635
- }
30636
- else {
30637
- this.firstTimeLogin = false;
30638
- this._storageService.removeItem('currentUrl');
30639
- this.pageLoaded = true;
30640
- this.onlyShowMainContent = true;
30641
- }
30642
- return [3 /*break*/, 3];
30643
- case 2:
30644
- this.defaultRedirect();
30645
- _a.label = 3;
30646
- case 3:
30647
- // var versionDeploy = this._storageService.getItem('versionDeploy');
30648
- // let versionFromApplication = this.rootVersionDeploy;
30649
- // if (versionFromApplication && versionDeploy && (+versionDeploy) < (+versionFromApplication)) {
30650
- // this._storageService.setItem('versionDeploy', versionFromApplication);
30651
- // this._authenService.logout();
30652
- // }
30653
- this.getPinnedNotes();
30654
- try {
30655
- this._signalRService.init().then(function () {
30656
- _this._signalRService.start('ConsistencyHub', 'BroadcastMessage', _this.clearAuthorizeCache.bind(_this));
30657
- _this._signalRService.start('NotificationHub', 'RefreshForUpdate', function (data) {
30658
- if (data.appCodes && data.appCodes.some(function (x) { return x.toUpperCase() == _this.appCode.toUpperCase(); })) {
30659
- _this._componentContextService.fireEvent(ComCtxConstants.COMMON.FORCE_RELOAD);
30660
- }
30661
- });
30662
- });
30663
- }
30664
- catch (e) {
30665
- }
30666
- return [2 /*return*/];
30630
+ this._entityMetadataService.setupSyncCacheEntityMetadata();
30631
+ this._router.config
30632
+ .forEach(function (route) { return _this.addGuard(route); });
30633
+ if (this.firstTimeLogin) {
30634
+ // lần đầu đăng nhập thì vào trang mặc định
30635
+ // if (this.rootVersionDeploy) {
30636
+ // this._storageService.setItem('versionDeploy', this.rootVersionDeploy);
30637
+ // }
30638
+ // Thêm vào để đánh dấu lần dầu login => để xử lý
30639
+ // UserA đag ở màn hình 1 => đăng xuất => đăng nhập vào tài khoản UserB không có quyền màn hình 1 => redirect về "/"
30640
+ this._storageService.removeItem('current_user_info');
30641
+ this._storageService.setItem('firstTimeLogin', true);
30642
+ oldUrl = this._storageService.getItem('currentUrl');
30643
+ if (oldUrl && oldUrl != top.location.href + '') {
30644
+ this._storageService.removeItem('currentUrl');
30645
+ top.location.href = "" + oldUrl;
30646
+ }
30647
+ else {
30648
+ this.firstTimeLogin = false;
30649
+ this._storageService.removeItem('currentUrl');
30650
+ this.pageLoaded = true;
30651
+ this.onlyShowMainContent = true;
30652
+ }
30653
+ }
30654
+ else {
30655
+ this.defaultRedirect();
30656
+ }
30657
+ // var versionDeploy = this._storageService.getItem('versionDeploy');
30658
+ // let versionFromApplication = this.rootVersionDeploy;
30659
+ // if (versionFromApplication && versionDeploy && (+versionDeploy) < (+versionFromApplication)) {
30660
+ // this._storageService.setItem('versionDeploy', versionFromApplication);
30661
+ // this._authenService.logout();
30662
+ // }
30663
+ this.getPinnedNotes();
30664
+ try {
30665
+ this._signalRService.init().then(function () {
30666
+ _this._signalRService.start('ConsistencyHub', 'BroadcastMessage', _this.clearAuthorizeCache.bind(_this));
30667
+ _this._signalRService.start('NotificationHub', 'RefreshForUpdate', function (data) {
30668
+ if (data.appCodes && data.appCodes.some(function (x) { return x.toUpperCase() == _this.appCode.toUpperCase(); })) {
30669
+ _this._componentContextService.fireEvent(ComCtxConstants.COMMON.FORCE_RELOAD);
30670
+ }
30671
+ });
30672
+ });
30673
+ }
30674
+ catch (e) {
30667
30675
  }
30676
+ return [2 /*return*/];
30668
30677
  });
30669
30678
  }); });
30670
30679
  var defaultModulePages = this._componentContextService.data.personalize.defaultModulePages;
@@ -30710,6 +30719,23 @@
30710
30719
  root.data.allowAnonymous = this.allowAnonymous;
30711
30720
  // get current User
30712
30721
  this._userService.populateCurrentUser();
30722
+ this._componentContextService.subscribe(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE, function () { return __awaiter(_this, void 0, void 0, function () {
30723
+ var lstAppCodes, res;
30724
+ return __generator(this, function (_a) {
30725
+ switch (_a.label) {
30726
+ case 0:
30727
+ lstAppCodes = this.environment.appMetadata.appSwitcher.map(function (app) { return app.code; });
30728
+ return [4 /*yield*/, this._permissionService.cleanPermissionCache(lstAppCodes)];
30729
+ case 1:
30730
+ res = _a.sent();
30731
+ if (!res.success) {
30732
+ this._notifierService.showWarning('Có lỗi trong lúc clear cache phân quyền');
30733
+ }
30734
+ this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED);
30735
+ return [2 /*return*/];
30736
+ }
30737
+ });
30738
+ }); });
30713
30739
  this._componentContextService.subscribe(ComCtxConstants.ROOT.KEY_DOWN_ARROWLEFT, function (e) {
30714
30740
  if (document.activeElement === _this.cancelButton.nativeElement) {
30715
30741
  _this.okButton.nativeElement.focus();
@@ -30943,7 +30969,7 @@
30943
30969
  _this._authenService.cleanupLocalStorage();
30944
30970
  _this._authenService.cleanupSessionStorage();
30945
30971
  _this._storageUpdatedService.cleanupStorageService();
30946
- _this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, true);
30972
+ _this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, _this.firstTimeLogin);
30947
30973
  }
30948
30974
  else if (evt.type === 'token_expires') {
30949
30975
  _this._oauthService.tryLogin();
@@ -30974,7 +31000,7 @@
30974
31000
  this._permissionService.cleanPermissionCache(lstPhanHeCode);
30975
31001
  }
30976
31002
  if (this._oauthService.hasValidAccessToken()) {
30977
- this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, true);
31003
+ this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, this.firstTimeLogin);
30978
31004
  this._oauthService.setupAutomaticSilentRefresh();
30979
31005
  }
30980
31006
  else {