diff --git a/connect/curators/curator.service.ts b/connect/curators/curator.service.ts index cb016368..58155e40 100644 --- a/connect/curators/curator.service.ts +++ b/connect/curators/curator.service.ts @@ -1,9 +1,9 @@ -import {Injectable} from "@angular/core"; -import {HttpClient, HttpHeaders} from "@angular/common/http"; -import {BehaviorSubject, Observable} from "rxjs"; -import {Curator} from "../../utils/entities/CuratorInfo"; -import {EnvProperties} from "../../utils/properties/env-properties"; -import {COOKIE} from "../../login/utils/helper.class"; +import {Injectable} from '@angular/core'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {BehaviorSubject, Observable} from 'rxjs'; +import {Curator} from '../../utils/entities/CuratorInfo'; +import {EnvProperties} from '../../utils/properties/env-properties'; +import {COOKIE} from '../../login/utils/helper.class'; @Injectable() export class CuratorService { @@ -24,13 +24,17 @@ export class CuratorService { return this.curatorsSubject.asObservable(); } - public updateCurator(url: string, curator: Curator) { - this.http.post(url, {curator: curator}, this.getAuthOptions()).subscribe((res) => { - let curators = this.curatorsSubject.value; - curator.id = null; + public updateCurators(curator: Curator) { + const curators = this.curatorsSubject.value; + if (curators && curator) { + curator._id = null; curators.push(curator); this.curatorsSubject.next(curators); - }); + } + } + + public updateCurator(url: string, curator: Curator) { + return this.http.post(url, curator, this.getAuthOptions()); } public getCurator(properties: EnvProperties, url: string): Observable { @@ -39,10 +43,11 @@ export class CuratorService { // TODO remove and use CustomOptions.getAuthOptions() private getAuthOptions(): any { - const httpOptions = { + const httpOptions = { headers: new HttpHeaders({ 'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id), }), withCredentials: true }; + return httpOptions; } } diff --git a/services/curatorPhoto.service.ts b/services/curatorPhoto.service.ts new file mode 100644 index 00000000..fa32cec6 --- /dev/null +++ b/services/curatorPhoto.service.ts @@ -0,0 +1,31 @@ +import {Injectable} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {CustomOptions} from './servicesUtils/customOptions.class'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; +import {COOKIE} from '../login/utils/helper.class'; + +@Injectable() +export class CuratorPhotoService { + constructor(private http: HttpClient) { + } + + uploadPhoto(url: string, photo: File): Observable { + const formData = new FormData(); + formData.append('photo', photo); + return this.http.post(url, formData, this.getAuthOptions()); + } + + deletePhoto(url: string) { + return this.http.delete(url, this.getAuthOptions()); + } + + // TODO remove and use CustomOptions.getAuthOptions(false) + private getAuthOptions(): any { + const httpOptions = { + headers: new HttpHeaders({ + 'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id), + }) + }; + return httpOptions; + } +} diff --git a/utils/entities/CuratorInfo.ts b/utils/entities/CuratorInfo.ts index ec2ee2bc..db9b5733 100644 --- a/utils/entities/CuratorInfo.ts +++ b/utils/entities/CuratorInfo.ts @@ -1,9 +1,8 @@ export class Curator { - id: string = null; + _id: string = null; email: string; name: string; - surname: string; affiliations: Affiliation[]; photo: string; bio: string; diff --git a/utils/modal/alert.ts b/utils/modal/alert.ts index fc4472b0..d1c0d7e0 100644 --- a/utils/modal/alert.ts +++ b/utils/modal/alert.ts @@ -1,4 +1,4 @@ -import {Component, ViewEncapsulation, ElementRef, EventEmitter, Output} from '@angular/core'; +import {Component, ViewEncapsulation, ElementRef, EventEmitter, Output, Input} from '@angular/core'; @Component({ selector: 'modal-alert', @@ -26,9 +26,10 @@ import {Component, ViewEncapsulation, ElementRef, EventEmitter, Output} from '@a
- + - + +
@@ -90,7 +91,16 @@ export class AlertModal{ */ public isOpen:boolean=false; + /** + * if the value is true ok button align on the left, else on the right + */ public okButtonLeft: boolean = true; + + /** + * if the value is true ok button is disabled + */ + @Input() + public okDisabled: boolean = false; /** * Emitted when a ok button was clicked * or when Ok method is called. diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 4fd80f05..a7faf7ac 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -14,7 +14,6 @@ export class EnvProperties { statisticsAPIURL; loginAPIURL; - claimsAPIURL; searchAPIURLLAst; @@ -57,6 +56,8 @@ export class EnvProperties { uploadService; + downloadUrl; + deleteUrl; vocabulariesAPI;