diff --git a/client/source/scripts/util/formatData.js b/client/source/scripts/util/formatData.js
index 5431e9b2..ca7a8666 100644
--- a/client/source/scripts/util/formatData.js
+++ b/client/source/scripts/util/formatData.js
@@ -1,7 +1,75 @@
+import React from 'react';
+
const format = {
- data: function(bytes, extraUnits, precision) {
+ eta: function(eta) {
+ if (eta === 'Infinity') {
+ return '∞';
+ } else if (eta.years > 0) {
+ return (
+
+
+ {eta.years}yr
+
+
+ {eta.weeks}wk
+
+
+ );
+ } else if (eta.weeks > 0) {
+ return (
+
+
+ {eta.weeks}wk
+
+
+ {eta.days}d
+
+
+ );
+ } else if (eta.days > 0) {
+ return (
+
+
+ {eta.days}d
+
+
+ {eta.hours}hr
+
+
+ );
+ } else if (eta.hours > 0) {
+ return (
+
+
+ {eta.hours}hr
+
+
+ {eta.minutes}m
+
+
+ );
+ } else if (eta.minutes > 0) {
+ return (
+
+
+ {eta.minutes}m
+
+
+ {eta.seconds}s
+
+
+ );
+ } else {
+ return (
+
+ {eta.seconds}s
+
+ );
+ }
+ },
+ data: function(bytes, extraUnits, precision) {
precision = precision || 2;
let kilobyte = 1024,
@@ -36,10 +104,22 @@ const format = {
}
return {
- 'value': value,
- 'unit': unit
+ value,
+ unit
};
+ },
+ ratio: function(ratio) {
+ ratio = ratio / 1000;
+ let precision = 1;
+
+ if (ratio < 10) {
+ precision = 2;
+ } else if (ratio < 100) {
+ precision = 0;
+ }
+
+ return ratio.toFixed(precision);
}
};