Generalize store quering functions

This commit is contained in:
Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent 93c6a4dfcd
commit 9b827c5f5e
26 files changed
+1362 -321

No files matched your search

+5 -5
View File
@@ -5,7 +5,7 @@ import m from "mithril";
const drawChart = function(chartData) {
let slices = chartData.slices;
let total = Array.from(Object.values(chartData.slices)).reduce(
(a, s) => a + s.count,
(a, s) => a + (s.count.value || 0),
0
);
let legend = [];
@@ -17,7 +17,7 @@ const drawChart = function(chartData) {
let endX, endY;
for (let slice of Object.values(slices)) {
let percent = total > 0 ? slice.count / total : 0;
let percent = total > 0 ? (slice.count.value || 0) / total : 0;
legend.push(
m(".legend-line", [
m("span.color", {
@@ -28,10 +28,10 @@ const drawChart = function(chartData) {
"a",
{
href: `/#!/devices/?${m.buildQueryString({
filter: slice.filter
filter: slice.filter.toString()
})}`
},
slice.count
slice.count.value || 0
),
` (${(percent * 100).toFixed(2)}%)`
])
@@ -68,7 +68,7 @@ const drawChart = function(chartData) {
"a",
{
href: `/#!/devices/?${m.buildQueryString({
filter: slice.filter
filter: slice.filter.toString()
})}`
},
[