Implement task queue and notifications

This commit is contained in:
Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent 9b827c5f5e
commit b24c3626ac
20 files changed
+1000 -88

No files matched your search

+53 -6
View File
@@ -2,6 +2,7 @@
import m from "mithril";
import * as components from "../components";
import * as taskQueue from "../task-queue";
const component = {
view: vnode => {
@@ -12,14 +13,18 @@ const component = {
if (!device[object]) return null;
const instances = new Set();
const prefix = `${object}.`;
for (let p in device)
if (p.startsWith(object))
instances.add(p.slice(0, p.indexOf(".", object.length + 1)));
if (p.startsWith(prefix)) {
let i = p.indexOf(".", prefix.length);
if (i === -1) instances.add(p);
else instances.add(p.slice(0, i));
}
const headers = Object.values(parameters).map(p => m("th", p.label));
const thead = m("thead", m("tr", headers));
const thead = m(
"thead",
m("tr", Object.values(parameters).map(p => m("th", p.label)))
);
const rows = [];
for (let i of instances) {
const row = Object.values(parameters).map(p =>
@@ -33,8 +38,50 @@ const component = {
)
)
);
if (device[i].writable === true)
row.push(
m(
"td",
m(
"a.delete",
{
onclick: () => {
taskQueue.queueTask({
name: "deleteObject",
device: device["DeviceID.ID"].value[0],
objectName: i
});
}
},
"−"
)
)
);
rows.push(m("tr", row));
}
if (device[object].writable === true)
rows.push(
m(
"tr",
m("td", { colspan: headers.length }),
m(
"td",
m(
"a.add",
{
onclick: () => {
taskQueue.queueTask({
name: "addObject",
device: device["DeviceID.ID"].value[0],
objectName: object
});
}
},
"+"
)
)
)
);
return m("table.parameter-table", thead, m("tbody", rows));
}
};