From a56e91b7ec0e9ec103dce13a7786ae06f0c1cddb Mon Sep 17 00:00:00 2001 From: argirok Date: Fri, 17 May 2024 10:04:58 +0300 Subject: [PATCH] [pluginsFunctionality | DONE | CHANGED] Deposit: add Suggested repos component and links --- src/app/app-routing.module.ts | 5 + src/app/deposit/deposit.component.ts | 14 +- src/app/deposit/deposit.module.ts | 3 +- .../searchDataprovidersToDeposit.component.ts | 14 +- .../searchDataprovidersToDeposit.module.ts | 3 +- .../suggestedRepositories-routing.module.ts | 16 ++ .../suggestedRepositories.component.html | 78 ++++++ .../suggestedRepositories.component.ts | 141 ++++++++++ .../suggested/suggestedRepositories.module.ts | 38 +++ .../zenodo/shareInZenodo.component.html | 254 +++++++++--------- .../deposit/zenodo/shareInZenodo.module.ts | 3 +- 11 files changed, 440 insertions(+), 129 deletions(-) create mode 100644 src/app/deposit/suggested/suggestedRepositories-routing.module.ts create mode 100644 src/app/deposit/suggested/suggestedRepositories.component.html create mode 100644 src/app/deposit/suggested/suggestedRepositories.component.ts create mode 100644 src/app/deposit/suggested/suggestedRepositories.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 56ec1ae..20c94d9 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -279,6 +279,11 @@ const routes: Routes = [ loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule), data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard] }, + { + path: 'participate/deposit/suggested', + loadChildren: () => import('./deposit/suggested/suggestedRepositories.module').then(m => m.SuggestedRepositoriesModule), + data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard] + }, /** Linking Pages */ { path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule), diff --git a/src/app/deposit/deposit.component.ts b/src/app/deposit/deposit.component.ts index 1939465..ed0ee19 100644 --- a/src/app/deposit/deposit.component.ts +++ b/src/app/deposit/deposit.component.ts @@ -8,6 +8,7 @@ import {ZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommuni import {CommunityService} from "../openaireLibrary/connect/community/community.service"; import {Subscriber, Subscription} from "rxjs"; import {properties} from "../../environments/environment"; +import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service"; @Component({ selector: 'openaire-deposit', @@ -30,7 +31,8 @@ export class OpenaireDepositComponent { constructor(private route: ActivatedRoute, private _zenodoCommunitieService: ZenodoCommunitiesService, - private _communityService: CommunityService) { + private _communityService: CommunityService, + private searchCommunityDataprovidersService: SearchCommunityDataprovidersService) { this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService); } @@ -46,6 +48,16 @@ export class OpenaireDepositComponent { this.zenodoInformation.url = this.properties.zenodo; this.zenodoInformation.name = "Zenodo"; } + this.subs.push(this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.communityId, true).subscribe( + res => { + if(res && res.length > 0){ + this.zenodoInformation.hasSuggestedRepositories = true; + } + }, + error => { + console.log(error); + } + )); } })); if (!this.zenodoInformation.shareInZenodoUrl) { diff --git a/src/app/deposit/deposit.module.ts b/src/app/deposit/deposit.module.ts index 7ff01ee..377504a 100644 --- a/src/app/deposit/deposit.module.ts +++ b/src/app/deposit/deposit.module.ts @@ -9,6 +9,7 @@ import {DepositRoutingModule} from "./deposit-routing.module"; import {DepositFirstPageModule} from "../openaireLibrary/deposit/depositFirstPage.module"; import {ZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service"; +import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service"; @NgModule({ imports: [ @@ -21,7 +22,7 @@ import {ZenodoCommunitiesService} from "../openaireLibrary/connect/zenodoCommuni exports: [ OpenaireDepositComponent, ], - providers: [PreviousRouteRecorder, IsRouteEnabled, + providers: [PreviousRouteRecorder, IsRouteEnabled, SearchCommunityDataprovidersService, ZenodoCommunitiesService] }) export class LibDepositModule { } diff --git a/src/app/deposit/searchDataprovidersToDeposit.component.ts b/src/app/deposit/searchDataprovidersToDeposit.component.ts index e7ccca5..54afdf9 100644 --- a/src/app/deposit/searchDataprovidersToDeposit.component.ts +++ b/src/app/deposit/searchDataprovidersToDeposit.component.ts @@ -9,6 +9,7 @@ import {ZenodoInformationClass} from '../openaireLibrary/deposit/utils/zenodoInf import {FetchZenodoInformation} from './utils/fetchZenodoInformation.class'; import {Subscriber, Subscription} from "rxjs"; import {properties} from "../../environments/environment"; +import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service"; @Component({ selector: 'openaire-search-deposit', @@ -28,7 +29,8 @@ export class OpenaireSearchDataprovidersToDepositComponent { constructor(private route: ActivatedRoute, private _zenodoCommunitieService: ZenodoCommunitiesService, - private _communityService: CommunityService) { + private _communityService: CommunityService, + private searchCommunityDataprovidersService: SearchCommunityDataprovidersService) { this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService); } @@ -44,6 +46,16 @@ export class OpenaireSearchDataprovidersToDepositComponent { this.zenodoInformation.url = this.properties.zenodo; this.zenodoInformation.name = "Zenodo"; } + this.subs.push(this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.communityId, true).subscribe( + res => { + if(res && res.length > 0){ + this.zenodoInformation.hasSuggestedRepositories = true; + } + }, + error => { + console.log(error); + } + )); } } )); diff --git a/src/app/deposit/searchDataprovidersToDeposit.module.ts b/src/app/deposit/searchDataprovidersToDeposit.module.ts index 3dcecba..04d0ecf 100644 --- a/src/app/deposit/searchDataprovidersToDeposit.module.ts +++ b/src/app/deposit/searchDataprovidersToDeposit.module.ts @@ -9,6 +9,7 @@ import {SearchDataprovidersToDepositModule} from '../openaireLibrary/deposit/sea import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {IsRouteEnabled} from '../openaireLibrary/error/isRouteEnabled.guard'; import {ZenodoCommunitiesServiceModule} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module'; +import {SearchCommunityDataprovidersService} from "../openaireLibrary/connect/contentProviders/searchDataproviders.service"; @NgModule({ imports: [ @@ -23,6 +24,6 @@ import {ZenodoCommunitiesServiceModule} from '../openaireLibrary/connect/zenodoC exports: [ OpenaireSearchDataprovidersToDepositComponent, ], - providers: [PreviousRouteRecorder, IsRouteEnabled] + providers: [PreviousRouteRecorder, IsRouteEnabled, SearchCommunityDataprovidersService] }) export class LibSearchDataprovidersToDepositModule { } diff --git a/src/app/deposit/suggested/suggestedRepositories-routing.module.ts b/src/app/deposit/suggested/suggestedRepositories-routing.module.ts new file mode 100644 index 0000000..4f8e43e --- /dev/null +++ b/src/app/deposit/suggested/suggestedRepositories-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; +import {IsRouteEnabled} from "../../openaireLibrary/error/isRouteEnabled.guard"; +import {SuggestedRepositoriesComponent} from "./suggestedRepositories.component"; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SuggestedRepositoriesComponent, canActivate: [IsRouteEnabled], canDeactivate: [PreviousRouteRecorder] } + + ]) + ] +}) +export class SuggestedRepositoriesRoutingModule { } diff --git a/src/app/deposit/suggested/suggestedRepositories.component.html b/src/app/deposit/suggested/suggestedRepositories.component.html new file mode 100644 index 0000000..6f36aa4 --- /dev/null +++ b/src/app/deposit/suggested/suggestedRepositories.component.html @@ -0,0 +1,78 @@ + +
+
+ +
+
+
+ +
+
+

