1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/frontend/app/ui/settings/indexing/indexing.settings.service.ts

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2018-03-30 15:30:30 -04:00
import {Injectable} from '@angular/core';
import {NetworkService} from '../../../model/network/network.service';
2018-03-30 15:30:30 -04:00
import {SettingsService} from '../settings.service';
import {AbstractSettingsService} from '../_abstract/abstract.settings.service';
import {DatabaseType, IndexingConfig} from '../../../../../common/config/private/IPrivateConfig';
import {IndexingProgressDTO} from '../../../../../common/entities/settings/IndexingProgressDTO';
2018-05-22 20:27:07 -04:00
import {BehaviorSubject} from 'rxjs';
import {IndexingDTO} from '../../../../../common/entities/settings/IndexingDTO';
import {StatisticDTO} from '../../../../../common/entities/settings/StatisticDTO';
2017-07-25 21:09:37 +02:00
@Injectable()
2017-07-27 23:10:16 +02:00
export class IndexingSettingsService extends AbstractSettingsService<IndexingConfig> {
2017-07-25 21:09:37 +02:00
public progress: BehaviorSubject<IndexingProgressDTO>;
constructor(private _networkService: NetworkService,
_settingsService: SettingsService) {
super(_settingsService);
this.progress = new BehaviorSubject(null);
}
2017-07-27 23:10:16 +02:00
public updateSettings(settings: IndexingConfig): Promise<void> {
2018-03-30 15:30:30 -04:00
return this._networkService.putJson('/settings/indexing', {settings: settings});
2017-07-27 23:10:16 +02:00
}
2017-07-25 21:09:37 +02:00
public isSupported(): boolean {
2018-05-03 18:23:48 -04:00
return this._settingsService.settings.value.Server.database.type !== DatabaseType.memory;
2017-07-25 21:09:37 +02:00
}
2018-11-28 23:49:33 +01:00
public index(createThumbnails: boolean) {
2018-11-24 13:08:34 +01:00
return this._networkService.postJson('/admin/indexes/job', <IndexingDTO>{createThumbnails: createThumbnails});
2017-07-25 21:09:37 +02:00
}
public cancel() {
2018-03-30 15:30:30 -04:00
return this._networkService.deleteJson('/admin/indexes/job');
2017-07-25 21:09:37 +02:00
}
public async getProgress() {
2018-03-30 15:30:30 -04:00
this.progress.next(await this._networkService.getJson<IndexingProgressDTO>('/admin/indexes/job/progress'));
2017-07-25 21:09:37 +02:00
}
public reset() {
2018-03-30 15:30:30 -04:00
return this._networkService.deleteJson('/admin/indexes');
2017-07-25 21:09:37 +02:00
}
2018-12-09 23:25:39 +01:00
getStatistic() {
return this._networkService.getJson<StatisticDTO>('/admin/statistic');
}
2017-07-25 21:09:37 +02:00
}