[Connect|Trunk]

Zenodo communities: paging for zenodo communites



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@60288 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-01-25 10:55:25 +00:00
parent 22a6a878e1
commit 5dcbc657c4
3 changed files with 40 additions and 19 deletions

View File

@ -83,49 +83,61 @@
class="uk-animation-fade uk-margin-top uk-width-1-1 uk-alert uk-alert-warning" role="alert">
No zenodo communities found
</div>
<ul *ngIf="communities.length > 0" class="uk-list uk-margin uk-margin-large-top">
Other related Zenodo communities ({{communities.length}})
<li *ngFor="let item of communities;" class="uk-animation-fade uk-margin-top">
<div class="uk-margin-large-top">Other related Zenodo communities <span *ngIf="communityIds &&
communityIds.length <= size">({{communityIds.length}})</span></div>
<no-load-paging *ngIf="communityIds && communityIds.length > size" [type]="'Zenodo communities'"
(pageChange)="getCommunities($event)"
[page]="page" [pageSize]="size"
[totalResults]="communityIds.length" >
</no-load-paging>
<ul *ngIf="communityIds && communityIds.length > 0" class="uk-list uk-margin ">
<ng-template ngFor let-item [ngForOf]="communityIds" let-i="index" >
<li *ngIf="i>=((page-1)*size) && i < communityIds.length && i< this.page * this.size &&
communities[this.communityIds[i]['zenodoid']]"
class="uk-animation-fade uk-margin-top">
<div class=" uk-card uk-card-default uk-card-body uk-padding-remove-horizontal">
<div class="uk-comment-header uk-grid-medium uk-flex-middle uk-padding uk-padding-remove-vertical" uk-grid>
<div class="uk-width-auto">
<a target="_blank" [href]="item.link">
<img *ngIf="item.logoUrl" class="uk-comment-avatar" src="{{item.logoUrl}}" width="80" height="80"
<a target="_blank" [href]="communities[this.communityIds[i]['zenodoid']].link">
<img *ngIf="communities[this.communityIds[i]['zenodoid']].logoUrl" class="uk-comment-avatar" src="{{communities[this.communityIds[i]['zenodoid']].logoUrl}}" width="80" height="80"
alt="">
</a>
</div>
<div class="uk-width-expand">
<h4 class="uk-comment-title uk-margin-remove">
<a class="uk-width-expand" target="_blank" href="{{item.link}}">
<a class="uk-width-expand" target="_blank" href="{{communities[this.communityIds[i]['zenodoid']].link}}">
<span class="custom-external custom-icon large"></span>
<span class="space"></span>
<span *ngIf="item.title">{{item.title}}</span>
<span *ngIf="!item.title">[no name available]</span>
<span *ngIf="communities[this.communityIds[i]['zenodoid']].title">{{communities[this.communityIds[i]['zenodoid']].title}}</span>
<span *ngIf="!communities[this.communityIds[i]['zenodoid']].title">[no name available]</span>
</a>
</h4>
<div class="uk-comment-meta ">
last update: {{item.date | date:'yyyy/MM/dd'}}
last update: {{communities[this.communityIds[i]['zenodoid']].date | date:'yyyy/MM/dd'}}
</div>
</div>
<!-- <div>-->
<!-- <a class="uk-button portal-button" target="_blank" [href]="depositLink + item.id " >-->
<!-- <a class="uk-button portal-button" target="_blank" [href]="depositLink + communities[this.communityIds[i]['zenodoid']].id " >-->
<!-- <span class="uk-icon"> <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="upload" ratio="1"><polyline fill="none" stroke="#000" points="5 8 9.5 3.5 14 8 "></polyline><rect x="3" y="17" width="13" height="1"></rect><line fill="none" stroke="#000" x1="9.5" y1="15" x2="9.5" y2="4"></line></svg></span>-->
<!-- <span> New upload</span>-->
<!-- </a>-->
<!-- </div>-->
<span class="uk-width-expand uk-flex uk-flex-bottom uk-flex-right">
<a [href]="depositLink + item.id " target="_blank" type="submit"
<a [href]="depositLink + communities[this.communityIds[i]['zenodoid']].id " target="_blank" type="submit"
class=" zenodoButton uk-float-right uk-button portal-button uk-padding uk-padding-remove-vertical uk-margin-small-left">
<span><span>New upload</span><span uk-icon="arrow-right"></span></span>
</a>
</span>
</div>
<div class="uk-comment-body uk-overflow-auto uk-height-max-medium uk-padding uk-padding-remove-vertical">
<p *ngIf="item.description" [innerHtml]=item.description></p>
<p *ngIf="communities[this.communityIds[i]['zenodoid']].description"
[innerHtml]="communities[this.communityIds[i]['zenodoid']].description"></p>
</div>
</div>
</li>
</ng-template>
</ul>
</div>
<helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0"

View File

@ -45,7 +45,8 @@ export class ShareInZenodoComponent {
communityIds = null;
communities = [];
page = 1;
size = 5;
zenodoCommunitiesLoadedCount = 0;
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
errorCodes: ErrorCodes = new ErrorCodes();
@ -125,9 +126,7 @@ export class ShareInZenodoComponent {
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"]);
}
this.getCommunities()
},
error => {
@ -186,9 +185,9 @@ export class ShareInZenodoComponent {
getZenodoCommunityById(zenodoid, openaireId) {
this.subs.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
result => {
this.communities.push(result);
this.communities[zenodoid] = result;
this.zenodoCommunitiesLoadedCount++;
if (this.zenodoCommunitiesLoadedCount >= this.communityIds.length) {
if (this.zenodoCommunitiesLoadedCount >= this.communityIds.length || this.page * this.size) {
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
@ -214,4 +213,13 @@ export class ShareInZenodoComponent {
private handleError(message: string, error) {
console.error("Share in Zenodo Page: " + message, error);
}
public getCommunities($event = {value:1}) {
this.page = $event.value;
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"]]) {
this.getZenodoCommunityById(this.communityIds[i]["zenodoid"], this.communityIds[i]["id"]);
}
}
}
}

View File

@ -15,12 +15,13 @@ import {PiwikServiceModule} from "../../openaireLibrary/utils/piwik/piwikService
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";
@NgModule({
imports: [
CommonModule, ShareInZenodoRoutingModule, ZenodoCommunitiesServiceModule, SearchZenodoCommunitiesServiceModule,
RouterModule, HelperModule,
PiwikServiceModule, Schema2jsonldModule, SEOServiceModule, BreadcrumbsModule
PiwikServiceModule, Schema2jsonldModule, SEOServiceModule, BreadcrumbsModule, NoLoadPaging
],
declarations: [
ShareInZenodoComponent