From 749d31b170bf7427bf7b26ad18ce6bab1e57e076 Mon Sep 17 00:00:00 2001 From: ElonH Date: Mon, 1 Jun 2020 16:17:10 +0800 Subject: [PATCH] feat(task-component): a task manager --- src/app/pages/manager/manager.component.ts | 38 +++++- src/app/pages/manager/manager.module.ts | 4 + .../manager/{ => tasks}/task.service.spec.ts | 0 .../pages/manager/{ => tasks}/task.service.ts | 46 ++++++- .../manager/tasks/tasks.component.spec.ts | 27 ++++ .../pages/manager/tasks/tasks.component.ts | 116 ++++++++++++++++++ 6 files changed, 222 insertions(+), 9 deletions(-) rename src/app/pages/manager/{ => tasks}/task.service.spec.ts (100%) rename src/app/pages/manager/{ => tasks}/task.service.ts (72%) create mode 100644 src/app/pages/manager/tasks/tasks.component.spec.ts create mode 100644 src/app/pages/manager/tasks/tasks.component.ts diff --git a/src/app/pages/manager/manager.component.ts b/src/app/pages/manager/manager.component.ts index 3ed752f..0b71a7d 100644 --- a/src/app/pages/manager/manager.component.ts +++ b/src/app/pages/manager/manager.component.ts @@ -5,16 +5,12 @@ import { CombErr } from 'src/app/@dataflow/core'; import { map, withLatestFrom } from 'rxjs/operators'; import { HomeModeComponent } from './homeMode/homeMode.component'; import { NbDialogService } from '@nebular/theme'; -import { - OperationsMkdirFlow, - OperationsMkdirFlowInNode, - OperationsCopyfileFlow, -} from 'src/app/@dataflow/rclone'; +import { OperationsMkdirFlow, OperationsMkdirFlowInNode } from 'src/app/@dataflow/rclone'; import { ConnectionService } from '../connection.service'; import { NbToastrService } from '@nebular/theme'; import { FileModeComponent } from './fileMode/fileMode.component'; import { ClipboardService } from './clipboard/clipboard.service'; -import { TaskService } from './task.service'; +import { TaskService } from './tasks/task.service'; @Component({ selector: 'app-manager', @@ -91,6 +87,27 @@ import { TaskService } from './task.service'; + + + + + + + + + + + Tasks + + + + + + + + + Order + + + + + + {{ row.srcRemote }} + {{ row.srcItem.Path }} + {{ row.dst.remote }} + {{ row.dst.path }} + + + + + + + + Failure + + + + + + + + {{ row.srcRemote }} + {{ row.srcItem.Path }} + {{ row.dst.remote }} + {{ row.dst.path }} + + + + + + `, + styles: [ + ` + .right { + margin-left: auto; + } + .rightest { + margin-right: auto; + } + `, + ], +}) +export class TasksComponent implements OnInit { + constructor(private service: TaskService) {} + public conf: Config; + public columns: Columns[] = [ + { key: 'oper', title: '', width: '3%' }, + { key: 'srcRemote', title: 'Source Remote', width: '10%' }, + { key: 'srcItem.Path', title: 'Source Path', width: '35%' }, + { key: 'dst.remote', title: 'Destination Remote', width: '10%' }, + { key: 'dst.path', title: 'Destination Path', width: '35%' }, + ]; + + orderSize = 0; + orderData: ClipboardItem[] = []; + + failSize = 0; + failData: ClipboardItem[] = []; + + ngOnInit() { + this.service.detail$.getOutput().subscribe((x) => { + if (x[1].length !== 0) return; + const order = x[0].order; + const fail = x[0].failure; + this.orderSize = order.size; + this.failSize = fail.size; + this.orderData = order.values; + this.failData = fail.values; + }); + } + + public manipulate2Icon(o: IManipulate): string { + if (o === 'del') return 'trash-2'; + return o; + } + + retryFailure() { + this.service.retryFailureTasks(); + } + + removeFailure() { + this.service.removeFailureTasks(); + } +}