1 |
41741550
|
Hung Hoang
|
import { Injectable } from '@angular/core';
|
2 |
|
|
import { HttpClient } from '@angular/common/http';
|
3 |
|
|
import { catchError } from 'rxjs/operators';
|
4 |
|
|
|
5 |
|
|
import { BasicService } from './basic.service';
|
6 |
|
|
import { Settings } from '../models/settings.model';
|
7 |
|
|
|
8 |
|
|
@Injectable({
|
9 |
|
|
providedIn: 'root'
|
10 |
|
|
})
|
11 |
|
|
export class SettingsService extends BasicService {
|
12 |
|
|
defaultSettingsUrl = this.baseUrl + '/settings/default';
|
13 |
|
|
|
14 |
|
|
getDefaultSettings() {
|
15 |
|
|
return this.http.get<Settings>(this.defaultSettingsUrl)
|
16 |
|
|
.pipe(
|
17 |
|
|
catchError(err => this.handleError(err))
|
18 |
|
|
);
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
postDefaultSettingsWithResponse(settings: Settings) {
|
22 |
|
|
return this.postDefaultSettingsWithOptions(settings, {observe: 'response'});
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
postDefaultSettings(settings: Settings) {
|
26 |
|
|
return this.postDefaultSettingsWithOptions(settings, {});
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
private postDefaultSettingsWithOptions(settings: Settings, options: any) {
|
30 |
|
|
return this.http.post<Settings>(this.defaultSettingsUrl, settings, options)
|
31 |
|
|
.pipe(
|
32 |
|
|
catchError(err => this.handleError(err))
|
33 |
|
|
);
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
constructor(protected http: HttpClient) {
|
37 |
|
|
super(http);
|
38 |
|
|
}
|
39 |
|
|
}
|