@resolveio/client-lib-core 1.2.9 → 1.3.0

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.
@@ -4812,27 +4812,7 @@ class NavbarModuleComponent extends BaseComponent {
4812
4812
  }));
4813
4813
  this.routerEvents$.push(this._services._app.navbarModuleData.subscribe(data => {
4814
4814
  this.menuData = data;
4815
- if (!this.selectedTab && this.menuData.tabs.length) {
4816
- this.selectedTab = this.menuData.tabs[0];
4817
- }
4818
- if (this.selectedTab) {
4819
- for (let i = 0; i < this.menuData.tabs.length; i++) {
4820
- let tabLink = '';
4821
- if (this.menuData.tabs[i].link.startsWith('/customer-portal/frac') || this.menuData.tabs[i].link.startsWith('/customer-portal/production')) {
4822
- tabLink = this.menuData.tabs[i].link;
4823
- }
4824
- else {
4825
- tabLink = this.menuData.tabs[i].link.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1');
4826
- }
4827
- if (tabLink === this.currentRoute) {
4828
- this.selectedTab = this.menuData.tabs[i];
4829
- break;
4830
- }
4831
- }
4832
- if (this.selectedTab === null) {
4833
- this.selectedTab = this.menuData.tabs[0];
4834
- }
4835
- }
4815
+ this.selectTabFromRouter();
4836
4816
  }));
