+
+
+ -
{{annotation.type}}
{{annotation.text}}
-
+
@@ -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[] = [];
@@ -100,12 +108,10 @@ export class AnnotationComponent implements OnInit, OnDestroy {
@HostListener('window:message', ['$event'])
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);
- }));
+ if (this.properties.b2noteAPIURL.includes(event.origin)) {
+ if (event.data === "B2NOTE loaded") {
+ let token = COOKIE.getCookie('AccessToken');
+ this.iframe.nativeElement.contentWindow.postMessage({token: token}, this.properties.b2noteAPIURL);
} else {
this.getAnnotations();
}
@@ -134,7 +140,7 @@ export class AnnotationComponent implements OnInit, OnDestroy {
}
}
}
- if(this.pid) {
+ if (this.pid) {
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;
});
}