Support for a textual state description
This commit is contained in:
parent
9967a651b5
commit
55c45d2139
1 changed files with 16 additions and 3 deletions
|
@ -4,6 +4,9 @@ const Component = withComponent();
|
||||||
class CurrentState extends Component {
|
class CurrentState extends Component {
|
||||||
static props = {
|
static props = {
|
||||||
timeseries: props.string,
|
timeseries: props.string,
|
||||||
|
trueword: props.string,
|
||||||
|
falseword: props.string,
|
||||||
|
unknownword: props.string,
|
||||||
status: props.boolean,
|
status: props.boolean,
|
||||||
statusknown: props.boolean,
|
statusknown: props.boolean,
|
||||||
interval: props.number,
|
interval: props.number,
|
||||||
|
@ -52,21 +55,31 @@ class CurrentState extends Component {
|
||||||
root.appendChild(render());
|
root.appendChild(render());
|
||||||
}
|
}
|
||||||
|
|
||||||
render({ status, statusknown }) {
|
render({ status, statusknown, trueword, falseword, unknownword }) {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.style.width = '100%';
|
el.style.width = '100%';
|
||||||
el.style.height = '100%';
|
el.style.height = '100%';
|
||||||
|
let content = '<slot></slot>';
|
||||||
if (!statusknown) {
|
if (!statusknown) {
|
||||||
el.style.backgroundColor = '#555753';
|
el.style.backgroundColor = '#555753';
|
||||||
el.innerHTML = '<slot></slot>';
|
if (unknownword) {
|
||||||
|
content = `${content} ${unknownword}`;
|
||||||
|
}
|
||||||
|
el.innerHTML = content;
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
el.style.backgroundColor = '#73d216';
|
el.style.backgroundColor = '#73d216';
|
||||||
|
if (trueword) {
|
||||||
|
content = `${content} ${trueword}`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
el.style.backgroundColor = '#cc0000';
|
el.style.backgroundColor = '#cc0000';
|
||||||
|
if (falseword) {
|
||||||
|
content = `${content} ${falseword}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
el.innerHTML = '<slot></slot>';
|
el.innerHTML = content;
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue