[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 {EnvProperties} from "../../utils/properties/env-properties";
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
import {UserManagementService} from "../../services/user-management.service";
|
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";
|
import {Subscriber} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -22,7 +22,7 @@ import {Subscriber} from "rxjs";
|
||||||
template: `
|
template: `
|
||||||
<div *ngIf="annotations && annotations.length > 0" class="sideInfoTitle uk-margin-small-bottom">Annotations</div>
|
<div *ngIf="annotations && annotations.length > 0" class="sideInfoTitle uk-margin-small-bottom">Annotations</div>
|
||||||
<div class="b2note">
|
<div class="b2note">
|
||||||
<form #form ngNoForm *ngIf="pid && user"
|
<form #form ngNoForm *ngIf="pid && isLoggedIn"
|
||||||
[action]="properties.b2noteAPIURL + 'widget'"
|
[action]="properties.b2noteAPIURL + 'widget'"
|
||||||
method="post"
|
method="post"
|
||||||
target="b2note_iframe"
|
target="b2note_iframe"
|
||||||
|
@ -87,20 +87,17 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
||||||
public visible: boolean = false;
|
public visible: boolean = false;
|
||||||
public annotations: Annotation[] = [];
|
public annotations: Annotation[] = [];
|
||||||
public annotationSize: number = 10;
|
public annotationSize: number = 10;
|
||||||
public user;
|
public isLoggedIn: boolean = Session.isLoggedIn();
|
||||||
public visibleAnnotations: number;
|
public visibleAnnotations: number;
|
||||||
public loading: boolean = false;
|
public loading: boolean = false;
|
||||||
public submitted: boolean = false;
|
public submitted: boolean = false;
|
||||||
@Output()
|
@Output()
|
||||||
public userEmitter: EventEmitter<User> = new EventEmitter<User>();
|
|
||||||
@Output()
|
|
||||||
public pidEmitter: EventEmitter<string> = new EventEmitter<string>();
|
public pidEmitter: EventEmitter<string> = new EventEmitter<string>();
|
||||||
@ViewChild('iframe') iframe: ElementRef;
|
@ViewChild('iframe') iframe: ElementRef;
|
||||||
@ViewChild('form') form: ElementRef;
|
@ViewChild('form') form: ElementRef;
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
|
|
||||||
constructor(private annotationService: AnnotationService,
|
constructor(private annotationService: AnnotationService) {
|
||||||
private userManagementService: UserManagementService) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:message', ['$event'])
|
@HostListener('window:message', ['$event'])
|
||||||
|
@ -116,10 +113,6 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
||||||
this.user = user;
|
|
||||||
this.userEmitter.emit(this.user);
|
|
||||||
}));
|
|
||||||
this.visibleAnnotations = this.annotationSize;
|
this.visibleAnnotations = this.annotationSize;
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
let id = this.id;
|
let id = this.id;
|
||||||
|
@ -146,7 +139,7 @@ export class AnnotationComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public get enabled(): boolean {
|
public get enabled(): boolean {
|
||||||
return this.pid && this.user;
|
return this.pid && this.isLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearSubscriptions() {
|
private clearSubscriptions() {
|
||||||
|
|
|
@ -101,14 +101,14 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="properties.b2noteAPIURL">
|
<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">
|
<span class="uk-icon-button uk-button-primary uk-icon">
|
||||||
<img src="assets/common-assets/b2note.png">
|
<img src="assets/common-assets/b2note.png">
|
||||||
</span>
|
</span>
|
||||||
<span class="uk-margin-small-left">add annotation</span>
|
<span class="uk-margin-small-left">add annotation</span>
|
||||||
</a>
|
</a>
|
||||||
<span *ngIf="!pid || !user" class="uk-link-text uk-text-bold uk-text-uppercase uk-text-muted"
|
<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':
|
[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'">
|
'Annotations are available only for logged in users'">
|
||||||
<span class="uk-icon-button uk-icon uk-disabled">
|
<span class="uk-icon-button uk-icon uk-disabled">
|
||||||
<img src="assets/common-assets/b2note.png">
|
<img src="assets/common-assets/b2note.png">
|
||||||
|
@ -501,7 +501,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- B2 Note-->
|
<!-- B2 Note-->
|
||||||
<div *ngIf="properties.b2noteAPIURL && resultLandingInfo" class="uk-margin-medium-top">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabulari
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
import {Session} from "../../login/utils/helper.class";
|
import {Session} from "../../login/utils/helper.class";
|
||||||
import {AnnotationComponent} from "../annotation/annotation.component";
|
import {AnnotationComponent} from "../annotation/annotation.component";
|
||||||
import {User} from "../../login/utils/helper.class";
|
import {Session, User} from "../../login/utils/helper.class";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -250,11 +250,6 @@ export class ResultLandingComponent {
|
||||||
this._vocabulariesService.clearSubscriptions();
|
this._vocabulariesService.clearSubscriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public userInit(event) {
|
|
||||||
this.user = event;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
public pidInit(event) {
|
public pidInit(event) {
|
||||||
this.pid = event;
|
this.pid = event;
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
|
|
Loading…
Reference in New Issue