[Connect | Trunk]: 1. Add new roles functionllities (subscribe - role-verification). 2. Comment customization. 3. Refactor getting community logic

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@60454 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-02-19 17:52:12 +00:00
parent 25e8dde7d5
commit 57cd810c3e
27 changed files with 725 additions and 1098 deletions

View File

@ -18,7 +18,6 @@ const routes: Routes = [
{ path: 'about/faq', loadChildren: './learn-how/faqs/faqs.module#FaqsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'about/faq', loadChildren: './learn-how/faqs/faqs.module#FaqsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'contact-us', loadChildren: './contact/contact.module#ContactModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'contact-us', loadChildren: './contact/contact.module#ContactModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'invite', loadChildren: './utils/subscribe/invite/invite.module#InviteModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'invite', loadChildren: './utils/subscribe/invite/invite.module#InviteModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'verify/:id', loadChildren: './verification-manager/verification-manager.module#VerificationManagerModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'content', loadChildren: './content/contentPage.module#ContentPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]}, { path: 'content', loadChildren: './content/contentPage.module#ContentPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]},
{ path: 'organizations', loadChildren: './htmlPages/organizations/organizationsPage.module#OrganizationsPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]}, { path: 'organizations', loadChildren: './htmlPages/organizations/organizationsPage.module#OrganizationsPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]},
{ path: 'publications', loadChildren: './htmlPages/publications/publications-page.module#PublicationsPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]}, { path: 'publications', loadChildren: './htmlPages/publications/publications-page.module#PublicationsPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }, canActivate:[IsCommunity]},

View File

@ -7,7 +7,6 @@ import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/env
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service"; import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import {Session, User} from './openaireLibrary/login/utils/helper.class'; import {Session, User} from './openaireLibrary/login/utils/helper.class';
import {ConnectHelper} from './openaireLibrary/connect/connectHelper'; import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from "./openaireLibrary/services/user-management.service"; import {UserManagementService} from "./openaireLibrary/services/user-management.service";
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service"; import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
@ -15,6 +14,7 @@ import {properties} from '../environments/environment';
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component"; import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {CommunityService} from "./openaireLibrary/connect/community/community.service"; import {CommunityService} from "./openaireLibrary/connect/community/community.service";
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
@Component({ @Component({
//changeDetection: ChangeDetectionStrategy.Default, //changeDetection: ChangeDetectionStrategy.Default,
@ -35,15 +35,17 @@ import {CommunityService} from "./openaireLibrary/connect/community/community.se
[showHomeMenuItem]="false"></navbar> [showHomeMenuItem]="false"></navbar>
<customization *ngIf="properties && communityId && communityId.length > 0" [properties]="properties" <customization *ngIf="properties && communityId && communityId.length > 0" [properties]="properties"
[communityId]="communityId"></customization> [communityId]="communityId"></customization>
<schema2jsonld *ngIf="properties && showMenu && !community" [URL]="properties.domain + properties.baseLink" <schema2jsonld *ngIf="properties && showMenu && !community" [URL]="properties.domain + properties.baseLink"
[logoURL]="properties.domain + properties.baseLink+'/assets/common-assets/logo-small-connect.png'" type="home" [logoURL]="properties.domain + properties.baseLink+'/assets/common-assets/logo-small-connect.png'"
type="home"
[searchActionRoute]="properties.searchLinkToCommunities" [searchAction]="true" [searchActionRoute]="properties.searchLinkToCommunities" [searchAction]="true"
name="OpenAIRE Connect" name="OpenAIRE Connect"
description="Build a Gateway for your Community: Turn Open Science into Practice. It takes your open and linked research outcomes."> description="Build a Gateway for your Community: Turn Open Science into Practice. It takes your open and linked research outcomes.">
</schema2jsonld> </schema2jsonld>
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community" [URL]="properties.domain + properties.baseLink" <schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
[URL]="properties.domain + properties.baseLink"
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults" [logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
[name]="community.name" [description]="community.description" > [name]="community.name" [description]="community.description">
</schema2jsonld> </schema2jsonld>
<div class="custom-main-content"> <div class="custom-main-content">
<main> <main>
@ -52,7 +54,7 @@ import {CommunityService} from "./openaireLibrary/connect/community/community.se
</div> </div>
<div id="subscribeAndInviteBtn" *ngIf="isClient && properties && community"> <div id="subscribeAndInviteBtn" *ngIf="isClient && properties && community">
<subscribe [communityId]="community.id" [properties]="properties"></subscribe> <subscribe [communityId]="community.id" [properties]="properties"></subscribe>
<invite *ngIf="managerOfCommunities" [longView]=false [buttonSizeSmall]=false [properties]="properties"></invite> <invite *ngIf="isManager" [longView]=false [buttonSizeSmall]=false [properties]="properties"></invite>
</div> </div>
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback--> <!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
<cookie-law *ngIf="isClient" position="bottom"> <cookie-law *ngIf="isClient" position="bottom">
@ -60,7 +62,7 @@ import {CommunityService} from "./openaireLibrary/connect/community/community.se
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible. experience possible.
By using the OpenAIRE portal you accept our use of cookies. <a By using the OpenAIRE portal you accept our use of cookies. <a
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon"> href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03"
points="7 4 13 10 7 16"></polyline></svg> points="7 4 13 10 7 16"></polyline></svg>
@ -72,6 +74,8 @@ import {CommunityService} from "./openaireLibrary/connect/community/community.se
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true" [showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties" [communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"
[darkBackground]="true" [centered]="true"></bottom> [darkBackground]="true" [centered]="true"></bottom>
<role-verification *ngIf="community" service="connect"
[id]="community.id" [name]="community.name" [type]="'community'"></role-verification>
</div> </div>
` `
@ -89,7 +93,6 @@ export class AppComponent {
showMenu: boolean = false; showMenu: boolean = false;
communities = null; communities = null;
subscriberOfCommunities = false; subscriberOfCommunities = false;
managerOfCommunities = false;
user: User; user: User;
communityId: string = ""; communityId: string = "";
header: Header; header: Header;
@ -97,7 +100,7 @@ export class AppComponent {
subscriptions = []; subscriptions = [];
// community: {id:string, name:string, logoUrl:string}; // community: {id:string, name:string, logoUrl:string};
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService, private _communitiesService: CommunitiesService,
private router: Router, private userManagementService: UserManagementService, private router: Router, private userManagementService: UserManagementService,
private configurationService: ConfigurationService, private _communityService: CommunityService) { private configurationService: ConfigurationService, private _communityService: CommunityService) {
this.subscriptions.push(router.events.forEach((event) => { this.subscriptions.push(router.events.forEach((event) => {
@ -106,6 +109,7 @@ export class AppComponent {
} }
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
this.subscriptions.forEach(subscription => { this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) { if (subscription instanceof Subscriber) {
@ -115,7 +119,6 @@ export class AppComponent {
this._communitiesService.clearSubscriptions(); this._communitiesService.clearSubscriptions();
this.userManagementService.clearSubscriptions(); this.userManagementService.clearSubscriptions();
this.configurationService.clearSubscriptions(); this.configurationService.clearSubscriptions();
this._subscribeService.clearSubscriptions();
this._communityService.clearSubscriptions(); this._communityService.clearSubscriptions();
} }
@ -134,6 +137,11 @@ export class AppComponent {
},error => this.init())); },error => this.init()));
} }
get isManager() {
return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))
}
private init() { private init() {
let communityId: string = ""; let communityId: string = "";
@ -160,37 +168,10 @@ export class AppComponent {
} }
public buildMenu(communityId: string) { public buildMenu(communityId: string) {
let community = null; if(communityId) {
this.community = null; if (!this.community || this.community.communityId !== communityId) {
this.subscriptions.push(this._communitiesService.getCommunitiesState().subscribe( this.subscriptions.push(this._communityService.getCommunityNew(communityId).subscribe(community => {
communities => { if (community && community.status !== 'hidden') {
if (!communities || communities.length == 0 && communityId !== null && communityId !== '') {
return;
}
for (var com of communities) {
if ((communityId && communityId != "" && com.communityId == communityId
&& community != null) ||
(
!(communityId && communityId != "" && com.communityId == communityId)
&&
this.managerOfCommunities && this.subscriberOfCommunities)) {
break;
}
if (this.user && com['status'] != "hidden") {
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) ||(this.communityId && Session.isManager('community', this.communityId, this.user))) {
this.managerOfCommunities = true;
} else if (com.managers.indexOf(this.user.email) != -1) {
this.managerOfCommunities = true;
}
}
if (communityId && communityId != "" && com.communityId == communityId) {
community = com;
let isCommunityManager: boolean = false;
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))) {
isCommunityManager = true;
} else if (this.user && com.managers.indexOf(this.user.email) != -1) {
isCommunityManager = true;
}
this.community = { this.community = {
id: community.communityId, id: community.communityId,
name: (community.shortTitle) ? community.shortTitle : community.title, name: (community.shortTitle) ? community.shortTitle : community.title,
@ -240,80 +221,86 @@ export class AppComponent {
new MenuItem("", "Projects and funding Opportunities", "", "/projects", false, [], ["/projects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}), new MenuItem("", "Projects and funding Opportunities", "", "/projects", false, [], ["/projects"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
] ]
}); });
if (isCommunityManager) { if (this.isManager) {
this.menuItems.push( this.menuItems.push(
{ {
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL +'/dashboard?communityId=' + community.communityId, "", false, [], [], {}), rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL +'/dashboard?communityId=' + community.communityId, "", false, [], [], {}),
items: [] items: []
}); });
} }
this.bottomMenuItems = [
} new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
}
if (community == null) {
this.header = {
route: "/",
url: null,
title: 'connect',
logoUrl: this.logoPath + 'logo-large-connect.png',
logoSmallUrl:this.logoPath + 'logo-small-connect.png',
position:'left',
badge:true
};
this.menuItems = [];
this.menuItems.push({
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], ["/about/learn-how"], {}),
items: [
new MenuItem("", "Learn the process", "", "/about/learn-how", false, [], ["/about/learn-in-depth"], {}),
new MenuItem("", "Publications", "", "/publications", false, [], ["/publications"], {}),
new MenuItem("", "Roadmap", "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard", "", false, [], [], {}),
new MenuItem("", "FAQs", "", "/about/faq", false, [], ["/about/faq"], {})
]
});
this.menuItems.push({
rootItem: new MenuItem("communities", "Communities", "", "/search/find/communities", false, [], ['/search/find/communities'], {}),
items: []
});
this.menuItems.push({
rootItem: new MenuItem("contact-us", "Contact us", "", "/contact-us", false, [], ['/contact-us'], {}),
items: []
});
this.bottomMenuItems = [
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
];
this.userMenuItems = [];
if (Session.isPortalAdministrator(this.user)) {
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
"", false, [], [], {}))
}
if (this.user) {
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
"/myCommunities", false, [], [], {}));
}
} else {
this.bottomMenuItems = [
new MenuItem("", "Supporting organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
];
if (this.properties.showContent) {
this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {}));
}
if(this.user) {
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Invite users", "", "/invite", false, [], [], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
]; ];
if (this.managerOfCommunities) { if (this.properties.showContent) {
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {})) this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {}));
} }
if(this.user) {
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
new MenuItem("", "Invite users", "", "/invite", false, [], [], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
];
if (this.isManager) {
this.userMenuItems.push(new MenuItem("", "Support", "https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611", "", false, [], [], {}))
}
}
this.showMenu = true;
} else {
this.navigateToError();
} }
} }));
} else {
this.showMenu = true; this.showMenu = true;
})); }
} else {
this.header = {
route: "/",
url: null,
title: 'connect',
logoUrl: this.logoPath + 'logo-large-connect.png',
logoSmallUrl:this.logoPath + 'logo-small-connect.png',
position:'left',
badge:true
};
this.menuItems = [];
this.menuItems.push({
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], ["/about/learn-how"], {}),
items: [
new MenuItem("", "Learn the process", "", "/about/learn-how", false, [], ["/about/learn-in-depth"], {}),
new MenuItem("", "Publications", "", "/publications", false, [], ["/publications"], {}),
new MenuItem("", "Roadmap", "https://trello.com/b/yfzUz0kp/openaire-connect-dashboard", "", false, [], [], {}),
new MenuItem("", "FAQs", "", "/about/faq", false, [], ["/about/faq"], {})
]
});
this.menuItems.push({
rootItem: new MenuItem("communities", "Communities", "", "/search/find/communities", false, [], ['/search/find/communities'], {}),
items: []
});
this.menuItems.push({
rootItem: new MenuItem("contact-us", "Contact us", "", "/contact-us", false, [], ['/contact-us'], {}),
items: []
});
this.bottomMenuItems = [
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
];
this.userMenuItems = [];
if (Session.isPortalAdministrator(this.user)) {
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
"", false, [], [], {}))
}
if (this.user) {
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
"/myCommunities", false, [], [], {}));
}
this.showMenu = true;
}
}
private navigateToError() {
this.router.navigate(['/error'], {queryParams: {'page': this.properties.baseLink + this.router.url}});
} }
} }

View File