Repositories suggested by the curators.

+ +
+ + + +
+ +
+ +
+
+ {{item.name}} +
+
+
+ + +
+
+
+
+
+
+ +
diff --git a/src/app/deposit/suggested/suggestedRepositories.component.ts b/src/app/deposit/suggested/suggestedRepositories.component.ts new file mode 100644 index 0000000..8da7f59 --- /dev/null +++ b/src/app/deposit/suggested/suggestedRepositories.component.ts @@ -0,0 +1,141 @@ +import {Component} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Meta, Title} from '@angular/platform-browser'; +import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; +import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; +import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; +import {HelperService} from "../../openaireLibrary/utils/helper/helper.service"; +import {RouterHelper} from "../../openaireLibrary/utils/routerHelper.class"; +import {SEOService} from "../../openaireLibrary/sharedComponents/SEO/SEO.service"; +import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service"; +import {Breadcrumb} from "../../openaireLibrary/utils/breadcrumbs/breadcrumbs.component"; +import {properties} from "../../../environments/environment"; +import {Subscriber, Subscription} from "rxjs"; +import {SearchCommunityDataprovidersService} from "../../openaireLibrary/connect/contentProviders/searchDataproviders.service"; + +@Component({ + selector: 'suggested-repositories', + templateUrl: './suggestedRepositories.component.html' +}) +export class SuggestedRepositoriesComponent { + public url: string = null; + public title: string = "Suggested Repositories"; + properties: EnvProperties = properties; + communityId: string = null; + community: CommunityInfo = null; + public pageContents = null; + public divContents = null; + + + // public warningMessage = ""; + // public infoMessage = ""; + + masterZenodoCommunityId = null; + masterZenodoCommunity = null; + + communityIds = null; + communities = []; + page = 1; + size = 5; + zenodoCommunitiesLoadedCount = 0; + zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass(); + errorCodes: ErrorCodes = new ErrorCodes(); + depositLink = "https://zenodo.org/deposit/new?c="; + depositLearnHowPage: string = null; + public routerHelper: RouterHelper = new RouterHelper(); + breadcrumbs: Breadcrumb[] = []; + + subs: Subscription[] = []; + contentProviders; + + constructor(private route: ActivatedRoute, + private _router: Router, + private _meta: Meta, + private _title: Title, + private _zenodoCommunitieService: ZenodoCommunitiesService, + private _communityService: CommunityService, + private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, + private helper: HelperService, + private _piwikService: PiwikService, + private seoService: SEOService) { + } + + public ngOnInit() { + this.zenodoSearchUtils.status = this.errorCodes.LOADING; + this.url = properties.domain + properties.baseLink + this._router.url; + this.seoService.createLinkForCanonicalURL(this.url, false); + this.updateUrl(this.url); + this.updateTitle(this.title); + this.updateDescription("sugested repositories, deposit"); + this.depositLearnHowPage = this.properties.depositLearnHowPage; + this.breadcrumbs.push({name: 'home', route: '/'}, { + name: "Deposit", + route: this.depositLearnHowPage + }, {name: "Suggested Repositories", route: null}); + //this.getDivContents(); + this.getPageContents(); + this.subs.push(this._communityService.getCommunityAsObservable().subscribe( + community => { + if (community) { + this.communityId = community.communityId; + this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe()); + this.community = community; + this.masterZenodoCommunityId = this.community.zenodoCommunity; + this.subs.push(this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community.communityId, true).subscribe( + res => { + this.contentProviders = res; + this.zenodoSearchUtils.status = this.contentProviders && this.contentProviders.length > 0 ? this.errorCodes.DONE: this.errorCodes.NONE; + }, + error => { + console.log(error); + } + )); + + } + })); + + } + + public ngOnDestroy() { + for (let sub of this.subs) { + if (sub instanceof Subscriber) { + sub.unsubscribe(); + } + } + } + + private updateDescription(description: string) { + this._meta.updateTag({content: description}, "name='description'"); + this._meta.updateTag({content: description}, "property='og:description'"); + } + + private updateTitle(title: string) { + var _title = ((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'"); + } + + private getPageContents() { + this.subs.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.pageContents = contents; + })); + } + + private getDivContents() { + this.subs.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => { + this.divContents = contents; + })); + } + + private handleError(message: string, error) { + console.error("Share in Zenodo Page: " + message, error); + } + +} diff --git a/src/app/deposit/suggested/suggestedRepositories.module.ts b/src/app/deposit/suggested/suggestedRepositories.module.ts new file mode 100644 index 0000000..db382e0 --- /dev/null +++ b/src/app/deposit/suggested/suggestedRepositories.module.ts @@ -0,0 +1,38 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; +import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard' + +import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module'; + +import {RouterModule} from "@angular/router"; +import {HelperModule} from "../../openaireLibrary/utils/helper/helper.module"; +import {PiwikServiceModule} from "../../openaireLibrary/utils/piwik/piwikService.module"; +import {Schema2jsonldModule} from "../../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module"; +import {SEOServiceModule} from "../../openaireLibrary/sharedComponents/SEO/SEOService.module"; +import {BreadcrumbsModule} from "../../openaireLibrary/utils/breadcrumbs/breadcrumbs.module"; +import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; +import {IconsModule} from 'src/app/openaireLibrary/utils/icons/icons.module'; +import {LoadingModule} from 'src/app/openaireLibrary/utils/loading/loading.module'; +import {SuggestedRepositoriesRoutingModule} from "./suggestedRepositories-routing.module"; +import {SuggestedRepositoriesComponent} from "./suggestedRepositories.component"; +import {SearchCommunityDataprovidersService} from "../../openaireLibrary/connect/contentProviders/searchDataproviders.service"; + +@NgModule({ + imports: [ + CommonModule, SuggestedRepositoriesRoutingModule, ZenodoCommunitiesServiceModule, + RouterModule, HelperModule, LoadingModule, + PiwikServiceModule, Schema2jsonldModule, SEOServiceModule, BreadcrumbsModule, NoLoadPaging, IconsModule + ], + declarations: [ + SuggestedRepositoriesComponent + ], + providers:[PreviousRouteRecorder, IsRouteEnabled, SearchCommunityDataprovidersService], + exports: [ + SuggestedRepositoriesComponent + ] +}) + + +export class SuggestedRepositoriesModule {} diff --git a/src/app/deposit/zenodo/shareInZenodo.component.html b/src/app/deposit/zenodo/shareInZenodo.component.html index 4bcd642..1855f6d 100644 --- a/src/app/deposit/zenodo/shareInZenodo.component.html +++ b/src/app/deposit/zenodo/shareInZenodo.component.html @@ -1,150 +1,156 @@
- +
- -
-

