[Library | Trunk]: Annotations: Add loaging gif on first load of annotations.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@59557 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
170414c894
commit
2ae1e1d6c0
|
@ -49,18 +49,25 @@ import {Subscriber} from "rxjs";
|
|||
<span>add annotation</span>
|
||||
</button>
|
||||
</div>
|
||||
<ul *ngIf="annotations" class="uk-list uk-list-divider">
|
||||
<li *ngFor="let annotation of annotations.slice(0, visibleAnnotations)" uk-grid class="uk-flex uk-flex-top uk-margin-remove-left">
|
||||
<div *ngIf="loading" class="loading-gif uk-margin-medium-top"></div>
|
||||
<ul *ngIf="annotations && !loading" class="uk-list uk-list-divider">
|
||||
<li *ngFor="let annotation of annotations.slice(0, visibleAnnotations)" uk-grid
|
||||
class="uk-flex uk-flex-top uk-margin-remove-left">
|
||||
<div [ngClass]="annotation.type" class="uk-width-auto">{{annotation.type}}</div>
|
||||
<div [class.uk-width-1-3]="annotation.urls" [class.uk-width-1-6@s]="annotation.urls">{{annotation.text}}</div>
|
||||
<ul class="uk-width-expand uk-list uk-margin-remove-top" *ngIf="annotation.urls">
|
||||
<li *ngFor="let url of annotation.urls.slice(0, annotation.urlSize)"><a [href]="url" target="_blank">{{url}}</a></li>
|
||||
<li *ngIf="annotation.urlSize < annotation.urls.length"><a (click)="annotation.urlSize = annotation.urls.length">+ {{annotation.urls.length - annotation.urlSize}} more</a></li>
|
||||
<li *ngFor="let url of annotation.urls.slice(0, annotation.urlSize)"><a [href]="url"
|
||||
target="_blank">{{url}}</a></li>
|
||||
<li *ngIf="annotation.urlSize < annotation.urls.length"><a
|
||||
(click)="annotation.urlSize = annotation.urls.length">+ {{annotation.urls.length - annotation.urlSize}}
|
||||
more</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="visibleAnnotations < annotations.length" class="uk-margin-medium-top uk-text-center">
|
||||
<button class="uk-button uk-button-primary" (click)="visibleAnnotations = (visibleAnnotations + annotationSize)">Load More</button>
|
||||
<button class="uk-button uk-button-primary"
|
||||
(click)="visibleAnnotations = (visibleAnnotations + annotationSize)">Load More
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div [class.uk-hidden]="!visible">
|
||||
|
@ -91,6 +98,7 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
public annotationSize: number = 3;
|
||||
public user;
|
||||
public visibleAnnotations: number;
|
||||
public loading: boolean = false;
|
||||
@ViewChild('iframe') iframe: ElementRef;
|
||||
private subscriptions: any[] = [];
|
||||
|
||||
|
@ -102,10 +110,8 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
public onChange(event) {
|
||||
if (this.properties.b2noteAPIURL.includes(event.origin)) {
|
||||
if (event.data === "B2NOTE loaded") {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
let token = COOKIE.getCookie('AccessToken');
|
||||
this.iframe.nativeElement.contentWindow.postMessage({token: token}, this.properties.b2noteAPIURL);
|
||||
}));
|
||||
} else {
|
||||
this.getAnnotations();
|
||||
}
|
||||
|
@ -150,11 +156,15 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
private getAnnotations() {
|
||||
if(!this.annotations || this.annotations.length === 0) {
|
||||
this.loading = true;
|
||||
}
|
||||
this.annotationService.getAllAnnotations(this.properties, this.pid).subscribe(annotations => {
|
||||
this.annotations = annotations;
|
||||
this.annotations.forEach(annotation => {
|
||||
annotation.urlSize = 3;
|
||||
});
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue