Skip to content

Commit

Permalink
Merge pull request openshift#1277 from jwforres/bug_1200346_include_m…
Browse files Browse the repository at this point in the history
…ultiplier_in_quota_comp

Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Mar 11, 2015
2 parents 84159e6 + ed44739 commit bd16bec
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 3 deletions.
49 changes: 47 additions & 2 deletions assets/app/scripts/filters/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,56 @@ angular.module('openshiftConsole')
}
var number = split[1];
if (number.indexOf(".") >= 0) {
return parseFloat(number);
var number = parseFloat(number);
}
else {
return parseInt(split[1]);
var number = parseInt(split[1]);
}
var siSuffix = split[2];
var multiplier = 1;
switch(siSuffix) {
case 'E':
multiplier = Math.pow(1000, 6);
break;
case 'P':
multiplier = Math.pow(1000, 5);
break;
case 'T':
multiplier = Math.pow(1000, 4);
break;
case 'G':
multiplier = Math.pow(1000, 3);
break;
case 'M':
multiplier = Math.pow(1000, 2);
break;
case 'K':
multiplier = 1000;
break;
case 'm':
multiplier = 0.001;
break;
case 'Ei':
multiplier = Math.pow(1024, 6);
break;
case 'Pi':
multiplier = Math.pow(1024, 5);
break;
case 'Ti':
multiplier = Math.pow(1024, 4);
break;
case 'Gi':
multiplier = Math.pow(1024, 3);
break;
case 'Mi':
multiplier = Math.pow(1024, 2);
break;
case 'Ki':
multiplier = 1024;
break;
}

return number * multiplier;
};
})
.filter('usageWithUnits', function() {
Expand Down
56 changes: 55 additions & 1 deletion pkg/assets/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -14791,7 +14791,61 @@ if (!a) return a;
var b = /(-?[0-9\.]+)\s*(.*)/.exec(a);
if (!b) return a;
var c = b[1];
return c.indexOf(".") >= 0 ? parseFloat(c) :parseInt(b[1]);
if (c.indexOf(".") >= 0) var c = parseFloat(c); else var c = parseInt(b[1]);
var d = b[2], e = 1;
switch (d) {
case "E":
e = Math.pow(1e3, 6);
break;

case "P":
e = Math.pow(1e3, 5);
break;

case "T":
e = Math.pow(1e3, 4);
break;

case "G":
e = Math.pow(1e3, 3);
break;

case "M":
e = Math.pow(1e3, 2);
break;

case "K":
e = 1e3;
break;

case "m":
e = .001;
break;

case "Ei":
e = Math.pow(1024, 6);
break;

case "Pi":
e = Math.pow(1024, 5);
break;

case "Ti":
e = Math.pow(1024, 4);
break;

case "Gi":
e = Math.pow(1024, 3);
break;

case "Mi":
e = Math.pow(1024, 2);
break;

case "Ki":
e = 1024;
}
return c * e;
};
}).filter("usageWithUnits", function() {
return function(a, b) {
Expand Down

0 comments on commit bd16bec

Please sign in to comment.