Make serial in device list into a link
This commit is contained in:
1 parent
ed3b7b57c3
commit
dc822cab9b
3 files changed
+38
-1
No files matched your search
@@ -11,6 +11,7 @@ import allParameters from "./components/all-parameters";
|
|||||||
import deviceActions from "./components/device-actions";
|
import deviceActions from "./components/device-actions";
|
||||||
import tags from "./components/tags";
|
import tags from "./components/tags";
|
||||||
import ping from "./components/ping";
|
import ping from "./components/ping";
|
||||||
|
import deviceLink from "./components/device-link";
|
||||||
|
|
||||||
function get(name) {
|
function get(name) {
|
||||||
if (name === "parameter") return parameter;
|
if (name === "parameter") return parameter;
|
||||||
@@ -24,6 +25,7 @@ function get(name) {
|
|||||||
else if (name === "device-actions") return deviceActions;
|
else if (name === "device-actions") return deviceActions;
|
||||||
else if (name === "tags") return tags;
|
else if (name === "tags") return tags;
|
||||||
else if (name === "ping") return ping;
|
else if (name === "ping") return ping;
|
||||||
|
else if (name === "device-link") return deviceLink;
|
||||||
else throw new Error(`No such component '${name}'`);
|
else throw new Error(`No such component '${name}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
import m from "mithril";
|
||||||
|
import * as components from "../components";
|
||||||
|
|
||||||
|
const component = {
|
||||||
|
view: vnode => {
|
||||||
|
let deviceId;
|
||||||
|
if (vnode.attrs.device)
|
||||||
|
deviceId = vnode.attrs.device["DeviceID.ID"].value[0];
|
||||||
|
|
||||||
|
const children = Object.values(vnode.attrs.components).map(c => {
|
||||||
|
if (typeof c !== "object") return `${c}`;
|
||||||
|
const attrs = Object.assign({}, vnode.attrs, c);
|
||||||
|
return m(components.get(attrs.type), attrs);
|
||||||
|
});
|
||||||
|
if (deviceId) {
|
||||||
|
return m(
|
||||||
|
"a",
|
||||||
|
{ href: `#!/devices/${encodeURIComponent(deviceId)}` },
|
||||||
|
children
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default component;
|
||||||
+7
-1
@@ -107,7 +107,13 @@
|
|||||||
"index": [
|
"index": [
|
||||||
{
|
{
|
||||||
"label": "Serial number",
|
"label": "Serial number",
|
||||||
"parameter": "DeviceID.SerialNumber"
|
"parameter": "DeviceID.SerialNumber",
|
||||||
|
"type": "device-link",
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"type": "parameter"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Product class",
|
"label": "Product class",
|
||||||
|
|||||||
Reference in new issue
Block a user