diff --git a/package.json b/package.json index 1fdef0a..da89f6a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@types/node": "^6.0.101", "angular-datatables": "^4.4.1", "citation-js": "^0.3.4", - "ckeditor4-angular": "^1.2.2", + "ng2-ckeditor": "1.1.9", "clipboard": "^1.5.16", "core-js": "2.6.8", "datatables.net": "^1.10.19", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 518cd5d..95f809e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -363,6 +363,13 @@ export class AppComponent implements OnInit { '', false, [], [], null), items: [] }); + if(this.properties.environment === "development") { + users.items.push({ + rootItem: new MenuItem('managers', 'Managers', '/managers', + '/managers', false, [], [], {communityId: this.communityId}), + items: [] + }); + } users.items.push({ rootItem: new MenuItem('subscribers', 'Subscribers', '/manage-subscribers', '/manage-subscribers', false, [], [], {communityId: this.communityId}), diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index 0c09942..af538d5 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -48,6 +48,11 @@ const appRoutes: Routes = [ loadChildren: './pages/community/community-edit-form/community-edit-form.module#CommunityEditFormModule', resolve: { envSpecific: EnvironmentSpecificResolver } }, + { + path: 'managers', + loadChildren: './pages/managers/managers.module#ManagersModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, { path: 'manage-zenodo-communities', loadChildren: './pages/zenodo-communities/zenodo-communities.module#ZenodoCommunitiesModule', diff --git a/src/app/pages/divhelpcontent/div-help-content-form.module.ts b/src/app/pages/divhelpcontent/div-help-content-form.module.ts index 6a966ed..7cc9bd6 100644 --- a/src/app/pages/divhelpcontent/div-help-content-form.module.ts +++ b/src/app/pages/divhelpcontent/div-help-content-form.module.ts @@ -5,7 +5,7 @@ import {FABModule} from '../../utils/fabModule.module'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; import {SafeHtmlPipeModule} from '../../openaireLibrary/utils/pipes/safeHTMLPipe.module'; import {DivContentFormComponent} from './div-help-content-form.component'; -import {CKEditorModule} from 'ckeditor4-angular'; +import {CKEditorModule} from 'ng2-ckeditor'; @NgModule({ imports: [ diff --git a/src/app/pages/helpcontent/page-help-content-form.component.html b/src/app/pages/helpcontent/page-help-content-form.component.html index fffe502..3513bad 100644 --- a/src/app/pages/helpcontent/page-help-content-form.component.html +++ b/src/app/pages/helpcontent/page-help-content-form.component.html @@ -39,7 +39,6 @@ }', disallowedContent:'script; *[on*]'}" --> +
+ +
+ {{error}} +
+
+
+
+
Managers
+
+ +
+ +
+
+ + + + + + + + + + + + + +
EmailAction
+ {{(showManagers)?item.email:item}} + + +
+
+
+
+ + +
+ Email: + +
+
+ + diff --git a/src/app/pages/managers/managers.component.ts b/src/app/pages/managers/managers.component.ts new file mode 100644 index 0000000..37f0f82 --- /dev/null +++ b/src/app/pages/managers/managers.component.ts @@ -0,0 +1,121 @@ +import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {UserRegistryService} from '../../openaireLibrary/services/user-registry.service'; +import {Subscription} from 'rxjs/Rx'; +import {ActivatedRoute} from '@angular/router'; +import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; +import {FormBuilder, FormControl, Validators} from '@angular/forms'; + +@Component({ + selector: 'managers', + templateUrl: 'managers.component.html' +}) +export class ManagersComponent implements OnInit, OnDestroy { + + public managers: any[]; + public pending: any[]; + public communityId: string; + public showManagers: boolean = true; + public subs: any[] = []; + public loadManagers: boolean = true; + public loadPending: boolean = true; + public error: string; + public selectedUser: string = null; + public invited: FormControl; + @ViewChild('inviteManagerModal') inviteManagerModal: AlertModal; + @ViewChild('deleteManagerModal') deleteManagerModal: AlertModal; + @ViewChild('deletePendingModal') deletePendingModal: AlertModal; + + constructor(private userRegistryService: UserRegistryService, + private fb: FormBuilder, + private route: ActivatedRoute) { + } + + ngOnInit() { + this.subs.push(this.route.queryParams.subscribe(params => { + if (params && params['communityId']) { + this.communityId = params['communityId']; + this.subs.push(this.userRegistryService.getManagersEmail('community', this.communityId).subscribe(managers => { + this.managers = managers; + this.loadManagers = false; + }, error => { + this.managers = []; + this.error = error.error.response; + this.loadManagers = false; + })); + this.subs.push(this.userRegistryService.getPendingManagers('community', this.communityId).subscribe(pending => { + this.pending = pending; + this.loadPending = false; + }, error => { + this.managers = []; + this.error = error.error.response; + this.loadManagers = false; + })); + } + })); + } + + ngOnDestroy() { + this.subs.forEach(sub => { + if (sub instanceof Subscription) { + sub.unsubscribe(); + } + }); + } + + openDeleteModal(item: any) { + if(this.showManagers) { + this.selectedUser = item.email; + this.deleteManagerModal.alertTitle = 'Delete ' + item.email + ' from managers'; + this.deleteManagerModal.open(); + } else { + this.selectedUser = item; + this.deletePendingModal.alertTitle = 'Delete ' + item + ' from managers'; + this.deletePendingModal.open(); + } + } + + openInviteModal() { + this.inviteManagerModal.alertTitle = 'Invite user to be manager'; + this.inviteManagerModal.okButtonLeft = false; + this.invited = this.fb.control('', [Validators.required, Validators.email]); + this.inviteManagerModal.open(); + } + + deleteManager() { + this.loadManagers = true; + this.userRegistryService.removeManagerRole('community', this.communityId, this.selectedUser).subscribe(() => { + this.managers = this.managers.filter(manager => manager.email != this.selectedUser); + this.loadManagers = false; + this.error = null; + },error => { + this.error = error.error.response; + this.loadManagers = false; + }); + } + + deletePendingManager() { + this.loadPending = true; + this.userRegistryService.cancelInvitation('community', this.communityId, this.selectedUser).subscribe(() => { + this.pending = this.pending.filter(manager => manager != this.selectedUser); + this.error = null; + this.loadPending = false; + },error => { + this.error = error.error.response; + this.loadPending = false; + }); + } + + inviteManager() { + this.loadManagers = true; + this.userRegistryService.invite('community', this.communityId, this.invited.value).subscribe(invitation => { + this.error = null; + if(!this.pending.includes(this.invited.value)) { + this.pending.push(this.invited.value); + } + this.loadManagers = false; + },error => { + this.error = error.error.response; + this.loadManagers = false; + }) + } +} diff --git a/src/app/pages/managers/managers.module.ts b/src/app/pages/managers/managers.module.ts new file mode 100644 index 0000000..3ae0b07 --- /dev/null +++ b/src/app/pages/managers/managers.module.ts @@ -0,0 +1,17 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {ManagersRoutingModule} from './managers-routing.module'; +import {ManagersComponent} from './managers.component'; +import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard'; +import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard'; +import {EmailService} from '../../openaireLibrary/utils/email/email.service'; +import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; +import {ReactiveFormsModule} from '@angular/forms'; + +@NgModule({ + imports: [CommonModule, ManagersRoutingModule, AlertModalModule, ReactiveFormsModule], + declarations: [ManagersComponent], + exports: [ManagersComponent], + providers: [IsCommunity, ConnectAdminLoginGuard, EmailService] +}) +export class ManagersModule {} diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts index 14501a5..4ec3950 100644 --- a/src/environments/environment.beta.ts +++ b/src/environments/environment.beta.ts @@ -36,8 +36,9 @@ export let properties: EnvProperties = { utilsService: "https://demo.openaire.eu/utils-service", vocabulariesAPI: "https://beta.services.openaire.eu/provision/mvc/vocabularies/", piwikBaseUrl: " https://analytics.openaire.eu/piwik.php?idsite=6", - loginUrl: "https://beta.services.openaire.eu/admin-user-management/openid_connect_login", + loginUrl: "https://beta.services.openaire.eu/connect-user-management/openid_connect_login", userInfoUrl: "https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=", + registryUrl: 'https://beta.services.openaire.eu/uoa-user-management/api/registry/', logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", cookieDomain: ".openaire.eu", feedbackmail: "feedback@openaire.eu", diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 4bc64f5..0b33543 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -38,11 +38,10 @@ export let properties: EnvProperties = { vocabulariesAPI:"https://services.openaire.eu/provision/mvc/vocabularies/", piwikBaseUrl:" https://analytics.openaire.eu/piwik.php?idsite=6", - loginUrl:"https://services.openaire.eu/admin-user-management/openid_connect_login", - + loginUrl: "https://services.openaire.eu/connect-user-management/openid_connect_login", userInfoUrl: " https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=", - - logoutUrl:"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", + registryUrl: 'https://services.openaire.eu/uoa-user-management/api/registry/', + logoutUrl: "https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=", cookieDomain:".openaire.eu", diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 5ef6572..ea1245e 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -43,10 +43,10 @@ export let properties: EnvProperties = { vocabulariesAPI: 'https://beta.services.openaire.eu/provision/mvc/vocabularies/', piwikBaseUrl: ' https://analytics.openaire.eu/piwik.php?idsite=6', - loginUrl: 'http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_connect_login', - - userInfoUrl: 'http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=', - logoutUrl: 'https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=', + loginUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login', + userInfoUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=', + registryUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/', + logoutUrl: 'https://openaire-dev.aai-dev.grnet.gr/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=', cookieDomain: '.di.uoa.gr', diff --git a/src/index.html b/src/index.html index f7b61af..aa85824 100644 --- a/src/index.html +++ b/src/index.html @@ -29,6 +29,7 @@ +