Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
* Simple devices: top nav -- list by type added
* Simple devices: fix of properties update (keep user's data if already set)
  • Loading branch information
sergejey committed Aug 17, 2022
1 parent f13ecd9 commit 9679941
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 28 deletions.
5 changes: 3 additions & 2 deletions modules/devices/devices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function getParams()

function setDictionary()
{
include_once(dirname(__FILE__) . '/devices_structure.inc.php');
include_once(dirname(__FILE__) . '/devices_structure_links.inc.php');
include(dirname(__FILE__) . '/devices_structure.inc.php');
include(dirname(__FILE__) . '/devices_structure_links.inc.php');
}

/**
Expand Down Expand Up @@ -393,6 +393,7 @@ function renderStructure()
if (is_array($pv)) {
foreach ($pv as $ppk => $ppv) {
if (substr($ppk, 0, 1) == '_') continue;
if ($ppk == 'KEEP_HISTORY' && $property[$ppk]) continue;
$property[$ppk] = $ppv;
}
SQLUpdate('properties', $property);
Expand Down
2 changes: 1 addition & 1 deletion modules/devices/devices_structure.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
'periodTime'=>array('DESCRIPTION'=>'Period to calculate minimum value (seconds)','_CONFIG_TYPE'=>'num','_CONFIG_HELP'=>'SdSensorPeriodTime'),
),
'METHODS'=>array(
'valueUpdated'=>array('DESCRIPTION'=>'Value Updated'),
'valueUpdated'=>array('DESCRIPTION'=>'Value Updated','CALL_PARENT'=>1),
'periodMinValueUpdated'=>array('DESCRIPTION'=>'Period Min value updated'),
),
),
Expand Down
22 changes: 21 additions & 1 deletion modules/panel.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,33 @@ function run()
$modules[$i]['ICON_SM'] = ROOTHTML . 'img/modules/default.png';
}
if ($modules[$i]['NAME']=='devices') {
$links=array();
$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");
if (is_array($devices)) {
$links=array();
$links[]=array('TITLE'=>LANG_ALL,'LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME']);
foreach($devices as $device) {
$links[]=array('TITLE'=>processTitle($device['TITLE']).' ('.$device['TOTAL'].')','LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME'].'&location_id='.$device['LOCATION_ID']);
}
}

$devices = SQLSelect("SELECT devices.TYPE, COUNT(devices.ID) as TOTAL FROM devices GROUP BY devices.TYPE ORDER BY devices.TYPE");
$totall = count($devices);
if ($totall) {
$links[]=array('DIVIDER'=>1);
require DIR_MODULES.'devices/devices_structure.inc.php';

foreach($devices as &$device) {
$device['TITLE']=processTitle($this->device_types[$device['TYPE']]['TITLE']);
}
usort($devices, function ($a, $b) {
return strcmp($a["TITLE"], $b["TITLE"]);
});

for($il=0;$il<$totall;$il++) {
$links[]=array('TITLE'=>$devices[$il]['TITLE'].' ('.$devices[$il]['TOTAL'].')','LINK'=>ROOTHTML.'admin.php?action='.$modules[$i]['NAME'].'&type='.$devices[$il]['TYPE']);
}
}
if (isset($links[0])) {
$modules[$i]['LINKS']=$links;
}
}
Expand Down
65 changes: 41 additions & 24 deletions templates/panel_nav_top.tpl
Original file line number Diff line number Diff line change
@@ -1,43 +1,60 @@
<script type="text/javascript">
function showNotyDate(id) {
$('#notyAddtimeBlock_'+id).show();
$('#notyMsgBlock_'+id).hide();
$('#notyAddtimeBlock_' + id).show();
$('#notyMsgBlock_' + id).hide();
}
function hideNotyDate(id) {
$('#notyMsgBlock_'+id).show();
$('#notyAddtimeBlock_'+id).hide();
$('#notyMsgBlock_' + id).show();
$('#notyAddtimeBlock_' + id).hide();
}
</script>
{foreach $SUB_MODULES as $item}

{if $item.NEW_CATEGORY}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{$item.CATEGORY} <b class="caret"></b></a>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">{$item.CATEGORY} <b class="caret"></b></a>
<ul class="dropdown-menu">
{/if}

{if !$item.DENIED}
{if $item.LINKS}
<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>
<ul class="dropdown-menu">
{foreach $item.LINKS as $link}
<li class="menu-item"><a href="{$link.LINK}">{$link.TITLE}</a></li>
{/foreach}
</ul>
</li>
<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>
<ul class="dropdown-menu">
{foreach $item.LINKS as $link}
{if $link.DIVIDER==1}
<li class="divider" role="separator"></li>
{else}
<li class="menu-item"><a href="{$link.LINK}">{$link.TITLE}</a></li>
{/if}
{/foreach}
</ul>
</li>
{else}
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID}" id="module_{$item.NAME}_link">
<a href='<#ROOTHTML#>admin.php?action={$item.NAME}' class="top-menu"><img src="{$item.ICON_SM}" width="24" height="24">&nbsp;{$item.TITLE}
{if $item.NOTIFICATIONS_COUNT != 0}
<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>
{/if}</a>
</li>
{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}
<li class="[#if SELECTED#]active[#endif#] category{$item.CATEGORY_ID}" id="module_{$item.NAME}_link">
<a href='<#ROOTHTML#>admin.php?action={$item.NAME}' class="top-menu"><img src="{$item.ICON_SM}"
width="24"
height="24">&nbsp;{$item.TITLE}
{if $item.NOTIFICATIONS_COUNT != 0}
<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>
{/if}</a>
</li>
{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}
{/if}
{/if}

{if $item.LAST_IN_CATEGORY}
</ul>
</li>
{/if}
{if $item.LAST_IN_CATEGORY}
</ul>
</li>
{/if}
{/foreach}

0 comments on commit 9679941

Please sign in to comment.