[Trunk|Library]: 1. Add a new service for curator photo. 2. Add at properties url for curator download and delete photo. 3. Add a parameter at modal alert to disable ok button. 4. Add CuratorInfo.ts with curator and affiliation classes. 5. Add methods at curators service.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55945 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-06-02 18:52:26 +00:00
parent 6564a4d74b
commit 10ed032ead
5 changed files with 64 additions and 18 deletions

View File

@ -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<Curator>(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<Curator>(url, curator, this.getAuthOptions());
}
public getCurator(properties: EnvProperties, url: string): Observable<Curator> {
@ -44,5 +48,6 @@ export class CuratorService {
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id),
}), withCredentials: true
};
return httpOptions;
}
}

View File

@ -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<any> {
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;
}
}

View File

@ -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;

View File

@ -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',
@ -28,7 +28,8 @@ import {Component, ViewEncapsulation, ElementRef, EventEmitter, Output} from '@a
<button class="uk-button uk-button-default" (click)="cancel()">{{cancelButtonText}}</button>
</span>
<span [hidden]=!okButton >
<button class="uk-button portal-button" (click)="ok()">{{okButtonText}}</button>
<button *ngIf="okDisabled" class="uk-button uk-button-default" disabled>{{okButtonText}}</button>
<button *ngIf="!okDisabled" class="uk-button portal-button" (click)="ok()">{{okButtonText}}</button>
</span>
</div>
@ -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.

View File

@ -14,7 +14,6 @@ export class EnvProperties {
statisticsAPIURL;
loginAPIURL;
claimsAPIURL;
searchAPIURLLAst;
@ -57,6 +56,8 @@ export class EnvProperties {
uploadService;
downloadUrl;
deleteUrl;
vocabulariesAPI;