2021-05-19 13:40:29 +02:00
|
|
|
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
|
|
|
import {ActivatedRoute} from '@angular/router';
|
|
|
|
import {Title} from '@angular/platform-browser';
|
|
|
|
import {AlertModal} from "../../../openaireLibrary/utils/modal/alert";
|
|
|
|
import {CuratorService} from "../../../openaireLibrary/connect/curators/curator.service";
|
|
|
|
import {UtilitiesService} from "../../../openaireLibrary/services/utilities.service";
|
|
|
|
import {UserManagementService} from "../../../openaireLibrary/services/user-management.service";
|
|
|
|
import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms";
|
|
|
|
import {Subscriber} from "rxjs";
|
|
|
|
import {EnvProperties} from "../../../openaireLibrary/utils/properties/env-properties";
|
|
|
|
import {properties} from "../../../../environments/environment";
|
|
|
|
import {User} from "../../../openaireLibrary/login/utils/helper.class";
|
|
|
|
import {Affiliation, Curator} from "../../../openaireLibrary/utils/entities/CuratorInfo";
|
|
|
|
import {HelpContentService} from "../../../services/help-content.service";
|
|
|
|
import {Page} from "../../../domain/page";
|
|
|
|
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
|
|
|
import {StringUtils} from "../../../openaireLibrary/utils/string-utils.class";
|
2022-06-28 20:15:05 +02:00
|
|
|
import {CommunityInfo} from "../../../openaireLibrary/connect/community/communityInfo";
|
2021-05-19 13:40:29 +02:00
|
|
|
|
|
|
|
declare var UIkit;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'personal-info',
|
|
|
|
template: `
|
2022-06-28 20:15:05 +02:00
|
|
|
<div page-content (stickyEmitter)="stickyPageHeader = $event">
|
2021-05-19 13:40:29 +02:00
|
|
|
<div header>
|
2022-06-28 20:15:05 +02:00
|
|
|
<div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
|
|
|
|
<div>
|
|
|
|
<div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage Personal Info &
|
|
|
|
Affiliations
|
|
|
|
</div>
|
|
|
|
<h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-19 13:40:29 +02:00
|
|
|
<users-tabs tab="personal"></users-tabs>
|
|
|
|
</div>
|
|
|
|
<div inner>
|
2022-06-30 12:41:36 +02:00
|
|
|
<div class="uk-margin-top uk-container">
|
2022-06-28 20:15:05 +02:00
|
|
|
<div class="uk-flex uk-flex-center uk-flex-right@m">
|
|
|
|
<button class="uk-button uk-button-secondary" [class.uk-disabled]="!hasChanged || loading"
|
|
|
|
[disabled]="!hasChanged || loading"
|
|
|
|
(click)="reset()">Reset
|
|
|
|
</button>
|
|
|
|
<button class="uk-button uk-margin-left uk-button-primary"
|
|
|
|
[disabled]="!hasChanged || loading" [class.uk-disabled]="!hasChanged || loading"
|
|
|
|
(click)="updateCurator()">Save
|
|
|
|
</button>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-30 17:23:14 +02:00
|
|
|
<div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
|
|
|
|
<div *ngIf="loading" class="uk-position-center">
|
|
|
|
<loading></loading>
|
|
|
|
</div>
|
2022-06-28 20:15:05 +02:00
|
|
|
<div *ngIf="!loading" class="uk-container">
|
2021-05-19 13:40:29 +02:00
|
|
|
<form *ngIf="curatorFb" [formGroup]="curatorFb">
|
|
|
|
<div class="uk-grid uk-margin-large-bottom" uk-grid>
|
|
|
|
<div class="uk-grid uk-width-1-1 uk-flex-middle" uk-grid>
|
|
|
|
<div>
|
|
|
|
<div class="image">
|
|
|
|
<img [src]="photo"/>
|
|
|
|
<input #fileInput id="photo" type="file" class="uk-hidden" (change)="fileChangeEvent($event)"/>
|
2022-06-30 12:41:36 +02:00
|
|
|
<icon class="uk-text-secondary clickable" name="photo_camera" ratio="1.5"
|
2021-05-19 13:40:29 +02:00
|
|
|
(click)="$event.stopPropagation();uploadPhoto(fileInput);$event.preventDefault()"></icon>
|
|
|
|
<div *ngIf="curator.photo || file" #element
|
|
|
|
uk-dropdown="mode: click; pos: bottom-left; delay-hide: 0; flip: false">
|
|
|
|
<ul class="uk-nav uk-dropdown-nav">
|
|
|
|
<li><a (click)="fileInput.click();hide(element)">Upload a new photo</a></li>
|
|
|
|
<li><a (click)="removePhoto();hide(element)">Remove this photo</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="uk-width-expand">
|
2022-06-30 12:41:36 +02:00
|
|
|
<div input class="uk-width-large@m uk-width-1-1" placeholder="Name"
|
2022-06-28 20:15:05 +02:00
|
|
|
[formInput]="curatorFb.get('name')" inputClass="border-bottom normal-font-size"></div>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-30 12:41:36 +02:00
|
|
|
<div input class="uk-width-1-1" placeholder="Biography"
|
2022-06-28 20:15:05 +02:00
|
|
|
[formInput]="curatorFb.get('bio')" type="textarea" rows="8"></div>
|
2021-05-19 13:40:29 +02:00
|
|
|
<div class="uk-width-1-1">
|
|
|
|
<h5 class="uk-margin-large uk-text-bold">My Affiliations</h5>
|
|
|
|
<div class="uk-flex uk-flex-center">
|
2022-06-28 20:15:05 +02:00
|
|
|
<button (click)="editAffiliationOpen()" class="uk-button uk-button-link uk-flex uk-flex-middle">
|
|
|
|
<icon [flex]="true" name="add"></icon>
|
|
|
|
<span class="uk-margin-small-left">Add New Affiliation</span>
|
|
|
|
</button>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
2022-07-02 13:45:34 +02:00
|
|
|
<div class="uk-margin-medium uk-grid uk-child-width-1-2@m uk-child-width-1-1" uk-height-match="target: .uk-card-body; row: false" uk-grid>
|
2022-06-28 20:15:05 +02:00
|
|
|
<div *ngFor="let affiliation of affiliations.controls; let i=index">
|
|
|
|
<div class="uk-card uk-card-default uk-margin-bottom">
|
|
|
|
<div class="uk-card-body">
|
2022-06-30 17:23:14 +02:00
|
|
|
<div class="uk-flex uk-flex-middle uk-flex-column">
|
2022-07-04 20:45:20 +02:00
|
|
|
<div class="uk-flex uk-flex-center uk-height-xsmall">
|
|
|
|
<img class="uk-height-max-xsmall uk-blend-multiply" [src]="affiliation.value.logo_url | urlPrefix">
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
2022-06-30 17:23:14 +02:00
|
|
|
<h5>{{affiliation.value.name}}</h5>
|
|
|
|
<div class="uk-text-truncate uk-text-small">
|
|
|
|
<span class="uk-text-meta uk-margin-xsmall-right">URL:</span>
|
|
|
|
<a [href]="affiliation.value.website_url | urlPrefix" class="uk-link"
|
|
|
|
target="_blank">{{affiliation.value.website_url}}</a>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-28 20:15:05 +02:00
|
|
|
</div>
|
|
|
|
<div class="uk-card-footer uk-padding-remove-vertical">
|
|
|
|
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
|
|
|
<div>
|
2021-05-19 13:40:29 +02:00
|
|
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
2022-06-28 20:15:05 +02:00
|
|
|
<a (click)="editAffiliationOpen(i)"
|
|
|
|
class="uk-button uk-button-link uk-flex uk-flex-middle">
|
|
|
|
<icon name="edit" [flex]="true"></icon>
|
|
|
|
<span class="uk-margin-xsmall-left">Edit</span>
|
2021-05-19 13:40:29 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-28 20:15:05 +02:00
|
|
|
<div>
|
|
|
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
|
|
|
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
|
|
|
(click)="deleteAffiliationOpen(i)">
|
|
|
|
<icon name="delete" [flex]="true"></icon>
|
2022-06-30 17:23:14 +02:00
|
|
|
<span class="uk-margin-xsmall-left">Delete</span>
|
2022-06-28 20:15:05 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-28 20:15:05 +02:00
|
|
|
</div>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="uk-width-1-1 uk-text-small">
|
|
|
|
Your personal info will be visible in the Curators page of your Community Gateway.
|
|
|
|
Read <a (click)="privacy()">privacy policy statement</a>.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-28 20:15:05 +02:00
|
|
|
<modal-alert #privacyStatement [overflowBody]="false" (alertOutput)="privacyStatement.cancel()">
|
2021-05-19 13:40:29 +02:00
|
|
|
<div class="uk-text-small">
|
|
|
|
Your personal data and photo are processed by OpenAIRE in conformity with personal data protection legal
|
|
|
|
framework.
|
|
|
|
They will be stored safely in our system for as long as OpenAIRE exists. Since you press the "save" button,
|
|
|
|
you give us the consent to make them public in your Community Gateway to let users know who is
|
|
|
|
configuring the platform. You always have the right to exercise your rights and ask for access,
|
2021-05-24 12:54:00 +02:00
|
|
|
rectification, erasure and restriction of your data. Please contact <a href="mailto:rcd@openaire.eu">rcd@openaire.eu</a>
|
2021-05-19 13:40:29 +02:00
|
|
|
if you have any inquiries.
|
|
|
|
</div>
|
|
|
|
</modal-alert>
|
2022-07-04 20:45:20 +02:00
|
|
|
<modal-alert #affiliationModal [okDisabled]="affiliationFb && affiliationFb.invalid" classTitle="uk-background-primary uk-light"
|
2022-06-28 20:15:05 +02:00
|
|
|
(alertOutput)="editAffiliation()">
|
2021-05-19 13:40:29 +02:00
|
|
|
<form *ngIf="affiliationFb" [formGroup]="affiliationFb">
|
2022-06-28 20:15:05 +02:00
|
|
|
<div class="uk-grid uk-child-width-1-1" uk-grid>
|
|
|
|
<div input placeholder="Name"
|
|
|
|
[formInput]="affiliationFb.get('name')"></div>
|
|
|
|
<div input type="logoURL" placeholder="Logo URL"
|
|
|
|
[formInput]="affiliationFb.get('logo_url')"></div>
|
|
|
|
<div input type="URL" placeholder="Website URL"
|
|
|
|
[formInput]="affiliationFb.get('website_url')"></div>
|
2021-05-19 13:40:29 +02:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</modal-alert>
|
2022-07-04 20:45:20 +02:00
|
|
|
<modal-alert #removeAffiliationModal [overflowBody]="false" (alertOutput)="removeAffiliation()" classTitle="uk-background-primary uk-light">
|
2021-05-19 13:40:29 +02:00
|
|
|
</modal-alert>
|
2022-07-04 20:45:20 +02:00
|
|
|
<modal-alert #enableCuratorsModal [overflowBody]="false" (alertOutput)="enableCurators()" classTitle="uk-background-primary uk-light">
|
2022-06-28 20:15:05 +02:00
|
|
|
Your personal information has been successfully saved.<br><br>
|
|
|
|
This information will be visible in <span class="uk-text-bold">Curators page</span> of Research Community
|
|
|
|
Dashboard, which is <span class="uk-text-bold">disabled</span>.
|
|
|
|
Do you want to <span class="uk-text-bold">enable</span> it now?
|
2021-05-19 13:40:29 +02:00
|
|
|
</modal-alert>
|
|
|
|
`,
|
2022-06-28 20:15:05 +02:00
|
|
|
styleUrls: ['personal-info.component.less']
|
2021-05-19 13:40:29 +02:00
|
|
|
})
|
|
|
|
export class PersonalInfoComponent implements OnInit, OnDestroy {
|
|
|
|
/** Curator information */
|
|
|
|
public loading = false;
|
|
|
|
public user: User;
|
|
|
|
public curator: Curator;
|
|
|
|
public curatorFb: FormGroup;
|
|
|
|
public properties: EnvProperties = properties;
|
|
|
|
public curatorsPage: Page;
|
|
|
|
public newCurator = false;
|
2022-06-28 20:15:05 +02:00
|
|
|
public community: CommunityInfo;
|
|
|
|
public stickyPageHeader: boolean = false;
|
2021-05-19 13:40:29 +02:00
|
|
|
/** Photo */
|
|
|
|
public photo: any = null;
|
|
|
|
private photoChanged: boolean = false;
|
|
|
|
public file: File = null;
|
|
|
|
private maxsize: number = 200 * 1024;
|
|
|
|
private deletePhoto = false;
|
|
|
|
private subs: any[] = [];
|
|
|
|
/** Affiliations */
|
|
|
|
public affiliationFb: FormGroup;
|
|
|
|
public index: number = -1;
|
|
|
|
@ViewChild('fileInput') fileInput: ElementRef;
|
|
|
|
@ViewChild('privacyStatement') privacyStatement: AlertModal;
|
|
|
|
@ViewChild('affiliationModal') affiliationModal: AlertModal;
|
|
|
|
@ViewChild('removeAffiliationModal') removeAffiliationModal: AlertModal;
|
|
|
|
@ViewChild('enableCuratorsModal') enableCuratorsModal: AlertModal;
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
|
|
private title: Title,
|
|
|
|
private fb: FormBuilder,
|
|
|
|
private curatorService: CuratorService,
|
|
|
|
private utilitiesService: UtilitiesService,
|
|
|
|
private helpContentService: HelpContentService,
|
|
|
|
private communityService: CommunityService,
|
|
|
|
private userManagementService: UserManagementService) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.subs.push(this.communityService.getCommunityAsObservable().subscribe(community => {
|
2022-06-28 20:15:05 +02:00
|
|
|
this.community = community;
|
2021-05-19 13:40:29 +02:00
|
|
|
this.subs.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
if (this.user) {
|
2022-06-28 20:15:05 +02:00
|
|
|
this.title.setTitle(community.shortTitle.toUpperCase() + " | Personal Info");
|
2021-05-19 13:40:29 +02:00
|
|
|
this.loading = true;
|
|
|
|
this.subs.push(this.curatorService.getCurator(properties).subscribe(curator => {
|
|
|
|
this.initCurator(curator);
|
|
|
|
this.reset();
|
|
|
|
this.loading = false;
|
|
|
|
}, error => {
|
|
|
|
if (error.status === 404) {
|
|
|
|
this.initCurator(null);
|
|
|
|
this.reset();
|
|
|
|
} else {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
this.loading = false;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subs.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
hide(element: any) {
|
|
|
|
UIkit.dropdown(element).hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
initCurator(curator: Curator) {
|
|
|
|
if (curator) {
|
|
|
|
this.curator = curator;
|
|
|
|
this.curator.email = this.user.email;
|
|
|
|
} else {
|
|
|
|
this.newCurator = true;
|
|
|
|
this.curator = new Curator();
|
|
|
|
this.curator._id = this.user.id;
|
|
|
|
this.curator.email = this.user.email;
|
|
|
|
this.curator.name = this.user.fullname;
|
|
|
|
this.curator.affiliations = [];
|
|
|
|
this.curator.bio = '';
|
|
|
|
this.curator.photo = null;
|
|
|
|
}
|
|
|
|
this.curatorsPageStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
this.photoChanged = false;
|
|
|
|
this.file = null;
|
|
|
|
if (this.fileInput) {
|
|
|
|
this.fileInput.nativeElement.value = null;
|
|
|
|
}
|
|
|
|
let affiliations: FormArray = this.fb.array([]);
|
|
|
|
this.curator.affiliations.forEach(affiliation => {
|
|
|
|
affiliations.push(this.fb.group({
|
|
|
|
id: this.fb.control(affiliation.id),
|
|
|
|
name: this.fb.control(affiliation.name, Validators.required),
|
|
|
|
logo_url: this.fb.control(affiliation.logo_url, [Validators.required, StringUtils.urlValidator()]),
|
|
|
|
website_url: this.fb.control(affiliation.website_url, [Validators.required, StringUtils.urlValidator()]),
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
this.curatorFb = this.fb.group({
|
|
|
|
_id: this.fb.control(this.curator._id),
|
|
|
|
name: this.fb.control(this.curator.name, Validators.required),
|
|
|
|
bio: this.fb.control(this.curator.bio),
|
|
|
|
email: this.fb.control(this.curator.email),
|
|
|
|
photo: this.fb.control(this.curator.photo),
|
|
|
|
affiliations: affiliations
|
|
|
|
});
|
|
|
|
if (this.curator.photo) {
|
|
|
|
this.photo = this.properties.utilsService + '/download/' + this.curator.photo;
|
|
|
|
} else {
|
|
|
|
this.photo = 'assets/common-assets/curator-default.png';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get affiliations(): FormArray {
|
|
|
|
return this.curatorFb.get('affiliations') as FormArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
saveCurator() {
|
|
|
|
this.curatorService.updateCurator(this.properties, this.curatorFb.value).subscribe((curator) => {
|
|
|
|
if (curator) {
|
|
|
|
UIkit.notification('Your data has been <b>saved successfully</b>', {
|
|
|
|
status: 'success',
|
|
|
|
timeout: 6000,
|
|
|
|
pos: 'bottom-right'
|
|
|
|
});
|
|
|
|
this.newCurator = false;
|
|
|
|
this.deletePhoto = false;
|
|
|
|
this.initCurator(curator);
|
|
|
|
this.reset();
|
2022-06-28 20:15:05 +02:00
|
|
|
if (!this.curatorsEnabled) {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.curatorsEnabledOpen();
|
|
|
|
}
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
this.handleUpdateError('An error has occurred. Try again later!');
|
|
|
|
this.reset();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateCurator() {
|
|
|
|
if (this.curatorFb.valid) {
|
|
|
|
this.loading = true;
|
|
|
|
if (this.file) {
|
|
|
|
this.utilitiesService.uploadPhoto(this.properties.utilsService + '/upload/' + this.curator._id, this.file).subscribe((res) => {
|
|
|
|
if (this.curator.photo) {
|
|
|
|
this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe();
|
|
|
|
}
|
|
|
|
this.curatorFb.get('photo').setValue(res.filename);
|
|
|
|
this.saveCurator();
|
|
|
|
}, error => {
|
|
|
|
this.handleUpdateError('An error has occurred during photo uploading.');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
if (this.deletePhoto && this.curator.photo) {
|
|
|
|
this.utilitiesService.deletePhoto(this.properties.utilsService + '/delete/' + this.curator.photo).subscribe();
|
|
|
|
this.curatorFb.get('photo').setValue(null);
|
|
|
|
}
|
|
|
|
this.saveCurator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private curatorsPageStatus() {
|
2022-06-28 20:15:05 +02:00
|
|
|
this.helpContentService.getCommunityPagesByRoute(this.community.communityId, '/curators', this.properties.adminToolsAPIURL).subscribe((page) => {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.curatorsPage = page;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public get curatorsEnabled(): boolean {
|
|
|
|
return !this.curatorsPage || this.curatorsPage.isEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileChangeEvent(event) {
|
|
|
|
this.loading = 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 file with type: image/png or image/jpeg!');
|
|
|
|
this.file = null;
|
|
|
|
} else if (this.file.size > this.maxsize) {
|
|
|
|
this.handleUpdateError('File exceeds size\'s limit! Maximum size 200KB.');
|
|
|
|
this.file = null;
|
|
|
|
} else {
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.readAsDataURL(this.file);
|
|
|
|
reader.onload = () => {
|
|
|
|
this.photo = reader.result;
|
|
|
|
this.photoChanged = true;
|
|
|
|
this.loading = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
removePhoto() {
|
|
|
|
this.deletePhoto = true;
|
|
|
|
this.file = null;
|
|
|
|
this.fileInput.nativeElement.value = null;
|
|
|
|
this.photoChanged = !!this.curator.photo;
|
|
|
|
this.photo = 'assets/common-assets/curator-default.png';
|
|
|
|
}
|
|
|
|
|
|
|
|
handleUpdateError(message: string) {
|
|
|
|
UIkit.notification(message, {
|
|
|
|
status: 'danger',
|
|
|
|
timeout: 6000,
|
|
|
|
pos: 'bottom-right'
|
|
|
|
});
|
|
|
|
this.loading = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
privacy() {
|
|
|
|
this.privacyStatement.cancelButton = false;
|
|
|
|
this.privacyStatement.okButtonText = 'Close';
|
|
|
|
this.privacyStatement.alertTitle = 'Privacy policy statement';
|
|
|
|
this.privacyStatement.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadPhoto(fileInput: HTMLInputElement) {
|
|
|
|
if (!this.curator.photo && !this.file) {
|
|
|
|
fileInput.click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasChanged(): boolean {
|
|
|
|
return (this.curatorFb && this.curatorFb.dirty) || this.newCurator || this.photoChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
editAffiliationOpen(index = -1) {
|
|
|
|
this.index = index;
|
|
|
|
let affiliation: Affiliation = new Affiliation();
|
2022-06-28 20:15:05 +02:00
|
|
|
if (index === -1) {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.affiliationModal.alertTitle = 'Add Affiliation';
|
|
|
|
this.affiliationModal.okButtonText = 'Add';
|
|
|
|
} else {
|
|
|
|
this.affiliationModal.alertTitle = 'Edit Affiliation';
|
|
|
|
this.affiliationModal.okButtonText = 'Update';
|
|
|
|
affiliation = this.affiliations.at(index).value;
|
|
|
|
}
|
|
|
|
this.affiliationFb = this.fb.group({
|
|
|
|
id: this.fb.control(affiliation.id),
|
|
|
|
name: this.fb.control(affiliation.name, Validators.required),
|
|
|
|
logo_url: this.fb.control(affiliation.logo_url, [Validators.required, StringUtils.urlValidator()]),
|
|
|
|
website_url: this.fb.control(affiliation.website_url, [Validators.required, StringUtils.urlValidator()])
|
|
|
|
});
|
|
|
|
this.affiliationModal.okButtonLeft = false;
|
|
|
|
this.affiliationModal.cancelButtonText = 'Cancel';
|
|
|
|
this.affiliationModal.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteAffiliationOpen(index: number) {
|
|
|
|
this.index = index;
|
|
|
|
let affiliation: Affiliation = this.affiliations.at(index).value;
|
|
|
|
this.removeAffiliationModal.alertTitle = 'Delete Affiliation';
|
|
|
|
this.removeAffiliationModal.message = 'Do you want to remove <b>' +
|
2022-06-28 20:15:05 +02:00
|
|
|
affiliation.name + '</b> from your Affiliations?';
|
2021-05-19 13:40:29 +02:00
|
|
|
this.removeAffiliationModal.okButtonText = 'Yes';
|
|
|
|
this.removeAffiliationModal.cancelButtonText = 'No';
|
|
|
|
this.removeAffiliationModal.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
editAffiliation() {
|
2022-06-28 20:15:05 +02:00
|
|
|
if (this.index === -1) {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.affiliations.push(this.affiliationFb);
|
|
|
|
} else {
|
|
|
|
this.affiliations.at(this.index).setValue(this.affiliationFb.value);
|
|
|
|
}
|
|
|
|
this.curatorFb.markAsDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
removeAffiliation() {
|
|
|
|
this.affiliations.removeAt(this.index);
|
|
|
|
this.curatorFb.markAsDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private curatorsEnabledOpen() {
|
|
|
|
this.enableCuratorsModal.okButtonLeft = false;
|
|
|
|
this.enableCuratorsModal.alertTitle = 'Enable Curators Page';
|
|
|
|
this.enableCuratorsModal.okButtonText = 'Yes';
|
|
|
|
this.enableCuratorsModal.cancelButtonText = 'No';
|
|
|
|
this.enableCuratorsModal.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
enableCurators() {
|
2022-06-28 20:15:05 +02:00
|
|
|
this.helpContentService.togglePages(this.community.communityId, [this.curatorsPage._id], true, this.properties.adminToolsAPIURL).subscribe(() => {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.curatorsPage.isEnabled = true;
|
|
|
|
UIkit.notification('Curators Page has been <b>enabled successfully</b>', {
|
|
|
|
status: 'success',
|
|
|
|
timeout: 6000,
|
|
|
|
pos: 'bottom-right'
|
|
|
|
});
|
2022-06-28 20:15:05 +02:00
|
|
|
}, error => {
|
2021-05-19 13:40:29 +02:00
|
|
|
this.handleUpdateError('An error has occurred. Try again later!');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|