ngx-sp-auth 4.22.4 → 4.22.6

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.
@@ -8,7 +8,7 @@ import { LogLevel, PublicClientApplication, InteractionType } from '@azure/msal-
8
8
  import { take as take$1, tap as tap$1, map, switchMap as switchMap$1 } from 'rxjs/operators';
9
9
  import * as i1$1 from '@angular/router';
10
10
  import { RouterLink, NavigationEnd, RouterOutlet } from '@angular/router';
11
- import { BehaviorSubject, take, tap, Subject, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, map as map$1, firstValueFrom, of, lastValueFrom, from } from 'rxjs';
11
+ import { BehaviorSubject, take, tap, Subject, firstValueFrom, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, map as map$1, of, lastValueFrom, from } from 'rxjs';
12
12
  import * as i3 from 'ngx-sp-infra';
13
13
  import { Utils, SearchInputComponent, InfraModule, FormUtils, Usuario, RetPasswordPolicy, RetCheckPassword, CheckPasswordRecord, PasswordPolicyComponent, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
14
14
  import { openDB, deleteDB } from 'idb';
@@ -1598,7 +1598,7 @@ class MenuServicesService {
1598
1598
  // #region NewImg Event
1599
1599
  // Implementação de lógica vista no link: https://hasangalakdinu.medium.com/how-to-call-a-function-in-another-component-angular-using-rxjs-3f2e85920705
1600
1600
  this._subject = new Subject();
1601
- this._BASE_URL = `${this._customEnvironmentService.SpInfra2ErpWS}`; // SpInfra2ErpWS
1601
+ this._BASE_URL = `${this._customEnvironmentService.Sp2LocalhostWS}`; // SpInfra2ErpWS
1602
1602
  this._BASE_URL = !this._customEnvironmentService.production ? this._BASE_URL : `${this._customEnvironmentService.SpInfra2ErpWS}`;
1603
1603
  this._BASE_URL_VERSION_INFRA = `${this._customEnvironmentService.SpInfra2AuthWS.replace('SpInfra2AuthWS', 'SpInfra2VersionWS')}`; // SpInfra2VersionWS
1604
1604
  this._BASE_URL_VERSION_INFRA = !this._customEnvironmentService.production ? this._BASE_URL_VERSION_INFRA : `${this._customEnvironmentService.SpInfra2AuthWS.replace('SpInfra2AuthWS', 'SpInfra2VersionWS')}`;
@@ -1819,6 +1819,28 @@ class MenuServicesService {
1819
1819
  }
1820
1820
  }));
1821
1821
  }