4837
4817
  this.routerEvents$.push(this._services._app.tourStarted.subscribe(tourStarted => {
4838
4818
  this.tourStarted = tourStarted;
@@ -4844,38 +4824,24 @@ class NavbarModuleComponent extends BaseComponent {
4844
4824
  });
4845
4825
  }
4846
4826
  selectTabFromRouter() {
4847
- if (this._services._router.url === '/') {
4848
- this.selectedTab = this.menuData.tabs[0];
4849
- }
4850
- else {
4851
- this.selectedTab = null;
4852
- let routerLink = '';
4853
- if (this._services._router.url.startsWith('/customer-portal/frac') || this._services._router.url.startsWith('/customer-portal/production')) {
4854
- routerLink = this._services._router.url;
4827
+ if (this.menuData) {
4828
+ if (this._services._router.url === '/') {
4829
+ this.selectedTab = this.menuData.tabs[0];
4855
4830
  }
4856
4831
  else {
4857
- routerLink = this._services._router.url.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1');
4858
- }
4859
- if (routerLink.includes('?')) {
4860
- routerLink = routerLink.substring(0, routerLink.indexOf('?'));
4861
- }
4862
- this.currentRoute = routerLink;
4863
- for (let i = 0; i < this.menuData.tabs.length; i++) {
4864
- let tabLink = '';
4865
- if (this.menuData.tabs[i].link.startsWith('/customer-portal/frac') || this.menuData.tabs[i].link.startsWith('/customer-portal/production')) {
4866
- tabLink = this.menuData.tabs[i].link;
4867
- }
4868
- else {
4869
- tabLink = this.menuData.tabs[i].link.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1');
4832
+ this.selectedTab = null;
4833
+ this.currentRoute = this._services._router.url.replace(/\/[a-f0-9]{24}$/, '').replace(/\?.+$/, '');
4834
+ for (let i = 0; i < this.menuData.tabs.length; i++) {
4835
+ let tab = this.menuData.tabs[i];
4836
+ if (tab.link === this.currentRoute) {
4837
+ this.selectedTab = tab;
4838
+ break;
4839
+ }
4870
4840
  }
4871
- if (tabLink === routerLink) {
4872
- this.selectedTab = this.menuData.tabs[i];
4873
- break;
4841
+ if (this.selectedTab === null) {
4842
+ this.selectedTab = this.menuData.tabs[0];
4874
4843
  }
4875
4844
  }
4876
- if (this.selectedTab === null) {
4877
- this.selectedTab = this.menuData.tabs.filter(a => a.link === routerLink)[0] ? this.menuData.tabs.filter(a => a.link === routerLink)[0] : this.menuData.tabs[0];
4878
- }
4879
4845
  }
4880
4846
  }
4881
4847
  tabClass(tab) {
@@ -5543,14 +5509,49 @@ class AuthGuard {
5543
5509
  resolve(false);
5544
5510
  }
5545
5511
  else {
5546
- let view = state.url.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1').replace(/\?.+/, '');
5547
- let moduleView = view.replace(/^(\/.*\/).*/, '$1');
5548
- if (user.roles.super_admin) {
5549
- resolve(true);
5512
+ let view = state.url.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1').replace(/\?.+$/, '');
5513
+ let moduleView = view.replace(/^(\/[-a-z]+\/).*$/, '$1');
5514
+ if (!this.isLinkFakeRoute(view)) {
5515
+ if (user.roles.super_admin) {
5516
+ resolve(true);
5517
+ }
5518
+ else if (!user.roles.groups.filter(a => a.views.some(b => b === view && !this.isLinkPartialRoute(b))).length) {
5519
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5520
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5521
+ this._router.navigateByUrl(link);
5522
+ }
5523
+ else {
5524
+ this._router.navigateByUrl('/home');
5525
+ }
5526
+ resolve(false);
5527
+ }
5528
+ else if (!user.roles.groups.filter(a => a.views.some(b => b.startsWith(view) && this.isLinkPartialRoute(b))).length) {
5529
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5530
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5531
+ this._router.navigateByUrl(link);
5532
+ }
5533
+ else {
5534
+ this._router.navigateByUrl('/home');
5535
+ }
5536
+ resolve(false);
5537
+ }
5538
+ else {
5539
+ resolve(true);
5540
+ }
5550
5541
  }
5551
- else if (!user.roles.groups.filter(a => a.views.filter(b => b.startsWith(view)).length).length) {
5552
- if (user.roles.groups.filter(a => a.views.filter(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b)).length).length) {
5553
- let link = user.roles.groups.filter(a => a.views.filter(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b)).length)[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a))[0];
5542
+ else if (!user.roles.groups.filter(a => a.views.some(b => b === view && !this.isLinkPartialRoute(b))).length) {
5543
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5544
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5545
+ this._router.navigateByUrl(link);
5546
+ }
5547
+ else {
5548
+ this._router.navigateByUrl('/home');
5549
+ }
5550
+ resolve(false);
5551
+ }
5552
+ else if (!user.roles.groups.filter(a => a.views.some(b => b.startsWith(view) && this.isLinkPartialRoute(b))).length) {
5553
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5554
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5554
5555
  this._router.navigateByUrl(link);
5555
5556
  }
5556
5557
  else {
@@ -5559,7 +5560,7 @@ class AuthGuard {
5559
5560
  resolve(false);
5560
5561
  }
5561
5562
  else {
5562
- resolve(true);
5563
+ this._router.navigateByUrl('/home');
5563
5564
  }
5564
5565
  }
5565
5566
  });
@@ -5578,14 +5579,49 @@ class AuthGuard {
5578
5579
  resolve(false);
5579
5580
  }
5580
5581
  else {
5581
- let view = state.url.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1').replace(/\?.+/, '');
5582
- let moduleView = view.replace(/^(\/.*\/).*/, '$1');
5583
- if (user.roles.super_admin) {
5584
- resolve(true);
5582
+ let view = state.url.replace(/^(\/[-a-z]+\/[^\/]+)\/.*$/, '$1').replace(/\?.+$/, '');
5583
+ let moduleView = view.replace(/^(\/[-a-z]+\/).*$/, '$1');
5584
+ if (!this.isLinkFakeRoute(view)) {
5585
+ if (user.roles.super_admin) {
5586
+ resolve(true);
5587
+ }
5588
+ else if (!user.roles.groups.filter(a => a.views.some(b => b === view && !this.isLinkPartialRoute(b))).length) {
5589
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5590
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5591
+ this._router.navigateByUrl(link);
5592
+ }
5593
+ else {
5594
+ this._router.navigateByUrl('/home');
5595
+ }
5596
+ resolve(false);
5597
+ }
5598
+ else if (!user.roles.groups.filter(a => a.views.some(b => b.startsWith(view) && this.isLinkPartialRoute(b))).length) {
5599
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5600
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5601
+ this._router.navigateByUrl(link);
5602
+ }
5603
+ else {
5604
+ this._router.navigateByUrl('/home');
5605
+ }
5606
+ resolve(false);
5607
+ }
5608
+ else {
5609
+ resolve(true);
5610
+ }
5611
+ }
5612
+ else if (!user.roles.groups.filter(a => a.views.some(b => b === view && !this.isLinkPartialRoute(b))).length) {
5613
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5614
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5615
+ this._router.navigateByUrl(link);
5616
+ }
5617
+ else {
5618
+ this._router.navigateByUrl('/home');
5619
+ }
5620
+ resolve(false);
5585
5621
  }
5586
- else if (!user.roles.groups.filter(a => a.views.filter(b => b.startsWith(view)).length).length) {
5587
- if (user.roles.groups.filter(a => a.views.filter(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b)).length).length) {
5588
- let link = user.roles.groups.filter(a => a.views.filter(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b)).length)[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a))[0];
5622
+ else if (!user.roles.groups.filter(a => a.views.some(b => b.startsWith(view) && this.isLinkPartialRoute(b))).length) {
5623
+ if (user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b))).length) {
5624
+ let link = user.roles.groups.filter(a => a.views.some(b => b.startsWith(moduleView) && !this.doesLinkHaveParameter(b) && !this.isLinkFakeRoute(b)))[0].views.filter(a => a.startsWith(moduleView) && !this.doesLinkHaveParameter(a) && !this.isLinkFakeRoute(a))[0];
5589
5625
  this._router.navigateByUrl(link);
5590
5626
  }
