[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:
Konstantinos Triantafyllou 2019-12-21 13:32:43 +00:00
parent 5fa7e7ce2a
commit f5b746b8ba
3 changed files with 33 additions and 29 deletions

View File

@ -134,7 +134,8 @@ const routes: Routes = [
@NgModule({
imports: [RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules,
scrollPositionRestoration: "top"
scrollPositionRestoration: "top",
onSameUrlNavigation: "reload"
})],
exports: [RouterModule],
providers: [EnvironmentSpecificResolver, EnvironmentSpecificService]

View File

@ -1,11 +1,11 @@
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 {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import {Session, User} from './openaireLibrary/login/utils/helper.class';
import {UserManagementService} from "./openaireLibrary/services/user-management.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 {MenuItem} from "./openaireLibrary/sharedComponents/menu";
import {Item} from "./utils/entities/sidebar";
@ -18,19 +18,30 @@ import {Item} from "./utils/entities/sidebar";
export class AppComponent implements OnInit, OnDestroy {
properties: EnvProperties;
user: User;
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
hasSidebar: boolean = false;
hasHeader: boolean = false;
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
private subscriptions: any[] = [];
userMenuItems: MenuItem[] = [];
adminMenuItems: Item[] = [];
private subscriptions: any[] = [];
constructor(private route: ActivatedRoute,
constructor(private route: ActivatedRoute,
private propertiesService: EnvironmentSpecificService,
private router: Router,
private userManagementService: UserManagementService,
private layoutService: LayoutService,
private stakeholderService: StakeholderService,
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() {
@ -45,24 +56,18 @@ export class AppComponent implements OnInit, OnDestroy {
this.propertiesService.loadEnvironment()
.then(properties => {
this.properties = properties;
this.subscriptions.push(this.router.events.subscribe(() => {
let r = this.route;
while (r.firstChild) {
r = r.firstChild;
}
this.subscriptions.push(r.params.subscribe(params => {
if (params['stakeholder']) {
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);
this.subscriptions.push(this.params.subscribe( params => {
if (params && params['stakeholder']) {
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);
}
}));
this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;

View File

@ -108,14 +108,12 @@ body.dashboard {
height: var(--header-height);
}
.dashboard #header_main > nav {
.dashboard #header_main > .uk-navbar {
height: var(--header-height);
line-height: var(--header-height);
}
.dashboard #header_main > nav > * {
.dashboard #header_main > .uk-navbar > * {
vertical-align: middle;
line-height: inherit;
}
.dashboard #header_main #sidebar_main_toggle {