1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/model/tasks/DummyTask.ts
2019-07-27 22:56:12 +02:00

36 lines
897 B
TypeScript

import {TaskProgressDTO} from '../../../common/entities/settings/TaskProgressDTO';
import {ConfigTemplateEntry, DefaultsTasks} from '../../../common/entities/task/TaskDTO';
import {Utils} from '../../../common/Utils';
import {Task} from './Task';
const LOG_TAG = '[DummyTask]';
export class DummyTask extends Task {
public readonly Name = DefaultsTasks[DefaultsTasks.Dummy];
counter = 0;
public readonly ConfigTemplate: ConfigTemplateEntry[] = null;
public get Supported(): boolean {
return true;
}
protected async init() {
this.counter = 0;
}
protected async step(): Promise<TaskProgressDTO> {
await Utils.wait(1000);
if (!this.running) {
return null;
}
this.counter++;
this.progress.progress = this.counter;
this.progress.left = Math.pow(10, Math.floor(Math.log10(this.counter)) + 1) - this.counter;
return this.progress;
}
}