diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index e8b60a7..4480eba 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -168,6 +168,12 @@ export class AppComponent implements OnInit{
items: [],
ukIcon: 'home'
});
+ this.sideMenuItems.push({
+ rootItem: new MenuItem('personalInfo', 'Personal Info', '/personal',
+ '/personal', false, [], [], {communityId: this.communityId}),
+ items: [],
+ ukIcon: 'user'
+ });
if (this.isPortalAdministrator) {
const adminTools: SideMenuItem = {
rootItem: new MenuItem('adminTools', 'Admin Tools', '/communities',
diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts
index 14d1b13..f0c052c 100644
--- a/src/app/app.routing.ts
+++ b/src/app/app.routing.ts
@@ -28,6 +28,11 @@ const appRoutes: Routes = [
loadChildren: './pages/usernotifications/manage-user-notifications.module#ManageUserNotificationsModule',
resolve: {envSpecific: EnvironmentSpecificResolver}
},
+ {
+ path: 'personal',
+ loadChildren: './pages/curator/curator.module#CuratorModule',
+ resolve: { envSpecific: EnvironmentSpecificResolver }
+ },
{
path: 'communities',
loadChildren: './pages/community/communities.module#CommunitiesModule',
diff --git a/src/app/pages/curator/curator-routing.module.ts b/src/app/pages/curator/curator-routing.module.ts
new file mode 100644
index 0000000..68db1e7
--- /dev/null
+++ b/src/app/pages/curator/curator-routing.module.ts
@@ -0,0 +1,14 @@
+import { NgModule } from '@angular/core';
+import {RouterModule} from '@angular/router';
+import {CuratorComponent} from './curator.component';
+import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard';
+import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard';
+
+@NgModule({
+ imports: [
+ RouterModule.forChild([
+ { path: '', canActivate: [IsCommunity, ConnectAdminLoginGuard], component: CuratorComponent}
+ ])
+ ]
+})
+export class CuratorRoutingModule { }
diff --git a/src/app/pages/curator/curator.component.html b/src/app/pages/curator/curator.component.html
new file mode 100644
index 0000000..b31121e
--- /dev/null
+++ b/src/app/pages/curator/curator.component.html
@@ -0,0 +1,134 @@
+
Edit Personal Info
+
+
+
+
+
+
+
+ E-mail: |
+
+ {{curator.email}}
+ |
+
+
+
+ Name
+
+ *
+
+ :
+ |
+
+ Please add name.
+
+ |
+
+
+ Photo: |
+
+
+
+ ![Curator Photo]({{photo}})
+
+
+
+
+
+
+ |
+
+
+ Biography: |
+
+
+ |
+
+
+ |
+
+
+ * Required fields
+
+ |
+
+
+ |
+
+ {{updateErrorMessage}}
+ {{warning}}
+ {{successfulSaveMessage}}
+ {{successfulResetMessage}}
+ |
+
+
+
+
+
My Affiliations
+
+
+
+
+
+
+ -
+
+
![{{result.name}}]({{result.logoUrl}})
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/pages/curator/curator.component.ts b/src/app/pages/curator/curator.component.ts
new file mode 100644
index 0000000..90041bd
--- /dev/null
+++ b/src/app/pages/curator/curator.component.ts
@@ -0,0 +1,303 @@
+import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
+import {ActivatedRoute, Router} from '@angular/router';
+
+import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
+
+import {Session} from '../../openaireLibrary/login/utils/helper.class';
+import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
+import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service';
+import {Affiliation, Curator} from '../../openaireLibrary/utils/entities/CuratorInfo';
+import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
+import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
+import {CuratorPhotoService} from '../../openaireLibrary/services/curatorPhoto.service';
+
+@Component({
+ selector: 'curator',
+ templateUrl: './curator.component.html',
+})
+
+export class CuratorComponent implements OnInit {
+
+ @ViewChild('affiliationModal') affiliationModal: AlertModal;
+ @ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal;
+ public showLoading = true;
+ public updateErrorMessage = '';
+ public warning = '';
+
+ public successfulSaveMessage = '';
+ public successfulResetMessage = '';
+
+ public hasChanged = false;
+ public curatorId = null;
+ public curator: Curator = null;
+ public affiliation: Affiliation = new Affiliation();
+ public photo: any = null;
+ public properties: EnvProperties = null;
+
+ private file: File = null;
+ private enabled = true;
+ private index = 0;
+
+ constructor(private element: ElementRef,
+ private route: ActivatedRoute,
+ private _router: Router,
+ private curatorService: CuratorService,
+ private curatorPhotoService: CuratorPhotoService) {
+ }
+
+
+ ngOnInit() {
+ this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
+ this.properties = data.envSpecific;
+ if (!Session.isLoggedIn()) {
+ this._router.navigate(['/user-info'], {
+ queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
+ });
+ } else {
+ this.showLoading = true;
+ this.updateErrorMessage = '';
+ this.warning = '';
+ this.curatorId = Session.getUser().id;
+ this.curatorService.getCurator(this.properties,
+ this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
+ curator => {
+ if (curator) {
+ this.curator = curator;
+ this.curator.email = Session.getUserEmail();
+ if (this.curator.photo) {
+ this.photo = this.properties.downloadUrl + '/' + this.curator.photo;
+ } else {
+ this.photo = '../../../assets/common-assets/curator-default.png';
+ }
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ }
+ },
+ error => {
+ this.curator = new Curator();
+ this.curator._id = this.curatorId;
+ this.curator.email = Session.getUserEmail();
+ this.curator.name = Session.getUserFullName();
+ this.curator.affiliations = [];
+ this.curator.bio = '';
+ this.curator.photo = null;
+ this.handleWarning('No personal info has been found!');
+ this.photo = '../../../assets/common-assets/curator-default.png';
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ }
+ );
+ }
+ });
+ }
+
+ initAffiliation(affiliation: Affiliation = null) {
+ this.affiliation = new Affiliation();
+ if (affiliation) {
+ this.affiliation.name = affiliation.name;
+ this.affiliation.logoUrl = affiliation.logoUrl;
+ this.affiliation.websiteUrl = affiliation.websiteUrl;
+ this.affiliationModal.okButtonText = 'Edit Affiliation';
+ } else {
+ this.index = -1;
+ this.affiliationModal.okButtonText = 'Add new Affiliation';
+ }
+ this.affiliationModal.okButtonLeft = false;
+ this.affiliationModal.open();
+ }
+
+ public resetForm() {
+ if (!Session.isLoggedIn()) {
+ this._router.navigate(['/user-info'], {
+ queryParams:
+ {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
+ });
+ } else {
+ if (this.curatorId != null && this.curatorId !== '') {
+ this.showLoading = true;
+ this.updateErrorMessage = '';
+ this.warning = '';
+ this.curatorService.getCurator(this.properties,
+ this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
+ curator => {
+ if (curator) {
+ this.curator = curator;
+ this.curator.email = Session.getUserEmail();
+ this.handleSuccessfulReset('Your Personal Info has been reset!');
+ if (this.curator.photo) {
+ this.photo = this.properties.downloadUrl + '/' + this.curator.photo;
+ } else {
+ this.photo = '../../../assets/common-assets/curator-default.png';
+ }
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ }
+ },
+ error => {
+ this.curator = new Curator();
+ this.curator._id = this.curatorId;
+ this.curator.email = Session.getUserEmail();
+ this.curator.name = Session.getUserFullName();
+ this.curator.affiliations = [];
+ this.curator.bio = '';
+ this.curator.photo = null;
+ this.handleWarning('No personal info has been found!');
+ this.photo = '../../../assets/common-assets/curator-default.png';
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ }
+ );
+ }
+ this.resetChange();
+ }
+ }
+
+ private change() {
+ this.hasChanged = true;
+ }
+
+ private resetChange() {
+ this.hasChanged = false;
+ }
+
+ private resetMessages() {
+ this.successfulSaveMessage = '';
+ this.successfulResetMessage = '';
+ this.updateErrorMessage = '';
+ }
+
+ public chooseAffiliation(index: number, action: string = 'delete') {
+ this.index = index;
+ const affiliation: Affiliation = this.curator.affiliations[index];
+ if (action === 'delete') {
+ this.removeAffiliationModal.message = 'Do you want to remove ' +
+ affiliation.name + ' from your Affiliations?';
+ this.removeAffiliationModal.okButtonText = 'Yes';
+ this.removeAffiliationModal.cancelButtonText = 'No';
+ this.removeAffiliationModal.open();
+ } else if (action === 'edit') {
+ this.initAffiliation(affiliation);
+ }
+ }
+
+ handleUpdateError(message: string, error) {
+ this.resetMessages();
+ this.updateErrorMessage = message;
+ console.log('Server responded: ' + error);
+
+ this.showLoading = false;
+ }
+
+ handleWarning(message: string) {
+ this.warning = message;
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ }
+
+ handleSuccessfulSave(message) {
+ this.resetMessages();
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ this.successfulSaveMessage = message;
+ }
+
+ handleSuccessfulReset(message) {
+ this.resetMessages();
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ this.successfulResetMessage = message;
+ }
+
+
+ fileChangeEvent(event) {
+ this.showLoading = true;
+ if (event.target.files && event.target.files[0]) {
+ this.file = event.target.files[0];
+ if (this.file.type !== 'image/png' && this.file.type !== 'image/jpeg') {
+ this.handleUpdateError('You must choose a photo!', null);
+ this.file = null;
+ } else {
+ this.updateErrorMessage = '';
+ const reader = new FileReader();
+ reader.readAsDataURL(this.file);
+ reader.onload = () => {
+ this.photo = reader.result;
+ this.showLoading = false;
+ HelperFunctions.scroll();
+ };
+ }
+ }
+ }
+
+
+ updateCurator() {
+ if (this.hasChanged && this.curator && this.curator.name && this.curator.name !== '') {
+ this.showLoading = true;
+ if (this.file) {
+ this.curatorPhotoService.uploadPhoto(this.properties.uploadService + '/' + this.curator._id, this.file).subscribe((res) => {
+ if (this.curator.photo && this.curator.photo !== '') {
+ this.curatorPhotoService.deletePhoto(this.properties.deleteUrl + '/' + this.curator.photo).subscribe();
+ }
+ this.curator.photo = res.filename;
+ this.curatorService.updateCurator(this.properties.adminToolsAPIURL + 'curator',
+ this.curator).subscribe((curator) => {
+ if (curator) {
+ this.handleSuccessfulSave('Your data has been saved successfully!');
+ this.resetChange();
+ }
+ },
+ error => {
+ this.handleUpdateError('An error has occurred. Try again later!', error);
+ this.resetChange();
+ });
+ }, error => {
+ this.handleWarning('An error has occurred during photo uploading.');
+ }
+ );
+ } else {
+ this.curatorService.updateCurator(this.properties.adminToolsAPIURL + 'curator',
+ this.curator).subscribe((curator) => {
+ if (curator) {
+ this.handleSuccessfulSave('Your data has been saved successfully!');
+ this.resetChange();
+ }
+ },
+ error => {
+ this.handleUpdateError('An error has occurred. Try again later!', error);
+ this.resetChange();
+ });
+ }
+ }
+ }
+
+ isEmptyAffiliation(): boolean {
+ return ((!this.affiliation.name || this.affiliation.name === '') &&
+ (!this.affiliation.logoUrl || this.affiliation.logoUrl === '') &&
+ (!this.affiliation.websiteUrl || this.affiliation.websiteUrl === ''));
+ }
+
+ addAffiliation() {
+ if (!this.isEmptyAffiliation()) {
+ if (this.index === -1) {
+ this.curator.affiliations.push(this.affiliation);
+ } else {
+ this.curator.affiliations[this.index] = this.affiliation;
+ }
+ this.change();
+ }
+ }
+
+ removeAffiliation() {
+ this.curator.affiliations.splice(this.index, 1);
+ this.change();
+ }
+
+ onNameChange() {
+ this.hasChanged = true;
+ if (!this.curator.name || this.curator.name === '') {
+ this.enabled = false;
+ } else {
+ this.enabled = true;
+ }
+ }
+}
diff --git a/src/app/pages/curator/curator.module.ts b/src/app/pages/curator/curator.module.ts
new file mode 100644
index 0000000..d9d18c7
--- /dev/null
+++ b/src/app/pages/curator/curator.module.ts
@@ -0,0 +1,32 @@
+import {NgModule} from '@angular/core';
+import {CommonModule} from '@angular/common';
+import {FormsModule} from '@angular/forms';
+import {RouterModule} from '@angular/router';
+
+import {CuratorComponent} from './curator.component';
+
+import {CuratorRoutingModule} from './curator-routing.module';
+import {IsCommunity} from '../../openaireLibrary/connect/communityGuard/isCommunity.guard';
+import {ConnectAdminLoginGuard} from '../../openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard';
+import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service';
+import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
+import {StickyModule} from '../../utils/stickyButton/sticky.module';
+import {CuratorPhotoService} from '../../openaireLibrary/services/curatorPhoto.service';
+
+@NgModule({
+ imports: [
+ CuratorRoutingModule, CommonModule, FormsModule, RouterModule,
+ AlertModalModule, StickyModule
+ ],
+ declarations: [
+ CuratorComponent
+ ],
+ providers: [
+ CuratorService, CuratorPhotoService, IsCommunity, ConnectAdminLoginGuard
+ ],
+ exports: [
+ CuratorComponent
+ ]
+})
+
+export class CuratorModule { }
diff --git a/src/app/utils/stickyButton/sticky.component.ts b/src/app/utils/stickyButton/sticky.component.ts
new file mode 100644
index 0000000..0293cf9
--- /dev/null
+++ b/src/app/utils/stickyButton/sticky.component.ts
@@ -0,0 +1,30 @@
+import {Component, EventEmitter, Input, Output} from '@angular/core';
+
+@Component({
+ selector: 'sticky',
+ template: `
+
+
+
+
+
+ `
+})
+
+export class StickyComponent {
+ @Output() public save: EventEmitter = new EventEmitter();
+ @Output() public cancel: EventEmitter = new EventEmitter();
+
+ @Input() public enabled: boolean;
+
+ constructor () {}
+
+ public onSave() {
+ this.save.emit(true);
+ }
+
+ public onCancel() {
+ this.cancel.emit(true);
+ }
+
+}
diff --git a/src/app/utils/stickyButton/sticky.module.ts b/src/app/utils/stickyButton/sticky.module.ts
new file mode 100644
index 0000000..4267dbf
--- /dev/null
+++ b/src/app/utils/stickyButton/sticky.module.ts
@@ -0,0 +1,19 @@
+import { NgModule } from '@angular/core';
+import { CommonModule} from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import {StickyComponent} from './sticky.component';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FormsModule
+ ],
+ declarations: [
+ StickyComponent
+ ],
+ exports: [
+ StickyComponent
+ ]
+})
+
+export class StickyModule { }
diff --git a/src/assets/env-properties.json b/src/assets/env-properties.json
index 03cf7ce..4730340 100644
--- a/src/assets/env-properties.json
+++ b/src/assets/env-properties.json
@@ -8,7 +8,7 @@
"claimsAPIURL" : "http://scoobydoo.di.uoa.gr:8080/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/",
"statisticsAPIURL" : "https://beta.services.openaire.eu/stats-api/",
"statisticsFrameAPIURL":"https://beta.openaire.eu/stats/",
- "searchAPIURLLAst" : "https://beta.services.openaire.eu/search/v2/api/",
+ "searchAPIURLLAst" : "https://beta.services.openaire.eu/search/v2/api/",
"searchResourcesAPIURL" : "https://beta.services.openaire.eu/search/v2/api/resources",
"openCitationsAPIURL" : "https://services.openaire.eu/opencitations/getCitations?id=",
"csvAPIURL" : "http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/reports",
@@ -28,7 +28,9 @@
"h2020Guidlines" : "https://www.openaire.eu/oa-publications/h2020/open-access-in-horizon-2020",
"ercGuidlines" : "http://erc.europa.eu/sites/default/files/document/file/ERC_Open_Access_Guidelines-revised_2014.pdf",
"helpdesk" : "https://www.openaire.eu/support/helpdesk",
- "uploadService" : "http://scoobydoo.di.uoa.gr:8000/upload",
+ "uploadService" : "http://mpagasas.di.uoa.gr:8000/upload",
+ "downloadUrl" : "http://mpagasas.di.uoa.gr:8000/download",
+ "deleteUrl" : "http://mpagasas.di.uoa.gr:8000/delete",
"vocabulariesAPI" :"https://beta.services.openaire.eu/provision/mvc/vocabularies/",
@@ -49,7 +51,7 @@
"cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=",
- "adminToolsAPIURL" :"http://duffy.di.uoa.gr:8080/uoa-admin-tools/",
+ "adminToolsAPIURL" :"http://mpagasas.di.uoa.gr:8080/uoa-admin-tools/",
"adminToolsCommunity" :"openaire",
"communityAPI": "https://dev-openaire.d4science.org/openaire/community/",