Browse Source

UI: Add routes tab settings replaceUrl

pull/8911/head
Vladyslav_Prykhodko 3 years ago
parent
commit
054b190144
  1. 1
      ui-ngx/src/app/modules/home/components/router-tabs.component.html
  2. 6
      ui-ngx/src/app/modules/home/components/router-tabs.component.ts
  3. 9
      ui-ngx/src/app/modules/home/home.component.ts
  4. 10
      ui-ngx/src/app/modules/home/pages/account/account-routing.module.ts

1
ui-ngx/src/app/modules/home/components/router-tabs.component.html

@ -20,6 +20,7 @@
<nav fxFlex *ngIf="!routerOutlet?.activatedRouteData?.hideTabs && !hideCurrentTabs && (tabs$ | async).length > 1" mat-tab-nav-bar mat-stretch-tabs="false" class="tb-router-tabs" [tabPanel]="tabPanel"> <nav fxFlex *ngIf="!routerOutlet?.activatedRouteData?.hideTabs && !hideCurrentTabs && (tabs$ | async).length > 1" mat-tab-nav-bar mat-stretch-tabs="false" class="tb-router-tabs" [tabPanel]="tabPanel">
<a *ngFor="let tab of tabs$ | async" <a *ngFor="let tab of tabs$ | async"
routerLink="{{tab.path}}" routerLink="{{tab.path}}"
replaceUrl="{{ replaceUrl }}"
routerLinkActive routerLinkActive
#rla="routerLinkActive" #rla="routerLinkActive"
mat-tab-link mat-tab-link

6
ui-ngx/src/app/modules/home/components/router-tabs.component.ts

@ -39,6 +39,8 @@ export class RouterTabsComponent extends PageComponent implements OnInit {
hideCurrentTabs = false; hideCurrentTabs = false;
replaceUrl = false;
tabs$: Observable<Array<MenuSection>>; tabs$: Observable<Array<MenuSection>>;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
@ -67,6 +69,10 @@ export class RouterTabsComponent extends PageComponent implements OnInit {
); );
} }
if (this.activatedRoute.snapshot.data.replaceUrl) {
this.replaceUrl = true;
}
this.activatedRoute.data.subscribe( this.activatedRoute.data.subscribe(
(data) => this.buildTabsHeaderComponent(data) (data) => this.buildTabsHeaderComponent(data)
); );

9
ui-ngx/src/app/modules/home/home.component.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { AfterViewInit, Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core';
import { fromEvent } from 'rxjs'; import { fromEvent } from 'rxjs';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged, tap } from 'rxjs/operators';
@ -27,10 +27,10 @@ import { MediaBreakpoints } from '@shared/models/constants';
import screenfull from 'screenfull'; import screenfull from 'screenfull';
import { MatSidenav } from '@angular/material/sidenav'; import { MatSidenav } from '@angular/material/sidenav';
import { AuthState } from '@core/auth/auth.models'; import { AuthState } from '@core/auth/auth.models';
import { WINDOW } from '@core/services/window.service';
import { instanceOfSearchableComponent, ISearchableComponent } from '@home/models/searchable-component.models'; import { instanceOfSearchableComponent, ISearchableComponent } from '@home/models/searchable-component.models';
import { ActiveComponentService } from '@core/services/active-component.service'; import { ActiveComponentService } from '@core/services/active-component.service';
import { RouterTabsComponent } from '@home/components/router-tabs.component'; import { RouterTabsComponent } from '@home/components/router-tabs.component';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'tb-home', selector: 'tb-home',
@ -65,8 +65,8 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
hideLoadingBar = false; hideLoadingBar = false;
constructor(protected store: Store<AppState>, constructor(protected store: Store<AppState>,
@Inject(WINDOW) private window: Window,
private activeComponentService: ActiveComponentService, private activeComponentService: ActiveComponentService,
private router: Router,
public breakpointObserver: BreakpointObserver) { public breakpointObserver: BreakpointObserver) {
super(store); super(store);
} }
@ -120,8 +120,7 @@ export class HomeComponent extends PageComponent implements AfterViewInit, OnIni
} }
goBack() { goBack() {
const dashboardId = this.authState.userDetails.additionalInfo.defaultDashboardId; this.window.history.back();
this.router.navigate(['dashboard', dashboardId]).then(() => {});
} }
activeComponentChanged(activeComponent: any) { activeComponentChanged(activeComponent: any) {

10
ui-ngx/src/app/modules/home/pages/account/account-routing.module.ts

@ -14,12 +14,15 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { NgModule } from '@angular/core'; import { inject, NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { RouterTabsComponent } from '@home/components/router-tabs.component'; import { RouterTabsComponent } from '@home/components/router-tabs.component';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
import { securityRoutes } from '@home/pages/security/security-routing.module'; import { securityRoutes } from '@home/pages/security/security-routing.module';
import { profileRoutes } from '@home/pages/profile/profile-routing.module'; import { profileRoutes } from '@home/pages/profile/profile-routing.module';
import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
const routes: Routes = [ const routes: Routes = [
{ {
@ -31,7 +34,10 @@ const routes: Routes = [
label: 'account.account', label: 'account.account',
icon: 'account_circle' icon: 'account_circle'
}, },
useChildrenRoutesForTabs: true useChildrenRoutesForTabs: true,
},
resolve: {
replaceUrl: () => getCurrentAuthState(inject(Store<AppState>)).forceFullscreen
}, },
children: [ children: [
{ {

Loading…
Cancel
Save