@ -23,15 +23,16 @@ import {SubscribeModule} from './utils/subscribe/subscribe.module';
import {CustomizationModule} from "./utils/customization/customization.module"; import {CustomizationModule} from "./utils/customization/customization.module";
import {HttpInterceptorService} from "./openaireLibrary/http-interceptor.service"; import {HttpInterceptorService} from "./openaireLibrary/http-interceptor.service";
import {InviteBasicModule} from "./utils/subscribe/invite/inviteBasic.module"; import {InviteBasicModule} from "./utils/subscribe/invite/inviteBasic.module";
import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service";
import {PageURLResolverModule} from "./openaireLibrary/utils/pageURLResolver.module"; import {PageURLResolverModule} from "./openaireLibrary/utils/pageURLResolver.module";
import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module"; import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service"; import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service"; import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service";
import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard"; import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard";
import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service";
import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, SharedModule,
CommonModule, CommonModule,
@ -47,12 +48,12 @@ import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.
AppRoutingModule, AppRoutingModule,
BrowserTransferStateModule, BrowserTransferStateModule,
BrowserAnimationsModule, BrowserAnimationsModule,
PageURLResolverModule, Schema2jsonldModule PageURLResolverModule, Schema2jsonldModule, RoleVerificationModule
], ],
declarations: [ AppComponent, OpenaireErrorPageComponent], declarations: [ AppComponent, OpenaireErrorPageComponent],
exports: [ AppComponent ], exports: [ AppComponent ],
providers:[ providers:[
EnvironmentSpecificResolver, CommunitiesService, LayoutService, SubscribeService, IsCommunity, EnvironmentSpecificResolver, CommunitiesService, LayoutService, IsCommunity, SubscribeService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: HttpInterceptorService, useClass: HttpInterceptorService,

View File

@ -3,7 +3,6 @@ import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service'; import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo'; import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
@ -47,7 +46,6 @@ export class CommunitiesComponent {
private _title: Title, private _title: Title,
private _piwikService: PiwikService, private _piwikService: PiwikService,
private _communitiesService: CommunitiesService, private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService,
private helper: HelperService, private helper: HelperService,
private seoService: SEOService) { private seoService: SEOService) {

View File

@ -275,8 +275,8 @@
</div> </div>
</div> </div>
<div *ngIf="isRouteEnabled('/curators')" [class]="community.managers ? 'uk-margin-small-bottom' : ''"> <div *ngIf="isRouteEnabled('/curators')" class="uk-margin-small-bottom">
<curators [longView]="false" [managers]="community.managers" [communityId]="communityId"></curators> <curators [longView]="false"></curators>
</div> </div>
<div [class]="community.date || subscribers ? 'uk-margin-small-bottom' : ''"> <div [class]="community.date || subscribers ? 'uk-margin-small-bottom' : ''">
<span *ngIf="community.date" class="uk-margin-right"> <span *ngIf="community.date" class="uk-margin-right">

View File

@ -38,68 +38,68 @@ export class CommunityComponent {
public projectTotal = null; public projectTotal = null;
public contentProviderTotal = null; public contentProviderTotal = null;
public projectsCalculated: boolean = false; public projectsCalculated: boolean = false;
public contentProvidersCalculated: boolean = false; public contentProvidersCalculated: boolean = false;
params: any = {}; params: any = {};
properties: EnvProperties; properties: EnvProperties = properties;
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
// Request results of each tab only the one time (first time tab is clicked) // Request results of each tab only the one time (first time tab is clicked)
private reloadPublications: boolean = true; private reloadPublications: boolean = true;
private reloadDatasets: boolean = true; private reloadDatasets: boolean = true;
private reloadSoftware: boolean = true; private reloadSoftware: boolean = true;
private reloadOrps: boolean = true; private reloadOrps: boolean = true;
// Variables for publications, research data, projects, content providers, related content providers tabs // Variables for publications, research data, projects, content providers, related content providers tabs
public fetchPublications: FetchResearchResults; public fetchPublications: FetchResearchResults;
public fetchDatasets: FetchResearchResults; public fetchDatasets: FetchResearchResults;
public fetchSoftware: FetchResearchResults; public fetchSoftware: FetchResearchResults;
public fetchOrps: FetchResearchResults; public fetchOrps: FetchResearchResults;
public searchNumber: number = 5; public searchNumber: number = 5;
@Input() communityId = null; @Input() communityId = null;
public community = null; public community = null;
public communityInfo = null; public communityInfo = null;
public showLoading: boolean = true; public showLoading: boolean = true;
masterZenodoCommunity = null; masterZenodoCommunity = null;
zenodoCommunityIdS = []; zenodoCommunityIdS = [];
showAllDescription = false; showAllDescription = false;
public thresholdDescription: number = 500; public thresholdDescription: number = 500;
public descriptionDiff: number = 100; public descriptionDiff: number = 100;
subscribers: number = 0; subscribers: number = 0;
// TODO Unsubscribe // TODO Unsubscribe
subs: Subscription[] = []; subs: Subscription[] = [];
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null; @ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
public activeTab = "summary"; public activeTab = "summary";
public show: string = 'overview'; public show: string = 'overview';
public analyticsActiveTab:string = ""; public analyticsActiveTab: string = "";
public analyticsChecked: boolean = false; public analyticsChecked: boolean = false;
searchLinkToResults: string = null; searchLinkToResults: string = null;
searchLinkToProjects: string = null; searchLinkToProjects: string = null;
searchLinkToDataProviders: string = null; searchLinkToDataProviders: string = null;
searchLinkToAdvancedResults: string = null; searchLinkToAdvancedResults: string = null;
shareInZenodoPage: string = null; shareInZenodoPage: string = null;
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
private user: User; private user: User;
@ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent = null; @ViewChild(SubscribeComponent) subscribeComponent: SubscribeComponent = null;
//Search Form //Search Form
selectedEntity; selectedEntity;
selectedEntitySimpleUrl; selectedEntitySimpleUrl;
selectedEntityAdvancedUrl; selectedEntityAdvancedUrl;
keyword:string =""; keyword: string = "";
customFilter; customFilter;
placeholderText="Search by title, author, abstract, DOI, orcid... "; placeholderText = "Search by title, author, abstract, DOI, orcid... ";
constructor( constructor(
private element: ElementRef, private element: ElementRef,
private route: ActivatedRoute, private route: ActivatedRoute,
@ -117,45 +117,44 @@ export class CommunityComponent {
private _zenodoCommunitieService: ZenodoCommunitiesService, private _zenodoCommunitieService: ZenodoCommunitiesService,
private seoService: SEOService, private seoService: SEOService,
private userManagementService: UserManagementService) { private userManagementService: UserManagementService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community"; var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect"; var title = "OpenAIRE - Connect";
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title); this._title.setTitle(title);
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService); this.fetchDatasets = new FetchResearchResults(this._searchResearchResultsService);
this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService); this.fetchSoftware = new FetchResearchResults(this._searchResearchResultsService);
this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService); this.fetchOrps = new FetchResearchResults(this._searchResearchResultsService);
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties;
this.searchLinkToResults = this.properties.searchLinkToResults; this.searchLinkToResults = this.properties.searchLinkToResults;
this.searchLinkToProjects = this.properties.searchLinkToProjects; this.searchLinkToProjects = this.properties.searchLinkToProjects;
this.searchLinkToDataProviders = this.properties.searchLinkToDataProviders; this.searchLinkToDataProviders = this.properties.searchLinkToDataProviders;
this.searchLinkToAdvancedResults = this.properties.searchLinkToAdvancedResults; this.searchLinkToAdvancedResults = this.properties.searchLinkToAdvancedResults;
this.shareInZenodoPage = this.properties.shareInZenodoPage; this.shareInZenodoPage = this.properties.shareInZenodoPage;
this.url =properties.domain + properties.baseLink + this._router.url; this.url = properties.domain + properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url, false); this.seoService.createLinkForCanonicalURL(this.url, false);
this._meta.updateTag({content: this.url}, "property='og:url'"); this._meta.updateTag({content: this.url}, "property='og:url'");
this.subs.push(this.userManagementService.getUserInfo().subscribe(user => { this.subs.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
})); }));
if (this.communityId != null && this.communityId != '') { this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe( community => {
community => { if(community) {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
HelperFunctions.scroll(); HelperFunctions.scroll();
} }
this.community = community; this.community = community;
if(community.description != null && (community.description.length - this.thresholdDescription <= this.descriptionDiff)) { if (community.description != null && (community.description.length - this.thresholdDescription <= this.descriptionDiff)) {
this.thresholdDescription = community.description.length; this.thresholdDescription = community.description.length;
} }
if (this.properties.environment == "development") { if (this.properties.environment == "development") {
this.params = {communityId: community.communityId}; this.params = {communityId: community.communityId};
} }
@ -184,54 +183,52 @@ export class CommunityComponent {
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error); this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
} }
)); ));
//console.log(community);
}));
this.countResearchResults("publication");
this.countResearchResults("dataset");
this.countResearchResults("software");
this.countResearchResults("other");
this.subs.push(this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
projectTotal => {
this.projectTotal = projectTotal;
},
error => {
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
},
() => {
this.projectsCalculated = true;
} }
)); }));
this.subs.push(this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe( this.countResearchResults("publication");
contentProviderTotal => { this.countResearchResults("dataset");
this.contentProviderTotal = contentProviderTotal; this.countResearchResults("software");
//console.log(contentProviderTotal); this.countResearchResults("other");
},
error => { this.subs.push(this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
this.handleError("Error getting number of content providers for community with id: " + this.communityId, error); projectTotal => {
}, this.projectTotal = projectTotal;
() => { },
this.contentProvidersCalculated = true; error => {
} this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
)); },
this.subs.push(this.config.communityInformationState.subscribe( () => {
res => { this.projectsCalculated = true;
this.communityInfo = res; }
}, ));
error => {
//console.log(error) this.subs.push(this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
this.handleError("Error getting community with id: " + this.communityId, error); contentProviderTotal => {
} this.contentProviderTotal = contentProviderTotal;
)); //console.log(contentProviderTotal);
} },
error => {
this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
},
() => {
this.contentProvidersCalculated = true;
}
));
this.subs.push(this.config.communityInformationState.subscribe(
res => {
this.communityInfo = res;
},
error => {
//console.log(error)
this.handleError("Error getting community with id: " + this.communityId, error);
}
));
} }
private searchPublications(page: number, size: number) { private searchPublications(page: number, size: number) {
this.setActiveTab("publication"); this.setActiveTab("publication");
if (this.reloadPublications && if (this.reloadPublications &&
(this.fetchPublications.searchUtils.status == this.errorCodes.LOADING || (this.fetchPublications.searchUtils.status == this.errorCodes.LOADING ||
(this.fetchPublications.searchUtils.status == this.errorCodes.DONE && this.fetchPublications.searchUtils.totalResults > 0) (this.fetchPublications.searchUtils.status == this.errorCodes.DONE && this.fetchPublications.searchUtils.totalResults > 0)
@ -241,10 +238,10 @@ export class CommunityComponent {
} }
this.reloadPublications = false; this.reloadPublications = false;
} }
private searchDatasets(page: number, size: number) { private searchDatasets(page: number, size: number) {
this.setActiveTab("dataset"); this.setActiveTab("dataset");
if (this.reloadDatasets && if (this.reloadDatasets &&
(this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING || (this.fetchDatasets.searchUtils.status == this.errorCodes.LOADING ||
(this.fetchDatasets.searchUtils.status == this.errorCodes.DONE && this.fetchDatasets.searchUtils.totalResults > 0) (this.fetchDatasets.searchUtils.status == this.errorCodes.DONE && this.fetchDatasets.searchUtils.totalResults > 0)
@ -254,10 +251,10 @@ export class CommunityComponent {
} }
this.reloadDatasets = false; this.reloadDatasets = false;
} }
private searchSoftware(page: number, size: number) { private searchSoftware(page: number, size: number) {
this.setActiveTab("software"); this.setActiveTab("software");
if (this.reloadSoftware && if (this.reloadSoftware &&
(this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING || (this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
(this.fetchSoftware.searchUtils.status == this.errorCodes.DONE && this.fetchSoftware.searchUtils.totalResults > 0) (this.fetchSoftware.searchUtils.status == this.errorCodes.DONE && this.fetchSoftware.searchUtils.totalResults > 0)
@ -267,10 +264,10 @@ export class CommunityComponent {
} }
this.reloadSoftware = false; this.reloadSoftware = false;
} }
private searchOrps(page: number, size: number) { private searchOrps(page: number, size: number) {
this.setActiveTab("other"); this.setActiveTab("other");
if (this.reloadOrps && if (this.reloadOrps &&
(this.fetchOrps.searchUtils.status == this.errorCodes.LOADING || (this.fetchOrps.searchUtils.status == this.errorCodes.LOADING ||
(this.fetchOrps.searchUtils.status == this.errorCodes.DONE && this.fetchOrps.searchUtils.totalResults > 0) (this.fetchOrps.searchUtils.status == this.errorCodes.DONE && this.fetchOrps.searchUtils.totalResults > 0)
@ -280,10 +277,10 @@ export class CommunityComponent {
} }
this.reloadOrps = false; this.reloadOrps = false;
} }
private countResearchResults(resultType: string) { private countResearchResults(resultType: string) {
let fetch: FetchResearchResults; let fetch: FetchResearchResults;
if (resultType == "publication") { if (resultType == "publication") {
fetch = this.fetchPublications; fetch = this.fetchPublications;
} else if (resultType == "dataset") { } else if (resultType == "dataset") {
@ -293,7 +290,7 @@ export class CommunityComponent {
} else if (resultType == "other") { } else if (resultType == "other") {
fetch = this.fetchOrps; fetch = this.fetchOrps;
} }
fetch.getNumForCommunity(resultType, this.communityId, this.properties); fetch.getNumForCommunity(resultType, this.communityId, this.properties);
} }
@ -306,19 +303,19 @@ export class CommunityComponent {
this.fetchOrps.clearSubscriptions(); this.fetchOrps.clearSubscriptions();
this.fetchSoftware.clearSubscriptions(); this.fetchSoftware.clearSubscriptions();
} }
isEntityEnabled(entity: string) { isEntityEnabled(entity: string) {
return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled'] === true); return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled'] === true);
} }
isRouteEnabled(route: string) { isRouteEnabled(route: string) {
return this.communityInfo.pages.some(x => x['route'] == route && x['isEnabled'] === true); return this.communityInfo.pages.some(x => x['route'] == route && x['isEnabled'] === true);
} }
showInvite() { showInvite() {
return this.isManager(); return this.isManager();
} }
isManager() { isManager() {
if (!this.user) { if (!this.user) {
return false; return false;
@ -330,11 +327,11 @@ export class CommunityComponent {
} }
return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || index != -1; return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || index != -1;
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Community (component): " + message, error); console.error("Community (component): " + message, error);
} }
getSearchPlaceHolder() { getSearchPlaceHolder() {
var entities = []; var entities = [];
if (this.isEntityEnabled("publication")) { if (this.isEntityEnabled("publication")) {
@ -351,7 +348,7 @@ export class CommunityComponent {
} }
return "Search" + ((entities.length > 0) ? (" for " + entities.join(', ') + "...") : ""); return "Search" + ((entities.length > 0) ? (" for " + entities.join(', ') + "...") : "");
} }
countOtherGraphs() { countOtherGraphs() {
var count = 0; var count = 0;
if (this.statistics && this.statistics.allowedEntities) { if (this.statistics && this.statistics.allowedEntities) {
@ -363,11 +360,11 @@ export class CommunityComponent {
} }
return count; return count;
} }
createParams(param) { createParams(param) {
return StringUtils.quote(StringUtils.URIEncode(param)); return StringUtils.quote(StringUtils.URIEncode(param));
} }
private setActiveTab(entityType: string) { private setActiveTab(entityType: string) {
if (entityType == "other") { if (entityType == "other") {
this.activeTab = "orp"; this.activeTab = "orp";
@ -375,15 +372,15 @@ export class CommunityComponent {
this.activeTab = entityType; this.activeTab = entityType;
} }
} }
public getParamsForSearchLink(type: string = "") { public getParamsForSearchLink(type: string = "") {
if(type) { if (type) {
return this.routerHelper.createQueryParams(['type', 'qf', 'sortBy'], [type, 'false', 'resultdateofacceptance,descending']); return this.routerHelper.createQueryParams(['type', 'qf', 'sortBy'], [type, 'false', 'resultdateofacceptance,descending']);
} else { } else {
return {}; return {};
} }
} }
private getEntityName(entityType: string, plural: boolean, full: boolean): string { private getEntityName(entityType: string, plural: boolean, full: boolean): string {
if (entityType == "publication") { if (entityType == "publication") {
return "publication" + (plural ? "s" : ""); return "publication" + (plural ? "s" : "");
@ -395,56 +392,56 @@ export class CommunityComponent {
return (full ? ("other research product" + (plural ? "s" : "")) : "other"); return (full ? ("other research product" + (plural ? "s" : "")) : "other");
} }
} }
public buildProjectsAndContentProvidesTooltip(): string { public buildProjectsAndContentProvidesTooltip(): string {
let tooltipContent: string = "<div class='uk-margin'>"; let tooltipContent: string = "<div class='uk-margin'>";
if(this.projectTotal != null && this.projectTotal > 0 && this.isEntityEnabled('project') && this.isRouteEnabled(this.searchLinkToProjects)) { if (this.projectTotal != null && this.projectTotal > 0 && this.isEntityEnabled('project') && this.isRouteEnabled(this.searchLinkToProjects)) {
tooltipContent += "<span class='uk-text-bold'>Projects</span>"; tooltipContent += "<span class='uk-text-bold'>Projects</span>";
} }
if(this.projectTotal != null && this.projectTotal > 0 && this.isEntityEnabled('project') && this.isRouteEnabled(this.searchLinkToProjects) if (this.projectTotal != null && this.projectTotal > 0 && this.isEntityEnabled('project') && this.isRouteEnabled(this.searchLinkToProjects)
&& (this.contentProviderTotal != null && this.contentProviderTotal > 0 && this.isEntityEnabled('datasource') && this.isRouteEnabled(this.searchLinkToDataProviders))) { && (this.contentProviderTotal != null && this.contentProviderTotal > 0 && this.isEntityEnabled('datasource') && this.isRouteEnabled(this.searchLinkToDataProviders))) {
tooltipContent += " and "; tooltipContent += " and ";
} }
if(this.contentProviderTotal != null && this.contentProviderTotal > 0 && this.isEntityEnabled('datasource') && this.isRouteEnabled(this.searchLinkToDataProviders)) { if (this.contentProviderTotal != null && this.contentProviderTotal > 0 && this.isEntityEnabled('datasource') && this.isRouteEnabled(this.searchLinkToDataProviders)) {
tooltipContent += "<span class='uk-text-bold'>Content Providers</span>"; tooltipContent += "<span class='uk-text-bold'>Content Providers</span>";
} }
tooltipContent += " have been selected as relevant for your community by the gateway curators."; tooltipContent += " have been selected as relevant for your community by the gateway curators.";
tooltipContent += "</div>"; tooltipContent += "</div>";
return tooltipContent; return tooltipContent;
} }
public buildZenodoCommunitiesTooltip(): string { public buildZenodoCommunitiesTooltip(): string {
let tooltipContent: string = "<div class='uk-margin'>"; let tooltipContent: string = "<div class='uk-margin'>";
tooltipContent += "<span class='uk-text-bold'>Zenodo</span> is a catch-all repository for OpenAIRE."; tooltipContent += "<span class='uk-text-bold'>Zenodo</span> is a catch-all repository for OpenAIRE.";
tooltipContent += "<div class='uk-margin-small-top'>A <span class='uk-text-bold'>Zenodo Community</span> is created and curated by Zenodo users.</div>"; tooltipContent += "<div class='uk-margin-small-top'>A <span class='uk-text-bold'>Zenodo Community</span> is created and curated by Zenodo users.</div>";
tooltipContent += "</div>"; tooltipContent += "</div>";
return tooltipContent; return tooltipContent;
} }
entityChanged($event){ entityChanged($event) {
this.selectedEntity = $event.entity; this.selectedEntity = $event.entity;
this.selectedEntitySimpleUrl = $event.simpleUrl; this.selectedEntitySimpleUrl = $event.simpleUrl;
this.selectedEntityAdvancedUrl = $event.advancedUrl; this.selectedEntityAdvancedUrl = $event.advancedUrl;
if(this.selectedEntity == 'result'){ if (this.selectedEntity == 'result') {
this.placeholderText ="Search by title, author, abstract, DOI, orcid... "; this.placeholderText = "Search by title, author, abstract, DOI, orcid... ";
}else if(this.selectedEntity == 'project') { } else if (this.selectedEntity == 'project') {
this.placeholderText = "Search by project title, grant id, funder..."; this.placeholderText = "Search by project title, grant id, funder...";
}else if(this.selectedEntity == 'dataprovider') { } else if (this.selectedEntity == 'dataprovider') {
this.placeholderText = "Search by name..."; this.placeholderText = "Search by name...";
}else{ } else {
this.placeholderText = "Search community content"; this.placeholderText = "Search community content";
} }
} }
goTo(simple:boolean){ goTo(simple: boolean) {
let url = (simple)?this.selectedEntitySimpleUrl:this.selectedEntityAdvancedUrl; let url = (simple) ? this.selectedEntitySimpleUrl : this.selectedEntityAdvancedUrl;
let parameterNames = []; let parameterNames = [];
let parameterValues = []; let parameterValues = [];
if(this.keyword.length > 0) { if (this.keyword.length > 0) {
parameterNames.push("fv0"); parameterNames.push("fv0");
parameterValues.push(this.keyword); parameterValues.push(this.keyword);
parameterNames.push("f0"); parameterNames.push("f0");
@ -452,11 +449,11 @@ export class CommunityComponent {
} }
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)}); this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
} }
public countSubscribersEvent($event){ public countSubscribersEvent($event) {
this.subscribers = $event.value; this.subscribers = $event.value;
} }
public checkStatistics(type: string) { public checkStatistics(type: string) {
return !!(this.isEntityEnabled(type) return !!(this.isEntityEnabled(type)
&& this.statistics && this.statistics.statisticsDisplay && this.statistics.statisticsDisplay.isActive && this.statistics && this.statistics.statisticsDisplay && this.statistics.statisticsDisplay.isActive
@ -472,28 +469,28 @@ export class CommunityComponent {
&& this.statistics.allowedChartsMode['showInMonitor'][type] && this.statistics.allowedChartsMode['showInMonitor'][type]
&& this.statistics.allowedChartsMode['showInMonitor'][type].length > 0))); && this.statistics.allowedChartsMode['showInMonitor'][type].length > 0)));
} }
public initializeAnalyticsActiveTab() { public initializeAnalyticsActiveTab() {
if(!this.analyticsChecked) { if (!this.analyticsChecked) {
if(this.checkStatistics("publication")) { if (this.checkStatistics("publication")) {
this.analyticsActiveTab = "publication"; this.analyticsActiveTab = "publication";
} else if(this.checkStatistics("dataset")) { } else if (this.checkStatistics("dataset")) {
this.analyticsActiveTab = "dataset"; this.analyticsActiveTab = "dataset";
} else if(this.checkStatistics("software")) { } else if (this.checkStatistics("software")) {
this.analyticsActiveTab = "software"; this.analyticsActiveTab = "software";
} else if(this.checkStatistics("orp")) { } else if (this.checkStatistics("orp")) {
this.analyticsActiveTab = "orp"; this.analyticsActiveTab = "orp";
} }
} }
} }
public showAnalyticsTab() { public showAnalyticsTab() {
this.initializeAnalyticsActiveTab(); this.initializeAnalyticsActiveTab();
return this.analyticsActiveTab; return this.analyticsActiveTab;
} }
public onSelectActiveTab(activeTabId) { public onSelectActiveTab(activeTabId) {
if(this.activeTab != "activaTabId") { // tab really changed if (this.activeTab != "activaTabId") { // tab really changed
if (activeTabId == 'summary') { if (activeTabId == 'summary') {
this.activeTab = 'summary'; this.activeTab = 'summary';
} else if (activeTabId == 'publications') { } else if (activeTabId == 'publications') {
@ -506,7 +503,7 @@ export class CommunityComponent {
this.show = 'overview'; this.show = 'overview';
this.searchSoftware(1, this.searchNumber); this.searchSoftware(1, this.searchNumber);
} else if (activeTabId == 'other') { } else if (activeTabId == 'other') {
this.show='overview'; this.show = 'overview';
this.searchOrps(1, this.searchNumber); this.searchOrps(1, this.searchNumber);
} else if (activeTabId == 'analytics') { } else if (activeTabId == 'analytics') {
this.show = 'analysis'; this.show = 'analysis';

View File

@ -24,13 +24,13 @@ import {UserRegistryService} from "../openaireLibrary/services/user-registry.ser
}) })
export class CuratorsComponent { export class CuratorsComponent {
@Input() managers: string[];
@Input() communityId = null;
@Input() longView = true; @Input() longView = true;
managers: string[];
communityId = null;
public downloadUrl = null; public downloadUrl = null;
public showLoading = true; public showLoading = true;
public curators: Curator[]; public curators: Curator[] = [];
public curatorsLimit: number = 5; public curatorsLimit: number = 5;
public numberOfCurators: number = 5; public numberOfCurators: number = 5;
@ -64,19 +64,45 @@ export class CuratorsComponent {
ngOnInit() { ngOnInit() {
this.showLoading = true; this.showLoading = true;
this.properties = properties; this.properties = properties;
if (this.longView) {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
}
this.url = this.properties.domain + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url);
this.updateTitle(this.pageTitle);
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
}
this.downloadUrl = this.properties.utilsService + '/download/'; this.downloadUrl = this.properties.utilsService + '/download/';
//if (properties.environment !== 'development') { //if (properties.environment !== 'development') {
if (!this.longView) { if (!this.longView) {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if (community) {
this.communityId = community.communityId;
this.getCurators();
}
}));
} else {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if(community) {
this.communityId = community.communityId;
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
}
this.url = this.properties.domain + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url);
this.updateUrl(this.url);
this.updateTitle(this.pageTitle);
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
//this.getDivContents();
this.getPageContents();
this.getCurators();
}
}));
}
}
ngOnDestroy() {
for (let sub of this.subs) {
sub.unsubscribe();
}
}
private getCurators() {
this.subs.push(this.userRegistryService.getActiveEmail('community', this.communityId).subscribe(managers => {
this.managers = managers.map(manager => manager.email);
if(this.managers.length > 0) {
let emails = this.managers.join(); let emails = this.managers.join();
this.subs.push(this.curatorsService.getCurators(this.properties, emails).subscribe(curators => { this.subs.push(this.curatorsService.getCurators(this.properties, emails).subscribe(curators => {
this.curators = curators; this.curators = curators;
@ -86,58 +112,8 @@ export class CuratorsComponent {
this.showLoading = false; this.showLoading = false;
HelperFunctions.scroll(); HelperFunctions.scroll();
})); }));
} else {
this.subs.push(this.route.queryParams.subscribe(data => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if (!this.communityId) {
this.communityId = data['communityId'];
}
//this.getDivContents();
this.getPageContents();
this.subs.push(this.communityService.getCommunityByState(this.properties,
this.properties.communityAPI + this.communityId).subscribe(community => {
this.managers = community.managers;
let emails = this.managers.join();
this.subs.push(this.curatorsService.getCurators(this.properties, emails).subscribe(curators => {
this.curators = curators;
for (let i = 0; i < this.curators.length; i++) {
this.showMore[i] = false;
}
this.showLoading = false;
HelperFunctions.scroll();
}));
}));
}));
} }
// } else { }));
// this.subs.push(this.route.queryParams.subscribe(data => {
// this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
// if (!this.communityId) {
// this.communityId = data['communityId'];
// }
// if(this.longView) {
// //this.getDivContents();
// this.getPageContents();
// }
// this.subs.push(this.userRegistryService.getManagersEmail('community', this.communityId).subscribe(managers => {
// let emails = managers.map(manager => manager.email).join();
// this.subs.push(this.curatorsService.getCurators(this.properties, emails).subscribe(curators => {
// this.curators = curators;
// for (let i = 0; i < this.curators.length; i++) {
// this.showMore[i] = false;
// }
// this.showLoading = false;
// HelperFunctions.scroll();
// }));
// }));
// }));
// }
}
ngOnDestroy() {
for (let sub of this.subs) {
sub.unsubscribe();
}
} }
private getPageContents() { private getPageContents() {

View File

@ -14,77 +14,64 @@ import {properties} from "../../environments/environment";
@Component({ @Component({
selector: 'openaire-deposit', selector: 'openaire-deposit',
template: ` template: `
<deposit-first-page [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation" <deposit-first-page [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"
[communityId]="communityId"></deposit-first-page> [communityId]="communityId"></deposit-first-page>
` `
}) })
export class OpenaireDepositComponent { export class OpenaireDepositComponent {
properties:EnvProperties; properties: EnvProperties = properties;
piwikSiteId = null; piwikSiteId = null;
public pageContents = null; public pageContents = null;
public divContents = null; public divContents = null;
public communityId = null; public communityId = null;
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
fetchZenodoInformation: FetchZenodoInformation; fetchZenodoInformation: FetchZenodoInformation;
subs: Subscription[] = []; subs: Subscription[] = [];
constructor ( private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _zenodoCommunitieService: ZenodoCommunitiesService, private _zenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService, private _communityService: CommunityService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) { private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService); this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties; this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
community => {
this.subs.push(this.route.queryParams.subscribe(params => { if(community) {
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, this.properties.environment);
if (!communityId) { this.communityId = community.communityId
communityId = params['communityId']; let masterZenodoCommunityId = community.zenodoCommunity;
} if (masterZenodoCommunityId) {
if (communityId != null && communityId != '') { this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
this.communityId = communityId; } else {
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment); this.zenodoInformation.url = this.properties.zenodo;
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + communityId).subscribe( this.zenodoInformation.name = "Zenodo";
community => { }
let masterZenodoCommunityId = community.zenodoCommunity; }
if (masterZenodoCommunityId) { }));
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage; if (!this.zenodoInformation.shareInZenodoUrl) {
} else { this.zenodoInformation.url = this.properties.zenodo;
this.zenodoInformation.url = this.properties.zenodo; }
this.zenodoInformation.name = "Zenodo"; if (!this.zenodoInformation.name) {
} this.zenodoInformation.name = "Zenodo";
}, }
error => {
this.handleError("Error getting community with id: " + communityId, error);
}
));
}
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
}));
} }
public ngOnDestroy() { public ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
if(sub instanceof Subscriber) { if (sub instanceof Subscriber) {
sub.unsubscribe(); sub.unsubscribe();
} }
} }
this.fetchZenodoInformation.clearSubscriptions(); this.fetchZenodoInformation.clearSubscriptions();
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Deposit First Page: "+message, error); console.error("Deposit First Page: " + message, error);
} }
} }

