mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-29 13:22:42 +00:00
new folder service
This commit is contained in:
parent
75b3b31d11
commit
81c539c516
16
src/app/folder.service.spec.ts
Normal file
16
src/app/folder.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { FolderService } from './folder.service';
|
||||||
|
|
||||||
|
describe('FolderService', () => {
|
||||||
|
let service: FolderService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(FolderService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
45
src/app/folder.service.ts
Normal file
45
src/app/folder.service.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { SystemConfigService } from './system-config.service';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
import { Folder } from './folder';
|
||||||
|
import { DbStatusService } from './db-status.service';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class FolderService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private systemConfigService: SystemConfigService,
|
||||||
|
private dbStatusService: DbStatusService
|
||||||
|
) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getAll() finds all folders and uses db status service to
|
||||||
|
* set all their statuses
|
||||||
|
*/
|
||||||
|
getAll(): Observable<Folder> {
|
||||||
|
const dbs = this.dbStatusService;
|
||||||
|
const folderObservable: Observable<Folder> = new Observable((observer) => {
|
||||||
|
this.systemConfigService.getFolders().subscribe({
|
||||||
|
next(folders) {
|
||||||
|
let folder: Folder;
|
||||||
|
for (folder of folders) {
|
||||||
|
// Get the status of each folder
|
||||||
|
dbs.getFolderStatus(folder.id).subscribe(
|
||||||
|
status => {
|
||||||
|
console.log(status)
|
||||||
|
folder["status"] = status;
|
||||||
|
|
||||||
|
observer.next(folder);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error(err) { console.log("getAll error!", err) }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return folderObservable
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user