Merge remote-tracking branch 'ui/master'

This commit is contained in:
Zaid Abdulla committed 2018-12-27 22:22:44 -08:00
commit 4530967b6b
70 files changed
+10951 -8

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
"use strict";
import m from "mithril";
import config from "../config";
import * as store from "../store";
import * as expression from "../../lib/common/expression";
import memoize from "../../lib/common/memoize";
const memoizedParse = memoize(expression.parse);
const CHARTS = config.ui.overview.charts;
const component = {
view: vnode => {
const device = vnode.attrs.device;
const chart = CHARTS[vnode.attrs.chart];
for (const slice of Object.values(chart.slices)) {
const filter = memoizedParse(slice.filter);
if (store.evaluateExpression(filter, device)) {
const dot = m(
"svg",
{
width: "1em",
height: "1em",
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink"
},
m("circle", {
cx: "0.5em",
cy: "0.5em",
r: "0.4em",
fill: slice.color
})
);
return m("span.overview-dot", dot, `${slice.label}`);
}
}
return null;
}
};
export default component;