1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/settings/indexing/indexing.settings.service.ts
2017-07-25 21:09:37 +02:00

46 lines
1.4 KiB
TypeScript

import {Injectable} from "@angular/core";
import {NetworkService} from "../../model/network/network.service";
import {SettingsService} from "../settings.service";
import {AbstractSettingsService} from "../_abstract/abstract.settings.service";
import {DatabaseType} from "../../../../common/config/private/IPrivateConfig";
import {IndexingProgressDTO} from "../../../../common/entities/settings/IndexingProgressDTO";
import {BehaviorSubject} from "rxjs/BehaviorSubject";
@Injectable()
export class IndexingSettingsService extends AbstractSettingsService<void> {
public progress: BehaviorSubject<IndexingProgressDTO>;
constructor(private _networkService: NetworkService,
_settingsService: SettingsService) {
super(_settingsService);
this.progress = new BehaviorSubject(null);
}
public isSupported(): boolean {
return this._settingsService.settings.value.Server.database.type != DatabaseType.memory;
}
public index() {
return this._networkService.putJson("/admin/indexes/job");
}
public cancel() {
return this._networkService.deleteJson("/admin/indexes/job");
}
public async getProgress() {
this.progress.next(await this._networkService.getJson<IndexingProgressDTO>("/admin/indexes/job/progress"));
}
public reset() {
return this._networkService.deleteJson("/admin/indexes");
}
updateSettings(settings: void): Promise<void> {
throw new Error("Method not implemented.");
}
}