|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import {Component} from '@angular/core';
|
|
|
|
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
|
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
|
|
|
|
|
|
|
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
|
|
|
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
|
|
|
@ -7,7 +7,6 @@ import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/env
|
|
|
|
|
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
|
|
|
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
|
|
|
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
|
|
|
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
|
|
|
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
|
|
|
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
|
|
|
|
import {properties} from '../environments/environment';
|
|
|
|
@ -20,6 +19,7 @@ import {CustomizationOptions} from "./openaireLibrary/connect/community/Customiz
|
|
|
|
|
import {LayoutService} from "./openaireLibrary/services/layout.service";
|
|
|
|
|
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
|
|
|
|
|
import {Meta} from "@angular/platform-browser";
|
|
|
|
|
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
//changeDetection: ChangeDetectionStrategy.Default,
|
|
|
|
@ -28,12 +28,12 @@ import {Meta} from "@angular/platform-browser";
|
|
|
|
|
styles: [`
|
|
|
|
|
`],
|
|
|
|
|
template: `
|
|
|
|
|
<div [class]="(community)?(community.id +'App communityApp'):'connectApp'">
|
|
|
|
|
<div [class]="(community)?(community.communityId +'App communityApp'):'connectApp'">
|
|
|
|
|
<navbar *ngIf="properties && showMenu && !community && header" [portal]="properties.dashboard" [onlyTop]=false
|
|
|
|
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user" [header]="header"
|
|
|
|
|
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="false" communityId="connect"></navbar>
|
|
|
|
|
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.id" [onlyTop]=false
|
|
|
|
|
[communityId]="community.id" [header]="header"
|
|
|
|
|
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.communityId" [onlyTop]=false
|
|
|
|
|
[communityId]="community.communityId" [header]="header"
|
|
|
|
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
|
|
|
|
[showMenu]=showMenu [properties]="properties" [enableSearch]="false"
|
|
|
|
|
searchRoute="/search/find/research-outcomes"
|
|
|
|
@ -50,15 +50,15 @@ import {Meta} from "@angular/platform-browser";
|
|
|
|
|
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
|
|
|
|
|
[URL]="properties.domain + properties.baseLink"
|
|
|
|
|
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
|
|
|
|
|
[name]="community.name" [description]="community.description">
|
|
|
|
|
[name]="(community.shortTitle) ? community.shortTitle : community.title" [description]="community.description">
|
|
|
|
|
</schema2jsonld>
|
|
|
|
|
<div class="custom-main-content">
|
|
|
|
|
<main>
|
|
|
|
|
<router-outlet></router-outlet>
|
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="subscribeAndInviteBtn" *ngIf="isClient && community">
|
|
|
|
|
<subscribe [communityId]="community.id"></subscribe>
|
|
|
|
|
<div id="subscribeAndInviteBtn" *ngIf="isClient && communityId && community">
|
|
|
|
|
<subscribe [communityId]="community.communityId"></subscribe>
|
|
|
|
|
<invite *ngIf="isManager" [longView]="false"></invite>
|
|
|
|
|
</div>
|
|
|
|
|
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
|
|
|
|
@ -77,10 +77,10 @@ import {Meta} from "@angular/platform-browser";
|
|
|
|
|
[properties]="properties"></bottom>
|
|
|
|
|
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
|
|
|
|
|
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
|
|
|
|
|
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"
|
|
|
|
|
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties"
|
|
|
|
|
[darkBackground]="true" [centered]="true"></bottom>
|
|
|
|
|
<role-verification *ngIf="community" service="connect"
|
|
|
|
|
[id]="community.id" [name]="community.name" [type]="'community'"></role-verification>
|
|
|
|
|
[id]="community.communityId" [name]="community.title" [type]="'community'"></role-verification>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ export class AppComponent {
|
|
|
|
|
userMenuItems: MenuItem[] = [];
|
|
|
|
|
menuItems: RootMenuItem [] = [];
|
|
|
|
|
bottomMenuItems: MenuItem[] = [];
|
|
|
|
|
public community = null;
|
|
|
|
|
public community:CommunityInfo = null;
|
|
|
|
|
properties: EnvProperties = properties;
|
|
|
|
|
showMenu: boolean = false;
|
|
|
|
|
communities = null;
|
|
|
|
@ -120,6 +120,7 @@ export class AppComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
console.log("aaap init")
|
|
|
|
|
if (this.properties.environment == "production" || this.properties.environment == "development") {
|
|
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(data => {
|
|
|
|
|
this._meta.updateTag({content: 'all', name: 'robots'});
|
|
|
|
@ -134,21 +135,27 @@ export class AppComponent {
|
|
|
|
|
}
|
|
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
|
this.user = user;
|
|
|
|
|
console.log(user, "call init")
|
|
|
|
|
this.init();
|
|
|
|
|
}, error => this.init()));
|
|
|
|
|
}, error => {
|
|
|
|
|
console.log(" user error call init")
|
|
|
|
|
this.init()}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get isManager() {
|
|
|
|
|
return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get isPrivate() {
|
|
|
|
|
return this.community && !ConnectHelper.isPrivate(this.community, this.user)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private init() {
|
|
|
|
|
let communityId: string = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
|
|
|
|
this.showMenu = false;
|
|
|
|
|
this.initAdminToolCommunity(communityId);
|
|
|
|
|
this.buildMenu(communityId);
|
|
|
|
|
this.communityId = communityId;
|
|
|
|
|
// this.communityId = communityId;
|
|
|
|
|
if (this.communityId === null) {
|
|
|
|
|
this.userManagementService.fixRedirectURL = properties.afterLoginRedirectLink;
|
|
|
|
|
} else {
|
|
|
|
@ -184,21 +191,43 @@ export class AppComponent {
|
|
|
|
|
}
|
|
|
|
|
public buildMenu(communityId: string) {
|
|
|
|
|
if (communityId) {
|
|
|
|
|
if (!this.community || this.community.communityId !== communityId) {
|
|
|
|
|
console.log(communityId)
|
|
|
|
|
if (!this.community || this.communityId !== communityId) {
|
|
|
|
|
console.log("new")
|
|
|
|
|
this.subscriptions.push(this._communityService.getCommunity(communityId).subscribe(community => {
|
|
|
|
|
if (community && !this.isPrivate(community)) {
|
|
|
|
|
this.community = {
|
|
|
|
|
if (community) {
|
|
|
|
|
/* this.community = {
|
|
|
|
|
id: community.communityId,
|
|
|
|
|
name: (community.shortTitle) ? community.shortTitle : community.title,
|
|
|
|
|
logoUrl: (community.isUpload) ? (properties.utilsService + '/download/' + community.logoUrl) : (StringUtils.urlPrefix(community.logoUrl) + community.logoUrl),
|
|
|
|
|
description: community.description
|
|
|
|
|
};
|
|
|
|
|
description: community.description,
|
|
|
|
|
status: community.status
|
|
|
|
|
};*/
|
|
|
|
|
this.community = community;
|
|
|
|
|
}else{
|
|
|
|
|
this.community = null;
|
|
|
|
|
this.communityId = null;
|
|
|
|
|
}
|
|
|
|
|
this.buildCommunityMenu();
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
console.log("same")
|
|
|
|
|
this.buildCommunityMenu();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.buildConnectMenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildCommunityMenu(){
|
|
|
|
|
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
|
|
|
|
|
this.communityId = this.community.communityId;
|
|
|
|
|
this.header = {
|
|
|
|
|
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
|
|
|
|
|
route: "/",
|
|
|
|
|
title: this.community.name,
|
|
|
|
|
logoUrl: this.community.logoUrl,
|
|
|
|
|
logoSmallUrl: this.community.logoUrl,
|
|
|
|
|
title: (this.community.shortTitle) ? this.community.shortTitle : this.community.title,
|
|
|
|
|
logoUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
|
|
|
|
|
logoSmallUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
|
|
|
|
|
position: 'left',
|
|
|
|
|
badge: true
|
|
|
|
|
};
|
|
|
|
@ -239,7 +268,7 @@ export class AppComponent {
|
|
|
|
|
if (this.isManager) {
|
|
|
|
|
this.menuItems.push(
|
|
|
|
|
{
|
|
|
|
|
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + community.communityId, "", false, [], [], {}),
|
|
|
|
|
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + this.community.communityId, "", false, [], [], {}),
|
|
|
|
|
items: []
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -261,44 +290,31 @@ export class AppComponent {
|
|
|
|
|
}
|
|
|
|
|
this.showMenu = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.showPrivateOrNoCommunity(community ? community.status : null);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
this.showMenu = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.buildConnectMenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isPrivate(community) {
|
|
|
|
|
return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isCommunityCurator(this.user) || Session.isManager("community", community.communityId, this.user))))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showPrivateOrNoCommunity(restrictedData: string) {
|
|
|
|
|
console.log(this.community && this.community.status?this.community.status:"no community");
|
|
|
|
|
this.communityId = null;
|
|
|
|
|
this.community = null;
|
|
|
|
|
this.properties.adminToolsPortalType = "connect";
|
|
|
|
|
this.configurationService.initCommunityInformation(this.properties, "connect");
|
|
|
|
|
this.initAdminToolCommunity(null);
|
|
|
|
|
this.buildConnectMenu(true);
|
|
|
|
|
if (restrictedData == "manager") {
|
|
|
|
|
if (this.community && this.community.status == "manager") {
|
|
|
|
|
if (!this.user && typeof location !== 'undefined') {
|
|
|
|
|
console.log("no user")
|
|
|
|
|
this.router.navigate(['/user-info'], {
|
|
|
|
|
queryParams: {
|
|
|
|
|
"errorCode": LoginErrorCodes.NOT_LOGIN,
|
|
|
|
|
"redirectUrl": location.pathname+ location.search + location.hash
|
|
|
|
|
}
|
|
|
|
|
}, queryParamsHandling: "merge"
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.router.navigate(['/error'], {queryParams: {'page': -1}});
|
|
|
|
|
this.router.navigate(['/'], { queryParamsHandling: "merge" });
|
|
|
|
|
}
|
|
|
|
|
}else if (this.community && this.community.status == "hidden") {
|
|
|
|
|
this.router.navigate(['/error']);
|
|
|
|
|
}else{
|
|
|
|
|
this.router.navigate(['/'], this.community && this.community.status ? { queryParamsHandling: "merge" } : {});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.router.navigate(['/error'], restrictedData ? {queryParams: {'page': -1}} : {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildConnectMenu(restrictedData: boolean = false) {
|
|
|
|
|
let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu";
|
|
|
|
|
this.header = {
|
|
|
|
|