View File

@ -17,75 +17,62 @@ import {properties} from "../../environments/environment";
@Component({ @Component({
selector: 'openaire-search-deposit', selector: 'openaire-search-deposit',
template: ` template: `
<deposit-search-dataproviders [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation" [communityId]="communityId"></deposit-search-dataproviders> <deposit-search-dataproviders [piwikSiteId]=piwikSiteId [zenodoInformation]="zenodoInformation"
` [communityId]="communityId"></deposit-search-dataproviders>
`
}) })
export class OpenaireSearchDataprovidersToDepositComponent { export class OpenaireSearchDataprovidersToDepositComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass(); public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
properties:EnvProperties; properties: EnvProperties = properties;
fetchZenodoInformation: FetchZenodoInformation; fetchZenodoInformation: FetchZenodoInformation;
piwikSiteId = null; piwikSiteId = null;
communityId: string = null; communityId: string = null;
subs: Subscription[] = []; subs: Subscription[] = [];
constructor ( private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _zenodoCommunitieService: ZenodoCommunitiesService, private _zenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) { private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService); this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties; this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
this.subs.push(this.route.queryParams.subscribe(params => { community => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); if(community) {
if(!this.communityId) { this.communityId = community.communityId;
this.communityId = params['communityId']; this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, this.properties.environment);
} let masterZenodoCommunityId = community.zenodoCommunity;
if (masterZenodoCommunityId) {
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment); this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
} else {
if(this.communityId) { this.zenodoInformation.url = this.properties.zenodo;
this.zenodoInformation.name = "Zenodo";
if (this.communityId != '') { }
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI+this.communityId).subscribe (
community => {
let masterZenodoCommunityId = community.zenodoCommunity;
if (masterZenodoCommunityId) {
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage;
} else {
this.zenodoInformation.url = this.properties.zenodo;
this.zenodoInformation.name = "Zenodo";
} },
error => {
this.handleError("Error getting community with id: "+this.communityId, error);
}
));
} }
} }
));
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo; if (!this.zenodoInformation.shareInZenodoUrl) {
} this.zenodoInformation.url = this.properties.zenodo;
if (!this.zenodoInformation.name) { }
this.zenodoInformation.name = "Zenodo"; if (!this.zenodoInformation.name) {
} this.zenodoInformation.name = "Zenodo";
})); }
} }
public ngOnDestroy() { public ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
if(sub instanceof Subscriber) { if (sub instanceof Subscriber) {
sub.unsubscribe(); sub.unsubscribe();
} }
} }
this.fetchZenodoInformation.clearSubscriptions(); this.fetchZenodoInformation.clearSubscriptions();
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Deposit Publications Page: "+message, error); console.error("Deposit Publications Page: " + message, error);
} }
} }

