[plugins-functionality | WIP] move curators component in openaireLibrary

This commit is contained in:
Alex Martzios 2024-02-05 09:42:12 +02:00
parent 34ef34fc00
commit 552edbd0e2
5 changed files with 358 additions and 1 deletions

View File

@ -0,0 +1,15 @@
import { NgModule} from '@angular/core';
import { RouterModule } from '@angular/router';
import {CuratorsComponent} from "./curators.component";
import {IsRouteEnabled} from "../../../error/isRouteEnabled.guard";
import {PreviousRouteRecorder} from "../../../utils/piwik/previousRouteRecorder.guard";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: CuratorsComponent, canActivate: [IsRouteEnabled], canDeactivate: [PreviousRouteRecorder]}
])
]
})
export class CuratorsRoutingModule {
}

View File

@ -0,0 +1,152 @@
<schema2jsonld *ngIf="url" [URL]="url" [name]="pageTitle" type="other"></schema2jsonld>
<ng-container *ngIf="longView else shortView">
<div style="min-height: 650px;">
<div class="uk-container uk-container-large uk-section uk-section-small uk-padding-remove-bottom">
<div class="uk-padding-small uk-padding-remove-horizontal">
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>
</div>
</div>
<div class="uk-container uk-container-large uk-section uk-section-small">
<div *ngIf="showLoading" class="uk-margin-large uk-padding-large uk-padding-remove-horizontal">
<loading></loading>
</div>
<div *ngIf="!showLoading">
<h1 class="uk-margin-top">
Curators
</h1>
<div *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" class="uk-margin-medium">
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
[texts]="pageContents['top']">
</helper>
</div>
<div *ngIf="curators" class="uk-margin-large-top">
<div *ngFor="let curator of curators let i=index;" class="uk-card uk-card-default uk-padding uk-margin-medium-bottom">
<div class="uk-grid" uk-grid>
<div class="uk-width-2-3@m uk-flex uk-flex-middle">
<div class="uk-width-small">
<img *ngIf="curator.photo && curator.photo !== ''" class="uk-border-circle" style="width: 150px; height: 150px;"
src="{{downloadUrl + curator.photo}}" alt="Curator Photo">
<img *ngIf="!curator.photo || curator.photo == ''" class="uk-border-circle" style="width: 150px; height: 150px;"
src="../../assets/common-assets/curator-default.png" alt="Curator Photo">
</div>
<div class="uk-width-expand">
<div class="uk-padding">
<h4 class="uk-margin-remove">{{curator.name}}</h4>
<div *ngIf="curator.bio" class="uk-margin-top uk-height-max-large uk-overflow-auto">
<div class="uk-text-muted uk-margin-small-bottom">
Biography
</div>
<div>
<div *ngIf="!viewingMore">{{format(curator.bio)}}</div>
<div *ngIf="viewingMore">{{curator.bio}}</div>
<div *ngIf="curator.bio.length >= maxCharacters" class="uk-text-right uk-margin-small-top">
<a *ngIf="curator.bio.length >= maxCharacters"
(click)="openFsModal(curator)">
View details
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div *ngIf="curator.affiliations && curator.affiliations.length > 0" class="uk-width-1-3@m uk-padding" style="border-left: 1px solid #eaeaea">
<div class="uk-text-muted uk-margin-bottom">
Affiliations
</div>
<div class="uk-grid uk-flex-middle uk-child-width-1-2" uk-grid>
<div *ngFor="let affiliation of curator.affiliations">
<span *ngIf="!affiliation.website_url">
<img [src]="affiliation.logo_url | urlPrefix" [alt]="affiliation.name">
</span>
<a *ngIf="affiliation.website_url"
target="_blank" [href]="affiliation.website_url | urlPrefix">
<img [src]="affiliation.logo_url | urlPrefix" [alt]="affiliation.name">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-margin-medium">
<helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0"
[texts]="pageContents['bottom']">
</helper>
</div>
</div>
</div>
</ng-container>
<!-- Short view for community's homepage -->
<ng-template #shortView>
<div *ngIf="curators && curators.length > 0" class="uk-grid" uk-grid>
<span class="uk-width-auto">
Curated by:
</span>
<div class="uk-width-expand uk-padding-remove uk-overflow-auto">
<div class="uk-height-max-medium uk-margin-xsmall-left">
<a routerLink="/curators">
<span *ngFor="let curator of curators.slice(0,curatorsLimit) let i=index;">
{{curator.name}}
<span *ngIf="i < curators.length-1 && i < curatorsLimit-1">, </span>
</span>
<span *ngIf="curators.length > curatorsLimit">
+{{curators.length-curatorsLimit}} more
</span>
</a>
</div>
</div>
</div>
</ng-template>
<fs-modal #fsModal classTitle="">
<div *ngIf="curatorInModal" class="uk-width-1-1 uk-height-1-1">
<div class="uk-container uk-container-large uk-section">
<div class="uk-margin-large-top uk-grid uk-grid-large" uk-grid>
<div class="uk-width-1-3@m">
<h2>
{{curatorInModal.name}}
</h2>
<img *ngIf="curatorInModal.photo && curatorInModal.photo !== ''" class="uk-width-2-3 uk-border-circle uk-margin-top uk-margin-bottom"
src="{{downloadUrl + curatorInModal.photo}}" alt="Curator Photo">
<img *ngIf="!curatorInModal.photo || curatorInModal.photo == ''" class="uk-width-2-3 uk-border-circle uk-margin-top uk-margin-bottom"
src="../../assets/common-assets/curator-default.png" alt="Curator Photo">
</div>
<div class="uk-width-2-3@m">
<ul class="uk-tab" uk-tab>
<li>
<a>Biography</a>
</li>
<li *ngIf="curatorInModal.affiliations && curatorInModal.affiliations.length > 0">
<a>Affiliations</a>
</li>
</ul>
<ul class="uk-switcher">
<li class="uk-padding uk-padding-remove-left">
<h5>
Biography
</h5>
<div>
{{curatorInModal.bio}}
</div>
</li>
<li *ngIf="curatorInModal.affiliations && curatorInModal.affiliations.length > 0" class="uk-padding uk-padding-remove-left">
<div class="uk-grid uk-flex-middle uk-child-width-1-3" uk-grid>
<div *ngFor="let affiliation of curatorInModal.affiliations">
<span *ngIf="!affiliation.website_url">
<img [src]="affiliation.logo_url | urlPrefix" [alt]="affiliation.name">
</span>
<a *ngIf="affiliation.website_url"
target="_blank" [href]="affiliation.website_url | urlPrefix">
<img [src]="affiliation.logo_url | urlPrefix" [alt]="affiliation.name">
</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</fs-modal>

