[Lirabry | Trunk]: Annotation add tooltip if no pid is existed

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58804 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-05-29 09:50:49 +00:00
parent 4fd8439224
commit 4bb8760d78
2 changed files with 31 additions and 12 deletions

View File

@ -8,7 +8,7 @@ import {EnvProperties} from "../../utils/properties/env-properties";
template: ` template: `
<div class="sideInfoTitle uk-margin-small-bottom">Annotations</div> <div class="sideInfoTitle uk-margin-small-bottom">Annotations</div>
<div class="b2note"> <div class="b2note">
<form ngNoForm <form ngNoForm *ngIf="pid"
action="https://b2note-dev.bsc.es/widget/" action="https://b2note-dev.bsc.es/widget/"
method="post" method="post"
target="b2note_iframe" target="b2note_iframe"
@ -37,13 +37,19 @@ import {EnvProperties} from "../../utils/properties/env-properties";
<span>add annotation</span> <span>add annotation</span>
</button> </button>
</form> </form>
<ul class="uk-list uk-list-divider"> <div *ngIf="!pid">
<button class="uk-flex uk-flex-middle disabled" title="Annotations are only available for resources with a PID (persistent identifier) like DOI, handle, PMID">
<img src="assets/common-assets/b2note.png" width="48" height="24">
<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"> <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 [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> <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"> <ul class="uk-width-expand uk-list uk-margin-remove-top" *ngIf="annotation.urls">
<li *ngFor="let url of annotation.urls.slice(0, urlSize)"><a [href]="url" target="_blank">{{url}}</a></li> <li *ngFor="let url of annotation.urls.slice(0, annotation.urlSize)"><a [href]="url" target="_blank">{{url}}</a></li>
<li *ngIf="urlSize < annotation.urls.length"><a (click)="urlSize = annotation.urls.length">+ {{annotation.urls.length - urlSize}} more</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> </ul>
</li> </li>
</ul> </ul>
@ -77,9 +83,8 @@ export class AnnotationComponent implements OnInit, OnDestroy {
public keywords: string[] = []; public keywords: string[] = [];
public visible: boolean = false; public visible: boolean = false;
public annotations: Annotation[] = []; public annotations: Annotation[] = [];
public annotationSize: number = 10; public annotationSize: number = 3;
public visibleAnnotations: number; public visibleAnnotations: number;
public urlSize: number = 3;
constructor(private annotationService: AnnotationService) { constructor(private annotationService: AnnotationService) {
} }
@ -102,12 +107,25 @@ export class AnnotationComponent implements OnInit, OnDestroy {
this.pid = this.landingInfo.identifiers.get(key)[0]; this.pid = this.landingInfo.identifiers.get(key)[0];
} }
} }
} else {
this.pid = id;
} }
this.annotationService.getAllAnnotations(this.properties, this.pid).subscribe(annotations => { if(this.pid) {
this.annotations = annotations; this.annotationService.getAllAnnotations(this.properties, this.pid).subscribe(annotations => {
}); this.annotations = annotations;
this.annotations.forEach(annotation => {
annotation.urlSize = 3;
});
});
}
}
}
public getTypeName(): string {
if (this.landingInfo.resultType === "dataset") {
return "research data";
} else if (this.landingInfo.resultType === "other") {
return "research product";
} else {
return this.landingInfo.resultType;
} }
} }

View File

@ -10,6 +10,7 @@ export interface Annotation {
text: string; text: string;
type: 'semantic' | 'keyword' | 'comment'; type: 'semantic' | 'keyword' | 'comment';
urls?: string[]; urls?: string[];
urlSize?: number;
} }
@Injectable({ @Injectable({