[Library | Trunk]: Remove getUserInfo from annotation component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60222 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
4f5cdad9a9
commit
31d164f8cd
|
@ -14,7 +14,7 @@ import {ResultLandingInfo} from "../../utils/entities/resultLandingInfo";
|
|||
import {EnvProperties} from "../../utils/properties/env-properties";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
import {COOKIE, User} from "../../login/utils/helper.class";
|
||||
import {COOKIE, Session, User} from "../../login/utils/helper.class";
|
||||
import {Subscriber} from "rxjs";
|
||||
|
||||
@Component({
|
||||
|
@ -22,7 +22,7 @@ import {Subscriber} from "rxjs";
|
|||
template: `
|
||||
<div *ngIf="annotations && annotations.length > 0" class="sideInfoTitle uk-margin-small-bottom">Annotations</div>
|
||||
<div class="b2note">
|
||||
<form #form ngNoForm *ngIf="pid && user"
|
||||
<form #form ngNoForm *ngIf="pid && isLoggedIn"
|
||||
[action]="properties.b2noteAPIURL + 'widget'"
|
||||
method="post"
|
||||
target="b2note_iframe"
|
||||
|
@ -87,20 +87,17 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
public visible: boolean = false;
|
||||
public annotations: Annotation[] = [];
|
||||
public annotationSize: number = 10;
|
||||
public user;
|
||||
public isLoggedIn: boolean = Session.isLoggedIn();
|
||||
public visibleAnnotations: number;
|
||||
public loading: boolean = false;
|
||||
public submitted: boolean = false;
|
||||
@Output()
|
||||
public userEmitter: EventEmitter<User> = new EventEmitter<User>();
|
||||
@Output()
|
||||
public pidEmitter: EventEmitter<string> = new EventEmitter<string>();
|
||||
@ViewChild('iframe') iframe: ElementRef;
|
||||
@ViewChild('form') form: ElementRef;
|
||||
private subscriptions: any[] = [];
|
||||
|
||||
constructor(private annotationService: AnnotationService,
|
||||
private userManagementService: UserManagementService) {
|
||||
constructor(private annotationService: AnnotationService) {
|
||||
}
|
||||
|
||||
@HostListener('window:message', ['$event'])
|
||||
|
@ -116,10 +113,6 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
this.userEmitter.emit(this.user);
|
||||
}));
|
||||
this.visibleAnnotations = this.annotationSize;
|
||||
if (typeof window !== "undefined") {
|
||||
let id = this.id;
|
||||
|
@ -146,7 +139,7 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
public get enabled(): boolean {
|
||||
return this.pid && this.user;
|
||||
return this.pid && this.isLoggedIn;
|
||||
}
|
||||
|
||||
private clearSubscriptions() {
|
||||
|
|
|
@ -101,14 +101,14 @@
|
|||
</a>
|
||||
</li>
|
||||
<li *ngIf="properties.b2noteAPIURL">
|
||||
<a *ngIf="user && pid" class="uk-link-text uk-text-bold uk-text-uppercase" (click)="annotation.toggleAnnotation($event)">
|
||||
<a *ngIf="isLoggedIn && pid" class="uk-link-text uk-text-bold uk-text-uppercase" (click)="annotation.toggleAnnotation($event)">
|
||||
<span class="uk-icon-button uk-button-primary uk-icon">
|
||||
<img src="assets/common-assets/b2note.png">
|
||||
</span>
|
||||
<span class="uk-margin-small-left">add annotation</span>
|
||||
</a>
|
||||
<span *ngIf="!pid || !user" class="uk-link-text uk-text-bold uk-text-uppercase uk-text-muted"
|
||||
[attr.uk-tooltip]="!pid?'Annotations are available only for resources with a PID (persistent identifier) like DOI, handle, PMID':
|
||||
<span *ngIf="!pid || !isLoggedIn" class="uk-link-text uk-text-bold uk-text-uppercase uk-text-muted"
|
||||
[attr.uk-tooltip]="!pid?'Annotations are available only for resources with a PID (persistent identifier) like DOI, handle, PMID':
|
||||
'Annotations are available only for logged in users'">
|
||||
<span class="uk-icon-button uk-icon uk-disabled">
|
||||
<img src="assets/common-assets/b2note.png">
|
||||
|
@ -501,7 +501,7 @@
|
|||
</div>
|
||||
<!-- B2 Note-->
|
||||
<div *ngIf="properties.b2noteAPIURL && resultLandingInfo" class="uk-margin-medium-top">
|
||||
<b2note #annotation [id]="id" [landingInfo]="resultLandingInfo" (userEmitter)="userInit($event)" (pidEmitter)="pidInit($event)"></b2note>
|
||||
<b2note #annotation [id]="id" [landingInfo]="resultLandingInfo" (pidEmitter)="pidInit($event)"></b2note>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -22,7 +22,7 @@ import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabulari
|
|||
import {Subscriber} from "rxjs";
|
||||
import {Session} from "../../login/utils/helper.class";
|
||||
import {AnnotationComponent} from "../annotation/annotation.component";
|
||||
import {User} from "../../login/utils/helper.class";
|
||||
import {Session, User} from "../../login/utils/helper.class";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -250,11 +250,6 @@ export class ResultLandingComponent {
|
|||
this._vocabulariesService.clearSubscriptions();
|
||||
}
|
||||
|
||||
public userInit(event) {
|
||||
this.user = event;
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
|
||||
public pidInit(event) {
|
||||
this.pid = event;
|
||||
this.cdr.detectChanges();
|
||||
|
|
Loading…
Reference in New Issue