View File

@ -0,0 +1,155 @@
import {Component, Input, ViewChild} from '@angular/core';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {CuratorService} from "../../curators/curator.service";
import {Curator} from "../../../utils/entities/CuratorInfo";
import {ActivatedRoute, Router} from "@angular/router";
import {CommunityService} from "../../community/community.service";
import {HelperService} from "../../../utils/helper/helper.service";
import {Meta, Title} from "@angular/platform-browser";
import {SEOService} from "../../../sharedComponents/SEO/SEO.service";
import {PiwikService} from "../../../utils/piwik/piwik.service";
import {Breadcrumb} from "../../../utils/breadcrumbs/breadcrumbs.component";
import {Subscription} from "rxjs";
import {properties} from "../../../../../environments/environment";
import {UserRegistryService} from "../../../services/user-registry.service";
import {FullScreenModalComponent} from '../../../utils/modal/full-screen-modal/full-screen-modal.component';
import {CommunityInfo} from "../../community/communityInfo";
@Component({
selector: 'curators',
templateUrl: './curators.component.html'
})
export class CuratorsComponent {
@Input() longView = true;
community: CommunityInfo;
public downloadUrl = null;
public showLoading = true;
public curators: Curator[] = [];
public curatorsLimit: number = 5;
public numberOfCurators: number = 5;
public showMore = [];
public maxCharacters = 450;
public viewingMore: boolean = false;
public curatorInModal;
public properties: EnvProperties;
public pageContents = null;
public divContents = null;
public url: string = null;
public pageTitle: string = "Curators";
public breadcrumbs: Breadcrumb[] = [{name: 'Home', route: '/'}, {name: 'About - Curators'}];
subs: Subscription[] = [];
@ViewChild('fsModal', { static: true }) fsModal: FullScreenModalComponent;
constructor(private route: ActivatedRoute,
private curatorsService: CuratorService,
private communityService: CommunityService,
private userRegistryService: UserRegistryService,
private _router: Router,
private helper: HelperService,
private _meta: Meta,
private _title: Title,
private seoService: SEOService,
private _piwikService: PiwikService) {
}
ngOnInit() {
this.showLoading = true;
this.properties = properties;
this.downloadUrl = this.properties.utilsService + '/download/';
//if (properties.environment !== 'development') {
if (!this.longView) {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if (community) {
this.community = community;
this.getCurators();
}
}));
} else {
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if (community) {
this.community = community;
this.subs.push(this._piwikService.trackView(this.properties, this.pageTitle).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.curatorsService.getCurators(this.properties, this.community.communityId).subscribe(curators => {
this.curators = curators;
this.showLoading = false;
}, error => {
console.error(error);
this.curators = [];
this.showLoading = false;
}));
}
private getPageContents() {
this.subs.push(this.helper.getPageHelpContents(this.properties, this.community.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents;
}));
}
private getDivContents() {
this.subs.push(this.helper.getDivHelpContents(this.properties, this.community.communityId, this._router.url).subscribe(contents => {
this.divContents = contents;
}));
}
format(name: string) {
if (name) {
return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
} else {
return null;
}
}
public viewMore() {
this.viewingMore = !this.viewingMore;
}
public openFsModal(curator) {
this.curatorInModal = curator;
this.fsModal.title = this.community.shortTitle + ' Curator';
this.fsModal.open();
}
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'");
}
}

