1
|
import { Component, Input, ViewChild } from '@angular/core';
|
2
|
import { Location } from '@angular/common';
|
3
|
import {ActivatedRoute} from '@angular/router';
|
4
|
import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
5
|
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
|
6
|
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
7
|
@Component({
|
8
|
selector: 'manage',
|
9
|
template: `
|
10
|
|
11
|
|
12
|
<a *ngIf="isManager" [href]="'https://beta.admin.connect.openaire.eu/dashboard?communityId='+communityId" class="uk-button uk-button-default uk-margin-left" target="_blank" >
|
13
|
<span class="uk-margin-small-right uk-icon" uk-icon="cog"> </span>Manage</a>
|
14
|
|
15
|
|
16
|
`
|
17
|
})
|
18
|
|
19
|
export class ManageComponent {
|
20
|
@Input() communityId:string;
|
21
|
|
22
|
|
23
|
isManager:boolean = false;
|
24
|
properties:EnvProperties;
|
25
|
constructor (private route: ActivatedRoute,
|
26
|
private _communityService: CommunityService
|
27
|
) {
|
28
|
}
|
29
|
|
30
|
public ngOnInit() {
|
31
|
this.route.data
|
32
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
33
|
this.properties = data.envSpecific;
|
34
|
if(Session.isLoggedIn()){
|
35
|
if(Session.isPortalAdministrator()||Session.isCommunityCurator()){
|
36
|
this.isManager = true;
|
37
|
}else if(Session.isLoggedIn()){
|
38
|
var email = Session.getUserEmail();
|
39
|
this._communityService.iscommunityManager(this.properties, this.properties.communityAPI+ this.communityId, email).subscribe (
|
40
|
res => {
|
41
|
this.isManager = res;
|
42
|
});
|
43
|
}
|
44
|
}
|
45
|
});
|
46
|
|
47
|
|
48
|
|
49
|
}
|
50
|
|
51
|
}
|