Skip to content

Commit

Permalink
fix(core-stats-flow): some properties is option
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonH committed Jun 2, 2020
1 parent 8af6baf commit a81284b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/app/@dataflow/rclone/core-stats-flow.ts
Expand Up @@ -10,14 +10,14 @@ export interface CoreStatsFlowParamsNode {
export interface CoreStatsFlowInNode extends CoreStatsFlowParamsNode, IRcloneServer {}

export interface ITransferring {
bytes: number;
eta: number;
group: string;
bytes?: number;
eta?: number;
group?: string;
name: string;
percentage: number;
percentage?: number;
size: number;
speed: number;
speedAvg: number;
speed?: number;
speedAvg?: number;
}

export interface CoreStatsFlowOutItemNode {
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/speed-chart/speed-chart.component.ts
Expand Up @@ -188,8 +188,10 @@ export class RngSpeedChartComponent implements OnInit {
let speed = 0;
let avg = 0;
if (node[0]['core-stats'].transferring) {
node[0]['core-stats'].transferring.forEach(x => (avg += x.speedAvg));
node[0]['core-stats'].transferring.forEach(x => (speed += x.speed));
node[0]['core-stats'].transferring.forEach(x => {
if (x.speed) speed += x.speed;
if (x.speedAvg) avg += x.speedAvg;
});
}
const speedData = this.lineChartData[0].data as ChartPoint[];
const avgData = this.lineChartData[1].data as ChartPoint[];
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/summary/summary.component.ts
Expand Up @@ -61,7 +61,9 @@ export class RngSummaryComponent implements OnInit {
if (err.length !== 0) return;
let speed = 0;
if (this.values.transferring) {
this.values.transferring.forEach(y => (speed += y.speed));
this.values.transferring.forEach(y => {
if (y.speed) speed += y.speed;
});
}
this.values = JSON.parse(JSON.stringify(x['core-stats']));
this.values.bytesHumanReadable = FormatBytes(this.values.bytes, 4);
Expand Down

0 comments on commit a81284b

Please sign in to comment.