[Monitor Dashboard | Trunk]: Fix event bug on app component.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57931 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
5fa7e7ce2a
commit
f5b746b8ba
|
@ -134,7 +134,8 @@ const routes: Routes = [
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(routes, {
|
imports: [RouterModule.forRoot(routes, {
|
||||||
preloadingStrategy: PreloadAllModules,
|
preloadingStrategy: PreloadAllModules,
|
||||||
scrollPositionRestoration: "top"
|
scrollPositionRestoration: "top",
|
||||||
|
onSameUrlNavigation: "reload"
|
||||||
})],
|
})],
|
||||||
exports: [RouterModule],
|
exports: [RouterModule],
|
||||||
providers: [EnvironmentSpecificResolver, EnvironmentSpecificService]
|
providers: [EnvironmentSpecificResolver, EnvironmentSpecificService]
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';
|
import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
import {ActivatedRoute, NavigationEnd, Params, Router} from '@angular/router';
|
||||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||||
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
||||||
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||||
import {StakeholderService} from "./services/stakeholder.service";
|
import {StakeholderService} from "./services/stakeholder.service";
|
||||||
import {Subscriber} from "rxjs";
|
import {BehaviorSubject, Subscriber} from "rxjs";
|
||||||
import {LayoutService} from "./library/sharedComponents/sidebar/layout.service";
|
import {LayoutService} from "./library/sharedComponents/sidebar/layout.service";
|
||||||
import {MenuItem} from "./openaireLibrary/sharedComponents/menu";
|
import {MenuItem} from "./openaireLibrary/sharedComponents/menu";
|
||||||
import {Item} from "./utils/entities/sidebar";
|
import {Item} from "./utils/entities/sidebar";
|
||||||
|
@ -18,21 +18,32 @@ import {Item} from "./utils/entities/sidebar";
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
user: User;
|
user: User;
|
||||||
|
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
|
||||||
hasSidebar: boolean = false;
|
hasSidebar: boolean = false;
|
||||||
hasHeader: boolean = false;
|
hasHeader: boolean = false;
|
||||||
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
userMenuItems: MenuItem[] = [];
|
||||||
private subscriptions: any[] = [];
|
|
||||||
adminMenuItems: Item[] = [];
|
adminMenuItems: Item[] = [];
|
||||||
|
private subscriptions: any[] = [];
|
||||||
constructor(private route: ActivatedRoute,
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
private propertiesService: EnvironmentSpecificService,
|
private propertiesService: EnvironmentSpecificService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private layoutService: LayoutService,
|
private layoutService: LayoutService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private cdr: ChangeDetectorRef) {
|
private cdr: ChangeDetectorRef) {
|
||||||
|
this.subscriptions.push(this.router.events.subscribe(event => {
|
||||||
|
if (event instanceof NavigationEnd) {
|
||||||
|
let r = this.route;
|
||||||
|
while (r.firstChild) {
|
||||||
|
r = r.firstChild;
|
||||||
|
}
|
||||||
|
let params = r.snapshot.params;
|
||||||
|
this.params.next(params);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => {
|
this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => {
|
||||||
this.hasSidebar = hasSidebar;
|
this.hasSidebar = hasSidebar;
|
||||||
|
@ -45,24 +56,18 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
this.propertiesService.loadEnvironment()
|
this.propertiesService.loadEnvironment()
|
||||||
.then(properties => {
|
.then(properties => {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.subscriptions.push(this.router.events.subscribe(() => {
|
this.subscriptions.push(this.params.subscribe( params => {
|
||||||
let r = this.route;
|
if (params && params['stakeholder']) {
|
||||||
while (r.firstChild) {
|
if (!this.stakeholderService.stakeholder ||
|
||||||
r = r.firstChild;
|
this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
|
||||||
}
|
this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
|
||||||
this.subscriptions.push(r.params.subscribe(params => {
|
this.stakeholderService.setStakeholder(stakeholder);
|
||||||
if (params['stakeholder']) {
|
this.layoutService.setOpen(true);
|
||||||
if (!this.stakeholderService.stakeholder ||
|
});
|
||||||
this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
|
|
||||||
this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
|
|
||||||
this.stakeholderService.setStakeholder(stakeholder);
|
|
||||||
this.layoutService.setOpen(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.stakeholderService.setStakeholder(null);
|
|
||||||
}
|
}
|
||||||
}));
|
} else {
|
||||||
|
this.stakeholderService.setStakeholder(null);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
|
@ -108,14 +108,12 @@ body.dashboard {
|
||||||
height: var(--header-height);
|
height: var(--header-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard #header_main > nav {
|
.dashboard #header_main > .uk-navbar {
|
||||||
height: var(--header-height);
|
height: var(--header-height);
|
||||||
line-height: var(--header-height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard #header_main > nav > * {
|
.dashboard #header_main > .uk-navbar > * {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
line-height: inherit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard #header_main #sidebar_main_toggle {
|
.dashboard #header_main #sidebar_main_toggle {
|
||||||
|
|
Loading…
Reference in New Issue