Work on db status service

This commit is contained in:
Jesse Lucas 2020-03-17 22:37:39 -04:00
parent 81c539c516
commit 206c0d0933

View File

@ -1,31 +1,42 @@
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),
return res; map(res => {
}) return res;
})
); );
} }
} }