Skip to content

Commit

Permalink
fix PR #2864
Browse files Browse the repository at this point in the history
  • Loading branch information
zoic21 authored Aug 30, 2024
1 parent 90c4d60 commit 82aecd2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
40 changes: 40 additions & 0 deletions core/template/dashboard/cmd.info.string.badge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<div class="cmd cmd-widget #history#" data-type="info" data-subtype="string" data-template="badge" data-cmd_id="#id#" data-cmd_uid="#uid#" data-version="#version#" data-eqLogic_id="#eqLogic_id#">
<div class="title #hide_name#">
<div class="cmdName">#name_display#</div>
</div>
<div class="content">
<div class="label label-info state"><span class="value"></span></div>
</div>
<div class="timeCmd label label-default #history#" data-type="info"></div>
<template>
<div>color : rgb(20,20,20) ({{Couleur de fond}})</div>
<div>fontcolor : rgb(20,20,20) ({{Couleur du texte}})</div>
<div>time : duration|date ({{Affiche durée ou date de la valeur}})</div>
</template>
<script>
jeedom.cmd.addUpdateFunction('#id#', function(_options) {
if (is_object(cmd = document.querySelector('.cmd[data-cmd_uid="#uid#"]'))) {
cmd.querySelector('.content').setAttribute('title', '{{Date de valeur}}: ' + _options.valueDate + '<br>{{Date de collecte}}: ' + _options.collectDate)
if ('#time#' == 'duration' || '#time#' == 'date') {
jeedom.cmd.displayDuration(_options.valueDate, cmd.querySelector('.timeCmd'), '#time#')
}
cmd.querySelector('.value').innerHTML = _options.display_value
if (_options.alertLevel == 'warning') {
cmd.querySelector('.value').innerHTML = '<span class="label label-warning"><i class="fas fa-bell"></i> ' + _options.value + '</span>'
} else if (_options.alertLevel == 'danger') {
cmd.querySelector('.value').innerHTML = '<span class="label label-danger"><i class="fas fa-exclamation"></i> ' + _options.value + '</span>'
}
}
})

jeedom.cmd.refreshValue([{ cmd_id: '#id#', value: '#value#', display_value: '#state#', valueDate: '#valueDate#', collectDate: '#collectDate#', alertLevel: '#alertLevel#', unit: '#unite#' }])

if (domUtils.issetWidgetOptParam('#color#', 'color')) {
document.querySelector('.cmd[data-cmd_uid="#uid#"] .label').style.setProperty('background-color', '#color#', 'important')
}
if (domUtils.issetWidgetOptParam('#fontcolor#', 'fontcolor')) {
document.querySelector('.cmd[data-cmd_uid="#uid#"] .label').style.setProperty('color', '#fontcolor#', 'important')
}
</script>
</div>

8 changes: 8 additions & 0 deletions core/template/mobile/cmd.info.string.badge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span class="cmd cmd-widget" data-type="info" data-subtype="string" data-template="badge" data-version="#version#" data-eqLogic_id="#eqLogic_id#" data-cmd_id="#id#" data-cmd_uid="#uid#">
<span class='ui-bar ui-bar-a state label-info'>#state#</span>
<script>
jeedom.cmd.addUpdateFunction('#id#',function(_options) {
$('.cmd[data-cmd_id=#id#] .state').empty().append(_options.display_value)
});
</script>
</span>

0 comments on commit 82aecd2

Please sign in to comment.