IsrouteEnabled remove community in every route | Add subscribers in community landing, add confirm for unsubscribe, add message to login for subscribe

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51199 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-03-13 16:06:04 +00:00
parent d6afc0d37e
commit 9e5b9375af
30 changed files with 80 additions and 41 deletions

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireClaimsAdminComponent, canActivate: [IsRouteEnabled, AdminLoginGuard],
data: {redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity}, canDeactivate: [PreviousRouteRecorder]}])
data: {redirect: '/error', api: Properties.adminToolsAPIURL}, canDeactivate: [PreviousRouteRecorder]}])
]
})
export class ClaimsAdminRoutingModule { }

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireClaimsByTokenComponent, canActivate: [IsRouteEnabled, LoginGuard],
data: {redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity}, canDeactivate: [PreviousRouteRecorder]}])
data: {redirect: '/error', api: Properties.adminToolsAPIURL}, canDeactivate: [PreviousRouteRecorder]}])
]
})
export class ClaimsByTokenRoutingModule { }

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDirectLinkingComponent, canActivate: [IsRouteEnabled, LoginGuard], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder]},
])

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireLinkingComponent, canActivate: [IsRouteEnabled, LoginGuard], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder]},
])

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireMyClaimsComponent, canActivate: [IsRouteEnabled, LoginGuard],
data: {redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity}, canDeactivate: [PreviousRouteRecorder]}])
data: {redirect: '/error', api: Properties.adminToolsAPIURL}, canDeactivate: [PreviousRouteRecorder]}])
]
})
export class MyClaimsRoutingModule { }

View File

@ -3,7 +3,6 @@
<div class="uk-container uk-margin-bottom">
<article class="uk-article ">
<subscribe *ngIf="communityId != null" [communityId]="communityId" class=" uk-align-right"></subscribe>
<div *ngIf="communityId != null && community != null">
<blockquote>
@ -25,7 +24,9 @@
<span *ngFor='let manager of community.managers; let i = index'>Curated by: {{manager}} </span>
</span>
<span *ngIf="community.date != null" class="uk-margin-left"> Created: {{community.date | date:'dd-MM-yyyy'}}</span>
<subscribe *ngIf="communityId != null" [communityId]="communityId" showNumbers=true class="uk-margin-left"></subscribe>
</p>
</div>
<div class="uk-child-width-1-6@l uk-child-width-1-6@m uk-child-width-1-3@s uk-text-center uk-grid" uk-grid="">
<div class="uk-first-column">

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDepositBySubjectResultComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -10,7 +10,7 @@ import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDepositDatasetsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -9,7 +9,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDepositDatasetsResultComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -9,7 +9,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDepositPublicationsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -9,7 +9,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDepositPublicationsResultComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDataProviderComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireDatasetComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -12,7 +12,7 @@ import {Properties} from '../../utils/properties';
RouterModule.forChild([
{ path: '', component: OpenaireHtmlProjectReportComponent , canActivate: [FreeGuard, IsRouteEnabled],
data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder]}
])
]

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireOrganizationComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireProjectComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -10,7 +10,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenairePublicationComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSoftwareComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
},canDeactivate: [PreviousRouteRecorder] }
])
]

View File

@ -13,7 +13,7 @@ import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousR
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireAdvancedSearchDatasetsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireAdvancedSearchPublicationsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchDataprovidersComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -13,7 +13,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchDatasetsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] , resolve: { envSpecific: EnvironmentSpecificResolver }},
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchOrganizationsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchProjectsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchPublicationsComponent, canActivate: [FreeGuard, IsRouteEnabled], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
}, canDeactivate: [PreviousRouteRecorder] }
])

View File

