2020-11-26 17:23:21 +01:00
|
|
|
import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from '@angular/core';
|
2021-07-14 18:02:04 +02:00
|
|
|
import {ActivatedRoute, Data, NavigationEnd, Params, Router} from '@angular/router';
|
2019-10-24 09:44:29 +02:00
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
2021-03-04 12:35:10 +01:00
|
|
|
import {Role, Session, User} from './openaireLibrary/login/utils/helper.class';
|
2019-10-24 09:44:29 +02:00
|
|
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
2020-06-03 15:44:03 +02:00
|
|
|
import {StakeholderService} from "./openaireLibrary/monitor/services/stakeholder.service";
|
2019-12-21 14:32:43 +01:00
|
|
|
import {BehaviorSubject, Subscriber} from "rxjs";
|
2019-12-23 14:54:37 +01:00
|
|
|
import {LayoutService} from "./openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
|
2020-10-12 14:54:57 +02:00
|
|
|
import {MenuItem, RootMenuItem} from "./openaireLibrary/sharedComponents/menu";
|
2020-10-23 15:58:16 +02:00
|
|
|
import {Stakeholder, Topic, Visibility} from "./openaireLibrary/monitor/entities/stakeholder";
|
2020-07-10 10:38:52 +02:00
|
|
|
import {LinksResolver} from "./search/links-resolver";
|
2020-10-19 11:07:43 +02:00
|
|
|
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
|
2020-10-30 12:33:51 +01:00
|
|
|
import {properties} from "../environments/environment";
|
2020-12-18 16:31:21 +01:00
|
|
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
2021-03-04 12:35:10 +01:00
|
|
|
import {Option} from "./openaireLibrary/sharedComponents/input/input.component";
|
|
|
|
import {StakeholderUtils} from "./utils/indicator-utils";
|
2021-04-12 23:56:46 +02:00
|
|
|
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
2021-07-14 18:02:04 +02:00
|
|
|
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
|
2019-11-24 17:30:04 +01:00
|
|
|
|
2019-10-24 09:44:29 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-12-20 12:48:35 +01:00
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html'
|
2019-10-24 09:44:29 +02:00
|
|
|
})
|
2019-11-24 17:30:04 +01:00
|
|
|
export class AppComponent implements OnInit, OnDestroy {
|
2020-11-01 16:41:56 +01:00
|
|
|
properties: EnvProperties = properties;
|
2019-12-20 12:48:35 +01:00
|
|
|
user: User;
|
2019-12-21 14:32:43 +01:00
|
|
|
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
|
2021-07-14 18:02:04 +02:00
|
|
|
data: BehaviorSubject<Data> = new BehaviorSubject<Data>(null);
|
2019-12-20 12:48:35 +01:00
|
|
|
hasSidebar: boolean = false;
|
|
|
|
hasHeader: boolean = false;
|
2019-12-23 14:54:37 +01:00
|
|
|
hasAdminMenu: boolean = false;
|
2020-07-06 11:19:01 +02:00
|
|
|
isFrontPage: boolean = false;
|
|
|
|
isViewPublic: boolean = false;
|
|
|
|
sideBarItems: MenuItem[] = [];
|
2020-10-30 12:33:51 +01:00
|
|
|
specialSideBarMenuItem: MenuItem = null;
|
2020-10-12 14:54:57 +02:00
|
|
|
menuItems: RootMenuItem[] = [];
|
2021-03-04 12:35:10 +01:00
|
|
|
notificationGroups: Option[] = [];
|
|
|
|
notificationGroupsInitialized: boolean = false;
|
|
|
|
stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
2020-10-30 12:33:51 +01:00
|
|
|
menuHeader: Header = {
|
|
|
|
route: "/",
|
|
|
|
url: null,
|
|
|
|
title: "Default menu header",
|
|
|
|
logoUrl: null,
|
|
|
|
logoSmallUrl: null,
|
|
|
|
position: 'center',
|
2022-03-02 22:58:53 +01:00
|
|
|
badge: true,
|
2022-02-28 17:02:38 +01:00
|
|
|
menuPosition: "center"
|
2020-10-30 12:33:51 +01:00
|
|
|
};
|
2020-11-01 16:41:56 +01:00
|
|
|
|
2020-11-03 11:59:48 +01:00
|
|
|
userMenuItems: MenuItem[] = [];
|
2019-12-23 14:54:37 +01:00
|
|
|
adminMenuItems: MenuItem[] = [];
|
2020-07-06 11:19:01 +02:00
|
|
|
stakeholder: Stakeholder = null;
|
|
|
|
activeTopic: Topic = null;
|
2020-10-30 12:33:51 +01:00
|
|
|
loading: boolean = true;
|
|
|
|
paramsResolved: boolean = false;
|
2020-08-04 09:57:51 +02:00
|
|
|
innerWidth;
|
2019-12-21 14:32:43 +01:00
|
|
|
private subscriptions: any[] = [];
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute,
|
2019-12-20 12:48:35 +01:00
|
|
|
private router: Router,
|
|
|
|
private userManagementService: UserManagementService,
|
|
|
|
private layoutService: LayoutService,
|
2021-04-12 23:56:46 +02:00
|
|
|
private smoothScroll: SmoothScroll,
|
2019-12-20 12:48:35 +01:00
|
|
|
private stakeholderService: StakeholderService,
|
2022-03-02 22:58:53 +01:00
|
|
|
private cdr: ChangeDetectorRef, private configurationService: ConfigurationService) {
|
2019-12-21 14:32:43 +01:00
|
|
|
this.subscriptions.push(this.router.events.subscribe(event => {
|
|
|
|
if (event instanceof NavigationEnd) {
|
|
|
|
let r = this.route;
|
|
|
|
while (r.firstChild) {
|
|
|
|
r = r.firstChild;
|
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
this.paramsResolved = true;
|
2021-07-14 18:02:04 +02:00
|
|
|
this.params.next(r.snapshot.params);
|
|
|
|
this.data.next(r.snapshot.data);
|
2019-12-21 14:32:43 +01:00
|
|
|
}
|
|
|
|
}));
|
2019-12-20 12:48:35 +01:00
|
|
|
}
|
2019-12-21 14:32:43 +01:00
|
|
|
|
2020-11-26 17:23:21 +01:00
|
|
|
@HostListener('window:resize', ['$event'])
|
|
|
|
onResize(event) {
|
2022-04-09 15:25:09 +02:00
|
|
|
if (this.layoutService.isSmallScreen && event.target.innerWidth > 640) {
|
2020-11-26 17:23:21 +01:00
|
|
|
this.layoutService.setSmallScreen(false);
|
2022-04-09 15:25:09 +02:00
|
|
|
} else if (!this.layoutService.isSmallScreen && event.target.innerWidth <= 640) {
|
2020-11-26 17:23:21 +01:00
|
|
|
this.layoutService.setSmallScreen(true);
|
|
|
|
this.layoutService.setOpen(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-20 12:48:35 +01:00
|
|
|
ngOnInit() {
|
2020-11-20 18:15:30 +01:00
|
|
|
if (typeof document !== 'undefined' && window) {
|
2020-08-04 09:57:51 +02:00
|
|
|
this.innerWidth = window.innerWidth;
|
|
|
|
}
|
2019-12-20 12:48:35 +01:00
|
|
|
this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => {
|
|
|
|
this.hasSidebar = hasSidebar;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
}));
|
|
|
|
this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => {
|
|
|
|
this.hasHeader = hasHeader;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
}));
|
2019-12-23 14:54:37 +01:00
|
|
|
this.subscriptions.push(this.layoutService.hasAdminMenu.subscribe(hasAdminMenu => {
|
|
|
|
this.hasAdminMenu = hasAdminMenu;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
}));
|
2020-06-04 13:30:26 +02:00
|
|
|
this.subscriptions.push(this.layoutService.isFrontPage.subscribe(isFrontPage => {
|
|
|
|
this.isFrontPage = isFrontPage;
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
}));
|
2020-07-06 11:19:01 +02:00
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
this.isViewPublic = (params['view'] == 'public');
|
|
|
|
});
|
2022-04-09 15:25:09 +02:00
|
|
|
this.layoutService.setSmallScreen((this.innerWidth && this.innerWidth <= 640));
|
|
|
|
this.layoutService.setOpen(!(this.innerWidth && this.innerWidth <= 640));
|
2020-10-30 12:33:51 +01:00
|
|
|
this.subscriptions.push(this.params.subscribe(params => {
|
2020-11-01 16:41:56 +01:00
|
|
|
if (this.paramsResolved) {
|
2020-10-30 12:33:51 +01:00
|
|
|
this.loading = true;
|
|
|
|
if (params && params['stakeholder']) {
|
2020-11-20 18:15:30 +01:00
|
|
|
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
|
2020-11-13 17:42:12 +01:00
|
|
|
this.subscriptions.push(this.stakeholderService.getStakeholder(params['stakeholder']).subscribe(stakeholder => {
|
2020-10-30 12:33:51 +01:00
|
|
|
if (stakeholder) {
|
|
|
|
this.stakeholder = stakeholder;
|
|
|
|
LinksResolver.setProperties(this.stakeholder.alias);
|
2021-07-14 18:02:04 +02:00
|
|
|
this.setProperties(this.stakeholder.alias, this.stakeholder.type);
|
2022-07-02 20:27:29 +02:00
|
|
|
if (params && params['topic'] && !this.activeTopic) {
|
2020-10-30 12:33:51 +01:00
|
|
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
|
2020-07-06 11:19:01 +02:00
|
|
|
} else {
|
2020-10-30 12:33:51 +01:00
|
|
|
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
|
2020-07-06 11:19:01 +02:00
|
|
|
}
|
2020-11-05 17:50:06 +01:00
|
|
|
this.setSideBar();
|
2020-11-20 18:15:30 +01:00
|
|
|
this.buildMenu();
|
2020-10-30 12:33:51 +01:00
|
|
|
this.loading = false;
|
|
|
|
} else {
|
2020-11-25 18:33:07 +01:00
|
|
|
this.stakeholder = null;
|
2020-07-10 10:38:52 +02:00
|
|
|
LinksResolver.resetProperties();
|
2020-06-10 16:03:28 +02:00
|
|
|
this.navigateToError();
|
2020-10-12 14:54:57 +02:00
|
|
|
this.buildMenu();
|
2020-10-30 12:33:51 +01:00
|
|
|
this.loading = false;
|
2020-07-06 11:19:01 +02:00
|
|
|
}
|
2020-11-13 17:42:12 +01:00
|
|
|
}));
|
2019-12-21 14:32:43 +01:00
|
|
|
} else {
|
2020-10-23 15:58:16 +02:00
|
|
|
this.buildMenu();
|
2022-07-02 20:27:29 +02:00
|
|
|
if (params && params['topic']) {
|
2020-10-30 12:33:51 +01:00
|
|
|
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
|
|
|
|
} else {
|
|
|
|
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
|
|
|
|
}
|
|
|
|
this.loading = false;
|
2020-10-23 15:58:16 +02:00
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
} else {
|
2022-07-03 10:55:49 +02:00
|
|
|
LinksResolver.resetProperties();
|
|
|
|
this.stakeholderService.setStakeholder(null);
|
|
|
|
this.stakeholder = null;
|
|
|
|
this.buildMenu();
|
2020-10-30 12:33:51 +01:00
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
2021-07-14 18:02:04 +02:00
|
|
|
this.subscriptions.push(this.data.subscribe(data => {
|
2022-03-02 22:58:53 +01:00
|
|
|
if (data && data.portal) {
|
2021-07-14 18:02:04 +02:00
|
|
|
this.setProperties(data.portal);
|
|
|
|
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
|
|
|
}
|
|
|
|
}));
|
2020-10-30 12:33:51 +01:00
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
if (user) {
|
|
|
|
this.buildMenu();
|
2022-03-02 22:58:53 +01:00
|
|
|
if (!this.notificationGroupsInitialized) {
|
2021-03-04 12:35:10 +01:00
|
|
|
this.setNotificationGroups();
|
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
}
|
|
|
|
}));
|
2019-12-20 12:48:35 +01:00
|
|
|
}
|
2020-07-06 11:19:01 +02:00
|
|
|
|
2021-03-04 12:35:10 +01:00
|
|
|
public setNotificationGroups() {
|
|
|
|
this.notificationGroups = [];
|
2022-03-02 22:58:53 +01:00
|
|
|
if (Session.isPortalAdministrator(this.user)) {
|
2021-03-04 12:35:10 +01:00
|
|
|
this.notificationGroups.push({value: Role.PORTAL_ADMIN, label: 'Portal Administrators'});
|
|
|
|
}
|
2022-03-02 22:58:53 +01:00
|
|
|
for (let type of this.stakeholderUtils.types) {
|
|
|
|
if (Session.isCurator(type.value, this.user) || Session.isPortalAdministrator(this.user)) {
|
2021-03-04 12:35:10 +01:00
|
|
|
this.notificationGroups.push({value: Role.curator(type.value), label: type.label + ' Curators'});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.subscriptions.push(this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL).subscribe(stakeholders => {
|
|
|
|
stakeholders.forEach(stakeholder => {
|
2022-03-02 22:58:53 +01:00
|
|
|
this.notificationGroups.push({
|
|
|
|
value: Role.manager(stakeholder.type, stakeholder.alias),
|
|
|
|
label: stakeholder.name + ' Managers'
|
|
|
|
});
|
|
|
|
this.notificationGroups.push({
|
|
|
|
value: Role.member(stakeholder.type, stakeholder.alias),
|
|
|
|
label: stakeholder.name + ' Members'
|
|
|
|
});
|
2021-03-04 12:35:10 +01:00
|
|
|
});
|
|
|
|
this.notificationGroupsInitialized = true;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2019-12-20 12:48:35 +01:00
|
|
|
public ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
2020-11-13 17:42:12 +01:00
|
|
|
this.userManagementService.clearSubscriptions();
|
|
|
|
this.layoutService.clearSubscriptions();
|
|
|
|
this.stakeholderService.clearSubscriptions();
|
2020-12-18 16:31:21 +01:00
|
|
|
this.configurationService.clearSubscriptions();
|
2021-04-12 23:56:46 +02:00
|
|
|
this.smoothScroll.clearSubscriptions();
|
2019-12-20 12:48:35 +01:00
|
|
|
}
|
2020-06-10 16:03:28 +02:00
|
|
|
|
|
|
|
private navigateToError() {
|
2022-05-11 11:57:00 +02:00
|
|
|
this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.properties.baseLink + this.router.url}});
|
2020-06-10 16:03:28 +02:00
|
|
|
}
|
2020-07-06 11:19:01 +02:00
|
|
|
|
2019-12-20 12:48:35 +01:00
|
|
|
public get open() {
|
|
|
|
return this.layoutService.open;
|
|
|
|
}
|
2020-07-06 11:19:01 +02:00
|
|
|
|
|
|
|
private setSideBar() {
|
|
|
|
let items: MenuItem[] = [];
|
2020-12-11 19:34:50 +01:00
|
|
|
if (this.isPublicOrIsMember(this.stakeholder.visibility)) {
|
2020-11-04 12:16:47 +01:00
|
|
|
this.stakeholder.topics.forEach((topic) => {
|
|
|
|
if (this.isPublicOrIsMember(topic.visibility)) {
|
|
|
|
let topicItem: MenuItem = new MenuItem(topic.alias, topic.name, "", (
|
2022-03-02 22:58:53 +01:00
|
|
|
'/' + this.stakeholder.alias + '/' + topic.alias),
|
2022-04-07 00:25:36 +02:00
|
|
|
null, [], [], {}, {svg: topic.icon}, null, null, (
|
2022-03-28 10:40:22 +02:00
|
|
|
'/' + this.stakeholder.alias + '/' + topic.alias));
|
2020-11-04 12:16:47 +01:00
|
|
|
items.push(topicItem);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (items.length === 0) {
|
|
|
|
items.push(new MenuItem('noTopics', 'No topics available yet', "", "", false, [], [], {}));
|
2020-07-06 11:19:01 +02:00
|
|
|
}
|
|
|
|
}
|
2022-07-02 20:27:29 +02:00
|
|
|
this.adminMenuItems = [];
|
|
|
|
this.adminMenuItems.push(new MenuItem("general", "General", "", "/admin/" + this.stakeholder.alias, false, [], [], {}, {name: 'badge'}));
|
|
|
|
this.adminMenuItems.push(new MenuItem("indicators", "Indicators", "", "/admin/" + this.stakeholder.alias + '/indicators', false, [], [], {}, {name: 'bar_chart'}));
|
|
|
|
if (this.stakeholder.defaultId) {
|
|
|
|
this.adminMenuItems.push(new MenuItem("users", "Users", "", "/admin/" + this.stakeholder.alias + "/users", false, [], [], {}, {name: 'group'}, null, null, "/admin/" + this.stakeholder.alias + "/users"));
|
|
|
|
if (Session.isPortalAdministrator(this.user)) {
|
|
|
|
this.adminMenuItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/admin/" + this.stakeholder.alias + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/admin/" + this.stakeholder.alias + "/admin-tools"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.specialSideBarMenuItem = new MenuItem("back", "Manage profiles", "", "/admin", false, [], null, {}, {
|
|
|
|
name: 'search',
|
|
|
|
class: 'uk-text-secondary'
|
|
|
|
});
|
2020-07-06 11:19:01 +02:00
|
|
|
this.sideBarItems = items;
|
2022-06-20 15:55:45 +02:00
|
|
|
this.hasSidebar = this.hasSidebar && this.sideBarItems.length > 0;
|
2020-07-06 11:19:01 +02:00
|
|
|
}
|
|
|
|
|
2019-12-20 12:48:35 +01:00
|
|
|
buildMenu() {
|
2020-10-12 14:54:57 +02:00
|
|
|
this.menuItems = [];
|
2019-12-20 12:48:35 +01:00
|
|
|
this.userMenuItems = [];
|
2020-11-03 10:42:47 +01:00
|
|
|
if (this.user) {
|
2020-11-03 11:59:48 +01:00
|
|
|
if (this.isCurator()) {
|
|
|
|
this.userMenuItems.push(new MenuItem("", "Manage profiles",
|
|
|
|
"", "/admin", false, [], [], {}));
|
|
|
|
}
|
2022-03-02 22:58:53 +01:00
|
|
|
if (Session.isPortalAdministrator(this.user)) {
|
|
|
|
this.userMenuItems.push(new MenuItem("adminOptions", "Super Admin options", "", "/admin/admin-tools/portals", false, [], [], {}));
|
|
|
|
this.userMenuItems.push(new MenuItem("monitorOptions", "Monitor portal options", "", "/admin/monitor/admin-tools/pages", false, [], [], {}));
|
|
|
|
|
2021-01-11 10:28:34 +01:00
|
|
|
}
|
2020-11-03 10:42:47 +01:00
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
if (this.stakeholder) {
|
2022-06-29 13:35:21 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "User information", "", "/" + this.stakeholder.alias + "/user-info", false, [], [], {}));
|
2022-03-28 10:40:22 +02:00
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("dashboard", "Dashboard",
|
|
|
|
"", "/" + this.stakeholder.alias, false, [], null, {}
|
|
|
|
, null, null, null, null), items: []
|
|
|
|
});
|
|
|
|
if (this.isPublicOrIsMember(this.stakeholder.visibility)) {
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("search", "Search", "", this.properties.searchLinkToResults,
|
|
|
|
false, [], null, {resultbestaccessright: '"' + encodeURIComponent("Open Access") + '"'},
|
|
|
|
null, null, null, null),
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
this.menuItems.push({
|
2022-06-20 15:55:45 +02:00
|
|
|
rootItem: new MenuItem("methodology", "Methodology",
|
|
|
|
"", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}), items: [
|
|
|
|
new MenuItem("methodology", "Terminology and construction",
|
|
|
|
"", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}),
|
|
|
|
new MenuItem("methodology", "See how it works",
|
|
|
|
"", "/" + this.stakeholder.alias + "/methodology", false, [], null, {}, null, "how"),
|
|
|
|
]
|
2022-03-28 10:40:22 +02:00
|
|
|
});
|
2022-06-20 15:55:45 +02:00
|
|
|
if (this.stakeholder.type === "funder") {
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("develop", "Develop",
|
|
|
|
"", "/" + this.stakeholder.alias + "/develop", false, [], null, {}), items: []
|
|
|
|
});
|
|
|
|
}
|
2022-03-28 10:40:22 +02:00
|
|
|
}
|
|
|
|
if (this.isManager(this.stakeholder)) {
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("manage", "Manage",
|
|
|
|
"", "/admin/" + this.stakeholder.alias, false, [], null, {}
|
|
|
|
, null, null, null, null), items: []
|
|
|
|
});
|
|
|
|
}
|
2022-03-14 17:36:50 +01:00
|
|
|
if (!this.hasAdminMenu && this.isFrontPage) {
|
2020-12-11 19:34:50 +01:00
|
|
|
this.menuHeader = {
|
2022-07-14 13:38:20 +02:00
|
|
|
route: null,
|
|
|
|
url: "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu',
|
|
|
|
title: "Monitor",
|
2022-03-15 15:30:36 +01:00
|
|
|
logoUrl: 'assets/common-assets/logo-services/monitor/small-inverted.svg',
|
|
|
|
logoSmallUrl: "assets/common-assets/logo-services/monitor/small-inverted.svg",
|
2022-03-02 22:58:53 +01:00
|
|
|
position: 'center',
|
2020-12-11 19:34:50 +01:00
|
|
|
badge: true,
|
2022-02-28 17:02:38 +01:00
|
|
|
menuPosition: "center"
|
2020-12-11 19:34:50 +01:00
|
|
|
};
|
2020-10-12 14:54:57 +02:00
|
|
|
} else {
|
|
|
|
this.menuHeader = {
|
2022-07-14 13:38:20 +02:00
|
|
|
route: null,
|
|
|
|
url: "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu',
|
|
|
|
title: "Monitor",
|
2022-03-28 10:40:22 +02:00
|
|
|
logoUrl: 'assets/common-assets/logo-services/monitor/small.svg',
|
|
|
|
logoSmallUrl: "assets/common-assets/logo-services/monitor/small.svg",
|
2020-10-12 14:54:57 +02:00
|
|
|
position: 'center',
|
2022-07-14 13:38:20 +02:00
|
|
|
badge: true,
|
2022-02-28 17:02:38 +01:00
|
|
|
menuPosition: "center"
|
2020-10-12 14:54:57 +02:00
|
|
|
};
|
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
} else {
|
|
|
|
if (this.isFrontPage || !this.hasAdminMenu) {
|
2022-06-29 13:35:21 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "User information", "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/user-info', '', false, [], [], {}, null, null, null, null, "_self"));
|
2020-10-30 12:33:51 +01:00
|
|
|
this.menuHeader = {
|
|
|
|
route: null,
|
|
|
|
url: "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu',
|
|
|
|
title: "Monitor",
|
2022-03-15 15:30:36 +01:00
|
|
|
logoUrl: 'assets/common-assets/logo-services/monitor/main.svg',
|
|
|
|
logoSmallUrl: "assets/common-assets/logo-services/monitor/small.svg",
|
2020-10-30 12:33:51 +01:00
|
|
|
position: 'left',
|
2020-10-30 14:59:37 +01:00
|
|
|
badge: true,
|
2022-02-28 17:02:38 +01:00
|
|
|
menuPosition: "center"
|
2020-10-30 12:33:51 +01:00
|
|
|
};
|
2020-11-03 11:59:48 +01:00
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("about", "About",
|
2022-06-29 13:35:21 +02:00
|
|
|
"https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/about/learn-how', "", false, [], null, {}, null, null, null, null, "_self"),
|
2020-12-11 19:34:50 +01:00
|
|
|
items: []
|
2020-11-03 11:59:48 +01:00
|
|
|
});
|
|
|
|
this.menuItems.push({
|
|
|
|
rootItem: new MenuItem("browse", "Browse",
|
2022-06-29 13:35:21 +02:00
|
|
|
"https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu/browse', "", false, [], null, {}, null, null, null, null, "_self"),
|
2020-12-11 19:34:50 +01:00
|
|
|
items: []
|
2020-11-03 11:59:48 +01:00
|
|
|
});
|
2020-10-30 12:33:51 +01:00
|
|
|
} else {
|
2022-06-29 13:35:21 +02:00
|
|
|
this.userMenuItems.push(new MenuItem("", "User information", "", "/admin/user-info", false, [], [], {}));
|
2020-10-30 12:33:51 +01:00
|
|
|
this.menuHeader = {
|
|
|
|
route: "/",
|
|
|
|
url: null,
|
|
|
|
title: "Monitor Dashboard",
|
|
|
|
logoUrl: null,
|
|
|
|
logoSmallUrl: null,
|
|
|
|
position: 'center',
|
2020-10-30 14:59:37 +01:00
|
|
|
badge: false,
|
2022-03-03 16:47:31 +01:00
|
|
|
stickyAnimation: true,
|
2022-02-28 17:02:38 +01:00
|
|
|
menuPosition: "center"
|
2020-10-30 12:33:51 +01:00
|
|
|
};
|
2020-10-12 14:54:57 +02:00
|
|
|
this.adminMenuItems = [];
|
|
|
|
this.specialSideBarMenuItem = null;
|
2022-06-24 17:22:55 +02:00
|
|
|
this.adminMenuItems.push(new MenuItem("stakeholders", "Manage profiles", "", "/admin", false, [], [], {}, {name: 'settings'}));
|
2022-04-07 19:31:55 +02:00
|
|
|
if (Session.isPortalAdministrator(this.user)) {
|
2022-06-27 14:52:14 +02:00
|
|
|
this.adminMenuItems.push(new MenuItem("super_admin", "Super Admin Options", "", "/admin/admin-tools/portals", false, [], [], {}, {name: 'settings'}, null, null, '/admin/admin-tools'));
|
|
|
|
this.adminMenuItems.push(new MenuItem("monitor", "Monitor Options", "", "/admin/monitor/admin-tools/pages", false, [], [], {}, {name: 'settings'}, null, null, '/admin/monitor/admin-tools'));
|
2022-04-07 19:31:55 +02:00
|
|
|
}
|
2022-06-20 15:55:45 +02:00
|
|
|
this.hasAdminMenu = this.hasAdminMenu && this.adminMenuItems.length > 0;
|
2020-10-12 14:54:57 +02:00
|
|
|
}
|
2019-12-20 12:48:35 +01:00
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
|
2019-12-20 12:48:35 +01:00
|
|
|
}
|
2020-12-11 19:34:50 +01:00
|
|
|
|
2020-11-03 11:59:48 +01:00
|
|
|
public isCurator() {
|
|
|
|
return this.user && (Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isKindOfMonitorManager(this.user));
|
|
|
|
}
|
2020-12-11 19:34:50 +01:00
|
|
|
|
|
|
|
public isManager(stakeholder: Stakeholder) {
|
2020-11-03 11:59:48 +01:00
|
|
|
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user));
|
2020-07-06 11:19:01 +02:00
|
|
|
}
|
2020-10-30 12:33:51 +01:00
|
|
|
|
2021-07-14 18:02:04 +02:00
|
|
|
public isPublicOrIsMember(visibility: Visibility): boolean {
|
|
|
|
return !(visibility == "PRIVATE" || (this.isViewPublic && visibility != "PUBLIC"));
|
2020-11-01 16:41:56 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 22:58:53 +01:00
|
|
|
setProperties(id, type = null) {
|
2021-07-14 18:02:04 +02:00
|
|
|
this.properties.adminToolsCommunity = id;
|
2022-03-02 22:58:53 +01:00
|
|
|
if (type) {
|
2021-07-14 18:02:04 +02:00
|
|
|
this.properties.adminToolsPortalType = type;
|
|
|
|
} else {
|
|
|
|
ConnectHelper.setPortalTypeFromPid(id);
|
2020-12-11 19:34:50 +01:00
|
|
|
}
|
2020-12-18 16:31:21 +01:00
|
|
|
this.configurationService.initCommunityInformation(this.properties, this.properties.adminToolsCommunity);
|
|
|
|
}
|
2019-10-24 09:44:29 +02:00
|
|
|
}
|