View File

@ -0,0 +1,35 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import {CuratorsComponent} from './curators.component';
import {CuratorService} from "../../curators/curator.service";
import {CuratorsRoutingModule} from "./curators-routing.module";
import {AffiliationsModule} from "../../../../affiliations/affiliations.module";
import {HelperModule} from "../../../utils/helper/helper.module";
import {Schema2jsonldModule} from "../../../sharedComponents/schema2jsonld/schema2jsonld.module";
import {SEOServiceModule} from "../../../sharedComponents/SEO/SEOService.module";
import {PiwikServiceModule} from "../../../utils/piwik/piwikService.module";
import {BreadcrumbsModule} from "../../../utils/breadcrumbs/breadcrumbs.module";
import {UrlPrefixModule} from "../../../utils/pipes/url-prefix.module";
import {LoadingModule} from '../../../utils/loading/loading.module';
import {FullScreenModalModule} from '../../../utils/modal/full-screen-modal/full-screen-modal.module';
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
CuratorsRoutingModule, AffiliationsModule, HelperModule,
Schema2jsonldModule, SEOServiceModule, PiwikServiceModule,
BreadcrumbsModule, UrlPrefixModule, LoadingModule,
FullScreenModalModule
],
declarations: [
CuratorsComponent
],
providers: [CuratorService],
exports: [
CuratorsComponent
]
})
export class CuratorsModule {}

View File

@ -9,7 +9,7 @@ import {IconsService} from "../../../../utils/icons/icons.service";
import {SearchResearchResultsServiceModule} from "../../../../services/searchResearchResultsService.module";
import {PluginFieldEditModule} from "../../utils/plugin-field-edit.module";
import {PluginGatewayInformationComponent} from './plugin-gateway-information.component';
import {CuratorsModule} from '../../../../../curators/curators.module';
import {CuratorsModule} from '../../../../connect/components/curators/curators.module';
import {SearchCommunityProjectsService} from '../../../../../openaireLibrary/connect/projects/searchProjects.service';
import {SearchCommunityDataprovidersService} from '../../../../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
import {ZenodoCommunitiesService} from '../../../../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';