View File

@ -27,22 +27,22 @@ import {Subscriber, Subscription} from "rxjs";
export class ShareInZenodoComponent { export class ShareInZenodoComponent {
public url: string = null; public url: string = null;
public title: string = "Share in Zenodo"; public title: string = "Share in Zenodo";
public piwikSiteId = null; public piwikSiteId = null;
properties: EnvProperties; properties: EnvProperties = properties;
communityId: string = null; communityId: string = null;
private community: CommunityInfo = null; private community: CommunityInfo = null;
public pageContents = null; public pageContents = null;
public divContents = null; public divContents = null;
// public warningMessage = ""; // public warningMessage = "";
// public infoMessage = ""; // public infoMessage = "";
masterZenodoCommunityId = null; masterZenodoCommunityId = null;
masterZenodoCommunity = null; masterZenodoCommunity = null;
communityIds = null; communityIds = null;
communities = []; communities = [];
page = 1; page = 1;
@ -52,11 +52,11 @@ export class ShareInZenodoComponent {
errorCodes: ErrorCodes = new ErrorCodes(); errorCodes: ErrorCodes = new ErrorCodes();
depositLink = "https://zenodo.org/deposit/new?c="; depositLink = "https://zenodo.org/deposit/new?c=";
depositLearnHowPage: string = null; depositLearnHowPage: string = null;
public routerHelper:RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
breadcrumbs:Breadcrumb[] = []; breadcrumbs: Breadcrumb[] = [];
subs: Subscription[] = []; subs: Subscription[] = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _router: Router, private _router: Router,
private _meta: Meta, private _meta: Meta,
@ -65,123 +65,106 @@ export class ShareInZenodoComponent {
private _communityService: CommunityService, private _communityService: CommunityService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
private helper: HelperService, private helper: HelperService,
private _piwikService:PiwikService, private _piwikService: PiwikService,
private seoService: SEOService) { private seoService: SEOService) {
} }
public ngOnInit() { public ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING; this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.url = properties.domain + properties.baseLink + this._router.url; this.url = properties.domain + properties.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url, false); this.seoService.createLinkForCanonicalURL(this.url, false);
this.updateUrl(this.url); this.updateUrl(this.url);
this.updateTitle(this.title); this.updateTitle(this.title);
this.updateDescription("Zenodo, repository, deposit, share"); this.updateDescription("Zenodo, repository, deposit, share");
this.depositLearnHowPage = this.properties.depositLearnHowPage;
this.properties = properties; this.breadcrumbs.push({name: 'home', route: '/'}, {
this.subs.push(this.route.queryParams.subscribe(params => { name: "Deposit",
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); route: this.depositLearnHowPage
if (!this.communityId) { }, {name: "Deposit in zenodo", route: null});
this.communityId = params['communityId']; //this.getDivContents();
} this.getPageContents();
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment); community => {
if (community) {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ this.communityId = community.communityId;
this.subs.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe()); this.piwikSiteId = PiwikHelper.getSiteId(this.communityId, this.properties.environment);
} if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subs.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
this.depositLearnHowPage = this.properties.depositLearnHowPage; }
this.breadcrumbs.push({name: 'home', route: '/'}, {name: "Deposit", route: this.depositLearnHowPage},{name:"Deposit in zenodo",route:null}); this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity;
//this.getDivContents(); if (typeof document !== 'undefined') {
this.getPageContents(); HelperFunctions.scroll();
if (this.communityId && this.communityId != '') { }
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe( if (this.masterZenodoCommunityId) {
community => { this.subs.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.masterZenodoCommunityId, null).subscribe(
this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (typeof document !== 'undefined') {
HelperFunctions.scroll();
}
if (this.masterZenodoCommunityId) {
this.subs.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.masterZenodoCommunityId, null).subscribe(
result => {
this.masterZenodoCommunity = result;
},
error => {
this.handleError("Error getting Master Zenodo community with id: " + this.masterZenodoCommunityId, error);
}
));
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.subs.push(this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
result => { result => {
this.communityIds = result; this.masterZenodoCommunity = result;
this.zenodoSearchUtils.totalResults = this.communityIds.length;
if (this.communityIds.length == 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
this.getCommunities()
}, },
error => { error => {
//console.error("list of zenodo communities couldn't be loaded"); this.handleError("Error getting Master Zenodo community with id: " + this.masterZenodoCommunityId, error);
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR; }
} //this.handleError('System error retrieving community profile', error)
)); ));
},
error => {
//console.error("Community couldn't be loaded");
this.handleError("Error getting community with id: " + this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR;
} }
)); this.zenodoSearchUtils.status = this.errorCodes.LOADING;
} this.subs.push(this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
})); result => {
this.communityIds = result;
this.zenodoSearchUtils.totalResults = this.communityIds.length;
if (this.communityIds.length == 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
this.getCommunities()
},
error => {
//console.error("list of zenodo communities couldn't be loaded");
this.handleError("Error getting list of zenodo communities for community with openaire id: " + this.communityId, error);
this.zenodoSearchUtils.status = this.errorCodes.ERROR;
} //this.handleError('System error retrieving community profile', error)
));
}
}));
} }
public ngOnDestroy() { public ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
if(sub instanceof Subscriber) { if (sub instanceof Subscriber) {
sub.unsubscribe(); sub.unsubscribe();
} }
} }
} }
private updateDescription(description: string) { private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
} }
private updateTitle(title: string) { private updateTitle(title: string) {
var _title = ((title.length > 50) ? title.substring(0, 50) : title); var _title = ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title); this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
} }
private updateUrl(url: string) { private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'"); this._meta.updateTag({content: url}, "property='og:url'");
} }
private getPageContents() { private getPageContents() {
this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
})); }));
} }
private getDivContents() { private getDivContents() {
this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
})); }));
} }
getZenodoCommunityById(zenodoid, openaireId) { getZenodoCommunityById(zenodoid, openaireId) {
this.subs.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe( this.subs.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
result => { result => {
@ -190,8 +173,8 @@ export class ShareInZenodoComponent {
if (this.zenodoCommunitiesLoadedCount >= this.communityIds.length || this.page * this.size) { if (this.zenodoCommunitiesLoadedCount >= this.communityIds.length || this.page * this.size) {
this.zenodoSearchUtils.status = this.errorCodes.DONE; this.zenodoSearchUtils.status = this.errorCodes.DONE;
} }
}, },
error => { error => {
// var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo();
@ -205,21 +188,22 @@ export class ShareInZenodoComponent {
} }
//console.error("Zenodo community'"+zenodoid+"' couldn't be loaded"); //console.error("Zenodo community'"+zenodoid+"' couldn't be loaded");
this.handleError("Error getting Zenodo community with id: " + zenodoid + " and openaire id: " + openaireId, error); this.handleError("Error getting Zenodo community with id: " + zenodoid + " and openaire id: " + openaireId, error);
} }
)); ));
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Share in Zenodo Page: " + message, error); console.error("Share in Zenodo Page: " + message, error);
} }
public getCommunities($event = {value:1}) {
public getCommunities($event = {value: 1}) {
this.page = $event.value; this.page = $event.value;
for (let i = (this.page - 1 ) * this.size; i < this.communityIds.length && i< this.page * this.size; i++) { for (let i = (this.page - 1) * this.size; i < this.communityIds.length && i < this.page * this.size; i++) {
if(!this.communities[this.communityIds[i]["zenodoid"]]) { if (!this.communities[this.communityIds[i]["zenodoid"]]) {
this.getZenodoCommunityById(this.communityIds[i]["zenodoid"], this.communityIds[i]["id"]); this.getZenodoCommunityById(this.communityIds[i]["zenodoid"], this.communityIds[i]["id"]);
} }
} }
} }
} }

