start of db status service

This commit is contained in:
Jesse Lucas 2020-03-17 09:46:32 -04:00
parent 08da982de5
commit 8bdf409d07
6 changed files with 54 additions and 8 deletions

View File

@ -15,7 +15,7 @@ export class DeviceChartComponent implements OnInit {
constructor(private systemConfigService: SystemConfigService) { }
ngOnInit(): void {
this.systemConfigService.getFolders().subscribe(
this.systemConfigService.getDevices().subscribe(
data => {
this.data = [0, 230, 32, 40];
}

View File

@ -14,7 +14,6 @@ export class DonutChartComponent {
val.forEach((v) => {
this.addData(v)
});
console.log("set the data?", val)
}
};
@ -34,7 +33,6 @@ export class DonutChartComponent {
ngAfterViewInit(): void {
console.log("is the data set?", this.data, this.elementID);
this.canvas = document.getElementById(this.elementID);
this.ctx = this.canvas.getContext('2d');
this.chart = new Chart(this.ctx, {

View File

@ -16,11 +16,15 @@ export class FolderChartComponent implements OnInit {
constructor(private systemConfigService: SystemConfigService) { }
ngOnInit(): void {
// Find total number of folders
this.systemConfigService.getFolders().subscribe(
data => {
this.data = [0, 1, 32, 40];
}
);
// Sequentially look up each folder to get status
// dbStatusService
}
/*
ngAfterViewInit() {

View File

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { DbStatusService } from './db-status.service';
describe('DbStatusService', () => {
let service: DbStatusService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DbStatusService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { CookieService } from './cookie.service';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from '../environments/environment'
import { apiURL } from './api-utils'
@Injectable({
providedIn: 'root'
})
export class DbStatusService {
private httpOptions: any;
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> {
return this.http
.get(this.dbStatusUrl, this.httpOptions)
.pipe(map(res => {
// TODO update folder in system-config service
return res;
})
);
}
}

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable, Subject, of } from 'rxjs';
import { Observable, Subject } from 'rxjs';
import { map } from 'rxjs/operators';
import { Folder } from './folder';
@ -14,14 +14,13 @@ import { apiURL } from './api-utils'
providedIn: 'root'
})
export class SystemConfigService {
private systemConfig: any;
private folders: Folder[];
private devices: Device[];
private foldersSubject: Subject<Folder[]> = new Subject();
private devicesSubject: Subject<Device[]> = new Subject();
private systemConfigUrl = environment.production ? apiURL + 'rest/system/config' : 'api/config';
private httpOptions;
private httpOptions: any;
private checkInterval: number = 100;
@ -33,8 +32,6 @@ export class SystemConfigService {
return this.http
.get(this.systemConfigUrl, this.httpOptions)
.pipe(map(res => {
this.systemConfig = res;
this.folders = res['folders'];
this.devices = res['devices'];
this.foldersSubject.next(this.folders);