Project

General

Profile

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-button-small uk-margin-left " target="_blank"  >
13
        <span uk-icon="">
14
          <svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="cog" ratio="0.8"><circle fill="none" stroke="#000" cx="9.997" cy="10" r="3.31"></circle><path fill="none" stroke="#000" d="M18.488,12.285 L16.205,16.237 C15.322,15.496 14.185,15.281 13.303,15.791 C12.428,16.289 12.047,17.373 12.246,18.5 L7.735,18.5 C7.938,17.374 7.553,16.299 6.684,15.791 C5.801,15.27 4.655,15.492 3.773,16.237 L1.5,12.285 C2.573,11.871 3.317,10.999 3.317,9.991 C3.305,8.98 2.573,8.121 1.5,7.716 L3.765,3.784 C4.645,4.516 5.794,4.738 6.687,4.232 C7.555,3.722 7.939,2.637 7.735,1.5 L12.263,1.5 C12.072,2.637 12.441,3.71 13.314,4.22 C14.206,4.73 15.343,4.516 16.225,3.794 L18.487,7.714 C17.404,8.117 16.661,8.988 16.67,10.009 C16.672,11.018 17.415,11.88 18.488,12.285 L18.488,12.285 Z"></path></svg>
15

    
16
        </span>
17

    
18
        Manage</a>
19

    
20

    
21
    `
22
})
23

    
24
export class ManageComponent {
25
   @Input() communityId:string;
26

    
27

    
28
  isManager:boolean = false;
29
  properties:EnvProperties;
30
    constructor (private route: ActivatedRoute,
31
      private _communityService: CommunityService
32
    ) {
33
    }
34

    
35
    public ngOnInit() {
36
      this.route.data
37
          .subscribe((data: { envSpecific: EnvProperties }) => {
38
             this.properties = data.envSpecific;
39
             if(Session.isLoggedIn()){
40
               if(Session.isPortalAdministrator()||Session.isCommunityCurator()){
41
                 this.isManager = true;
42
               }else if(Session.isLoggedIn()){
43
                 var email = Session.getUserEmail();
44
                 this._communityService.iscommunityManager(this.properties, this.properties.communityAPI+ this.communityId, email).subscribe (
45
                     res => {
46
                       this.isManager = res;
47
                     });
48
                 }
49
               }
50
             });
51

    
52

    
53

    
54
    }
55

    
56
}
(1-1/2)