Skip to content

Commit 9679941

Browse files
committed
Updates
* Simple devices: top nav -- list by type added * Simple devices: fix of properties update (keep user's data if already set)
1 parent f13ecd9 commit 9679941

File tree

4 files changed

+66
-28
lines changed

4 files changed

+66
-28
lines changed

modules/devices/devices.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function getParams()
8686

8787
function setDictionary()
8888
{
89-
include_once(dirname(__FILE__) . '/devices_structure.inc.php');
90-
include_once(dirname(__FILE__) . '/devices_structure_links.inc.php');
89+
include(dirname(__FILE__) . '/devices_structure.inc.php');
90+
include(dirname(__FILE__) . '/devices_structure_links.inc.php');
9191
}
9292

9393
/**
@@ -393,6 +393,7 @@ function renderStructure()
393393
if (is_array($pv)) {
394394
foreach ($pv as $ppk => $ppv) {
395395
if (substr($ppk, 0, 1) == '_') continue;
396+
if ($ppk == 'KEEP_HISTORY' && $property[$ppk]) continue;
396397
$property[$ppk] = $ppv;
397398
}
398399
SQLUpdate('properties', $property);

modules/devices/devices_structure.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494
'periodTime'=>array('DESCRIPTION'=>'Period to calculate minimum value (seconds)','_CONFIG_TYPE'=>'num','_CONFIG_HELP'=>'SdSensorPeriodTime'),
495495
),
496496
'METHODS'=>array(
497-
'valueUpdated'=>array('DESCRIPTION'=>'Value Updated'),
497+
'valueUpdated'=>array('DESCRIPTION'=>'Value Updated','CALL_PARENT'=>1),
498498
'periodMinValueUpdated'=>array('DESCRIPTION'=>'Period Min value updated'),
499499
),
500500
),

modules/panel.class.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,33 @@ function run()
207207
$modules[$i]['ICON_SM'] = ROOTHTML . 'img/modules/default.png';
208208
}
209209
if ($modules[$i]['NAME']=='devices') {
210+
$links=array();
210211
$devices = SQLSelect("SELECT devices.LOCATION_ID, locations.TITLE, COUNT(devices.ID) as TOTAL FROM devices LEFT JOIN locations ON devices.LOCATION_ID=locations.ID WHERE locations.ID>0 GROUP BY devices.LOCATION_ID ORDER BY locations.TITLE");
211212
if (is_array($devices)) {
212-
$links=array();
213213
$links[]=array('TITLE'=>LANG_ALL,'LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME']);
214214
foreach($devices as $device) {
215215
$links[]=array('TITLE'=>processTitle($device['TITLE']).' ('.$device['TOTAL'].')','LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME'].'&location_id='.$device['LOCATION_ID']);
216216
}
217+
}
218+
219+
$devices = SQLSelect("SELECT devices.TYPE, COUNT(devices.ID) as TOTAL FROM devices GROUP BY devices.TYPE ORDER BY devices.TYPE");
220+
$totall = count($devices);
221+
if ($totall) {
222+
$links[]=array('DIVIDER'=>1);
223+
require DIR_MODULES.'devices/devices_structure.inc.php';
224+
225+
foreach($devices as &$device) {
226+
$device['TITLE']=processTitle($this->device_types[$device['TYPE']]['TITLE']);
227+
}
228+
usort($devices, function ($a, $b) {
229+
return strcmp($a["TITLE"], $b["TITLE"]);
230+
});
231+
232+
for($il=0;$il<$totall;$il++) {
233+
$links[]=array('TITLE'=>$devices[$il]['TITLE'].' ('.$devices[$il]['TOTAL'].')','LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME'].'&type='.$devices[$il]['TYPE']);
234+
}
235+
}
236+
if (isset($links[0])) {
217237
$modules[$i]['LINKS']=$links;
218238
}
219239
}

templates/panel_nav_top.tpl

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,60 @@
11
<script type="text/javascript">
22
function showNotyDate(id) {
3-
$('#notyAddtimeBlock_'+id).show();
4-
$('#notyMsgBlock_'+id).hide();
3+
$('#notyAddtimeBlock_' + id).show();
4+
$('#notyMsgBlock_' + id).hide();
55
}
6+
67
function hideNotyDate(id) {
7-
$('#notyMsgBlock_'+id).show();
8-
$('#notyAddtimeBlock_'+id).hide();
8+
$('#notyMsgBlock_' + id).show();
9+
$('#notyAddtimeBlock_' + id).hide();
910
}
1011
</script>
1112
{foreach $SUB_MODULES as $item}
1213

1314
{if $item.NEW_CATEGORY}
14-
<li class="dropdown">
15-
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{$item.CATEGORY} <b class="caret"></b></a>
15+
<li class="dropdown">
16+
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
17+
aria-expanded="false">{$item.CATEGORY} <b class="caret"></b></a>
1618
<ul class="dropdown-menu">
1719
{/if}
1820

1921
{if !$item.DENIED}
2022
{if $item.LINKS}
21-
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID} menu-item dropdown dropdown-submenu" id="module_{$item.NAME}_link"><a href='{$smarty.const.ROOTHTML}admin.php?action={$item.NAME}' class="top-menu dropdown-toggle"><img src="{$item.ICON_SM}" width="24" height="24">&nbsp;{$item.TITLE}</a>
22-
<ul class="dropdown-menu">
23-
{foreach $item.LINKS as $link}
24-
<li class="menu-item"><a href="{$link.LINK}">{$link.TITLE}</a></li>
25-
{/foreach}
26-
</ul>
27-
</li>
23+
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID} menu-item dropdown dropdown-submenu"
24+
id="module_{$item.NAME}_link"><a href='{$smarty.const.ROOTHTML}admin.php?action={$item.NAME}'
25+
class="top-menu dropdown-toggle"><img src="{$item.ICON_SM}" width="24"
26+
height="24">&nbsp;{$item.TITLE}
27+
</a>
28+
<ul class="dropdown-menu">
29+
{foreach $item.LINKS as $link}
30+
{if $link.DIVIDER==1}
31+
<li class="divider" role="separator"></li>
32+
{else}
33+
<li class="menu-item"><a href="{$link.LINK}">{$link.TITLE}</a></li>
34+
{/if}
35+
{/foreach}
36+
</ul>
37+
</li>
2838
{else}
29-
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID}" id="module_{$item.NAME}_link">
30-
<a href='<#ROOTHTML#>admin.php?action={$item.NAME}' class="top-menu"><img src="{$item.ICON_SM}" width="24" height="24">&nbsp;{$item.TITLE}
31-
{if $item.NOTIFICATIONS_COUNT != 0}
32-
<span class="badge pull-right alert-{$item.NOTIFICATIONS_TYPE}" style="border: 1px solid;cursor: pointer;" data-container="body" data-toggle="popover" data-trigger="manual" data-placement="bottom" data-html="true" >{$item.NOTIFICATIONS_COUNT}</span>
33-
{/if}</a>
34-
</li>
35-
{if $item.NAME=="xray"}<li class="menu-item"><a href="#" onClick='return consoleToggle();'><i class="glyphicon glyphicon-flash"></i> {$smarty.const.LANG_CONSOLE}</a></li>{/if}
39+
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID}" id="module_{$item.NAME}_link">
40+
<a href='<#ROOTHTML#>admin.php?action={$item.NAME}' class="top-menu"><img src="{$item.ICON_SM}"
41+
width="24"
42+
height="24">&nbsp;{$item.TITLE}
43+
{if $item.NOTIFICATIONS_COUNT != 0}
44+
<span class="badge pull-right alert-{$item.NOTIFICATIONS_TYPE}"
45+
style="border: 1px solid;cursor: pointer;" data-container="body" data-toggle="popover"
46+
data-trigger="manual" data-placement="bottom"
47+
data-html="true">{$item.NOTIFICATIONS_COUNT}</span>
48+
{/if}</a>
49+
</li>
50+
{if $item.NAME=="xray"}
51+
<li class="menu-item"><a href="#" onClick='return consoleToggle();'><i
52+
class="glyphicon glyphicon-flash"></i> {$smarty.const.LANG_CONSOLE}</a></li>{/if}
3653
{/if}
3754
{/if}
3855

39-
{if $item.LAST_IN_CATEGORY}
40-
</ul>
41-
</li>
42-
{/if}
56+
{if $item.LAST_IN_CATEGORY}
57+
</ul>
58+
</li>
59+
{/if}
4360
{/foreach}

0 commit comments

Comments
 (0)