1822
+ /** Método executado para pegar o HostName de direcionamento para a V6. */
1823
+ GetHostServerV6() {
1824
+ const url = `${this._BASE_URL}/Menu/GetHostServerV6`;
1825
+ return this._httpClient.get(url, { headers: this._HTTP_HEADERS })
1826
+ .pipe(take(1), tap((response) => { if (response.Error)
1827
+ throw Error(response.ErrorMessage); }));
1828
+ }
1829
+ /**
1830
+ * **ESTE MÉTODO FOI DUPLICADO DO MÉTODO `GetHostServerOutSystems` PARA SER UTILIZADO DE FORMA ASSÍNCRONA, SEM *OBSERVABLE*, PARA EVITAR PROBLEMAS DE SINCRONIA NA CONSTRUÇÃO DO MENU DINÂMICO.**
1831
+ *
1832
+ * Método async executado para pegar o HostName de direcionamento para OS de forma estática, sem Observable.
1833
+ * Este método utiliza a função `firstValueFrom` do RxJS para converter o Observable retornado pelo HttpClient em uma Promise.
1834
+ *
1835
+ * @returns Promise<RetString> - Retorna uma Promise que resolve para um objeto RetString contendo o HostName de direcionamento para OS.
1836
+ * @throws Error - Lança um erro se a resposta da API contiver um erro.
1837
+ */
1838
+ async getHostServerOutSystemsStatic() {
1839
+ const url = `${this._BASE_URL}/Menu/GetHostServerOutSystems`;
1840
+ const response = await firstValueFrom(this._httpClient.get(url, { headers: this._HTTP_HEADERS }).pipe(take(1), tap(response => { if (response.Error)
1841
+ throw Error(response.ErrorMessage); })));
1842
+ return response;
1843
+ }
1822
1844
  getMenuFooterImg() {
1823
1845
  const cachedFooterImg = JSON.parse(localStorage.getItem('menuFooterImg'));
1824
1846
  if (cachedFooterImg) {
@@ -3504,8 +3526,8 @@ class MenuLateralComponent {
3504
3526
  // Método com customizações obter o Módulo para montagem do Menu Dinâmico Lateral
3505
3527
  const projetoId = this._customMenuService.menuDynamicGetProjetoId();
3506
3528
  this._menuServices.getMenuLateral(projetoId).subscribe({
3507
- next: response => {
3508
- const menus = this.constroiRegrasDynamicMenu(response.MenuSubmenu);
3529
+ next: async (response) => {
3530
+ const menus = await this.constroiRegrasDynamicMenu(response.MenuSubmenu);
3509
3531
  this._customMenuService.menuItems = this._customMenuService.menuConfig.initializeMenu(this._router.url, menus);
3510
3532
  }, error: error => {
3511
3533
  this._customMenuService.menuItems = this._customMenuService.menuConfig.initializeMenu(this._router.url);
@@ -3668,9 +3690,10 @@ class MenuLateralComponent {
3668
3690
  return url;
3669
3691
  return (isOutroModulo ? `https://${window.location.host}/SisproErpCloud/${url}` : `${this.HostServerOutSystems == "" ? `https://${window.location.host}` : this.HostServerOutSystems}/${url}`);
3670
3692
  }
3671
- constroiRegrasDynamicMenu(menus) {
3693
+ async constroiRegrasDynamicMenu(menus) {
3694
+ const hostOutsystems = await this._menuServices.getHostServerOutSystemsStatic();
3672
3695
  const home = { id: 0, label: "Início", descricao: "Tela inicial", icon: "casa", route: "home", isExternal: false, isSelected: this._router.url.includes("home"), isOutroModulo: false };
3673
- const cloud = { id: 1, label: "Ir para a Cloud", descricao: "Cloud OS", icon: "p-nuvem", route: `https://${this._hostServeUrlOutSystems}/SisproErp/`, isExternal: true, isSelected: this._router.url.includes("cloud"), isOutroModulo: true };
3696
+ const cloud = { id: 1, label: "Ir para a Cloud", descricao: "Cloud OS", icon: "p-nuvem", route: `${hostOutsystems.String}/SisproErp/`, isExternal: true, isSelected: this._router.url.includes("cloud"), isOutroModulo: true };
3674
3697
  menus.unshift(cloud);
3675
3698
  menus.unshift(home);
3676
3699
  return menus;
@@ -4744,20 +4767,32 @@ class SubMenuCardComponent {
4744
4767
  // #region ==========> PROPERTIES <==========
4745
4768
  // #region PUBLIC
4746
4769
  this.subMenuCards = [];
4747
- this.hostName = "";
4748
- this.getExternalUrl = (url, isOutroModulo) => { return (isOutroModulo ? `${this.hostName}/SisproErpCloud/${url}` : `${this.hostName == "" ? `https://${window.location.host}` : this.hostName}/${url}`); };
4770
+ this.hostnameOS = "";
4771
+ this.hostnameV6 = "";
4772
+ this.getOutroModuloUrl = (url) => { return !this.hostnameV6.startsWith('https://') ? `https://${this.hostnameV6}/SisproErpCloud/${url}` : `${this.hostnameV6}/SisproErpCloud/${url}`; };
4773
+ this.getOutsystemsUrl = (url, isOutroModulo) => { return (isOutroModulo ? `${this.hostnameOS}/SisproErpCloud/${url}` : `${this.hostnameOS == "" ? `https://${window.location.host}` : this.hostnameOS}/${url}`); };
4749
4774
  }
4750
4775
  ngOnInit() {
4751
- this.GetHostName();
4776
+ this.GetHostNameOS();
4777
+ this.GetHostNameV6();
4752
4778
  }
4753
4779
  // #region ==========> API METHODS <==========
4754
4780
  // #region GET
4755
- GetHostName() {
4781
+ GetHostNameOS() {
4756
4782
  // Validação adicionada para ignorar esta chamada caso o componente seja exibido na docs
4757
4783
  if (this._customEnv.product === "InfraCodeDocs")
4758
4784
  return;
4759
4785
  this._menuService.GetHostServerOutSystems().subscribe({
4760
- next: response => this.hostName = response.String,
4786
+ next: response => this.hostnameOS = response.String,
4787
+ error: error => this._authUtilService.showHttpError(error)
4788
+ });
4789
+ }
4790
+ GetHostNameV6() {
4791
+ // Validação adicionada para ignorar esta chamada caso o componente seja exibido na docs
4792
+ if (this._customEnv.product === "InfraCodeDocs")
4793
+ return;
4794
+ this._menuService.GetHostServerV6().subscribe({
4795
+ next: response => this.hostnameV6 = response.String,
4761
4796
  error: error => this._authUtilService.showHttpError(error)
4762
4797
  });
4763
4798
  }
@@ -4765,8 +4800,25 @@ class SubMenuCardComponent {
4765
4800
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SubMenuCardComponent, isStandalone: true, selector: "sub-menu-card, lib-submenu-card", inputs: { subMenuCards: "subMenuCards" }, ngImport: i0, template: `
4766
4801
  <div class="max-card-menu row">
4767
4802
  @for(card of subMenuCards; track $index) {
4768
- @if (card.isExternal || card.is_OutroModulo) {
4769
- <a [href]="getExternalUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
4803
+
4804
+ <!-- VALIDAÇÃO DE 'IS_EXTERNAL' SIGNIFICA QUE A ROTA É OS -->
4805
+ @if (card.isExternal) {
4806
+ <a [href]="getOutsystemsUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
4807
+ <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4808
+ <div class="card-icon">
4809
+ <div class="card-icon2">
4810
+ <lib-icon class="bold" [iconName]="card.icon ? card.icon : 'engrenagem'" iconColor="blue" [iconSize]="35" />
4811
+ </div>
4812
+ </div>
4813
+
4814
+ <h3 class="card-title">{{ card.titulo }}</h3>
4815
+ <p class="card-text" [title]="card.descricao"> {{ card.descricao }} </p>
4816
+ </div>
4817
+ </a>
4818
+ }
4819
+ <!-- VALIDAÇÃO DE 'IS_OUTROMODULO' SIGNIFICA QUE A ROTA É V6 PORÉM DE OUTRO PROJETO FRONTEND -->
4820
+ @else if (card.is_OutroModulo) {
4821
+ <a [href]="getOutroModuloUrl(card.urlPath)" target="_blank" class="card-link col-4">
4770
4822
  <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4771
4823
  <div class="card-icon">
4772
4824
  <div class="card-icon2">
@@ -4779,8 +4831,9 @@ class SubMenuCardComponent {
4779
4831
  </div>
4780
4832
  </a>
4781
4833
  }
4834
+ <!-- CASO CONTRÁRIO DE TUDO SIGNIFICA QUE A ROTA É V6 E DENTRO DO MESMO MÓDULO -->
4782
4835
  @else {
4783
- <a [routerLink]="[ '/'+card.urlPath ]" class="card-link col-4">
4836
+ <a routerLink="/{{ card.urlPath }}" class="card-link col-4">
4784
4837
  <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4785
4838
  <div class="card-icon">
4786
4839
  <div class="card-icon2">
@@ -4805,8 +4858,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
4805
4858
  ], template: `
4806
4859
  <div class="max-card-menu row">
4807
4860
  @for(card of subMenuCards; track $index) {
4808
- @if (card.isExternal || card.is_OutroModulo) {
4809
- <a [href]="getExternalUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
4861
+
4862
+ <!-- VALIDAÇÃO DE 'IS_EXTERNAL' SIGNIFICA QUE A ROTA É OS -->
4863
+ @if (card.isExternal) {
4864
+ <a [href]="getOutsystemsUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
4865
+ <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4866
+ <div class="card-icon">
4867
+ <div class="card-icon2">
4868
+ <lib-icon class="bold" [iconName]="card.icon ? card.icon : 'engrenagem'" iconColor="blue" [iconSize]="35" />
4869
+ </div>
4870
+ </div>
4871
+
4872
+ <h3 class="card-title">{{ card.titulo }}</h3>
4873
+ <p class="card-text" [title]="card.descricao"> {{ card.descricao }} </p>
4874
+ </div>
4875
+ </a>
4876
+ }
4877
+ <!-- VALIDAÇÃO DE 'IS_OUTROMODULO' SIGNIFICA QUE A ROTA É V6 PORÉM DE OUTRO PROJETO FRONTEND -->
4878
+ @else if (card.is_OutroModulo) {
4879
+ <a [href]="getOutroModuloUrl(card.urlPath)" target="_blank" class="card-link col-4">
4810
4880
  <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4811
4881
  <div class="card-icon">
4812
4882
  <div class="card-icon2">
@@ -4819,8 +4889,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
4819
4889
  </div>
4820
4890
  </a>
4821
4891
  }
4892
+ <!-- CASO CONTRÁRIO DE TUDO SIGNIFICA QUE A ROTA É V6 E DENTRO DO MESMO MÓDULO -->
4822
4893
  @else {
4823
- <a [routerLink]="[ '/'+card.urlPath ]" class="card-link col-4">
4894
+ <a routerLink="/{{ card.urlPath }}" class="card-link col-4">
4824
4895
  <div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
4825
4896
  <div class="card-icon">
4826
4897
  <div class="card-icon2">