[Monitor Dashboard | Trunk]: Reset user menu items before build
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57884 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
d7a84cb3aa
commit
5da23e9673
|
@ -17,7 +17,6 @@ import {MenuItem} from "./openaireLibrary/sharedComponents/menu";
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
user: User;
|
user: User;
|
||||||
loginCheck: boolean = false;
|
|
||||||
hasSidebar: boolean = false;
|
hasSidebar: boolean = false;
|
||||||
hasHeader: boolean = false;
|
hasHeader: boolean = false;
|
||||||
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})];
|
||||||
|
@ -65,7 +64,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}));
|
}));
|
||||||
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;
|
||||||
this.loginCheck = true;
|
|
||||||
this.buildMenu();
|
this.buildMenu();
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log("App couldn't fetch properties");
|
console.log("App couldn't fetch properties");
|
||||||
|
@ -96,6 +94,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
buildMenu() {
|
buildMenu() {
|
||||||
|
this.userMenuItems = [];
|
||||||
if (Session.isPortalAdministrator(this.user)) {
|
if (Session.isPortalAdministrator(this.user)) {
|
||||||
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
||||||
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
||||||
|
|
|
@ -88,7 +88,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
||||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||||
let subscription: Subscription;
|
let subscription: Subscription;
|
||||||
this.route.params.subscribe(params => {
|
this.route.params.subscribe(params => {
|
||||||
if(subscription) {
|
if (subscription) {
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
this.properties = data.envSpecific;
|
this.properties = data.envSpecific;
|
||||||
|
@ -198,7 +198,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
||||||
if (params['category']) {
|
if (params['category']) {
|
||||||
this.activeCategory = this.activeTopic.categories.find(category =>
|
this.activeCategory = this.activeTopic.categories.find(category =>
|
||||||
(category.alias === params['category']) && category.isPublic && category.isActive);
|
(category.alias === params['category']) && category.isPublic && category.isActive);
|
||||||
if(!this.activeCategory) {
|
if (!this.activeCategory) {
|
||||||
this.navigateToError();
|
this.navigateToError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
||||||
if (params['subCategory']) {
|
if (params['subCategory']) {
|
||||||
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
|
||||||
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
|
(subCategory.alias === params['subCategory'] && subCategory.isPublic && subCategory.isActive));
|
||||||
if(!this.activeSubCategory) {
|
if (!this.activeSubCategory) {
|
||||||
this.navigateToError();
|
this.navigateToError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
||||||
subItems, null, open));
|
subItems, null, open));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(items.length === 0) {
|
if (items.length === 0) {
|
||||||
items.push(new Item('noCategories', 'No categories available yet', null, [], null, false));
|
items.push(new Item('noCategories', 'No categories available yet', null, [], null, false));
|
||||||
}
|
}
|
||||||
this.sideBar = new Sidebar(items, null);
|
this.sideBar = new Sidebar(items, null);
|
||||||
|
@ -360,12 +360,13 @@ export class MonitorComponent implements OnInit, OnDestroy, IDeactivateComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
buildMenu() {
|
buildMenu() {
|
||||||
|
this.userMenuItems = [];
|
||||||
if (Session.isPortalAdministrator(this.user)) {
|
if (Session.isPortalAdministrator(this.user)) {
|
||||||
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
this.userMenuItems.push(new MenuItem("", "Manage helptexts",
|
||||||
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
|
||||||
|
|
||||||
}
|
}
|
||||||
if(this.user) {
|
if (this.user) {
|
||||||
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue