Skip to content

Commit

Permalink
fix(summary): make speed and bytes human-readable
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed May 29, 2020
1 parent b7dc850 commit 721dd71
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/app/pages/jobs/summary/summary.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit, Input } from '@angular/core';
import { CoreStatsFlow, CoreStatsFlowOutItemNode } from 'src/app/@dataflow/rclone';
import { FormatBytes } from 'src/app/utils/format-bytes';

@Component({
selector: 'jobs-summary',
Expand Down Expand Up @@ -32,8 +33,8 @@ export class SummaryComponent implements OnInit {
stats$: CoreStatsFlow;

keys: { key: string; title?: string }[] = [
{ key: 'bytes', title: 'Bytes' },
{ key: 'speed', title: 'Speed' },
{ key: 'bytesHumanReadable', title: 'Bytes' },
{ key: 'speedHumanReadable', title: 'Speed' },
{ key: 'transferring-count', title: 'Transferring' },
{ key: 'transfers', title: 'Transferred' },
{ key: 'checks', title: 'Checks' },
Expand All @@ -43,7 +44,10 @@ export class SummaryComponent implements OnInit {
{ key: 'fatalError', title: 'FatalError' },
{ key: 'retryError', title: 'RetryError' },
];
values: CoreStatsFlowOutItemNode = {} as any;
values: CoreStatsFlowOutItemNode & {
speedHumanReadable: string;
bytesHumanReadable: string;
} = {} as any;

constructor() {}
isDefine(val: any) {
Expand All @@ -54,6 +58,8 @@ export class SummaryComponent implements OnInit {
this.stats$.getOutput().subscribe(([x, err]) => {
if (err.length !== 0) return;
this.values = JSON.parse(JSON.stringify(x['core-stats']));
this.values.bytesHumanReadable = FormatBytes(this.values.bytes, 4);
this.values.speedHumanReadable = FormatBytes(this.values.speed, 4) + '/s';
this.values['transferring-count'] = this.values.transferring
? this.values.transferring.length
: 0;
Expand Down

0 comments on commit 721dd71

Please sign in to comment.