View File

@ -2,7 +2,6 @@ import {Component, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {UserComponent} from '../openaireLibrary/login/user.component'; import {UserComponent} from '../openaireLibrary/login/user.component';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {EmailService} from "../openaireLibrary/utils/email/email.service"; import {EmailService} from "../openaireLibrary/utils/email/email.service";
import {Session} from '../openaireLibrary/login/utils/helper.class'; import {Session} from '../openaireLibrary/login/utils/helper.class';
@ -54,8 +53,7 @@ export class OpenaireUserComponent {
public server: boolean = true; public server: boolean = true;
loggedIn: boolean = false; loggedIn: boolean = false;
sub; sub;
constructor(private _subscribeService: SubscribeService, constructor(private _emailService: EmailService, private route: ActivatedRoute) {
private _emailService: EmailService, private route: ActivatedRoute) {
} }
ngOnDestroy() { ngOnDestroy() {
if (this.sub instanceof Subscriber) { if (this.sub instanceof Subscriber) {

View File

@ -3,7 +3,6 @@ import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser'; import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service'; import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo'; import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
@ -38,10 +37,11 @@ export class MyCommunitiesComponent {
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent; private errorMessages: ErrorMessagesComponent;
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'my Communities'}]; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'my Communities'}];
properties: EnvProperties; properties: EnvProperties;
private user: User; private user: User;
subscriptions = []; subscriptions = [];
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
@ -49,25 +49,24 @@ export class MyCommunitiesComponent {
private _title: Title, private _title: Title,
private _piwikService: PiwikService, private _piwikService: PiwikService,
private _communitiesService: CommunitiesService, private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService,
private helper: HelperService, private helper: HelperService,
private seoService: SEOService, private seoService: SEOService,
private userManagementService: UserManagementService) { private userManagementService: UserManagementService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community " + var description = "OpenAIRE - Connect, Community Dashboard, research community " +
"| My managing and subscribed to Communities"; "| My managing and subscribed to Communities";
var title = "OpenAIRE - Connect | My Communities"; var title = "OpenAIRE - Connect | My Communities";
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title); this._title.setTitle(title);
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties; this.properties = properties;
var url = this.properties.domain + this.properties.baseLink + this._router.url; var url = this.properties.domain + this.properties.baseLink + this._router.url;
@ -78,36 +77,36 @@ export class MyCommunitiesComponent {
} }
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
if(this.user) { if (this.user) {
this.getCommunities(); this.getCommunities();
} }
//this.getDivContents(); //this.getDivContents();
//this.getPageContents(); //this.getPageContents();
})); }));
} }
private getPageContents() { private getPageContents() {
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
})); }));
} }
private getDivContents() { private getDivContents() {
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getDivHelpContents(this.properties, 'connect', this._router.url).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
})); }));
} }
public getCommunities() { public getCommunities() {
this.loading = true; this.loading = true;
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.subscriberErrorMessage = ""; this.subscriberErrorMessage = "";
this.subscriberOfCommunities = []; this.subscriberOfCommunities = [];
this.managerOfCommunities = []; this.managerOfCommunities = [];
this.researchCommunities = []; this.researchCommunities = [];
this.subscriptions.push(this._communitiesService.getCommunitiesState().subscribe( this.subscriptions.push(this._communitiesService.getCommunitiesState().subscribe(
communitiesResults => { communitiesResults => {
if (!communitiesResults) { if (!communitiesResults) {
@ -117,71 +116,35 @@ export class MyCommunitiesComponent {
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
return; return;
} }
;
this.sort(communitiesResults); this.sort(communitiesResults);
var subscribedLoading = communitiesResults.length;
var mail = this.user.email;
communitiesResults.forEach((community, index) => { communitiesResults.forEach((community, index) => {
let showCommunity: boolean = true; let showCommunity: boolean = true;
let isManager: boolean = false; community.isManager = Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || Session.isManager('community', community.communityId, this.user);
let isSubscriber: boolean = false;
if (community['status'] == "hidden") { if (community['status'] == "hidden") {
showCommunity = false; showCommunity = false;
} else { } else {
if (mail == null && community['status'] == "manager") { // no user if(!community.isManager && community['status'] == "manager") {
showCommunity = false;
} else if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
isManager = true;
} else if (community.managers.indexOf(mail) != -1) {
isManager = true;
} else if (community['status'] == "manager") {
showCommunity = false; showCommunity = false;
} }
} }
if (showCommunity) { if (showCommunity) {
this.researchCommunities.push(community); this.researchCommunities.push(community);
if (isManager) { if (community.isManager) {
community.isManager = true;
this.managerOfCommunities.push(community); this.managerOfCommunities.push(community);
} }
} }
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
if (this.user && showCommunity) {
if (mail != null && showCommunity) { community.isSubscribed = Session.isSubscribedTo('community', community.communityId, this.user);
this.subscriptions.push(this._subscribeService.isSubscribedToCommunity(this.properties, community.communityId).subscribe( if(community.isSubscribed) {
res => { if (community.isManager) {
isSubscriber = res; this.subscriberOfCommunities.push(community);
if (isSubscriber) { } else {
community.isSubscribed = true; this.subscriberOfCommunities.unshift(community);
if (isManager) { }
this.subscriberOfCommunities.push(community);
} else {
this.subscriberOfCommunities.unshift(community);
}
}
subscribedLoading--;
if (subscribedLoading == 0) {
this.loading = false;
}
},
error => {
this.handleError("Error getting response if email: " + mail + " is subscribed to community with id: " + community.communityId, error);
subscribedLoading--;
if (subscribedLoading == 0) {
this.loading = false;
}
}));
} else {
subscribedLoading--;
if (subscribedLoading == 0) {
this.loading = false;
} }
} }
this.loading = false;
}); });
}, },
error => { error => {
@ -190,7 +153,7 @@ export class MyCommunitiesComponent {
} }
)); ));
} }
private sort(results: CommunityInfo[]) { private sort(results: CommunityInfo[]) {
results.sort((left, right): number => { results.sort((left, right): number => {
if (!right.date || left.date > right.date) { if (!right.date || left.date > right.date) {
@ -208,11 +171,11 @@ export class MyCommunitiesComponent {
} }
}) })
} }
public quote(param: string): string { public quote(param: string): string {
return StringUtils.quote(param); return StringUtils.quote(param);
} }
ngOnDestroy() { ngOnDestroy() {
this.subscriptions.forEach(subscription => { this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) { if (subscription instanceof Subscriber) {
@ -220,7 +183,7 @@ export class MyCommunitiesComponent {
} }
}); });
} }
private handleError(message: string, error): number { private handleError(message: string, error): number {
var code = ""; var code = "";
if (!error.status) { if (!error.status) {
@ -228,9 +191,9 @@ export class MyCommunitiesComponent {
} else { } else {
code = error.status; code = error.status;
} }
console.error("Communities (component): " + message, error); console.error("Communities (component): " + message, error);
return this.errorMessages.getErrorCode(code); return this.errorMessages.getErrorCode(code);
} }
} }

View File

