From c720c86f449c2563e573b24f5f2eeb50910ed3b1 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Fri, 23 Nov 2018 09:52:51 +0000 Subject: [PATCH] Create new page "Share in Zenodo" (add componets, routing, menu item, properties) remove unused my-communities folder git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@53934 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app-routing.module.ts | 1 + src/app/app.component.ts | 7 +- .../zenodo/shareInZenodo-routing.module.ts | 16 ++ .../zenodo/shareInZenodo.component.html | 92 ++++++++++ .../deposit/zenodo/shareInZenodo.component.ts | 159 ++++++++++++++++++ .../deposit/zenodo/shareInZenodo.module.ts | 29 ++++ .../communities-routing.module.ts | 17 -- .../my-communities/communities.component.html | 104 ------------ .../my-communities/communities.component.ts | 101 ----------- src/app/my-communities/communities.module.ts | 36 ---- src/assets/env-properties.json | 1 + 11 files changed, 303 insertions(+), 260 deletions(-) create mode 100644 src/app/deposit/zenodo/shareInZenodo-routing.module.ts create mode 100644 src/app/deposit/zenodo/shareInZenodo.component.html create mode 100644 src/app/deposit/zenodo/shareInZenodo.component.ts create mode 100644 src/app/deposit/zenodo/shareInZenodo.module.ts delete mode 100644 src/app/my-communities/communities-routing.module.ts delete mode 100644 src/app/my-communities/communities.component.html delete mode 100644 src/app/my-communities/communities.component.ts delete mode 100644 src/app/my-communities/communities.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 100030a..5e9ac7f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -26,6 +26,7 @@ const routes: Routes = [ { path: 'participate/deposit-subject-result', loadChildren: './deposit/datasets/depositBySubjectResults.module#LibDepositBySubjectResultsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'participate/deposit-publications', loadChildren: './deposit/publications/depositPublications.module#LibDepositPublicationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'participate/deposit-publications-result', loadChildren: './deposit/publications/depositPublicationsResults.module#LibDepositPublicationsResultsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, + { path: 'participate/share-zenodo', loadChildren: './deposit/zenodo/shareInZenodo.module#ShareInZenodoModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/find', loadChildren: './searchPages/find/libSearch.module#LibMainSearchModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/find/publications', loadChildren: './searchPages/simple/searchPublications.module#LibSearchPublicationsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, { path: 'search/find/datasets', loadChildren: './searchPages/simple/searchDatasets.module#LibSearchDatasetsModule', resolve: { envSpecific: EnvironmentSpecificResolver }}, diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c037e8d..38c1902 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -96,8 +96,11 @@ export class AppComponent { items: [] }, { - rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets"],{communityId:community.communityId}), - items: [new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],{communityId:community.communityId}), + rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets","/participate/share-zenodo"],{communityId:community.communityId}), + items: [ + new MenuItem("","in Zenodo","","/participate/share-zenodo",false,[],[],{communityId:community.communityId}), + new MenuItem("","in other content providers","","",false,[],[],{}), + new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],{communityId:community.communityId}), new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],{communityId:community.communityId})] }, { diff --git a/src/app/deposit/zenodo/shareInZenodo-routing.module.ts b/src/app/deposit/zenodo/shareInZenodo-routing.module.ts new file mode 100644 index 0000000..9973034 --- /dev/null +++ b/src/app/deposit/zenodo/shareInZenodo-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import {ShareInZenodoComponent} from './shareInZenodo.component'; +import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ShareInZenodoComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } + + ]) + ] +}) +export class ShareInZenodoRoutingModule { } diff --git a/src/app/deposit/zenodo/shareInZenodo.component.html b/src/app/deposit/zenodo/shareInZenodo.component.html new file mode 100644 index 0000000..dfeee5f --- /dev/null +++ b/src/app/deposit/zenodo/shareInZenodo.component.html @@ -0,0 +1,92 @@ + +
+
+
+ Share in Zenodo +
+
+
+
Master Zenodo community
+
+ +
+ + + +
+
+

+ + {{masterZenodoCommunity.title}} + [no name available] + +
+ {{masterZenodoCommunity.title}} + [no name available] +
+

+
+ last update: {{masterZenodoCommunity.date | date:'yyyy/MM/dd'}} +
+ +
+ +
+
+

+
+
+
+ + + +
+
diff --git a/src/app/deposit/zenodo/shareInZenodo.component.ts b/src/app/deposit/zenodo/shareInZenodo.component.ts new file mode 100644 index 0000000..4cc44b7 --- /dev/null +++ b/src/app/deposit/zenodo/shareInZenodo.component.ts @@ -0,0 +1,159 @@ +import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Title, Meta} from '@angular/platform-browser'; +import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; +import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; +import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; +import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper'; + +import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; + +@Component({ + selector: 'share-in-zenodo', + templateUrl: './shareInZenodo.component.html' +}) +export class ShareInZenodoComponent { + properties:EnvProperties; + private communityId: string = null; + private community:CommunityInfo = null; + + + // public warningMessage = ""; + // public infoMessage = ""; + + masterZenodoCommunityId = null; + masterZenodoCommunity = null; + + CommunityIds = null; + communities = []; + + zenodocommunitiesloadedCount = 0; + zenodoSearchUtils:SearchUtilsClass = new SearchUtilsClass(); + private errorCodes: ErrorCodes = new ErrorCodes();; + depositLink = "https://zenodo.org/deposit/new?c="; + + + constructor ( private route: ActivatedRoute, private _router: Router, + private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService,private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {} + + public ngOnInit() { + this.zenodoSearchUtils.status = this.errorCodes.LOADING;; + this.route.data + .subscribe((data: { envSpecific: EnvProperties }) => { + this.updateUrl(data.envSpecific.baseLink+this._router.url); + this.updateTitle("Share in Zenodo"); + this.updateDescription("Zenodo, repository, deposit, share"); + this.properties = data.envSpecific; + this.route.queryParams.subscribe(params => { + this.communityId = params['communityId']; + if(!this.communityId){ + this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname); + } + + if(this.communityId) { + + if (this.communityId != null && this.communityId != '') { + + this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe ( + community => { + this.community = community; + this.masterZenodoCommunityId = this.community.zenodoCommunity; + if(this.masterZenodoCommunityId){ + this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.masterZenodoCommunityId, null).subscribe( + result => { + this.masterZenodoCommunity = result; + + }, + error => { + // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); + // emptyCommunity.id = this.masterZenodoCommunityId; + // emptyCommunity.title = this.masterZenodoCommunityId; + // this.masterZenodoCommunity = emptyCommunity; + console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded"); + + + } + ); + } + this.zenodoSearchUtils.status = this.errorCodes.LOADING;; + 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; + } + for(let i=0; i< this.CommunityIds.length; i++){ + this.getZenodoCommunityById(this.CommunityIds[i]["zenodoid"], this.CommunityIds[i]["id"]); + } + + }, + error => { + console.log("list of zenodo communities couldn't be loaded"); + this.zenodoSearchUtils.status = this.errorCodes.ERROR; + } //this.handleError('System error retrieving community profile', error) + ); + + }, + error => { + console.log("Community couldn't be loaded"); + this.zenodoSearchUtils.status = this.errorCodes.ERROR; + } + ); + + + } + + + } + }); + }); +} + + + private updateDescription(description:string){ + this._meta.updateTag({content:description},"name='description'"); + this._meta.updateTag({content:description},"property='og:description'"); + } + private updateTitle(title:string){ + var _prefix ="OpenAIRE | "; + var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title); + this._title.setTitle(_title); + this._meta.updateTag({content:_title},"property='og:title'"); + } + private updateUrl(url:string){ + this._meta.updateTag({content:url},"property='og:url'"); + } + getZenodoCommunityById(zenodoid, openaireId){ + this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+zenodoid, openaireId).subscribe( + result => { + this.communities.push(result); + this.zenodocommunitiesloadedCount++; + if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){ + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + + + }, + error => { + // var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); + // emptyCommunity.id = zenodoid; + // emptyCommunity.openaireId = openaireId; + // emptyCommunity.title = zenodoid; + // this.communities.push(emptyCommunity); + this.zenodocommunitiesloadedCount++; + if(this.zenodocommunitiesloadedCount >= this.CommunityIds.length){ + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + console.log("Zenodo community'"+zenodoid+"' couldn't be loaded"); + + + } +); +} +} diff --git a/src/app/deposit/zenodo/shareInZenodo.module.ts b/src/app/deposit/zenodo/shareInZenodo.module.ts new file mode 100644 index 0000000..3c0a55f --- /dev/null +++ b/src/app/deposit/zenodo/shareInZenodo.module.ts @@ -0,0 +1,29 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard'; +import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; +import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' + +import {ShareInZenodoComponent} from './shareInZenodo.component'; +import {ShareInZenodoRoutingModule} from './shareInZenodo-routing.module'; +import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module'; +import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module'; + +import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; + +@NgModule({ + imports: [ + CommonModule,ShareInZenodoRoutingModule, ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule + ], + declarations: [ + ShareInZenodoComponent + ], + providers:[FreeGuard,PreviousRouteRecorder, IsRouteEnabled, CommunityService], + exports: [ + ShareInZenodoComponent + ] +}) + + +export class ShareInZenodoModule{} diff --git a/src/app/my-communities/communities-routing.module.ts b/src/app/my-communities/communities-routing.module.ts deleted file mode 100644 index b9c841e..0000000 --- a/src/app/my-communities/communities-routing.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; - -import{MyCommunitiesComponent} from './communities.component'; - -import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard'; -import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - { path: '', component: MyCommunitiesComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] } - - ]) - ] -}) -export class CommunitiesRoutingModule { } diff --git a/src/app/my-communities/communities.component.html b/src/app/my-communities/communities.component.html deleted file mode 100644 index 80f3bab..0000000 --- a/src/app/my-communities/communities.component.html +++ /dev/null @@ -1,104 +0,0 @@ - - -
-
-
-
-
-
- Research Community Dashboard -
-

- Your view to open science -

-
-
-
-
- - -
-
- -
- -
- -
- {{(item.title)?item.title:item.shortTitle}} logo - - - -
-
-
-
-
- -
-
- -
-
- -
-

- - {{(item.title)?item.title:item.shortTitle}} - - {{(item.title)?item.title:item.shortTitle}} -

-
- - -

{{item.description}}

- - -
-
-
- -
-
- -
- -
- -
- {{(item.title)?item.title:item.shortTitle}} logo - - - -
-
-
-
-
- -
-
- -
-
- -
-

- - {{(item.title)?item.title:item.shortTitle}} - - {{(item.title)?item.title:item.shortTitle}} -

-
- - -

{{item.description}}

- - -
-
-
- -
-
-
diff --git a/src/app/my-communities/communities.component.ts b/src/app/my-communities/communities.component.ts deleted file mode 100644 index 295ddf2..0000000 --- a/src/app/my-communities/communities.component.ts +++ /dev/null @@ -1,101 +0,0 @@ -import {Component, Input, Output, EventEmitter} from '@angular/core'; -import {ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ViewEncapsulation} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {Location} from '@angular/common'; -import {Title, Meta} from '@angular/platform-browser'; - -import {Observable} from 'rxjs/Observable'; - -import "rxjs/add/observable/zip"; - -import {ConnectHelper} from '../openaireLibrary/connect/connectHelper'; -import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; -import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes'; - -import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; -import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service'; -import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; -import {Session} from '../openaireLibrary/login/utils/helper.class'; -@Component({ - selector: 'communities', - templateUrl: 'communities.component.html', -}) - -export class MyCommunitiesComponent { - public piwiksub: any; - public subfunders: any; - - public pageTitle = "OpenAIRE" - - public communitiesResults = null; - - properties:EnvProperties; - - constructor ( - private route: ActivatedRoute, - private _router: Router, - private location: Location, - private _meta: Meta, - private _title: Title, - private _piwikService:PiwikService, - private _communitiesService:CommunitiesService, - private config: ConfigurationService) { - - var description = "Community Dashboard"; - var title = "Community Dashboard"; - - this._meta.updateTag({content:description},"name='description'"); - this._meta.updateTag({content:description},"property='og:description'"); - this._meta.updateTag({content:title},"property='og:title'"); - this._title.setTitle(title); - } - - public ngOnInit() { - this.route.data - .subscribe((data: { envSpecific: EnvProperties }) => { - this.properties = data.envSpecific; - var url = data.envSpecific.baseLink+this._router.url - this._meta.updateTag({content:url},"property='og:url'"); - if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ - this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe(); - } - - this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe( - communitiesResults => { - this.communitiesResults = communitiesResults; - //console.log(communitiesResults); - }); - }); - } - - public ngOnDestroy() { - if(this.piwiksub){ - this.piwiksub.unsubscribe(); - } - } - isProduction():boolean{ - return ConnectHelper.isProduction(document.location.hostname); - - } - getProductionPrefix():string{ - return ConnectHelper.getProductionPrefix(document.location.hostname); - } - showCommunity(community):boolean{ - if(community['status'] == "hidden"){ - return false; - }else if(community['status'] == "manager"){ - var mail = Session.getUserEmail(); - if(mail == null){ // no user - return false; - }else if(Session.isCommunityCurator() || Session.isPortalAdministrator()){ - return true; - }else if(community.managers.indexOf(mail)!=-1){ - return true; - } - return false; - } - return true; - - } -} diff --git a/src/app/my-communities/communities.module.ts b/src/app/my-communities/communities.module.ts deleted file mode 100644 index cac7842..0000000 --- a/src/app/my-communities/communities.module.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {FormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; - -import {CommunitiesRoutingModule} from './communities-routing.module'; -import {SubscribeModule} from '../utils/subscribe/subscribe.module'; -import {ManageModule} from '../utils/manage/manage.module'; - -import {MyCommunitiesComponent} from './communities.component'; - -import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard'; -import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; - -import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; -import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service'; -import {CommunitiesService} from '../openaireLibrary/connect/communities/communities.service'; - -@NgModule({ - imports: [ - CommonModule, FormsModule, RouterModule, - CommunitiesRoutingModule, - SubscribeModule, ManageModule - ], - declarations: [ - MyCommunitiesComponent - ], - providers:[ - FreeGuard, PreviousRouteRecorder, ConfigurationService, - PiwikService, CommunitiesService - ], - exports: [ - MyCommunitiesComponent - ] -}) -export class MyCommunitiesModule { } diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json index 755feaf..21e846b 100644 --- a/src/assets/env-properties.json +++ b/src/assets/env-properties.json @@ -30,6 +30,7 @@ "openDoarURL": "http://v2.sherpa.ac.uk/id/repository/", "r3DataURL": "http://service.re3data.org/repository/", "zenodo" : "https://zenodo.org/", + "zenodoCommunities" : "https://zenodo.org/api/communities/", "openAccess" : "https://www.openaire.eu/support/faq#article-id-234", "openAccessRepo" : "https://www.openaire.eu/support/faq#article-id-310", "fp7Guidlines" : "https://www.openaire.eu/open-access-in-fp7-seventh-research-framework-programme",