Files
genieacs/client/components/overview-dot.js
T
Zaid Abdulla c2d13e8364 Replace Filter class with expression structure
This is in order to be able to support UPPER() and LOWER() functions in
queries which are needed for case-insensitive search.
2018-12-26 00:22:07 -08:00

40 lines
1.0 KiB
JavaScript

"use strict";
import m from "mithril";
import config from "../config";
import * as store from "../store";
import * as funcCache from "../../common/func-cache";
import * as expression from "../../common/expression";
const CHARTS = config.ui.overview.charts;
const component = {
view: vnode => {
const device = vnode.attrs.device;
const chart = CHARTS[vnode.attrs.chart];
for (let slice of Object.values(chart.slices)) {
const filter = funcCache.get(expression.parse, 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}`);
}
}
}
};
export default component;