mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-20 03:51:00 +00:00
start of db status service
This commit is contained in:
parent
08da982de5
commit
8bdf409d07
@ -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];
|
||||
}
|
||||
|
@ -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, {
|
||||
|
@ -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() {
|
||||
|
16
src/app/db-status.service.spec.ts
Normal file
16
src/app/db-status.service.spec.ts
Normal 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();
|
||||
});
|
||||
});
|
31
src/app/db-status.service.ts
Normal file
31
src/app/db-status.service.ts
Normal 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;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user