start of db status service
This commit is contained in:
@@ -15,7 +15,7 @@ export class DeviceChartComponent implements OnInit {
|
|||||||
constructor(private systemConfigService: SystemConfigService) { }
|
constructor(private systemConfigService: SystemConfigService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.systemConfigService.getFolders().subscribe(
|
this.systemConfigService.getDevices().subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.data = [0, 230, 32, 40];
|
this.data = [0, 230, 32, 40];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export class DonutChartComponent {
|
|||||||
val.forEach((v) => {
|
val.forEach((v) => {
|
||||||
this.addData(v)
|
this.addData(v)
|
||||||
});
|
});
|
||||||
console.log("set the data?", val)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +33,6 @@ export class DonutChartComponent {
|
|||||||
|
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
console.log("is the data set?", this.data, this.elementID);
|
|
||||||
this.canvas = document.getElementById(this.elementID);
|
this.canvas = document.getElementById(this.elementID);
|
||||||
this.ctx = this.canvas.getContext('2d');
|
this.ctx = this.canvas.getContext('2d');
|
||||||
this.chart = new Chart(this.ctx, {
|
this.chart = new Chart(this.ctx, {
|
||||||
|
|||||||
@@ -16,11 +16,15 @@ export class FolderChartComponent implements OnInit {
|
|||||||
constructor(private systemConfigService: SystemConfigService) { }
|
constructor(private systemConfigService: SystemConfigService) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
// Find total number of folders
|
||||||
this.systemConfigService.getFolders().subscribe(
|
this.systemConfigService.getFolders().subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.data = [0, 1, 32, 40];
|
this.data = [0, 1, 32, 40];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sequentially look up each folder to get status
|
||||||
|
// dbStatusService
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -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;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
|
||||||
import { Observable, Subject, of } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { Folder } from './folder';
|
import { Folder } from './folder';
|
||||||
@@ -14,14 +14,13 @@ import { apiURL } from './api-utils'
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class SystemConfigService {
|
export class SystemConfigService {
|
||||||
private systemConfig: any;
|
|
||||||
private folders: Folder[];
|
private folders: Folder[];
|
||||||
private devices: Device[];
|
private devices: Device[];
|
||||||
private foldersSubject: Subject<Folder[]> = new Subject();
|
private foldersSubject: Subject<Folder[]> = new Subject();
|
||||||
private devicesSubject: Subject<Device[]> = new Subject();
|
private devicesSubject: Subject<Device[]> = new Subject();
|
||||||
|
|
||||||
private systemConfigUrl = environment.production ? apiURL + 'rest/system/config' : 'api/config';
|
private systemConfigUrl = environment.production ? apiURL + 'rest/system/config' : 'api/config';
|
||||||
private httpOptions;
|
private httpOptions: any;
|
||||||
|
|
||||||
private checkInterval: number = 100;
|
private checkInterval: number = 100;
|
||||||
|
|
||||||
@@ -33,8 +32,6 @@ export class SystemConfigService {
|
|||||||
return this.http
|
return this.http
|
||||||
.get(this.systemConfigUrl, this.httpOptions)
|
.get(this.systemConfigUrl, this.httpOptions)
|
||||||
.pipe(map(res => {
|
.pipe(map(res => {
|
||||||
this.systemConfig = res;
|
|
||||||
|
|
||||||
this.folders = res['folders'];
|
this.folders = res['folders'];
|
||||||
this.devices = res['devices'];
|
this.devices = res['devices'];
|
||||||
this.foldersSubject.next(this.folders);
|
this.foldersSubject.next(this.folders);
|
||||||
|
|||||||
Reference in New Issue
Block a user