Update linting
This commit is contained in:
1 parent
4f2dfb4f48
commit
0c9c027a77
112 files changed
+3781
-4125
No files matched your search
@@ -17,24 +17,35 @@
|
||||
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ClosureComponent, Component } from "mithril";
|
||||
import { ClosureComponent } from "mithril";
|
||||
import { m } from "../components";
|
||||
import * as taskQueue from "../task-queue";
|
||||
import { evaluateExpression } from "../store";
|
||||
import { QueryResponse, evaluateExpression } from "../store";
|
||||
import * as expressionParser from "../../lib/common/expression/parser";
|
||||
import { getIcon } from "../icons";
|
||||
import { FlatDevice } from "../../lib/ui/db";
|
||||
import { Expression } from "../../lib/types";
|
||||
|
||||
const component: ClosureComponent = (): Component => {
|
||||
interface Attrs {
|
||||
device: FlatDevice;
|
||||
parameter: Expression;
|
||||
label: Expression;
|
||||
childParameters: Record<string, { label: string; parameter: Expression }>;
|
||||
filter?: Expression;
|
||||
deviceQuery: QueryResponse;
|
||||
}
|
||||
|
||||
const component: ClosureComponent<Attrs> = () => {
|
||||
return {
|
||||
oninit: (vnode) => {
|
||||
const obj = vnode.attrs["parameter"];
|
||||
const obj = vnode.attrs.parameter;
|
||||
if (!Array.isArray(obj) || obj[0] !== "PARAM")
|
||||
throw new Error("Object must be a parameter path");
|
||||
vnode.state["object"] = obj[1];
|
||||
vnode.state["parameters"] = Object.values(vnode.attrs["childParameters"]);
|
||||
vnode.state["parameters"] = Object.values(vnode.attrs.childParameters);
|
||||
},
|
||||
view: (vnode) => {
|
||||
const device = vnode.attrs["device"];
|
||||
const device = vnode.attrs.device;
|
||||
const object = evaluateExpression(vnode.state["object"], device);
|
||||
const parameters = vnode.state["parameters"];
|
||||
|
||||
@@ -56,7 +67,7 @@ const component: ClosureComponent = (): Component => {
|
||||
|
||||
const rows = [];
|
||||
for (const i of instances) {
|
||||
let filter = "filter" in vnode.attrs ? vnode.attrs["filter"] : true;
|
||||
let filter = "filter" in vnode.attrs ? vnode.attrs.filter : true;
|
||||
|
||||
filter = expressionParser.map(filter, (e) => {
|
||||
if (Array.isArray(e) && e[0] === "PARAM")
|
||||
@@ -84,8 +95,8 @@ const component: ClosureComponent = (): Component => {
|
||||
device: device,
|
||||
parameter: param,
|
||||
label: null,
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -100,14 +111,14 @@ const component: ClosureComponent = (): Component => {
|
||||
onclick: () => {
|
||||
taskQueue.queueTask({
|
||||
name: "deleteObject",
|
||||
device: device["DeviceID.ID"].value[0],
|
||||
device: device["DeviceID.ID"].value[0] as string,
|
||||
objectName: i,
|
||||
});
|
||||
},
|
||||
},
|
||||
getIcon("delete-instance")
|
||||
)
|
||||
)
|
||||
getIcon("delete-instance"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
rows.push(m("tr", row));
|
||||
@@ -115,7 +126,7 @@ const component: ClosureComponent = (): Component => {
|
||||
|
||||
if (!rows.length) {
|
||||
rows.push(
|
||||
m("tr.empty", m("td", { colspan: headers.length }, "No instances"))
|
||||
m("tr.empty", m("td", { colspan: headers.length }, "No instances")),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,29 +144,29 @@ const component: ClosureComponent = (): Component => {
|
||||
onclick: () => {
|
||||
taskQueue.queueTask({
|
||||
name: "addObject",
|
||||
device: device["DeviceID.ID"].value[0],
|
||||
device: device["DeviceID.ID"].value[0] as string,
|
||||
objectName: object,
|
||||
});
|
||||
},
|
||||
},
|
||||
getIcon("add-instance")
|
||||
)
|
||||
)
|
||||
)
|
||||
getIcon("add-instance"),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
let label;
|
||||
|
||||
const l = evaluateExpression(vnode.attrs["label"], device);
|
||||
const l = evaluateExpression(vnode.attrs.label, device);
|
||||
if (l != null) label = m("h2", l);
|
||||
|
||||
return [
|
||||
label,
|
||||
m(
|
||||
"loading",
|
||||
{ queries: [vnode.attrs["deviceQuery"]] },
|
||||
m("table.table", thead, m("tbody", rows))
|
||||
{ queries: [vnode.attrs.deviceQuery] },
|
||||
m("table.table", thead, m("tbody", rows)),
|
||||
),
|
||||
];
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user