Forked from AlexDoanTB/Hierarchy_widget_configuration
Created
September 24, 2021 14:24
-
-
Save bigdragon1977/436dae05038e0128d39d827b0cc9216c to your computer and use it in GitHub Desktop.
ThingsBoard vidoe tutorials: Examples of configuration of Hierarchy widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Configuration code for HTML widget// | |
<div class='card'> | |
<div class='content'> | |
<div class='column'> | |
<h1>Current entity</h1> | |
<div class='value'> | |
${entityName} | |
</div> | |
</div> | |
</div> | |
</div> | |
//To make your nodes in hierarchy coloured (red)// | |
var entity = nodeCtx.entity; | |
var text = entity.name; | |
var data = nodeCtx.data; | |
if (data.hasOwnProperty('hasAlarm') && data['hasAlarm'] !== null && data['hasAlarm'] === 'true') { | |
text = "<font color=\"red\">" + text + "</font>"; | |
} | |
//To add some text (exclamations for example) to nodes appearance// | |
var entity = nodeCtx.entity; | |
var text = entity.name; | |
var data = nodeCtx.data; | |
if (data.hasOwnProperty('hasAlarm') && data['hasAlarm'] !== null && data['hasAlarm'] === 'true') { | |
text = "<b> !!!</b>"; | |
} | |
//To change icon of particular node. You may choose any pic from MaterialIcons set or input URL to image file// | |
var data = nodeCtx.data; | |
if (data.hasOwnProperty('hasAlarm') && data['hasAlarm'] !== null && data['hasAlarm'] === 'true ') { | |
return {materialIcon: 'settings_remote'}; | |
} else { | |
return 'default'; | |
} | |
//Disabling makes your node inactive in hierarchy// | |
var data = nodeCtx.data; | |
if (data.hasOwnProperty('nodeDisabled') && data['nodeDisabled'] !== null) { | |
return data['nodeDisabled'] === 'true'; | |
} else { | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment