-
Notifications
You must be signed in to change notification settings - Fork 44
/
transferring.component.ts
44 lines (39 loc) · 1.34 KB
/
transferring.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Component, OnInit, Input } from '@angular/core';
import { Columns, Config, DefaultConfig } from 'ngx-easy-table';
import { CoreStatsFlow, ITransferring } from 'src/app/@dataflow/rclone';
import { FormatBytes } from 'src/app/utils/format-bytes';
@Component({
selector: 'jobs-transferring',
template: `
<ngx-table [configuration]="configuration" [data]="data" [columns]="columns"> </ngx-table>
`,
styles: [],
})
export class TransfersComponent implements OnInit {
@Input()
stats$: CoreStatsFlow;
public configuration: Config;
public columns: Columns[] = [
{ key: 'name', title: 'Name' },
{ key: 'sizeHumanReadable', title: 'Size' },
{ key: 'percentage', title: 'Percentage' },
{ key: 'speedHumanReadable', title: 'Speed' },
{ key: 'eta', title: 'eta' },
];
public data: (ITransferring & { sizeHumanReadable: string; speedHumanReadable: string })[] = [];
constructor() {}
ngOnInit() {
this.stats$.getOutput().subscribe(([x, err]) => {
if (err.length !== 0) return;
const data = x['core-stats'].transferring;
this.data = data ? data : ([] as any);
this.data.forEach((x) => {
x.sizeHumanReadable = FormatBytes(x.size, 3);
x.speedHumanReadable = FormatBytes(x.speed) + '/s';
});
});
this.configuration = { ...DefaultConfig };
this.configuration.searchEnabled = true;
this.configuration.isLoading = false;
}
}