5591
5627
  else {
@@ -5594,7 +5630,7 @@ class AuthGuard {
5594
5630
  resolve(false);
5595
5631
  }
5596
5632
  else {
5597
- resolve(true);
5633
+ this._router.navigateByUrl('/home');
5598
5634
  }
5599
5635
  }
5600
5636
  }
@@ -5608,12 +5644,33 @@ class AuthGuard {
5608
5644
  for (let j = 0; j < permission.views.length; j++) {
5609
5645
  let view = permission.views[j];
5610
5646
  if (view.link === link) {
5611
- if (view.has_parameter) {
5612
- return true;
5613
- }
5614
- else {
5615
- return false;
5616
- }
5647
+ return !!view.has_parameter;
5648
+ }
5649
+ }
5650
+ }
5651
+ return false;
5652
+ }
5653
+ isLinkFakeRoute(link) {
5654
+ let permissions = this._aps.getAllModulePermissions();
5655
+ for (let i = 0; i < permissions.length; i++) {
5656
+ let permission = permissions[i];
5657
+ for (let j = 0; j < permission.views.length; j++) {
5658
+ let view = permission.views[j];
5659
+ if (view.link === link) {
5660
+ return !!view.fake_route;
5661
+ }
5662
+ }
5663
+ }
5664
+ return false;
5665
+ }
5666
+ isLinkPartialRoute(link) {
5667
+ let permissions = this._aps.getAllModulePermissions();
5668
+ for (let i = 0; i < permissions.length; i++) {
5669
+ let permission = permissions[i];
5670
+ for (let j = 0; j < permission.views.length; j++) {
5671
+ let view = permission.views[j];
5672
+ if (view.link === link) {
5673
+ return !!view.partial_route;
5617
5674
  }
5618
5675
  }
5619
5676
  }
@@ -6496,7 +6553,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
6496
6553
  const UserSettingsModulePermission = {
6497
6554
  name: 'user-settings',
6498
6555
  views: [
6499
- { link: '/user-settings/settings', label: 'Settings', has_parameter: false }
6556
+ { link: '/user-settings/settings', label: 'Settings' }
6500
6557
  ],
6501
6558
  approval: {
6502
6559
  type: 'user-settings'
@@ -8700,10 +8757,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImpor
8700
8757
  const ReportBuilderModulePermission = {
8701
8758
  name: 'report-builder',
8702
8759
  views: [
8703
- { link: '/report-builder/list', label: 'List', has_parameter: false },
8704
- { link: '/report-builder/new', label: 'New', has_parameter: false },
8705
- { link: '/report-builder/scheduled-job', label: 'Scheduled Job', has_parameter: false },
8706
- { link: '/report-builder/dashboard-builder', label: 'Dashboard Builder', has_parameter: false },
8760
+ { link: '/report-builder/list', label: 'List' },
8761
+ { link: '/report-builder/new', label: 'New' },
8762
+ { link: '/report-builder/scheduled-job', label: 'Scheduled Job' },
8763
+ { link: '/report-builder/dashboard-builder', label: 'Dashboard Builder' },
8707
8764
  { link: '/report-builder/detail', label: 'Detail', has_parameter: true },
8708
8765
  { link: '/report-builder/edit', label: 'Edit', has_parameter: true },
8709
8766
  { link: '/report-builder/delete', label: 'Delete', has_parameter: true },
@@ -8713,9 +8770,9 @@ const ReportBuilderModulePermission = {
8713
8770
  const SuperAdminModulePermission = {
8714
8771
  name: 'super-admin',
8715
8772
  views: [
8716
- { link: '/super-admin/dashboard', label: 'Dashboard', has_parameter: false },
8717
- { link: '/super-admin/apm', label: 'APM', has_parameter: false },
8718
- { link: '/super-admin/monitor', label: 'Monitor', has_parameter: false }
8773
+ { link: '/super-admin/dashboard', label: 'Dashboard' },
8774
+ { link: '/super-admin/apm', label: 'APM' },
8775
+ { link: '/super-admin/monitor', label: 'Monitor' }
8719
8776
  ]
8720
8777
  };
8721
8778