[Trunk|Connect]: Change Manage component to be parametrized if it will be shown

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55224 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-08 12:44:23 +00:00
parent 7a3d001451
commit 42306ce984
2 changed files with 8 additions and 56 deletions

View File

@ -1,21 +1,11 @@
import { Component, Input, ViewChild } from '@angular/core';
import { Location } from '@angular/common';
import {ActivatedRoute} from '@angular/router';
import { EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import { Component, Input} from '@angular/core';
@Component({
selector: 'manage',
template: `
<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" >
<span uk-icon="">
<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>
</span>
Manage</a>
<a [href]="'https://beta.admin.connect.openaire.eu/dashboard?communityId='+communityId" class="uk-button uk-button-default uk-button-small portal-button" target="_blank">
Manage
</a>
`
@ -24,40 +14,6 @@ import {Session} from '../../openaireLibrary/login/utils/helper.class';
export class ManageComponent {
@Input() communityId:string;
isManager:boolean = false;
properties:EnvProperties;
constructor (private route: ActivatedRoute,
private _communityService: CommunityService
) {
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
if(Session.isLoggedIn()){
if(Session.isPortalAdministrator()||Session.isCommunityCurator()){
this.isManager = true;
}else if(Session.isLoggedIn()){
var email = Session.getUserEmail();
this._communityService.isCommunityManager(this.properties, this.properties.communityAPI+ this.communityId, email).subscribe (
res => {
this.isManager = res;
},
error => {
this.handleError("Error getting response if email: "+email+" is community manager for community with id: "+this.communityId, error);
}
);
}
}
});
}
private handleError(message: string, error) {
console.error("Manage (component): "+message, error);
}
constructor() {}
}

View File

@ -2,7 +2,6 @@ import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {ManageComponent} from './manage.component';
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
@ -12,12 +11,9 @@ import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.mod
],
declarations: [
ManageComponent
],
providers:[
CommunityService
],
],
exports: [
ManageComponent
]
]
})
export class ManageModule { }