mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-20 03:51:00 +00:00
Work on db status service
This commit is contained in:
parent
81c539c516
commit
206c0d0933
@ -1,29 +1,40 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
import { CookieService } from './cookie.service';
|
import { CookieService } from './cookie.service';
|
||||||
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, retry, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
import { environment } from '../environments/environment'
|
import { environment } from '../environments/environment'
|
||||||
import { apiURL } from './api-utils'
|
import { apiURL, apiRetry } from './api-utils'
|
||||||
|
import { FolderStatus, Folder } from './folder'
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DbStatusService {
|
export class DbStatusService {
|
||||||
private httpOptions: any;
|
private folderStatus: Object = {};
|
||||||
|
|
||||||
|
// TODO why isn't this working?
|
||||||
|
private httpOptions: { headers: HttpHeaders } | { params: HttpParams };
|
||||||
private dbStatusUrl = environment.production ? apiURL + 'rest/db/status' : 'api/dbStatus';
|
private dbStatusUrl = environment.production ? apiURL + 'rest/db/status' : 'api/dbStatus';
|
||||||
|
|
||||||
constructor(private http: HttpClient, private cookieService: CookieService) {
|
constructor(private http: HttpClient, private cookieService: CookieService) {
|
||||||
this.httpOptions = { headers: new HttpHeaders(this.cookieService.getCSRFHeader()) };
|
this.httpOptions = { headers: new HttpHeaders(this.cookieService.getCSRFHeader()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
getFolderStatus(id: string): Observable<any> {
|
getFolderStatus(id: string): Observable<FolderStatus> {
|
||||||
|
/*
|
||||||
|
if (id) {
|
||||||
|
this.httpOptions["params"] = new HttpParams().set('folder', id);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
.get(this.dbStatusUrl, this.httpOptions)
|
.get<FolderStatus>(this.dbStatusUrl, this.httpOptions)
|
||||||
.pipe(map(res => {
|
.pipe(
|
||||||
// TODO update folder in system-config service
|
retry(apiRetry),
|
||||||
|
map(res => {
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user