diff --git a/landingPages/annotation/annotation.component.ts b/landingPages/annotation/annotation.component.ts index 181f4f2f..6a70d3b2 100644 --- a/landingPages/annotation/annotation.component.ts +++ b/landingPages/annotation/annotation.component.ts @@ -91,7 +91,7 @@ export class AnnotationComponent implements OnInit, OnDestroy { public keywords: string[] = []; public visible: boolean = false; public annotations: Annotation[] = []; - public annotationSize: number = 3; + public annotationSize: number = 10; public user; public visibleAnnotations: number; public loading: boolean = false; @@ -164,7 +164,7 @@ export class AnnotationComponent implements OnInit, OnDestroy { annotations.forEach(annotation => { if (!this.annotations.find(element => element.type === annotation.type && element.text === annotation.text)) { annotation.targetSize = 3; - this.annotationService.getAnnotationsTargets(annotation.text, annotation.type).subscribe(targets => { + this.annotationService.getAnnotationTargets(annotation.text, annotation.type).subscribe(targets => { annotation.targets = targets.filter(target => target.id !== this.pid); /*for(let i = 0; i < 10; i++) { annotation.targets.push(targets[0]); diff --git a/landingPages/annotation/annotation.service.ts b/landingPages/annotation/annotation.service.ts index bf678c99..992f9044 100644 --- a/landingPages/annotation/annotation.service.ts +++ b/landingPages/annotation/annotation.service.ts @@ -28,16 +28,16 @@ export class AnnotationService { } getAllAnnotations(source: string): Observable { - let url = properties.b2noteAPIURL + this.api + 'annotations?target-id=' + encodeURIComponent(source); + let url = properties.b2noteAPIURL + this.api + 'annotations?target-id[]=' + encodeURIComponent(source); return this.http.get(url).pipe(map((response: any[]) => { return this.parseAnnotations(response); })); } - getAnnotationsTargets(value: string, type: 'semantic' | 'keyword' | 'comment'): Observable { - let url = properties.b2noteAPIURL + this.api + 'annotations?value=' + encodeURIComponent(value); + getAnnotationTargets(value: string, type: 'semantic' | 'keyword' | 'comment'): Observable { + let url = properties.b2noteAPIURL + this.api + 'annotations?value=' + encodeURIComponent(value) + '&type[]=' + type; return this.http.get(url).pipe(map((response: any[]) => { - return this.parseAnnotationTargets(response, type); + return this.parseAnnotationTargets(response); })); } @@ -78,30 +78,15 @@ export class AnnotationService { return annotations; } - private parseAnnotationTargets(response: any[], type: 'semantic' | 'keyword' | 'comment'): AnnotationTarget[] { + private parseAnnotationTargets(response: any[]): AnnotationTarget[] { let targets: AnnotationTarget[] = []; if (response && response.length > 0) { response.forEach(value => { if (value.visibility === 'public') { - let body = value.body; - if (body.type === 'TextualBody') { - if (body.purpose === 'tagging' && type === 'keyword') { - targets.push({ - id: value.target.id, - url: value.target.source - }); - } else if(type === 'comment'){ - targets.push({ - id: value.target.id, - url: value.target.source - }); - } - } else if(type === 'semantic'){ - targets.push({ - id: value.target.id, - url: value.target.source - }); - } + targets.push({ + id: value.target.id, + url: value.target.source + }); } }); }