@brggroup/share-lib 0.0.92 → 0.0.94

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, Injectable, Component, HostListener, ViewContainerRef, Input, ViewChild, EventEmitter, Output, Directive, Optional, Self, HostBinding, forwardRef, Pipe } from '@angular/core';
2
+ import { inject, Injectable, NgZone, Component, HostListener, ViewContainerRef, Input, ViewChild, EventEmitter, Output, Directive, Optional, Self, HostBinding, forwardRef, Pipe } from '@angular/core';
3
3
  import * as i1$4 from '@angular/router';
4
4
  import { Router, ActivatedRoute, NavigationEnd, RouterLink, RouterOutlet } from '@angular/router';
5
5
  import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
@@ -587,7 +587,7 @@ class AuthService extends HTTPService {
587
587
  /* ----------------------------------------
588
588
  LOGIN
589
589
  ---------------------------------------- */
590
- async signIn(username, password, orgid, returnUrl) {
590
+ async _signIn(username, password, orgid, returnUrl) {
591
591
  try {
592
592
  const body = {
593
593
  UserName: username,
@@ -619,7 +619,7 @@ class AuthService extends HTTPService {
619
619
  /* ----------------------------------------
620
620
  LOGOUT
621
621
  ---------------------------------------- */
622
- signOut() {
622
+ _signOut() {
623
623
  TokenStorage.clearToken();
624
624
  const currentUrl = this.router.routerState.snapshot.url;
625
625
  this.router.navigate(['/login'], {
@@ -930,10 +930,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImpor
930
930
  }] });
931
931
 
932
932
  class SessionManagerService {
933
- zone;
934
- constructor(zone) {
935
- this.zone = zone;
936
- }
933
+ zone = inject(NgZone);
937
934
  authService = inject(AuthService);
938
935
  idleTimer;
939
936
  refreshTimer;
@@ -957,13 +954,13 @@ class SessionManagerService {
957
954
  channel = null;
958
955
  /* -------------------------------- START -------------------------------- */
959
956
  start() {
960
- if (this.IDLE_TIME <= 0)
961
- return;
962
- console.log('SessionManagerService > start > IDLE_TIME:', SessionManagerService.IDLE_MIN);
957
+ console.log('SessionManagerService > start > IDLE_TIME: ' + SessionManagerService.IDLE_MIN + ' mins');
963
958
  if ('BroadcastChannel' in window) {
964
959
  this.channel = new BroadcastChannel('APP_SESSION');
965
960
  this.listenChannel();
966
961
  }
962
+ if (this.IDLE_TIME <= 0)
963
+ return;
967
964
  this.listenActivity();
968
965
  this.updateActivity();
969
966
  this.resetIdle();
@@ -975,14 +972,14 @@ class SessionManagerService {
975
972
  // clearInterval(this.heartbeatTimer);
976
973
  // }
977
974
  async login(username, password, orgid, returnUrl) {
978
- var ret = await this.authService.signIn(username, password, orgid, returnUrl);
975
+ var ret = await this.authService._signIn(username, password, orgid, returnUrl);
979
976
  if (ret) {
980
977
  console.log('SessionManagerService > broadcast LOGIN');
981
978
  this.broadcast(this.LOGIN_EVENT);
982
979
  }
983
980
  }
984
981
  logout() {
985
- this.authService.signOut();
982
+ this.authService._signOut();
986
983
  this.broadcast(this.LOGOUT_EVENT);
987
984
  }
988
985
  /* -------------------------------- ACTIVITY -------------------------------- */
@@ -1006,12 +1003,12 @@ class SessionManagerService {
1006
1003
  const last = Number(localStorage.getItem(this.ACTIVITY_KEY) || Date.now());
1007
1004
  const remain = this.IDLE_TIME - (Date.now() - last);
1008
1005
  if (remain <= 0) {
1009
- this.authService.signOut();
1006
+ this.authService._signOut();
1010
1007
  return;
1011
1008
  }
1012
1009
  this.zone.runOutsideAngular(() => {
1013
1010
  this.idleTimer = setTimeout(() => {
1014
- this.zone.run(() => this.authService.signOut());
1011
+ this.zone.run(() => this.authService._signOut());
1015
1012
  }, remain);
1016
1013
  });
1017
1014
  }
@@ -1084,6 +1081,7 @@ class SessionManagerService {
1084
1081
  }
1085
1082
  /* -------------------------------- CHANNEL -------------------------------- */
1086
1083
  listenChannel() {
1084
+ console.log('SessionManagerService > listenChannel:', this.channel);
1087
1085
  if (!this.channel)
1088
1086
  return;
1089
1087
  this.channel.onmessage = (msg) => {
@@ -1122,7 +1120,7 @@ class SessionManagerService {
1122
1120
  const payload = token.split('.')[1];
1123
1121
  return JSON.parse(atob(payload));
1124
1122
  }
1125
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: SessionManagerService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
1123
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: SessionManagerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1126
1124
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: SessionManagerService, providedIn: 'root' });
1127
1125
  }
1128
1126
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: SessionManagerService, decorators: [{
@@ -1130,7 +1128,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.7", ngImpor
1130
1128
  args: [{
1131
1129
  providedIn: 'root',
1132
1130
  }]
1133
- }], ctorParameters: () => [{ type: i0.NgZone }] });
1131
+ }] });
1134
1132
 
1135
1133
  class CustomModalService {
1136
1134
  modal;
@@ -6373,7 +6371,7 @@ class LayoutUser extends BaseComponent {
6373
6371
  this.goto('/admin/user_profile');
6374
6372
  }
6375
6373
  logout() {
6376
- this.sessionManager.authService.signOut();
6374
+ this.sessionManager.logout();
6377
6375
  }
6378
6376
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.7", ngImport: i0, type: LayoutUser, deps: null, target: i0.ɵɵFactoryTarget.Component });
6379
6377
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.7", type: LayoutUser, isStandalone: true, selector: "layout-user", usesInheritance: true, ngImport: i0, template: "<nz-badge [nzSize]=\"'small'\" [nzCount]=\"0\">\n <button nz-button nzType=\"text\" nzSize=\"small\">\n <nz-icon nzType=\"bell\" nzTheme=\"outline\" style=\"color: #ffffff\" />\n </button>\n</nz-badge>\n\n<button\n *ngIf=\"!isXSmall && TokenStorage.getOrgName()\"\n [@fadeInOut]\n nz-button\n nzType=\"text\"\n nz-dropdown\n [nzDropdownMenu]=\"menuOrg\"\n [nzTrigger]=\"'click'\"\n style=\"height: 50px; color: #ffffff\"\n>\n <nz-icon nzType=\"cluster\" nzTheme=\"outline\" />\n {{ TokenStorage.getOrgName() }}\n</button>\n\n<nz-dropdown-menu #menuOrg=\"nzDropdownMenu\">\n <ul nz-menu>\n @for (org of lstOrg; track $index) {\n <li *ngIf=\"$index > 0\" nz-menu-divider></li>\n <li nz-menu-item (click)=\"changeOrg(org)\">\n <nz-icon nzType=\"swap\" nzTheme=\"outline\" />&nbsp;&nbsp; {{ org.Name }}\n </li>\n }\n </ul>\n</nz-dropdown-menu>\n\n<button\n nz-button\n nzType=\"text\"\n nz-dropdown\n [nzDropdownMenu]=\"menuUser\"\n [nzTrigger]=\"'click'\"\n style=\"height: 50px; color: #ffffff\"\n>\n <nz-icon nzType=\"user\" nzTheme=\"outline\" />\n {{ TokenStorage.getUserFullname() }}\n</button>\n\n<nz-dropdown-menu #menuUser=\"nzDropdownMenu\">\n <ul nz-menu>\n <li *ngIf=\"!(!isXSmall && TokenStorage.getOrgName())\" nz-menu-item>\n <nz-icon nzType=\"cluster\" nzTheme=\"outline\" />&nbsp;&nbsp; {{ TokenStorage.getOrgName() }}\n </li>\n <li *ngIf=\"!(!isXSmall && TokenStorage.getOrgName())\" nz-menu-divider></li>\n <li nz-menu-item (click)=\"gotoSetting()\">\n <nz-icon nzType=\"setting\" nzTheme=\"outline\" />&nbsp;&nbsp; {{ TranslateKey.SETTING | translate }}\n </li>\n <li nz-menu-divider></li>\n <li nz-menu-item (click)=\"logout()\">\n <nz-icon nzType=\"logout\" nzTheme=\"outline\" />&nbsp;&nbsp; {{ TranslateKey.LOGOUT | translate }}\n </li>\n </ul>\n</nz-dropdown-menu>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: NzLayoutModule }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i1$2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzDropDownModule }, { kind: "directive", type: i4$2.NzMenuDirective, selector: "[nz-menu]", inputs: ["nzInlineIndent", "nzTheme", "nzMode", "nzInlineCollapsed", "nzSelectable"], outputs: ["nzClick"], exportAs: ["nzMenu"] }, { kind: "component", type: i4$2.NzMenuItemComponent, selector: "[nz-menu-item]", inputs: ["nzPaddingLeft", "nzDisabled", "nzSelected", "nzDanger", "nzMatchRouterExact", "nzMatchRouter"], exportAs: ["nzMenuItem"] }, { kind: "directive", type: i4$2.NzMenuDividerDirective, selector: "[nz-menu-divider]", exportAs: ["nzMenuDivider"] }, { kind: "directive", type: i5$3.NzDropDownDirective, selector: "[nz-dropdown]", inputs: ["nzDropdownMenu", "nzTrigger", "nzMatchWidthElement", "nzBackdrop", "nzClickHide", "nzDisabled", "nzVisible", "nzOverlayClassName", "nzOverlayStyle", "nzPlacement"], outputs: ["nzVisibleChange"], exportAs: ["nzDropdown"] }, { kind: "component", type: i5$3.NzDropdownMenuComponent, selector: "nz-dropdown-menu", exportAs: ["nzDropdownMenu"] }, { kind: "directive", type: i5$3.NzDropdownButtonDirective, selector: "[nz-button][nz-dropdown]" }, { kind: "ngmodule", type: NzGridModule }, { kind: "ngmodule", type: NzFlexModule }, { kind: "ngmodule", type: NzButtonModule }, { kind: "component", type: i8.NzButtonComponent, selector: "button[nz-button], a[nz-button]", inputs: ["nzBlock", "nzGhost", "nzSearch", "nzLoading", "nzDanger", "disabled", "tabIndex", "nzType", "nzShape", "nzSize"], exportAs: ["nzButton"] }, { kind: "directive", type: i9.ɵNzTransitionPatchDirective, selector: "[nz-button], nz-button-group, [nz-icon], nz-icon, [nz-menu-item], [nz-submenu], nz-select-top-control, nz-select-placeholder, nz-input-group", inputs: ["hidden"] }, { kind: "ngmodule", type: NzTreeModule }, { kind: "ngmodule", type: NzBackTopModule }, { kind: "ngmodule", type: NzDrawerModule }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: NzInputModule }, { kind: "ngmodule", type: NzSegmentedModule }, { kind: "ngmodule", type: NzBadgeModule }, { kind: "component", type: i8$1.NzBadgeComponent, selector: "nz-badge", inputs: ["nzShowZero", "nzShowDot", "nzStandalone", "nzDot", "nzOverflowCount", "nzColor", "nzStyle", "nzText", "nzTitle", "nzStatus", "nzCount", "nzOffset", "nzSize"], exportAs: ["nzBadge"] }], animations: [fadeInOut] });