diff --git a/src/app/db-status.service.ts b/src/app/db-status.service.ts index 5e8e05769..4c9e99797 100644 --- a/src/app/db-status.service.ts +++ b/src/app/db-status.service.ts @@ -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 { + getFolderStatus(id: string): Observable { + /* + 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(this.dbStatusUrl, this.httpOptions) + .pipe( + retry(apiRetry), + map(res => { + return res; + }) ); } -} +} \ No newline at end of file