@ -1,59 +1,48 @@
import {Component} from '@angular/core'; import {Component, OnDestroy, OnInit} from '@angular/core';
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper"; import {ConnectHelper} from "../../openaireLibrary/connect/connectHelper";
import {PiwikHelper} from "../../utils/piwikHelper"; import {PiwikHelper} from "../../utils/piwikHelper";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
@Component({ @Component({
selector: 'openaire-search-results', selector: 'openaire-search-results',
template: ` template: `
<search-research-results resultType="result" [simpleView]="false" [customFilter]=customFilter [piwikSiteId]="piwikSiteId" [hasPrefix]="false" [showBreadcrumb]="true" <search-research-results resultType="result" [simpleView]="false" [customFilter]=customFilter
[openaireLink]="'https://' + (properties.environment == 'production'?'':'beta.') + 'explore.openaire.eu/search/advanced/research-outcomes'" [piwikSiteId]="piwikSiteId" [hasPrefix]="false" [showBreadcrumb]="true"
></search-research-results> [openaireLink]="'https://' + (properties.environment == 'production'?'':'beta.') + 'explore.openaire.eu/search/advanced/research-outcomes'"
` ></search-research-results>
`
}) })
export class OpenaireSearchResearchResultsComponent { export class OpenaireSearchResearchResultsComponent implements OnInit, OnDestroy {
connectCommunityId:string; connectCommunityId: string;
piwikSiteId = null; piwikSiteId = null;
customFilter: SearchCustomFilter = null; customFilter: SearchCustomFilter = null;
properties:EnvProperties; properties: EnvProperties = properties;
sub;
constructor(private route: ActivatedRoute, private _communityService: CommunityService) { constructor(private route: ActivatedRoute, private _communityService: CommunityService) {
} }
sub; ngOnInit() {
this.setCommunity();
}
ngOnDestroy() { ngOnDestroy() {
if (this.sub instanceof Subscriber) { if (this.sub instanceof Subscriber) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
ngOnInit() {
this.properties = properties; setCommunity() {
var communityId = ConnectHelper.getCommunityFromDomain(properties.domain); this.sub = this._communityService.getCommunityAsObservable().subscribe(community => {
if (communityId) { if (community != null) {
this.connectCommunityId = communityId; this.connectCommunityId = community.communityId;
this.setCommunity(); this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId, properties.environment);
} else { this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, community.shortTitle);
this.route.queryParams.subscribe(params => {
if (params['communityId'] && params['communityId'] != "") {
this.connectCommunityId = params['communityId'];
this.setCommunity();
}
});
}
}
setCommunity(){
this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,properties.environment);
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
this.sub = this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.connectCommunityId).subscribe(community =>{
if(community != null){
this.customFilter.valueName = community.shortTitle;
} }
}); });
} }

View File

@ -9,7 +9,6 @@ import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields"
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service"; import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {Session, User} from "../../openaireLibrary/login/utils/helper.class"; import {Session, User} from "../../openaireLibrary/login/utils/helper.class";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from "../../openaireLibrary/services/user-management.service"; import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
@ -72,7 +71,6 @@ export class SearchCommunitiesComponent {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _communitiesService: CommunitiesService, private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService,
private userManagementService: UserManagementService) { private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
@ -84,7 +82,7 @@ export class SearchCommunitiesComponent {
this.properties = properties; this.properties = properties;
this.piwikSiteId = this.properties.piwikSiteId; this.piwikSiteId = this.properties.piwikSiteId;
this.baseUrl = this.properties.searchLinkToCommunities; this.baseUrl = this.properties.searchLinkToCommunities;
this.subscriptions.push(this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.searchPage.resultsPerPage = 10; this.searchPage.resultsPerPage = 10;
this.keyword = (params['fv0'] ? params['fv0'] : ''); this.keyword = (params['fv0'] ? params['fv0'] : '');
@ -116,7 +114,7 @@ export class SearchCommunitiesComponent {
} }
})); }));
} }
ngOnDestroy() { ngOnDestroy() {
this.subscriptions.forEach(subscription => { this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) { if (subscription instanceof Subscriber) {
@ -142,17 +140,11 @@ export class SearchCommunitiesComponent {
this.totalResults[i].isSubscribed = false; this.totalResults[i].isSubscribed = false;
if (this.user) { if (this.user) {
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]); this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
this.totalResults[i].isSubscribed = Session.isSubscribedTo('community', this.totalResults[i].communityId, this.user);
} }
} }
if (this.user) { if (this.user) {
this.subscriptions.push(this._subscribeService.getCommunitiesSubscribedTo(this.properties/*, this.user.email*/).subscribe( this._getResults(params);
res => {
for (let i = 0; i < this.totalResults.length; i++) {
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
}
this._getResults(params);
}
));
} else { } else {
this._getResults(params); this._getResults(params);
} }
@ -450,7 +442,7 @@ export class SearchCommunitiesComponent {
private isCommunityManager(community: CommunityInfo): boolean { private isCommunityManager(community: CommunityInfo): boolean {
return Session.isCommunityCurator(this.user) || community.managers.indexOf(this.user.email) != -1; return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isManager('community', community.communityId, this.user);
} }
/** /**

View File

@ -44,7 +44,7 @@ export class OpenaireSearchDataprovidersComponent {
public searchUtils:SearchUtilsClass = new SearchUtilsClass(); public searchUtils:SearchUtilsClass = new SearchUtilsClass();
public searchFields:SearchFields = new SearchFields(); public searchFields:SearchFields = new SearchFields();
public refineFields: string[] = [];// = this.searchFields.JOURNAL_FIELDS; public refineFields: string[] = [];// = this.searchFields.JOURNAL_FIELDS;
properties:EnvProperties; properties:EnvProperties= properties;
public disableForms: boolean = false; public disableForms: boolean = false;
public enableSearchView: boolean = true; public enableSearchView: boolean = true;
@ -63,31 +63,26 @@ export class OpenaireSearchDataprovidersComponent {
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties;
this.subscriptions.push(this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe(community =>{
if(!this.communityId) { if(community != null) {
this.communityId = params['communityId']; this.communityId = community.communityId;
} this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, community.shortTitle);
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, ""); this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment);
this.subscriptions.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe(community =>{ this.searchUtils.keyword = (params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
if(community != null){ //this.filters = this.createFilters();
this.customFilter.valueName = community.shortTitle; //this.searchPage.getParametersFromUrl(params);
if(this.initialLoad) {
this.initialLoad = false;
console.log("Init get results")
this._getResults(params);
} else {
// this.searchPage.transform(this.results);
this.searchPage.goTo(1);
console.log("Init transfrm " + this.searchUtils.keyword)
}
} }
})); }));
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment);
this.searchUtils.keyword = (params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
//this.filters = this.createFilters();
//this.searchPage.getParametersFromUrl(params);
if(this.initialLoad) {
this.initialLoad = false;
console.log("Init get results")
this._getResults(params);
}else{
// this.searchPage.transform(this.results);
this.searchPage.goTo(1);
console.log("Init transfrm " + this.searchUtils.keyword)
}
})); }));
} }

View File

@ -1,4 +1,4 @@
import {Component} from '@angular/core'; import {Component, OnDestroy, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {PiwikHelper} from '../../utils/piwikHelper'; import {PiwikHelper} from '../../utils/piwikHelper';
@ -7,38 +7,37 @@ import {Subscriber} from "rxjs";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
@Component({ @Component({
selector: 'openaire-search-organizations', selector: 'openaire-search-organizations',
template: ` template: `
<search-organizations> <search-organizations>
</search-organizations> </search-organizations>
` `
}) })
export class OpenaireSearchOrganizationsComponent { export class OpenaireSearchOrganizationsComponent implements OnInit, OnDestroy {
piwikSiteId = null; piwikSiteId = null;
constructor (private route: ActivatedRoute ) {
}
sub; sub;
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
var communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
if (communityId) {
this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment);
} else {
this.sub = this.route.queryParams.subscribe(params => {
if (params['communityId'] && params['communityId'] != "") {
communityId = params['communityId'];
this.piwikSiteId = PiwikHelper.getSiteId(communityId, properties.environment);
}
});
}
}
ngOnDestroy() { ngOnDestroy() {
if (this.sub instanceof Subscriber) { if (this.sub instanceof Subscriber) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
ngOnInit() {
var communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
if(communityId){
this.piwikSiteId = PiwikHelper.getSiteId(communityId,properties.environment);
}else{
this.sub = this.route.queryParams.subscribe(params => {
if(params['communityId'] && params['communityId']!=""){
communityId = params['communityId'];
this.piwikSiteId = PiwikHelper.getSiteId(communityId,properties.environment);
}
});
}
}
} }

View File

@ -48,7 +48,7 @@ export class OpenaireSearchProjectsComponent {
public _location:Location; public _location:Location;
public searchFields:SearchFields = new SearchFields(); public searchFields:SearchFields = new SearchFields();
public refineFields: string[] = [];// = this.searchFields.JOURNAL_FIELDS; public refineFields: string[] = [];// = this.searchFields.JOURNAL_FIELDS;
properties:EnvProperties; properties:EnvProperties = properties;
public disableForms: boolean = false; public disableForms: boolean = false;
public enableSearchView: boolean = true; public enableSearchView: boolean = true;
@ -66,28 +66,21 @@ export class OpenaireSearchProjectsComponent {
} }
public ngOnInit() { public ngOnInit() {
this.properties = properties;
this.subscriptions.push(this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe(community =>{
if(!this.communityId) {
this.communityId = params['communityId'];
}
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
this.subscriptions.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe(community =>{
if(community != null){ if(community != null){
this.customFilter.valueName = community.shortTitle; this.communityId = community.communityId;
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, community.shortTitle);
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment);
this.searchUtils.keyword = (params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
if(this.initialLoad) {
this.initialLoad = false;
this._getResults(params);
}else{
this.searchPage.goTo(1);
}
} }
})); }));
this.piwikSiteId = PiwikHelper.getSiteId(this.communityId,this.properties.environment);
this.searchUtils.keyword = (params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
if(this.initialLoad) {
this.initialLoad = false;
this._getResults(params);
}else{
this.searchPage.goTo(1);
}
})); }));
} }

View File

@ -1,4 +1,4 @@
import {Component} from '@angular/core'; import {Component, OnDestroy, OnInit} from '@angular/core';
import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {ActivatedRoute} from "@angular/router"; import {ActivatedRoute} from "@angular/router";
@ -18,44 +18,33 @@ import {CommunityService} from "../../openaireLibrary/connect/community/communit
` `
}) })
export class OpenaireSearchResearchResultsComponent { export class OpenaireSearchResearchResultsComponent implements OnInit, OnDestroy {
connectCommunityId: string; connectCommunityId: string;
piwikSiteId = null; piwikSiteId = null;
customFilter: SearchCustomFilter = null; customFilter: SearchCustomFilter = null;
properties:EnvProperties; properties:EnvProperties = properties;
sub;
constructor(private route: ActivatedRoute, private _communityService: CommunityService) { constructor(private route: ActivatedRoute, private _communityService: CommunityService) {
} }
sub; ngOnInit() {
this.setCommunity();
}
ngOnDestroy() { ngOnDestroy() {
if (this.sub instanceof Subscriber) { if (this.sub instanceof Subscriber) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
ngOnInit() {
this.properties = properties;
var communityId = ConnectHelper.getCommunityFromDomain(properties.domain);
if (communityId) {
this.connectCommunityId = communityId;
this.setCommunity();
} else {
this.route.queryParams.subscribe(params => {
if (params['communityId'] && params['communityId'] != "") {
this.connectCommunityId = params['communityId'];
this.setCommunity();
}
});
}
}
setCommunity(){ setCommunity(){
this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,properties.environment); this.sub = this._communityService.getCommunityAsObservable().subscribe(community =>{
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
this.sub = this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.connectCommunityId).subscribe(community =>{
if(community != null){ if(community != null){
this.customFilter.valueName = community.shortTitle; this.connectCommunityId = community.communityId;
this.piwikSiteId = PiwikHelper.getSiteId(this.connectCommunityId,properties.environment);
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, community.shortTitle);
} }
}); });
} }

View File

@ -29,7 +29,7 @@ import {properties} from "../../environments/environment";
export class StatisticsComponent { export class StatisticsComponent {
public pageTitle = "OpenAIRE"; public pageTitle = "OpenAIRE";
properties: EnvProperties; properties: EnvProperties = properties;
@Input() communityId = null; @Input() communityId = null;
@Input() currentMode = 'showInMonitor'; @Input() currentMode = 'showInMonitor';
communityInfo: any = null; communityInfo: any = null;
@ -42,12 +42,12 @@ export class StatisticsComponent {
//allowedChartsMode = {showInMonitor: {}/, showInDashboard: {}}; //allowedChartsMode = {showInMonitor: {}/, showInDashboard: {}};
allowedChartsMode = {showInMonitor: new Map<string, string[]>(), showInDashboard: new Map<string, string[]>()}; allowedChartsMode = {showInMonitor: new Map<string, string[]>(), showInDashboard: new Map<string, string[]>()};
allowedEntitiesMode = {showInMonitor: [], showInDashboard: []}; allowedEntitiesMode = {showInMonitor: [], showInDashboard: []};
statisticsSum: StatisticsSummary = null; statisticsSum: StatisticsSummary = null;
statisticsDisplay: StatisticsDisplay = null; statisticsDisplay: StatisticsDisplay = null;
chartTitlesMode = {showInMonitor: {}, showInDashboard: {}}; chartTitlesMode = {showInMonitor: {}, showInDashboard: {}};
chartsInfoMap: {}; chartsInfoMap: {};
displayedTimeline: string; displayedTimeline: string;
displayedTimelineUrl: string; displayedTimelineUrl: string;
displayedGraph: string; displayedGraph: string;
@ -58,9 +58,9 @@ export class StatisticsComponent {
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
status = null; status = null;
communityName = null; communityName = null;
subs: Subscription[] = []; subs: Subscription[] = [];
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
@ -73,49 +73,39 @@ export class StatisticsComponent {
private titleCase: TitleCasePipe, private titleCase: TitleCasePipe,
private _communityService: CommunityService, private _communityService: CommunityService,
private sanitizer: DomSanitizer) { private sanitizer: DomSanitizer) {
} }
public ngOnInit() { public ngOnInit() {
if (this.currentMode == "showInMonitor") { if (this.currentMode == "showInMonitor") {
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects "; var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
var title = "Monitor"; var title = "Monitor";
this._title.setTitle(title); this._title.setTitle(title);
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
this._meta.updateTag({content: title}, "property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
} }
this.properties = properties;
var url = properties.domain + properties.baseLink + this._router.url; var url = properties.domain + properties.baseLink + this._router.url;
this._meta.updateTag({content: url}, "property='og:url'"); this._meta.updateTag({content: url}, "property='og:url'");
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
this.subs.push(this.route.queryParams.subscribe( community => {
communityId => { if (typeof document !== 'undefined') {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); HelperFunctions.scroll();
if(!this.communityId) {
this.communityId = communityId['communityId'];
} }
if(community) {
if (this.currentMode == "showInMonitor" && this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.communityId = community.communityId;
this.subs.push(this._piwikService.trackView(this.properties, "Monitor " + this.communityId, PiwikHelper.siteIDs[this.communityId]).subscribe()); if (this.currentMode == "showInMonitor" && this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subs.push(this._piwikService.trackView(this.properties, "Monitor " + this.communityId, PiwikHelper.siteIDs[this.communityId]).subscribe());
}
this.communityName = community.shortTitle;
this.createChartUrlMap();
this.createStatisticsObjects();
} }
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
if (typeof document !== 'undefined') {
HelperFunctions.scroll();
}
this.communityName = community.shortTitle;
this.createChartUrlMap();
this.createStatisticsObjects();
}));
// console.log(" Stats! "+ this.properties.statisticsAPIURL);
})); }));
} }
public ngOnDestroy() { public ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
if (sub instanceof Subscriber) { if (sub instanceof Subscriber) {
@ -123,23 +113,23 @@ export class StatisticsComponent {
} }
} }
} }
getCamelCaseString(inputString: string) { getCamelCaseString(inputString: string) {
return this.titleCase.transform(inputString); return this.titleCase.transform(inputString);
} }
createStatisticsObjects() { createStatisticsObjects() {
// console.log(" Stats! "+ this.properties.statisticsAPIURL); // console.log(" Stats! "+ this.properties.statisticsAPIURL);
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.subs.push(this._statisticsService.getCommunityStatistics(this.properties, this.communityId).subscribe( this.subs.push(this._statisticsService.getCommunityStatistics(this.properties, this.communityId).subscribe(
res => { res => {
if(res) { if (res) {
this.statisticsSum = res; this.statisticsSum = res;
if (res["other"]) { //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name if (res["other"]) { //hack because in stats API the entity name is "other" while in admin API is "orp". This component uses also "orp" name
this.statisticsSum["orp"] = res["other"]; this.statisticsSum["orp"] = res["other"];
} }
this.getDisplayOptions(); this.getDisplayOptions();
}else{ } else {
console.error("Error getting community statistics for community with id: " + this.communityId); console.error("Error getting community statistics for community with id: " + this.communityId);
this.status = this.errorCodes.ERROR; this.status = this.errorCodes.ERROR;
} }
@ -150,16 +140,16 @@ export class StatisticsComponent {
this.status = this.errorCodes.ERROR; this.status = this.errorCodes.ERROR;
})); }));
} }
getDisplayOptions() { getDisplayOptions() {
this.subs.push(this._statisticsService.getCommunityAdminStatisticsChoices(this.properties, this.communityId) this.subs.push(this._statisticsService.getCommunityAdminStatisticsChoices(this.properties, this.communityId)
.subscribe( .subscribe(
res => { res => {
this.statisticsDisplay = res; this.statisticsDisplay = res;
this.getCommunityInfo(); this.getCommunityInfo();
this.status = this.errorCodes.DONE; this.status = this.errorCodes.DONE;
}, },
error => { error => {
//console.log(error); //console.log(error);
@ -168,8 +158,8 @@ export class StatisticsComponent {
} }
)); ));
} }
getCommunityInfo() { getCommunityInfo() {
// console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`); // console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
this.subs.push(this._configService.communityInformationState.subscribe( this.subs.push(this._configService.communityInformationState.subscribe(
@ -191,11 +181,11 @@ export class StatisticsComponent {
} }
)); ));
} }
initializeDisplayedCharts() { initializeDisplayedCharts() {
let firstEntity: string; let firstEntity: string;
this.entitiesList = Array.from(this.entitiesMap.keys()); this.entitiesList = Array.from(this.entitiesMap.keys());
this.allowedChartsMode[this.currentMode] = this.allowedCharts; this.allowedChartsMode[this.currentMode] = this.allowedCharts;
this.allowedEntitiesMode[this.currentMode] = this.allowedEntities; this.allowedEntitiesMode[this.currentMode] = this.allowedEntities;
let titles = []; let titles = [];
@ -217,7 +207,7 @@ export class StatisticsComponent {
} else { } else {
this.chartTitlesMode.showInDashboard[entity + this.getCamelCaseString(chart)] = false; this.chartTitlesMode.showInDashboard[entity + this.getCamelCaseString(chart)] = false;
} }
// console.log(`added ${entity} - ${chart} to allowedCharts`); // console.log(`added ${entity} - ${chart} to allowedCharts`);
} }
if (this.statisticsSum[entity].total && if (this.statisticsSum[entity].total &&
@ -232,7 +222,7 @@ export class StatisticsComponent {
this.chartTitlesMode.showInMonitor[entity + this.getCamelCaseString(chart)] = false; this.chartTitlesMode.showInMonitor[entity + this.getCamelCaseString(chart)] = false;
} }
// console.log(`added ${entity} - ${chart} to allowedCharts`); // console.log(`added ${entity} - ${chart} to allowedCharts`);
} }
} }
if (this.allowedChartsMode.showInMonitor[entity].length) { if (this.allowedChartsMode.showInMonitor[entity].length) {
@ -253,24 +243,24 @@ export class StatisticsComponent {
} }
} }
} }
} }
createChartUrlMap() { createChartUrlMap() {
let communityCharts: CommunityCharts = new CommunityCharts(this.sanitizer); let communityCharts: CommunityCharts = new CommunityCharts(this.sanitizer);
this.chartsInfoMap = communityCharts.getChartsForCommunity(this.communityId, this.communityName, this.properties); this.chartsInfoMap = communityCharts.getChartsForCommunity(this.communityId, this.communityName, this.properties);
} }
onChangeEntity(entity: string) { onChangeEntity(entity: string) {
this.displayedEntity = entity; this.displayedEntity = entity;
// console.log(`displayed entity is ${entity}`); // console.log(`displayed entity is ${entity}`);
// console.log(`statisticsSum[${entity}].total is ${this.statisticsSum[entity].total}`); // console.log(`statisticsSum[${entity}].total is ${this.statisticsSum[entity].total}`);
if (this.statisticsSum[entity].total && if (this.statisticsSum[entity].total &&
this.allowedEntities.filter(x => x == entity).length) { this.allowedEntities.filter(x => x == entity).length) {
// console.log(`found ${entity} in allowedEntities`); // console.log(`found ${entity} in allowedEntities`);
this.displayedTimeline = `${entity}Timeline`; this.displayedTimeline = `${entity}Timeline`;
this.displayedTimelineUrl = this.chartsInfoMap[this.displayedTimeline].url; this.displayedTimelineUrl = this.chartsInfoMap[this.displayedTimeline].url;
@ -297,13 +287,13 @@ export class StatisticsComponent {
// console.log(`displayed Graph is: ${this.displayedGraph}`); // console.log(`displayed Graph is: ${this.displayedGraph}`);
} }
} }
changeDisplayedProjectChart(chartName: string) { changeDisplayedProjectChart(chartName: string) {
this.displayedProjectChart = chartName; this.displayedProjectChart = chartName;
this.displayedProjectChartUrl = this.chartsInfoMap[this.displayedProjectChart].url; this.displayedProjectChartUrl = this.chartsInfoMap[this.displayedProjectChart].url;
// console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`); // console.log(`displayed ProjectChart is: ${this.displayedProjectChart}`);
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Statistics (Monitor) Page: " + message, error); console.error("Statistics (Monitor) Page: " + message, error);
} }
@ -320,5 +310,5 @@ export class StatisticsForDashboardComponent extends StatisticsComponent {
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
} }
} }

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {CommunityService} from "../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper"; import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
@ -18,107 +18,93 @@ import {Subscriber, Subscription} from "rxjs";
selector: 'subjects', selector: 'subjects',
template: ` template: `
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other"></schema2jsonld> <schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other"></schema2jsonld>
<div style=" min-height: 650px;" class=""> <div style=" min-height: 650px;" class="">
<div class="uk-section uk-padding-remove-top uk-padding-remove-bottom"> <div class="uk-section uk-padding-remove-top uk-padding-remove-bottom">
<breadcrumbs addClass="uk-margin-large-left uk-margin-remove-bottom uk-margin-small-top" [breadcrumbs]="breadcrumbs"></breadcrumbs> <breadcrumbs addClass="uk-margin-large-left uk-margin-remove-bottom uk-margin-small-top"
<!-- <div *ngIf="communityId != null && communityId != ''" --> [breadcrumbs]="breadcrumbs"></breadcrumbs>
<!-- class="uk-container uk-container-large uk-margin-top white-box-with-border">--> <div class="uk-container uk-container-large">
<div *ngIf="showLoading">
<div class="uk-animation-fade uk-width-1-1" role="alert"><span
class="loading-gif uk-align-center"></span></div>
</div>
<div *ngIf="!showLoading">
<h4 class="uk-margin-bottom uk-margin-medium-top">
<span>Subjects</span>
</h4>
<div class="uk-container uk-container-large"> <div style=" min-height: 250px;" class="white-box-with-border uk-padding uk-list">
<div *ngIf="showLoading"> <helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
<div class="uk-animation-fade uk-width-1-1" role="alert"><span [texts]="pageContents['top']"></helper>
class="loading-gif uk-align-center"></span></div>
</div>
<div *ngIf="!showLoading">
<h4 class="uk-margin-bottom uk-margin-medium-top">
<span>Subjects</span>
</h4>
<div style=" min-height: 250px;" class="white-box-with-border uk-padding uk-list">
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
[texts]="pageContents['top']"></helper>
<span *ngFor="let subject of subjects let i=index"> <span *ngFor="let subject of subjects let i=index">
<span *ngIf="subject != ''"> <span *ngIf="subject != ''">
<a class="portal-link" <a class="portal-link"
[queryParams]="{f0:'resultsubject',fv0:createParams(subject)}" [queryParams]="{f0:'resultsubject',fv0:createParams(subject)}"
routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults" > routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToAdvancedResults">
<span>{{subject}}</span> <span>{{subject}}</span>
</a> </a>
<span *ngIf="i < subjects.length-1">, </span> <span *ngIf="i < subjects.length-1">, </span>
</span> </span>
</span> </span>
</div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div> </div>
` `
}) })
export class SubjectsComponent { export class SubjectsComponent {
public subjects: string[]; public subjects: string[];
@Input() communityId = null; public communityId = null;
public showLoading = true; public showLoading = true;
public properties: EnvProperties; public properties: EnvProperties = properties;
public pageContents = null; public pageContents = null;
public divContents = null; public divContents = null;
public url: string = null; public url: string = null;
public pageTitle: string = "Subjects"; public pageTitle: string = "Subjects";
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'about - subjects'}]; public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'about - subjects'}];
subs: Subscription[] = []; subs: Subscription[] = [];
constructor (private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private communityService: CommunityService, private communityService: CommunityService,
private _router: Router, private _router: Router,
private helper: HelperService, private helper: HelperService,
private _meta: Meta, private _meta: Meta,
private _title: Title, private _title: Title,
private seoService: SEOService, private seoService: SEOService,
private _piwikService: PiwikService) {} private _piwikService: PiwikService) {
}
ngOnInit() { ngOnInit() {
this.showLoading = true; this.showLoading = true;
this.properties = properties; this.url = this.properties.domain + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { this.updateUrl(this.url);
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe()); this.updateTitle(this.pageTitle);
} this.updateDescription("OpenAIRE - Connect, Community Gateway, research community");
this.url = this.properties.domain + this._router.url; this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.seoService.createLinkForCanonicalURL(this.url); if (community) {
this.updateUrl(this.url); this.communityId = community.communityId;
this.updateTitle(this.pageTitle); if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community"); this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe());
this.subs.push(this.route.queryParams.subscribe(data => {
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if(!this.communityId) {
this.communityId = data['communityId'];
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.subs.push(this.communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe(community => { this.subjects = community.subjects;
this.subjects = community.subjects; this.showLoading = false;
this.showLoading = false; HelperFunctions.scroll();
HelperFunctions.scroll(); }
}, }));
error => {
console.error("Subjects Component: Error getting subjects for community with id: " + this.communityId, error);
this.showLoading = false;
} ));
}));
} }
createParams(param) { createParams(param) {
return StringUtils.quote(StringUtils.URIEncode(param)); return StringUtils.quote(StringUtils.URIEncode(param));
} }
ngOnDestroy() { ngOnDestroy() {
for (let sub of this.subs) { for (let sub of this.subs) {
if (sub instanceof Subscriber) { if (sub instanceof Subscriber) {
@ -126,30 +112,30 @@ export class SubjectsComponent {
} }
} }
} }
private getPageContents() { private getPageContents() {
this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
})); }));
} }
private getDivContents() { private getDivContents() {
this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
})); }));
} }
private updateDescription(description: string) { private updateDescription(description: string) {
this._meta.updateTag({content: description}, "name='description'"); this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'"); this._meta.updateTag({content: description}, "property='og:description'");
} }
private updateTitle(title: string) { private updateTitle(title: string) {
var _title = ((title.length > 50) ? title.substring(0, 50) : title); var _title = ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title); this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'"); this._meta.updateTag({content: _title}, "property='og:title'");
} }
private updateUrl(url: string) { private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'"); this._meta.updateTag({content: url}, "property='og:url'");
} }

View File

@ -104,7 +104,7 @@ export class CustomizationComponent {
} }
} }
private buildCss() { /*private buildCss() {
if(typeof document === 'undefined') { if(typeof document === 'undefined') {
return; return;
} }
@ -182,7 +182,7 @@ export class CustomizationComponent {
css = css.concat(' border-radius: ' + (this.layout.box.borderRadius != null ? this.layout.box.borderRadius : '6') + 'px;'); css = css.concat(' border-radius: ' + (this.layout.box.borderRadius != null ? this.layout.box.borderRadius : '6') + 'px;');
css = css.concat(' }'); css = css.concat(' }');
/*Panel Elements & cards*/ /!*Panel Elements & cards*!/
css = css.concat(' .communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {'); css = css.concat(' .communityPanelBackground .uk-card:not(.ignoreCommunityPanelBackground), .communityPanelBackground .uk-label:not(.ignoreCommunityPanelBackground) {');
css = css.concat(' background-color: ' + (this.layout.panel.panelElements.backgroundColor != null ? this.layout.panel.panelElements.backgroundColor : 'rgba(255, 255, 255, 0.5)') + ';'); css = css.concat(' background-color: ' + (this.layout.panel.panelElements.backgroundColor != null ? this.layout.panel.panelElements.backgroundColor : 'rgba(255, 255, 255, 0.5)') + ';');
css = css.concat( 'border-color: ' + (this.layout.panel.panelElements.borderColor != null ? this.layout.panel.panelElements.borderColor : 'rgba(255, 255, 255, 0.5)') + ';'); css = css.concat( 'border-color: ' + (this.layout.panel.panelElements.borderColor != null ? this.layout.panel.panelElements.borderColor : 'rgba(255, 255, 255, 0.5)') + ';');
@ -222,7 +222,7 @@ export class CustomizationComponent {
css = css.concat(' color: '+ (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : 'white') + ';'); css = css.concat(' color: '+ (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : 'white') + ';');
css = css.concat(' border-color: ' + (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : 'transparent') + ';'); css = css.concat(' border-color: ' + (this.layout.buttons.lightBackground.onHover.color != null ? this.layout.buttons.lightBackground.onHover.color : 'transparent') + ';');
css = css.concat(' }'); css = css.concat(' }');
/*Buttons*/ /!*Buttons*!/
css = css.concat(' .communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground) {'); css = css.concat(' .communityPanelBackground .uk-button:not(.ignoreCommunityPanelBackground) {');
css = css.concat( 'background-color: ' + css = css.concat( 'background-color: ' +
(this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.backgroundColor?this.layout.buttons.darkBackground.backgroundColor:'white') :(this.layout.buttons.lightBackground.backgroundColor?this.layout.buttons.lightBackground.backgroundColor:'var(--portal-main-color)') ) (this.layout.panel.onDarkBackground ? (this.layout.buttons.darkBackground.backgroundColor?this.layout.buttons.darkBackground.backgroundColor:'white') :(this.layout.buttons.lightBackground.backgroundColor?this.layout.buttons.lightBackground.backgroundColor:'var(--portal-main-color)') )
@ -264,7 +264,7 @@ export class CustomizationComponent {
background-color: white; background-color: white;
color: #666; color: #666;
box-shadow: 0 5px 12px rgba(0, 0, 0, .15); box-shadow: 0 5px 12px rgba(0, 0, 0, .15);
/*border:var(--portal-main-color) 1px solid;*/ /!*border:var(--portal-main-color) 1px solid;*!/
} }
.customTabs .uk-tab > .uk-active > a { .customTabs .uk-tab > .uk-active > a {
@ -284,5 +284,5 @@ export class CustomizationComponent {
css = css.concat(css1); css = css.concat(css1);
console.log(css); console.log(css);
appendCss(css); appendCss(css);
} }*/
} }

View File

@ -147,7 +147,7 @@ export class InviteComponent implements OnInit {
if (this.communityId != null && this.communityId != '') { if (this.communityId != null && this.communityId != '') {
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe( this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
community => { community => {
this.community = community; this.community = community;
this.fullname = (this.user) ? this.user.fullname : null; this.fullname = (this.user) ? this.user.fullname : null;

View File

@ -4,9 +4,8 @@ import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properti
import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
import {EmailService} from "../../openaireLibrary/utils/email/email.service"; import {EmailService} from "../../openaireLibrary/utils/email/email.service";
import {User} from '../../openaireLibrary/login/utils/helper.class'; import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {Email} from "../../openaireLibrary/utils/email/email"; import {Email} from "../../openaireLibrary/utils/email/email";
import {Composer} from "../../openaireLibrary/utils/email/composer"; import {Composer} from "../../openaireLibrary/utils/email/composer";
@ -15,20 +14,22 @@ import {UserManagementService} from "../../openaireLibrary/services/user-managem
import {Subscriber, Subscription} from "rxjs"; import {Subscriber, Subscription} from "rxjs";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {UserRegistryService} from "../../openaireLibrary/services/user-registry.service"; import {UserRegistryService} from "../../openaireLibrary/services/user-registry.service";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
declare var UIkit: any; declare var UIkit: any;
@Component({ @Component({
selector: 'subscribe', selector: 'subscribe',
template: ` template: `
<span *ngIf="subscribed != null && !showNumbers && showTemplate"> <span *ngIf="subscribed != null && !showNumbers && showTemplate">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert=""> <div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
<a class="uk-alert-close" uk-close></a> <a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p> <p>Please login first to subscribe</p>
</div> </div>
<button *ngIf="!subscribed" <button *ngIf="loading" class="uk-button portal-button-reverse uk-button-small uk-width-1-1">
[class]="'uk-button portal-button uk-button-small uk-width-1-1 ' + (loading ? ' uk-disabled' : '')" <span class="uk-icon"><loading [top_margin]="false" [size]="'small'" [color]="null"></loading></span>
</button>
<button *ngIf="!subscribed && !loading" class="uk-button portal-button uk-button-small uk-width-1-1"
(click)="subscribe()"> (click)="subscribe()">
<span class="uk-icon uk-flex uk-flex-middle"> <span class="uk-icon uk-flex uk-flex-middle">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
@ -39,8 +40,7 @@ declare var UIkit: any;
<span class="space">Subscribe</span> <span class="space">Subscribe</span>
</span> </span>
</button> </button>
<button *ngIf="subscribed" <button *ngIf="subscribed && !loading" class="subscribed-button uk-button uk-button-small uk-width-1-1"
[class]="'subscribed-button uk-button uk-button-small uk-width-1-1 ' + (loading ? ' uk-disabled' : '')"
(click)="confirmOpen()"> (click)="confirmOpen()">
<span class="uk-icon uk-flex uk-flex-middle"> <span class="uk-icon uk-flex uk-flex-middle">
<svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> <svg height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
@ -52,15 +52,13 @@ declare var UIkit: any;
</span> </span>
</button> </button>
</span> </span>
<span *ngIf="showNumbers && members > 0 && showTemplate" class="uk-display-inline-block">
<span *ngIf="showNumbers && subscribers !=null && subscribers > 0 && showTemplate" class="uk-display-inline-block"> <span class="lowOpacityColor uk-text-muted">Members: </span> {{members}}
<span class="lowOpacityColor uk-text-muted">Members: </span> {{subscribers}}
</span> </span>
<modal-alert (alertOutput)="confirmClose($event)"> <modal-alert (alertOutput)="confirmClose($event)">
</modal-alert> </modal-alert>
` `
}) })
export class SubscribeComponent { export class SubscribeComponent {
// @Input() showSubscribe:boolean = true; // @Input() showSubscribe:boolean = true;
@Input() showNumbers: boolean; @Input() showNumbers: boolean;
@ -73,8 +71,8 @@ export class SubscribeComponent {
loading: boolean = false; loading: boolean = false;
subscribed: boolean = null; subscribed: boolean = null;
@Input() properties: EnvProperties; @Input() properties: EnvProperties = properties;
subscribers: number = null; members: number = 0;
@Output() countSubscribersEvent = new EventEmitter(); @Output() countSubscribersEvent = new EventEmitter();
showLoginAlert: Boolean = false; showLoginAlert: Boolean = false;
@ViewChild(AlertModal) alert; @ViewChild(AlertModal) alert;
@ -83,19 +81,24 @@ export class SubscribeComponent {
subs: Subscription[] = []; subs: Subscription[] = [];
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _subscribeService: SubscribeService,
private _emailService: EmailService, private _emailService: EmailService,
private _communityService: CommunityService, private _communityService: CommunityService,
private router: Router, private router: Router,
private subscribeService: SubscribeService,
private userManagementService: UserManagementService, private userManagementService: UserManagementService,
private userRegistryService: UserRegistryService private userRegistryService: UserRegistryService) {
) {
} }
public ngOnInit() { public ngOnInit() {
if (!this.properties) { this.subs.push(this.subscribeService.getLoading().subscribe(loading => {
this.properties = properties; this.loading = loading;
} }));
this.subs.push(this.subscribeService.getMembers().subscribe(members => {
this.members = members;
this.countSubscribersEvent.emit({
value: this.members
});
}));
if (!this.showNumbers) { if (!this.showNumbers) {
this.subs.push(this.userManagementService.getUserInfo().subscribe( this.subs.push(this.userManagementService.getUserInfo().subscribe(
user => { user => {
@ -106,7 +109,6 @@ export class SubscribeComponent {
} else { } else {
this.init(); this.init();
} }
//this.init();
} }
public ngOnDestroy() { public ngOnDestroy() {
@ -118,25 +120,7 @@ export class SubscribeComponent {
} }
private isSubscribed() { private isSubscribed() {
// this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user); this.subscribed = Session.isSubscribedTo('community', this.communityId, this.user);
// if (!this.subscribed) {
this.subs.push(this._subscribeService.isSubscribed.subscribe(
res => {
this.subscribed = res;
if (this.subscribed) {
this.subscribeEvent.emit({
value: "ok"
});
}
}
));
// } else {
// if (this.subscribed) {
// this.subscribeEvent.emit({
// value: "ok"
// });
// }
// }
} }
private init() { private init() {
@ -146,40 +130,24 @@ export class SubscribeComponent {
this.subscribed = false; this.subscribed = false;
} else { } else {
if (this.communityId) { if (this.communityId) {
this._subscribeService.initIsSubscribedToCommunity(this.properties, this.communityId);
this.isSubscribed(); this.isSubscribed();
} }
} }
} else { } else {
if (this.communityId) { if (this.communityId) {
//if (properties.environment !== 'development') { this.subscribeService.setLoading(true);
this.subs.push(this._subscribeService.getNumberOfCommunitySubscribers(this.properties, this.communityId).subscribe( this.subs.push(this.userRegistryService.getMembersCount('community', this.communityId).subscribe(res => {
res => { this.subscribeService.setMembers((res && res.response) ? res.response : 0);
this.subscribers = (res && res.value) ? res.value : 0;//(res && res.subscribers && res.subscribers.length) ? res.subscribers.length : 0; this.subscribeService.setLoading(false);
this.countSubscribersEvent.emit({ },
value: this.subscribers error => {
}); this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
}, }));
error => {
this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
}));
// } else {
// this.subs.push(this.userRegistryService.getSubscribersCount('community', this.communityId).subscribe(res => {
// this.subscribers = (res && res.response) ? res.response : 0;
// this.countSubscribersEvent.emit({
// value: this.subscribers
// });
// },
// error => {
// this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
// }));
// }
} }
} }
if (this.communityId) { if (this.communityId) {
this.emailToInformManagers = {body: "", subject: "", recipients: []}; this.emailToInformManagers = {body: "", subject: "", recipients: []};
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
this.subs.push(this._communityService.getCommunityByState(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => { community => {
this.community = community; this.community = community;
}, },
@ -211,8 +179,7 @@ export class SubscribeComponent {
} }
subscribe() { subscribe() {
var email = (this.user) ? this.user.email : null; if (!this.user) {
if (email == null) {
this.subscribed = false; this.subscribed = false;
// this.showLoginAlert = true; // this.showLoginAlert = true;
this.router.navigate(['/user-info'], { this.router.navigate(['/user-info'], {
@ -222,56 +189,24 @@ export class SubscribeComponent {
} }
}); });
} else { } else {
this.loading = true; this.subscribeService.setLoading(true);
// this.showLoginAlert = false; this.showLoginAlert = false;
// if(properties.environment === 'development') { this.subs.push(this.userRegistryService.subscribeTo('community', this.communityId).subscribe(res => {
// this.subs.push(this.userRegistryService.subscribeTo('community', this.communityId).subscribe(res => { this.userManagementService.updateUserInfo();
// this.userManagementService.updateUserInfo(); this.subscribeService.setMembers(this.members + 1);
// this.loading = false; this.subscribeService.setLoading(false);
// this.successfulSubscribe(email); this.successfulSubscribe(this.user.email);
// },error => { }, error => {
// this.loading = false; this.subscribeService.setLoading(false);
// UIkit.notification({ UIkit.notification({
// message: '<strong>An error occurred. Please try again!<strong>', message: '<strong>An error occurred. Please try again!<strong>',
// status: 'warning', status: 'warning',
// timeout: 3000, timeout: 3000,
// pos: 'top-center' pos: 'top-center'
// }); });
// //console.log(error) //console.log(error)
// this.handleError("Error subscribing email: " + email + " from community with id: " + this.communityId, error); this.handleError("Error subscribing email: " + this.user.email + " from community with id: " + this.communityId, error);
// })); }));
// }
this.subs.push(this._subscribeService.subscribeToCommunity(this.properties, this.communityId).subscribe(
res => {
this.loading = false;
if (res.status && res.status != 200) {
this.subscribeEvent.emit({
value: "error"
});
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
} else {
this.successfulSubscribe(email);
}
},
error => {
this.loading = false;
this.subscribeEvent.emit({
value: "error"
});
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error subscribing email: " + email + " to community with id: " + this.communityId, error);
}));
} }
} }
@ -280,52 +215,23 @@ export class SubscribeComponent {
if (email == null) { if (email == null) {
this.subscribed = false; this.subscribed = false;
} else { } else {
this.loading = true; this.subscribeService.setLoading(true);
// if(properties.environment === 'development') { this.subs.push(this.userRegistryService.unsubscribeFrom('community', this.communityId).subscribe(res => {
// this.subs.push(this.userRegistryService.unsubscribeFrom('community', this.communityId).subscribe(res => { this.userManagementService.updateUserInfo();
// this.userManagementService.updateUserInfo(); this.subscribeService.setMembers(this.members - 1);
// this.loading = false; this.subscribeService.setLoading(false);
// this.subscribed = false; this.subscribed = false;
// },error => { }, error => {
// this.loading = false; this.subscribeService.setLoading(false);
// UIkit.notification({ UIkit.notification({
// message: '<strong>An error occurred. Please try again!<strong>', message: '<strong>An error occurred. Please try again!<strong>',
// status: 'warning', status: 'warning',
// timeout: 3000, timeout: 3000,
// pos: 'top-center' pos: 'top-center'
// }); });
// //console.log(error) //console.log(error)
// this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error); this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error);
// })); }));
// }
this.subs.push(this._subscribeService.unSubscribeToCommunity(this.properties, this.communityId).subscribe(
res => {
this.loading = false;
if (res.status && res.status != 200) {
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
} else {
//console.log(res);
if (this.subscribed) {
this.subscribed = false;
}
}
},
error => {
this.loading = false;
UIkit.notification({
message: '<strong>An error occurred. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error);
}));
} }
} }

View File

@ -5,10 +5,11 @@ import {RouterModule} from '@angular/router';
import {EmailService} from "../../openaireLibrary/utils/email/email.service"; import {EmailService} from "../../openaireLibrary/utils/email/email.service";
import {SubscribeComponent} from './subscribe.component'; import {SubscribeComponent} from './subscribe.component';
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, RouterModule, AlertModalModule CommonModule, RouterModule, AlertModalModule, LoadingModule
], ],
declarations: [ declarations: [
SubscribeComponent SubscribeComponent

View File

@ -1,15 +0,0 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {PreviousRouteRecorder} from "../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
import {VerificationGuard} from "../openaireLibrary/login/verification.guard";
import {VerificationManagerComponent} from "./verification-manager.component";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: VerificationManagerComponent, canActivate: [VerificationGuard], canDeactivate: [PreviousRouteRecorder]}
])
]
})
export class VerificationManagerRoutingModule {
}

View File

@ -1,61 +0,0 @@
import {Component, OnDestroy, OnInit} from "@angular/core";
import {UserRegistryService} from "../openaireLibrary/services/user-registry.service";
import {ActivatedRoute} from "@angular/router";
import {Subscriber, Subscription} from "rxjs";
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {properties} from "../../environments/environment";
@Component({
selector: 'verification-manager',
template: `
<div class="uk-section uk-container">
<div class="uk-card uk-card-default uk-card-body">
<div *ngIf="loading" class="loading-gif"></div>
<div *ngIf="!loading && invitation">
<verification [name]="name" [invitation]="invitation"></verification>
</div>
</div>
</div>
`
})
export class VerificationManagerComponent implements OnInit, OnDestroy {
private subscriptions: any[] = [];
public loading = true;
public invitation;
public name;
constructor(private userRegistryService: UserRegistryService,
private communityService: CommunityService,
private route: ActivatedRoute) {
}
ngOnInit() {
this.subscriptions.push(this.route.params.subscribe(params => {
if (params && params['id']) {
this.subscriptions.push(this.userRegistryService.getInvitation(params['id']).subscribe(invitation => {
this.invitation = invitation;
this.subscriptions.push(this.communityService.
getCommunityByState(properties, properties.communityAPI + invitation.entity).subscribe(community => {
this.name = community.title;
this.loading = false;
}));
}, error => {
this.loading = false;
console.error(error);
}));
}
}));
}
ngOnDestroy() {
this.subscriptions.forEach(sub => {
if (sub instanceof Subscription) {
if (sub instanceof Subscriber) {
sub.unsubscribe();
}
}
});
}
}

View File

@ -1,14 +0,0 @@
import {NgModule} from "@angular/core";
import {CommonModule} from "@angular/common";
import {VerificationManagerComponent} from "./verification-manager.component";
import {VerificationModule} from "../openaireLibrary/verification/verification.module";
import {VerificationGuard} from "../openaireLibrary/login/verification.guard";
import {VerificationManagerRoutingModule} from "./verification-manager-routing.module";
@NgModule({
imports: [CommonModule, VerificationModule, VerificationManagerRoutingModule],
declarations: [VerificationManagerComponent],
exports: [VerificationManagerComponent],
providers: [VerificationGuard]
})
export class VerificationManagerModule {}