Revision 55963
Added by Argiro Kokogiannaki almost 5 years ago
curator.service.ts | ||
---|---|---|
1 |
import {Injectable} from "@angular/core";
|
|
2 |
import {HttpClient, HttpHeaders} from "@angular/common/http";
|
|
3 |
import {BehaviorSubject, Observable} from "rxjs";
|
|
4 |
import {Curator} from "../../utils/entities/CuratorInfo";
|
|
5 |
import {EnvProperties} from "../../utils/properties/env-properties";
|
|
6 |
import {COOKIE} from "../../login/utils/helper.class";
|
|
1 |
import {Injectable} from '@angular/core';
|
|
2 |
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
|
3 |
import {BehaviorSubject, Observable} from 'rxjs';
|
|
4 |
import {Curator} from '../../utils/entities/CuratorInfo';
|
|
5 |
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
6 |
import {COOKIE} from '../../login/utils/helper.class';
|
|
7 | 7 |
|
8 | 8 |
@Injectable() |
9 | 9 |
export class CuratorService { |
... | ... | |
24 | 24 |
return this.curatorsSubject.asObservable(); |
25 | 25 |
} |
26 | 26 |
|
27 |
public updateCurator(url: string, curator: Curator) {
|
|
28 |
this.http.post<Curator>(url, {curator: curator}, this.getAuthOptions()).subscribe((res) => {
|
|
29 |
let curators = this.curatorsSubject.value;
|
|
30 |
curator.id = null; |
|
27 |
public updateCurators(curator: Curator) {
|
|
28 |
const curators = this.curatorsSubject.value;
|
|
29 |
if (curators && curator) {
|
|
30 |
curator._id = null;
|
|
31 | 31 |
curators.push(curator); |
32 | 32 |
this.curatorsSubject.next(curators); |
33 |
});
|
|
33 |
} |
|
34 | 34 |
} |
35 | 35 |
|
36 |
public updateCurator(url: string, curator: Curator) { |
|
37 |
return this.http.post<Curator>(url, curator, this.getAuthOptions()); |
|
38 |
} |
|
39 |
|
|
36 | 40 |
public getCurator(properties: EnvProperties, url: string): Observable<Curator> { |
37 | 41 |
return this.http.get<Curator>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url); |
38 | 42 |
} |
39 | 43 |
|
40 | 44 |
// TODO remove and use CustomOptions.getAuthOptions() |
41 | 45 |
private getAuthOptions(): any { |
42 |
const httpOptions = { |
|
46 |
const httpOptions = {
|
|
43 | 47 |
headers: new HttpHeaders({ |
44 | 48 |
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id), |
45 | 49 |
}), withCredentials: true |
46 | 50 |
}; |
51 |
return httpOptions; |
|
47 | 52 |
} |
48 | 53 |
} |
Also available in: Unified diff
[angular7|library]
Merging Trunk into branch 55904:55959