2019-12-09 21:05:06 +08:00
|
|
|
import {ITask} from './tasks/ITask';
|
|
|
|
import {IndexingTask} from './tasks/IndexingTask';
|
|
|
|
import {DBRestTask} from './tasks/DBResetTask';
|
|
|
|
import {VideoConvertingTask} from './tasks/VideoConvertingTask';
|
2019-07-28 04:56:12 +08:00
|
|
|
|
|
|
|
export class TaskRepository {
|
|
|
|
|
|
|
|
private static instance: TaskRepository = null;
|
|
|
|
availableTasks: { [key: string]: ITask<any> } = {};
|
|
|
|
|
|
|
|
public static get Instance(): TaskRepository {
|
|
|
|
if (TaskRepository.instance == null) {
|
|
|
|
TaskRepository.instance = new TaskRepository();
|
|
|
|
}
|
|
|
|
return TaskRepository.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
getAvailableTasks(): ITask<any>[] {
|
|
|
|
return Object.values(this.availableTasks).filter(t => t.Supported);
|
|
|
|
}
|
|
|
|
|
|
|
|
register(task: ITask<any>) {
|
|
|
|
this.availableTasks[task.Name] = task;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TaskRepository.Instance.register(new IndexingTask());
|
|
|
|
TaskRepository.Instance.register(new DBRestTask());
|
2019-12-09 21:05:06 +08:00
|
|
|
TaskRepository.Instance.register(new VideoConvertingTask());
|