refactoring

This commit is contained in:
Christian Lohmann
2016-12-20 18:52:24 +01:00
parent ece99f0d83
commit 26b7bbf7ee
3 changed files with 52 additions and 115 deletions

View File

@@ -2,23 +2,6 @@ import Pod from "./pod.js";
import Bars from './bars.js'
const PIXI = require('pixi.js');
// see https://github.com/kubernetes/kubernetes/blob/master/docs/design/resources.md
const FACTORS = {
'm': 1 / 1000,
'K': 1000,
'M': Math.pow(1000, 2),
'G': Math.pow(1000, 3),
'T': Math.pow(1000, 4),
'P': Math.pow(1000, 5),
'E': Math.pow(1000, 6),
'Ki': 1024,
'Mi': Math.pow(1024, 2),
'Gi': Math.pow(1024, 3),
'Ti': Math.pow(1024, 4),
'Pi': Math.pow(1024, 5),
'Ei': Math.pow(1024, 6)
};
export default class Node extends PIXI.Graphics {
constructor(node, tooltip) {
super();
@@ -36,52 +19,6 @@ export default class Node extends PIXI.Graphics {
return parseInt(match[1]) * factor
}
hsvToRgb(h, s, v) {
let r, g, b, i, f, p, q, t;
i = Math.floor(h * 6);
f = h * 6 - i;
p = v * (1 - s);
q = v * (1 - f * s);
t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0:
r = v;
g = t;
b = p;
break;
case 1:
r = q;
g = v;
b = p;
break;
case 2:
r = p;
g = v;
b = t;
break;
case 3:
r = p;
g = q;
b = v;
break;
case 4:
r = t;
g = p;
b = v;
break;
case 5:
r = v;
g = p;
b = q;
break;
}
return PIXI.utils.rgb2hex([r, g, b])
}
getBarColor(usage, capacity) {
return this.hsvToRgb(0.4 - (0.4 * (usage / capacity)), 0.6, 1)
}
getResourceUsage() {
const resources = {};
for (var key of Object.keys(this.node.status.capacity)) {