Work on db status service

This commit is contained in:
Jesse Lucas 2020-03-17 22:37:39 -04:00
parent 81c539c516
commit 206c0d0933
1 changed files with 23 additions and 12 deletions

View File

@ -1,31 +1,42 @@
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 { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { map, retry, catchError } from 'rxjs/operators';
import { environment } from '../environments/environment'
import { apiURL } from './api-utils'
import { apiURL, apiRetry } from './api-utils'
import { FolderStatus, Folder } from './folder'
@Injectable({
providedIn: 'root'
})
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';
constructor(private http: HttpClient, private cookieService: CookieService) {
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
.get(this.dbStatusUrl, this.httpOptions)
.pipe(map(res => {
// TODO update folder in system-config service
return res;
})
.get<FolderStatus>(this.dbStatusUrl, this.httpOptions)
.pipe(
retry(apiRetry),
map(res => {
return res;
})
);
}
}
}