-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(task-component): a task manager
- Loading branch information
Showing
6 changed files
with
222 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DebugElement } from '@angular/core'; | ||
|
||
import { TasksComponent } from './tasks.component'; | ||
|
||
describe('TasksComponent', () => { | ||
let component: TasksComponent; | ||
let fixture: ComponentFixture<TasksComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TasksComponent], | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TasksComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { TaskService } from './task.service'; | ||
import { Config, Columns } from 'ngx-easy-table'; | ||
import { ClipboardItem, IManipulate } from '../clipboard/clipboard.service'; | ||
|
||
@Component({ | ||
selector: 'manager-tasks', | ||
template: ` | ||
<nb-accordion multi> | ||
<!-- <nb-accordion-item *ngIf="orderSize !== 0"> --> | ||
<nb-accordion-item> | ||
<nb-accordion-item-header> | ||
Order | ||
</nb-accordion-item-header> | ||
<nb-accordion-item-body> | ||
<ngx-table | ||
#orderTable | ||
[configuration]="conf" | ||
[data]="orderData" | ||
id="order" | ||
[columns]="columns" | ||
> | ||
<ng-template let-row let-rowIdx="index"> | ||
<td><nb-icon [icon]="manipulate2Icon(row.oper)"></nb-icon></td> | ||
<td>{{ row.srcRemote }}</td> | ||
<td>{{ row.srcItem.Path }}</td> | ||
<td>{{ row.dst.remote }}</td> | ||
<td>{{ row.dst.path }}</td> | ||
</ng-template> | ||
</ngx-table> | ||
</nb-accordion-item-body> | ||
</nb-accordion-item> | ||
<nb-accordion-item *ngIf="failSize !== 0"> | ||
<nb-accordion-item-header> | ||
Failure | ||
<button nbButton ghost status="warning" class="right" (click)="retryFailure()"> | ||
Retry | ||
</button> | ||
<button nbButton ghost status="danger" class="rightest" (click)="removeFailure()"> | ||
Remove | ||
</button> | ||
</nb-accordion-item-header> | ||
<nb-accordion-item-body> | ||
<ngx-table | ||
#failTasksTable | ||
[configuration]="conf" | ||
[data]="failData" | ||
id="fail" | ||
[columns]="columns" | ||
> | ||
<ng-template let-row let-rowIdx="index"> | ||
<td><nb-icon [icon]="manipulate2Icon(row.oper)"></nb-icon></td> | ||
<td>{{ row.srcRemote }}</td> | ||
<td>{{ row.srcItem.Path }}</td> | ||
<td>{{ row.dst.remote }}</td> | ||
<td>{{ row.dst.path }}</td> | ||
</ng-template> | ||
</ngx-table> | ||
</nb-accordion-item-body> | ||
</nb-accordion-item> | ||
</nb-accordion> | ||
`, | ||
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(); | ||
} | ||
} |