Skip to content

Commit

Permalink
fix(transferring): make speed and size human-readable
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed May 29, 2020
1 parent 721dd71 commit 43bcaba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/app/pages/jobs/transferring/transferring.component.ts
@@ -1,6 +1,7 @@
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',
Expand All @@ -16,20 +17,24 @@ export class TransfersComponent implements OnInit {
public configuration: Config;
public columns: Columns[] = [
{ key: 'name', title: 'Name' },
{ key: 'size', title: 'Size' },
{ key: 'sizeHumanReadable', title: 'Size' },
{ key: 'percentage', title: 'Percentage' },
{ key: 'speed', title: 'Speed' },
{ key: 'speedHumanReadable', title: 'Speed' },
{ key: 'eta', title: 'eta' },
];
public data: ITransferring[] = [];
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 : [];
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 };
Expand Down

0 comments on commit 43bcaba

Please sign in to comment.