Modify retrieveValues array order to fix issue #62

This commit is contained in:
wez3 2017-01-09 21:23:37 +01:00
parent d7f0520bf1
commit be717b3559
16 changed files with 82 additions and 81 deletions

View File

@ -62,13 +62,14 @@ def retrieveValue(page, component):
match = re.search("^(.+)\[(.+)\]$", component)
if not match:
for k, v in config[page][component].iteritems():
v = strToList(v)
dict[k] = v
l = [None]
l.extend(strToList(v))
dict[k] = l
else:
for sk, sv in config[page][match.group(1)][match.group(2)].iteritems():
sv = strToList(sv)
sv.append(match.group(2))
dict[sk] = sv
l = [match.group(2)]
l.extend(strToList(sv))
dict[sk] = l
except:
dict = {}
return dict

View File

@ -27,9 +27,9 @@ var area_chart_block_{{count}} = Morris.Area({
$(document).ready(function() {
{% for k, v in blockArray[count]["area_charts"].iteritems() %}
redrawAreaChart("{{v[2]}}",{{v[0]}},"{{v[1]}}", area_chart_block_{{count}});
redrawAreaChart("{{v[3]}}",{{v[1]}},"{{v[2]}}", area_chart_block_{{count}});
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(redrawAreaChart,9000,"{{v[2]}}",{{v[0]}},"{{v[1]}}", area_chart_block_{{count}});
setInterval(redrawAreaChart,9000,"{{v[3]}}",{{v[1]}},"{{v[2]}}", area_chart_block_{{count}});
});
{% endfor %}
</script>

View File

@ -22,7 +22,7 @@ $(document).ready(function() {
var barChartElementsNames=[];
{% for k, v in blockArray[count]["bar_charts"].iteritems() %}
barChartElements.push("{{v[0]}}");
barChartElements.push("{{v[1]}}");
barChartElementsNames.push("{{k}}");
{% endfor %}
var bar_chart_block_{{count}} = Morris.Bar({

View File

@ -12,7 +12,7 @@
<br>
{% for k, v in blockArray[count]["camera"].iteritems() %}
{% if v[1] %}
<script> $('#s_title_{{ count }}').html("{{ v[1] }}");</script>
<script> $('#s_title_{{ count }}').html("{{ v[0] }}");</script>
{% endif %}
<form class="form-horizontal form-label-left" style="width: 80%; height: 80%; ">
<div class="form-group" style="">

View File

@ -17,9 +17,9 @@
$(document).ready(function() {
{% for k, v in blockArray[count]["domoticz_counter_charts"].iteritems() %}
ShowGeneralGraph("domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", 1, "{{v[2]}}", "{{v[1]}}");
ShowGeneralGraph("domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", 1, "{{v[3]}}", "{{v[2]}}");
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(ShowGeneralGraph,60000,"domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", 1, "{{v[2]}}", "{{v[1]}}");
setInterval(ShowGeneralGraph,60000,"domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", 1, "{{v[3]}}", "{{v[2]}}");
{% endfor %}
});
</script>

View File

@ -17,9 +17,9 @@
$(document).ready(function() {
{% for k, v in blockArray[count]["domoticz_percentage_charts"].iteritems() %}
ShowPercentageLog("domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[1]}}");
ShowPercentageLog("domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[2]}}");
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(ShowPercentageLog,60000,"domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[1]}}");
setInterval(ShowPercentageLog,60000,"domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[2]}}");
{% endfor %}
});
</script>

View File

@ -17,9 +17,9 @@
$(document).ready(function() {
{% for k, v in blockArray[count]["domoticz_smart_charts"].iteritems() %}
ShowSmartLog("domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[2]}}", "{{v[1]}}");
ShowSmartLog("domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[3]}}", "{{v[2]}}");
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(ShowSmartLog,60000,"domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[2]}}", "{{v[1]}}");
setInterval(ShowSmartLog,60000,"domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[3]}}", "{{v[2]}}");
{% endfor %}
});
</script>

View File

@ -17,9 +17,9 @@
$(document).ready(function() {
{% for k, v in blockArray[count]["domoticz_temp_charts"].iteritems() %}
ShowTempLog("domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[1]}}");
ShowTempLog("domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[2]}}");
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(ShowGeneralGraph,60000,"domoticz-chart-block-{{count}}",{{v[0]}},"{{k}}", "{{v[1]}}");
setInterval(ShowGeneralGraph,60000,"domoticz-chart-block-{{count}}",{{v[1]}},"{{k}}", "{{v[2]}}");
{% endfor %}
});
</script>

View File

@ -22,7 +22,7 @@ var donut_chart_block_{{count}} = Morris.Donut({
$(document).ready(function() {
var donutChartElements=[];
{% for k, v in blockArray[count]["donut_charts"].iteritems() %}
donutChartElements.push("{{v[0]}}");
donutChartElements.push("{{v[1]}}");
{% endfor %}
redrawDonutChart(donutChartElements, donut_chart_block_{{count}});
setInterval(redrawDonutChart,9000,donutChartElements, donut_chart_block_{{count}});

View File

@ -27,9 +27,9 @@ var line_chart_block_{{count}} = Morris.Line({
$(document).ready(function() {
{% for k, v in blockArray[count]["line_charts"].iteritems() %}
redrawLineChart("{{v[2]}}",{{v[0]}},"{{v[1]}}", line_chart_block_{{count}});
redrawLineChart("{{v[3]}}",{{v[1]}},"{{v[2]}}", line_chart_block_{{count}});
$("div#title_block_{{count}} h2").html("{{k}}");
setInterval(redrawLineChart,9000,"{{v[2]}}",{{v[0]}},"{{v[1]}}",line_chart_block_{{count}});
setInterval(redrawLineChart,9000,"{{v[3]}}",{{v[1]}},"{{v[2]}}",line_chart_block_{{count}});
});
{% endfor %}
</script>

View File

@ -21,10 +21,10 @@
$(document).ready(function() {
var location=[];
{% for k, v in blockArray[count]["map"].iteritems() %}
{% if v[1] %}
$('#s_title_{{ count }}').html("{{ v[1] }}");
{% if v[0] %}
$('#s_title_{{ count }}').html("{{ v[0] }}");
{% endif %}
location.push("{{v[0]}}");
location.push("{{v[1]}}");
{% endfor %}
refreshMapLocation(location, "locationIframe-{{count}}");
setInterval(refreshMapLocation, 60000, location, "locationIframe-{{count}}");

View File

@ -20,10 +20,10 @@
<div class="menu_section">
<ul class="nav side-menu">
{% for k, v in configValues["navbar"].iteritems() %}
{% if v is not string %}
{% if v|length > 1 %}
<li><a href="{{v[0]}}"> <i class="fa fa-{{v[1]}} fa-fw" aria-hidden="true"></i> {{k}}</a></li>
{% else %}
<li><a href="{{v}}">{{k}}</a></li>
<li><a href="{{v[0]}}">{{k}}</a></li>
{% endif %}
{% endfor %}
</ul>

View File

@ -14,8 +14,8 @@
<script>
$(document).ready(function() {
{% for k, v in blockArray[count]["news"].iteritems() %}
{% if v[1] %}
$('#s_title_{{ count }}').html("{{ v[1] }}");
{% if v[0] %}
$('#s_title_{{ count }}').html("{{ v[0] }}");
{% endif %}
{% endfor %}
});

View File

@ -22,7 +22,7 @@
{% for k, v in blockArray[count]["power_usage"].iteritems() %}
<tr>
<td>{{k}}</td>
<td id="power_usage_{{v[0]}}_{{count}}">{{v[1]}}</td>
<td id="power_usage_{{v[1]}}_{{count}}">{{v[2]}}</td>
</tr>
{% endfor %}
<tr>
@ -39,7 +39,7 @@
$(document).ready(function() {
var updatePowerUsage_{{count}}=[];
{% for k, v in blockArray[count]["power_usage"].iteritems() %}
updatePowerUsage_{{count}}.push("{{v[0]}}");
updatePowerUsage_{{count}}.push("{{v[1]}}");
{% endfor %}
refreshPowerUsage(updatePowerUsage_{{count}}, "{{count}}");
setInterval(refreshPowerUsage, 9000, updatePowerUsage_{{count}}, "{{count}}");

View File

@ -17,38 +17,38 @@
<table class="table" style="width: auto;">
{% for k, v in blockArray[count]["switches"].iteritems() %}
<tr>
{% if "dimmer" in v[1] or "rgb" in v[1] %}
{% if "dimmer" in v[2] or "rgb" in v[2] %}
<td style="border-top: none; vertical-align: middle;"><a id="dim_{{count}}" style="cursor: pointer;"><label style="cursor: pointer;" class=""> &nbsp;{{k}}</label></a></td>
{% else %}
<td style="border-top: none; vertical-align: middle;"><label class=""> &nbsp;{{k}}</label></td>
{% endif %}
<td style="border-top: none;">
{% if "switch" in v[1] %}
<input id="switch_{{v[0]}}_block_{{count}}" type="checkbox" checked data-size="mini">
{% elif "dimmer" in v[1] %}
<input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dim_{{v[0]}}_block_{{count}}' type="text" test={{ v[1] }} state="on" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
{% elif "pushon" in v[1] %}
<button id="push_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "pushoff" in v[1] %}
<button id="push_{{v[0]}}_block_{{count}}" class="btn btn-danger btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "group" in v[1] %}
<div><div style="float: left"><button id="groupon_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div><div style="padding-left: 20px; float: left"><button id="groupoff_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle btn-danger">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div></div>
{% elif "scene" in v[1] %}
<button id="scene_{{v[0]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "setpoint" in v[1] %}
{% if "switch" in v[2] %}
<input id="switch_{{v[1]}}_block_{{count}}" type="checkbox" checked data-size="mini">
{% elif "dimmer" in v[2] %}
<input id="dimmer_{{v[1]}}_block_{{count}}" data-slider-id='dim_{{v[1]}}_block_{{count}}' type="text" test={{ v[2] }} state="on" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
{% elif "pushon" in v[2] %}
<button id="push_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "pushoff" in v[2] %}
<button id="push_{{v[1]}}_block_{{count}}" class="btn btn-danger btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "group" in v[2] %}
<div><div style="float: left"><button id="groupon_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div><div style="padding-left: 20px; float: left"><button id="groupoff_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle btn-danger">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button></div></div>
{% elif "scene" in v[2] %}
<button id="scene_{{v[1]}}_block_{{count}}" class="btn btn-primary btn-circle">&nbsp;<li class="fa fa-power-off" aria-hidden="true"></i>&nbsp;</button>
{% elif "setpoint" in v[2] %}
<div>
<div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[0]}}_block_{{count}}" style="font-size: 16px;"></h1></div>
<div style="float: left; margin-right: 5px"><h1 id="setpoint_{{v[1]}}_block_{{count}}" style="font-size: 16px;"></h1></div>
<div style="float: left">
<div style=""><i onclick="changeUp({{ v[0] }}, {{count}})" class="fa fa-arrow-up" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
<div style=""><i onclick="changeDown({{ v[0] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
<div style=""><i onclick="changeUp({{ v[1] }}, {{count}})" class="fa fa-arrow-up" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
<div style=""><i onclick="changeDown({{ v[1] }}, {{count}})" class="fa fa-arrow-down" style="font-size: 13px; cursor: pointer;" aria-hidden="true"></i></div>
</div>
</div>
{% elif "rgb" in v[1] %}
&nbsp;<input id="dimmer_{{v[0]}}_block_{{count}}" data-slider-id='dim_{{v[0]}}_block_{{count}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
{% elif "rgb" in v[2] %}
&nbsp;<input id="dimmer_{{v[1]}}_block_{{count}}" data-slider-id='dim_{{v[1]}}_block_{{count}}' type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="14" />
<br><br>
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal-{{v[0]}}-block-{{count}}">RGB colors</button>
<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal-{{v[1]}}-block-{{count}}">RGB colors</button>
<!-- Modal -->
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="myModal-{{v[0]}}-block-{{count}}">
<div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="myModal-{{v[1]}}-block-{{count}}">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
@ -58,7 +58,7 @@
<h4 class="modal-title">RGB Selector</h4>
</div>
<div class="modal-body">
<div id="rgb_{{v[0]}}_block_{{count}}" class="inl-bl"></div>
<div id="rgb_{{v[1]}}_block_{{count}}" class="inl-bl"></div>
<style>
.inl-bl {
display: inline-block;
@ -66,7 +66,7 @@
</style>
<script>
$(function() {
$('#rgb_{{v[0]}}_block_{{count}}').colorpicker({
$('#rgb_{{v[1]}}_block_{{count}}').colorpicker({
color: '#ffaa00',
container: true,
inline: true
@ -75,7 +75,7 @@
</script>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="changeRgbColor('rgb_{{v[0]}}_block_{{count}}')">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="changeRgbColor('rgb_{{v[1]}}_block_{{count}}')">Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
@ -98,45 +98,45 @@ $(document).ready(function() {
{% for k, v in blockArray[count]["switches"].iteritems() %}
{% if v[2] %}
$('#s_title_{{ count }}').html("{{ v[2] }}");
{% if v[0] %}
$('#s_title_{{ count }}').html("{{ v[0] }}");
{% endif %}
{% if v[1] == "switch" %}
$('input[id="switch_{{v[0]}}_block_{{count}}"]').on('switchChange.bootstrapSwitch', function(event, state) {
changeSwitch(this, {{v[0]}});
{% if v[2] == "switch" %}
$('input[id="switch_{{v[1]}}_block_{{count}}"]').on('switchChange.bootstrapSwitch', function(event, state) {
changeSwitch(this, {{v[1]}});
});
updateSwitches_block_{{count}}.push("{{v[0]}}");
{% elif (v[1] == "pushon") %}
$('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) {
updateSwitches_block_{{count}}.push("{{v[1]}}");
{% elif (v[2] == "pushon") %}
$('button[id="push_{{v[1]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changePush({{v[0]}}, 'on');
changePush({{v[1]}}, 'on');
});
{% elif (v[1] == "pushoff") %}
$('button[id="push_{{v[0]}}_block_{{count}}"]').click(function(e) {
{% elif (v[2] == "pushoff") %}
$('button[id="push_{{v[1]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changePush({{v[0]}}, 'off');
changePush({{v[1]}}, 'off');
});
{% elif (v[1] == "group") or (v[1] == "scene") %}
$('button[id="groupon_{{v[0]}}_block_{{count}}"]').click(function(e) {
{% elif (v[2] == "group") or (v[2] == "scene") %}
$('button[id="groupon_{{v[1]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'on');
changeScene({{v[1]}}, 'on');
});
$('button[id="groupoff_{{v[0]}}_block_{{count}}"]').click(function(e) {
$('button[id="groupoff_{{v[1]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'off');
changeScene({{v[1]}}, 'off');
});
$('button[id="scene_{{v[0]}}_block_{{count}}"]').click(function(e) {
$('button[id="scene_{{v[1]}}_block_{{count}}"]').click(function(e) {
e.preventDefault();
changeScene({{v[0]}}, 'on');
changeScene({{v[1]}}, 'on');
});
{% elif (v[1] == "setpoint") %}
updateSetpoints_block_{{count}}.push("{{v[0]}}");
{% elif (v[1] == "dimmer" or v[1] == "rgb") %}
{% elif (v[2] == "setpoint") %}
updateSetpoints_block_{{count}}.push("{{v[1]}}");
{% elif (v[2] == "dimmer" or v[2] == "rgb") %}
$('#dim_{{count}}').click(function(e) {
e.preventDefault();
changeDimmer('dim_{{v[0]}}_block_{{count}}_track', {{v[0]}});
changeDimmer('dim_{{v[1]}}_block_{{count}}_track', {{v[1]}});
});
updateDimmers_block_{{count}}.push("{{v[0]}}");
updateDimmers_block_{{count}}.push("{{v[1]}}");
{% endif %}
{% endfor %}
refreshSwitches(updateSwitches_block_{{count}}, {{count}});

View File

@ -5,7 +5,7 @@
<div class="left"></div>
<div class="right">
<span class="count_top"><i class="fa fa-{{v[1]}}"></i> {{k}}</span>
<div class="count{% if v[2] == "On" %} green{% elif v[2] == "Off" %} red{% endif %} loading" id="top_tiles_block_{{count}}_{{v[0]}}" style="white-space: nowrap;"></div>
<div class="count{% if v[2] == "On" %} green{% elif v[2] == "Off" %} red{% endif %} loading" id="top_tiles_block_{{count}}_{{v[1]}}" style="white-space: nowrap;"></div>
</div>
</div>
{% endfor %}
@ -16,9 +16,9 @@ $(document).ready(function() {
var tilesPreviousArray_{{count}}=[];
var updateDivsType_block_{{count}} = [];
{% for k, v in blockArray[count]["top_tiles"].iteritems() %}
updateDivs_block_{{count}}.push("{{v[0]}}");
{% if v[2]|length > 3 %}
updateDivsType_block_{{count}}.push("{{v[2]}}");
updateDivs_block_{{count}}.push("{{v[1]}}");
{% if v[3]|length > 3 %}
updateDivsType_block_{{count}}.push("{{v[3]}}");
{% else %}
updateDivsType_block_{{count}}.push("Data");
{% endif %}