@ -11,7 +11,7 @@ import {Properties} from '../../utils/properties';
imports: [
RouterModule.forChild([
{ path: '', component: OpenaireSearchSoftwareComponent, canActivate: [FreeGuard, IsRouteEnabled], canDeactivate: [PreviousRouteRecorder], data: {
redirect: '/error', api: Properties.adminToolsAPIURL, community :Properties.adminToolsCommunity
redirect: '/error', api: Properties.adminToolsAPIURL
} }
])

View File

@ -65,6 +65,7 @@ export class StatisticsComponent {
this.route.queryParams.subscribe(
communityId => {
this.communityId = communityId['communityId'];
console.log(" Stats! "+ this.properties.statisticsAPIURL);
this._statisticsService.getCommunityStatistics(this.properties.statisticsAPIURL+"communities/",this.communityId).subscribe (
res => {
this.statistics = res;

View File

@ -1,7 +1,6 @@
export class Properties {
public static adminToolsAPIURL = "http://duffy.di.uoa.gr:8080/uoa-admin-tools";
public static adminToolsAPIURL_pm = "http://duffy.di.uoa.gr:8080/uoa-admin-tools";
// public static adminToolsAPIURL = "https://beta.services.openaire.eu/uoa-admin-tools/";
public static adminToolsCommunity = "egi";
public static communityAPI = "https://dev-openaire.d4science.org/openaire/community/";
}

View File

@ -1,7 +1,8 @@
import { Component, Input } from '@angular/core';
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 {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {SubscribeService} from './subscribe.service';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
@ -9,10 +10,20 @@ import {Session} from '../../openaireLibrary/login/utils/helper.class';
selector: 'subscribe',
template: `
<div *ngIf="subscribed != null">
<div *ngIf="subscribed != null && !showNumbers">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="" >
<a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p>
</div>
<a *ngIf="!subscribed" class="uk-button uk-button-primary" (click)="subscribe()"> Subscribe</a>
<a *ngIf="subscribed" class="uk-button uk-button-primary" (click)="unsubscribe()"> Unsubscribe</a>
<a *ngIf="subscribed" class="uk-button uk-button-danger" (click)="confirmOpen()"> Unsubscribe</a>
</div>
<span *ngIf="showNumbers && subscribers !=null && subscribers > 0" >
Members: {{subscribers}}
</span>
<modal-alert (alertOutput)="confirmClose($event)">
</modal-alert>
`
})
@ -24,6 +35,9 @@ export class SubscribeComponent {
subscribed:boolean = null;
properties:EnvProperties;
subscribers:number= null;
showLoginAlert:Boolean = false;
@ViewChild(AlertModal) alert;
constructor (private route: ActivatedRoute,
private _subscribeService: SubscribeService
) {
@ -33,27 +47,36 @@ export class SubscribeComponent {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
console.log("subscribe "+ this.communityId);
var email = Session.getUserEmail();
if(email == null){
this.subscribed = false;
if(!this.showNumbers){
var email = Session.getUserEmail();
if(email == null){
this.subscribed = false;
}else{
this._subscribeService.isSubscribedToCommunity(this.communityId, email,this.properties.adminToolsAPIURL).subscribe (
res => {
this.subscribed = res;
});
}
}else{
//this.properties.adminToolsAPIURL
this._subscribeService.isSubscribedToCommunity(this.communityId, email,this.properties.adminToolsAPIURL).subscribe (
this._subscribeService.getCommunitySubscribers(this.communityId, this.properties.adminToolsAPIURL).subscribe (
res => {
this.subscribed = res;
this.subscribers = (res && res.subscribers && res.subscribers.length )?res.subscribers.length:0;
});
}
});
}
subscribe(){
var email = Session.getUserEmail();
if(email == null){
this.subscribed = false;
this.showLoginAlert = true;
}else{
//this.properties.adminToolsAPIURL
this.showLoginAlert = false;
this._subscribeService.subscribeToCommunity(this.communityId, email, this.properties.adminToolsAPIURL).subscribe (
res => {
console.log(res);
@ -70,7 +93,7 @@ export class SubscribeComponent {
this.subscribed = false;
}else{
//this.properties.adminToolsAPIURL
this._subscribeService.unSubscribeToCommunity(this.communityId, email,"http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/").subscribe (
this._subscribeService.unSubscribeToCommunity(this.communityId, email,this.properties.adminToolsAPIURL).subscribe (
res => {
console.log(res);
if(this.subscribed){
@ -79,4 +102,18 @@ export class SubscribeComponent {
});
}
}
confirmOpen(){
this.alert.cancelButton = true;
this.alert.okButton = true;
this.alert.alertTitle = "Unsubscribe community ";
this.alert.message = "Do you want to proceed? ";
this.alert.okButtonText = "Yes";
this.alert.cancelButtonText = "No";
this.alert.open();
}
confirmClose(data){
this.unsubscribe();
}
}

View File

@ -4,10 +4,11 @@ import { RouterModule } from '@angular/router';
import { SubscribeService } from './subscribe.service';
import {SubscribeComponent} from './subscribe.component';
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
@NgModule({
imports: [
CommonModule, RouterModule
CommonModule, RouterModule, AlertModalModule
],
declarations: [
SubscribeComponent