diff --git a/src/app/pages/curator/curator.component.html b/src/app/pages/curator/curator.component.html
index e3b8dfe..735d7a2 100644
--- a/src/app/pages/curator/curator.component.html
+++ b/src/app/pages/curator/curator.component.html
@@ -65,9 +65,7 @@
|
{{updateErrorMessage}}
- {{warning}}
{{successfulSaveMessage}}
- {{successfulResetMessage}}
@@ -85,14 +83,14 @@
-
-
+
-
+
@@ -116,7 +114,7 @@
+ [(ngModel)]="affiliation.logo_url">
|
@@ -124,7 +122,7 @@
+ [(ngModel)]="affiliation.website_url">
|
diff --git a/src/app/pages/curator/curator.component.ts b/src/app/pages/curator/curator.component.ts
index bda4387..15c2070 100644
--- a/src/app/pages/curator/curator.component.ts
+++ b/src/app/pages/curator/curator.component.ts
@@ -22,10 +22,7 @@ export class CuratorComponent implements OnInit {
@ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal;
public showLoading = true;
public updateErrorMessage = '';
- public warning = '';
-
public successfulSaveMessage = '';
- public successfulResetMessage = '';
public hasChanged = false;
public curatorId = null;
@@ -57,7 +54,6 @@ export class CuratorComponent implements OnInit {
} 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(
@@ -72,20 +68,20 @@ export class CuratorComponent implements OnInit {
}
this.showLoading = false;
HelperFunctions.scroll();
+ } else {
+ 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.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();
}
);
}
@@ -96,11 +92,14 @@ export class CuratorComponent implements OnInit {
this.affiliation = new Affiliation();
if (affiliation) {
this.affiliation.name = affiliation.name;
- this.affiliation.logoUrl = affiliation.logoUrl;
- this.affiliation.websiteUrl = affiliation.websiteUrl;
+ this.affiliation.logo_url = affiliation.logo_url;
+ this.affiliation.website_url = affiliation.website_url;
this.affiliationModal.okButtonText = 'Edit Affiliation';
} else {
this.index = -1;
+ this.affiliation.name = '';
+ this.affiliation.logo_url = '';
+ this.affiliation.website_url = '';
this.affiliationModal.okButtonText = 'Add new Affiliation';
}
this.affiliationModal.okButtonLeft = false;
@@ -117,14 +116,12 @@ export class CuratorComponent implements OnInit {
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 {
@@ -132,20 +129,20 @@ export class CuratorComponent implements OnInit {
}
this.showLoading = false;
HelperFunctions.scroll();
+ } else {
+ 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.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();
}
);
}
@@ -163,7 +160,6 @@ export class CuratorComponent implements OnInit {
private resetMessages() {
this.successfulSaveMessage = '';
- this.successfulResetMessage = '';
this.updateErrorMessage = '';
}
@@ -189,12 +185,6 @@ export class CuratorComponent implements OnInit {
this.showLoading = false;
}
- handleWarning(message: string) {
- this.warning = message;
- this.showLoading = false;
- HelperFunctions.scroll();
- }
-
handleSuccessfulSave(message) {
this.resetMessages();
this.showLoading = false;
@@ -202,14 +192,6 @@ export class CuratorComponent implements OnInit {
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]) {
@@ -232,16 +214,38 @@ export class CuratorComponent implements OnInit {
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();
+ if (!Session.isLoggedIn()) {
+ this._router.navigate(['/user-info'], {
+ queryParams:
+ {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
+ });
+ } else {
+ 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.handleUpdateError('An error has occurred during photo uploading.', error);
}
- this.curator.photo = res.filename;
- this.curatorService.updateCurator(this.properties.adminToolsAPIURL + 'curator',
- this.curator).subscribe((curator) => {
+ );
+ } else {
+ this.curatorService.updateCurator(this.properties.adminToolsAPIURL + 'curator',
+ this.curator).subscribe((curator) => {
if (curator) {
this.handleSuccessfulSave('Your data has been saved successfully!');
this.resetChange();
@@ -251,30 +255,15 @@ export class CuratorComponent implements OnInit {
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 === ''));
+ return ((!this.affiliation.name || this.affiliation.name === '') ||
+ (!this.affiliation.logo_url || this.affiliation.logo_url === '') ||
+ (!this.affiliation.website_url || this.affiliation.website_url === ''));
}
addAffiliation() {
@@ -303,6 +292,10 @@ export class CuratorComponent implements OnInit {
}
_format(name: string){
- return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
+ if(name) {
+ return (((name).length > this.maxCharacters) ? (name.substring(0, (this.maxCharacters - ('...').length)) + '...') : name);
+ } else {
+ return null;
+ }
}
}
|