Deposit your research in Zenodo.

-
-
Main Zenodo community
-
-
-
-
-
-
- - - -
-
-

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

Deposit your research in Zenodo.

+
+
Main Zenodo community
+
+
+
+
+ + + +
+
+

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

-
- Last update: {{masterZenodoCommunity.date | date:'yyyy/MM/dd'}} -
-
-
-
-

-
-
+

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

+
+ -
-
-
- -
-
- - -
-
Other related Zenodo communities
-
Related Zenodo communities
- - - -
- -
-
-
-
-
- - - -
-
-

- - {{communities[this.communityIds[i]].title}} - [no name available] - -

-
- Last update: {{communities[this.communityIds[i]].date | date:'yyyy/MM/dd'}} -
-
-
-
-

-
-
+
+
+
+
+
+ +
+ + +
+
Other related Zenodo communities
+
Related Zenodo communities
+ + + -
-
- +
+ + + + + + + + diff --git a/src/app/deposit/zenodo/shareInZenodo.module.ts b/src/app/deposit/zenodo/shareInZenodo.module.ts index 12e2201..a657ddb 100644 --- a/src/app/deposit/zenodo/shareInZenodo.module.ts +++ b/src/app/deposit/zenodo/shareInZenodo.module.ts @@ -17,6 +17,7 @@ import {BreadcrumbsModule} from "../../openaireLibrary/utils/breadcrumbs/breadcr import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; import {IconsModule} from 'src/app/openaireLibrary/utils/icons/icons.module'; import {LoadingModule} from 'src/app/openaireLibrary/utils/loading/loading.module'; +import {SearchCommunityDataprovidersService} from "../../openaireLibrary/connect/contentProviders/searchDataproviders.service"; @NgModule({ imports: [ @@ -27,7 +28,7 @@ import {LoadingModule} from 'src/app/openaireLibrary/utils/loading/loading.modul declarations: [ ShareInZenodoComponent ], - providers:[PreviousRouteRecorder, IsRouteEnabled], + providers:[PreviousRouteRecorder, IsRouteEnabled, SearchCommunityDataprovidersService], exports: [ ShareInZenodoComponent ]