cleanup + added edit hint for drpds

This commit is contained in:
Jokob-sk
2022-12-27 18:17:00 +11:00
parent d0ad78920f
commit 6d58e5b675
7 changed files with 61 additions and 56 deletions

View File

@@ -452,7 +452,7 @@ def importConfig ():
closeDB()
#-------------------------------------------------------------------------------
importConfig()
# importConfig()
#===============================================================================
# USER CONFIG VARIABLES - END
@@ -1562,6 +1562,7 @@ def resolve_device_name (pMAC, pIP):
# Check MAC parameter
mac = pMACstr.replace (':','')
# file_print( ">>>>>> DIG >>>>>")
if len(pMACstr) != 17 or len(mac) != 12 :
return -2
@@ -1569,6 +1570,7 @@ def resolve_device_name (pMAC, pIP):
# file_print(pMAC, pIP)
# Resolve name with DIG
# file_print( ">>>>>> DIG1 >>>>>")
dig_args = ['dig', '+short', '-x', pIP]
# Execute command
@@ -1580,6 +1582,8 @@ def resolve_device_name (pMAC, pIP):
file_print(e.output)
newName = "Error - check logs"
# file_print( ">>>>>> DIG2 >>>>> Name", newName)
# Check returns
newName = newName.strip()
if len(newName) == 0 :
@@ -2554,11 +2558,12 @@ def upgradeDB ():
AND name='Settings';
""").fetchone() == None
# Re-creating Settings table
# if settingsMissing:
# Re-creating Settings table
file_print("[upgradeDB] Re-creating Settings table")
sql.execute("DROP TABLE Settings;")
if settingsMissing == False:
sql.execute("DROP TABLE Settings;")
sql.execute("""
CREATE TABLE "Settings" (
"Code_Name" TEXT,

View File

@@ -692,3 +692,9 @@ height: 50px;
width: auto
}
/* Devices */
.drp-edit
{
cursor: pointer;
}

View File

@@ -166,9 +166,10 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtOwner" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil drp-edit" onclick="editDrp('txtOwner');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down"></span></button>
<span class="fa fa-caret-down "></span></button>
<ul id="dropdownOwner" class="dropdown-menu dropdown-menu-right">
</ul>
</div>
@@ -182,14 +183,12 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtDeviceType" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil drp-edit" onclick="editDrp('txtDeviceType');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false" >
<span class="fa fa-caret-down"></span></button>
<ul id="dropdownDeviceType" class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" onclick="setTextValue('txtDeviceType','Smartphone')"> Smartphone </a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtDeviceType','Laptop')"> Laptop </a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtDeviceType','PC')"> PC </a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtDeviceType','Others')"> Others </a></li>
</ul>
</div>
</div>
@@ -218,16 +217,12 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtGroup" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil drp-edit" onclick="editDrp('txtGroup');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down"></span>
</button>
<ul id="dropdownGroup" class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" onclick="setTextValue('txtGroup','Always On')"> Always On </a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtGroup','Friends')"> Friends </a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtGroup','Personal')"> Personal </a></li>
<li class="divider"></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtGroup','Others')"> Others </a></li>
</ul>
</div>
</div>
@@ -240,17 +235,12 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtLocation" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil drp-edit" onclick="editDrp('txtLocation');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down"></span></button>
<ul id="dropdownLocation" class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Bathroom')"> Bathroom</a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Bedroom')"> Bedroom</a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Hall')"> Hall</a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Kitchen')"> Kitchen</a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Living room')"> Living room</a></li>
<li class="divider"></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtLocation','Others')"> Others</a></li>
</ul>
</div>
</div>
@@ -357,9 +347,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false" id="dropdownButtonScanCycle">
<span class="fa fa-caret-down"></span></button>
<ul id="dropdownScanCycle" class="dropdown-menu dropdown-menu-right">
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','1 min')"><?php echo lang('DevDetail_EveandAl_ScanCycle_a');?></a></li>
<!-- <li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','15 min');"> Scan 12 min every 15 min</a></li> -->
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','0 min');"><?php echo lang('DevDetail_EveandAl_ScanCycle_z');?></a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','yes')"><?php echo lang('DevDetail_EveandAl_ScanCycle_a');?></a></li>
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','no');"><?php echo lang('DevDetail_EveandAl_ScanCycle_z');?></a></li>
</ul>
</div>
</div>
@@ -831,7 +820,7 @@ function initializeCombos () {
// Initialize static combos
initializeComboSkipRepeated ();
}
// -----------------------------------------------------------------------------
function initializeCombo (dropdownId, queryAction, txtDataField, useCache) {
// check if we have the value cached already
@@ -873,7 +862,15 @@ function initializeCombo (dropdownId, queryAction, txtDataField, useCache) {
writeDropdownHtml(dropdownId, dropdownHtmlContent)
}
}
// -----------------------------------------------------------------------------
// Edit dropdown value
function editDrp(dropdownId)
{
$('#'+dropdownId).focus();
}
// -----------------------------------------------------------------------------
// write out the HTML for the dropdown
function writeDropdownHtml(dropdownId, dropdownHtmlContent)
{
@@ -885,7 +882,7 @@ function writeDropdownHtml(dropdownId, dropdownHtmlContent)
HTMLelement.innerHTML = ''
HTMLelement.innerHTML += dropdownHtmlContent;
}
// -----------------------------------------------------------------------------
function getCache(key)
{
// check cache
@@ -897,12 +894,12 @@ function getCache(key)
return "";
}
}
// -----------------------------------------------------------------------------
function setCache(key, data)
{
sessionStorage.setItem(key, data);
}
// -----------------------------------------------------------------------------
function initializeComboSkipRepeated () {
// find dropdown menu element
@@ -918,6 +915,8 @@ function initializeComboSkipRepeated () {
});
}
// -----------------------------------------------------------------------------
function findSkipRepeated (value='0') {
var itemSelected = skipRepeatedItems[0];
@@ -1286,7 +1285,7 @@ function getDeviceData (readAllData=false) {
$('#txtStatus').val (deviceData['dev_Status'].replace('-', ''));
if (deviceData['dev_StaticIP'] == 1) {$('#chkStaticIP').iCheck('check');} else {$('#chkStaticIP').iCheck('uncheck');}
$('#txtScanCycle').val (deviceData['dev_ScanCycle'] +' min');
$('#txtScanCycle').val (deviceData['dev_ScanCycle'] == "1" ? "yes" : "no");
if (deviceData['dev_AlertEvents'] == 1) {$('#chkAlertEvents').iCheck('check');} else {$('#chkAlertEvents').iCheck('uncheck');}
if (deviceData['dev_AlertDeviceDown'] == 1) {$('#chkAlertDown').iCheck('check');} else {$('#chkAlertDown').iCheck('uncheck');}
$('#txtSkipRepeated').val (findSkipRepeated (deviceData['dev_SkipRepeated']));
@@ -1390,7 +1389,7 @@ function setDeviceData (refreshCallback='') {
+ '&networknode=' + $('#txtNetworkNodeMac').val()
+ '&networknodeport=' + $('#txtNetworkPort').val()
+ '&staticIP=' + ($('#chkStaticIP')[0].checked * 1)
+ '&scancycle=' + $('#txtScanCycle').val().split(' ')[0]
+ '&scancycle=' + ($('#txtScanCycle').val() == "yes" ? "1" : "0")
+ '&alertevents=' + ($('#chkAlertEvents')[0].checked * 1)
+ '&alertdown=' + ($('#chkAlertDown')[0].checked * 1)
+ '&skiprepeated=' + $('#txtSkipRepeated').val().split(' ')[0]
@@ -1402,6 +1401,13 @@ function setDeviceData (refreshCallback='') {
deactivateSaveRestoreData ();
showMessage (msg);
// clear session storage
setCache("#dropdownOwner","");
setCache("#dropdownDeviceType","");
setCache("#dropdownGroup","");
setCache("#dropdownLocation","");
setCache("#dropdownNetworkNodeMac","");
// Callback fuction
if (typeof refreshCallback == 'function') {
refreshCallback();
@@ -1419,7 +1425,7 @@ function askSkipNotifications () {
}
// When Archived
if ($('#chkArchived')[0].checked && $('#txtScanCycle').val().split(' ')[0] != "0") {
if ($('#chkArchived')[0].checked && $('#txtScanCycle').val() != "no") {
// Ask skip notifications
showModalDefault ('Device Archived', 'Do you want to skip all notifications for this device?',
'<?php echo lang('Gen_Cancel');?>', '<?php echo lang('Gen_Okay');?>', 'skipNotifications');
@@ -1434,7 +1440,7 @@ function skipNotifications () {
}
// Set cycle 0
$('#txtScanCycle').val ('0 min');
$('#txtScanCycle').val ('no');
activateSaveRestoreData();
}
@@ -1552,4 +1558,9 @@ function setTextValue (textElement, textValue) {
activateSaveRestoreData ();
}
function addNewDrpItem(textElement)
{
showModalDefault("Add new item","Enter new item: <input><input>","Cancel","OK", "alert");
}
</script>

View File

@@ -237,23 +237,6 @@ if ($ENABLED_DARKMODE === True) {
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('help_faq.php') ) ){ echo 'active'; } ?>">
<a href="help_faq.php"><i class="fa fa-question"></i> <span><?php echo lang('Navigation_HelpFAQ');?></span></a>
</li>
<!--
<li class="treeview">
<a href="#"><i class="fa fa-link"></i> <span>Config</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('scancycles.php', 'scancyclesDetails.php') ) ){ echo 'active'; } ?>">
<a href="scancycles.php"><i class="fa fa-link"></i> <span>Scan Cycles</span></a>
</li>
<li><a href="#">Cron Status</a></li>
<li><a href="#">Current IP</a></li>
</ul>
</li>
-->
</ul>
<!-- /.sidebar-menu -->

View File

@@ -183,8 +183,8 @@ $lang['de_de'] = array(
'DevDetail_EveandAl_NewDevice' => 'Neues Gerät',
'DevDetail_EveandAl_Archived' => 'Archivierung',
'DevDetail_EveandAl_RandomMAC' => 'Zufällige MAC',
'DevDetail_EveandAl_ScanCycle_a' => 'Gerät scannen (1 min)',
'DevDetail_EveandAl_ScanCycle_z' => 'Gerät nicht scannen (0 min)',
'DevDetail_EveandAl_ScanCycle_a' => 'Gerät scannen',
'DevDetail_EveandAl_ScanCycle_z' => 'Gerät nicht scannen',
'DevDetail_button_Delete' => 'Lösche Gerät',
'DevDetail_button_Reset' => 'Verwerfen',
'DevDetail_button_Save' => 'Speichern',

View File

@@ -172,15 +172,15 @@ $lang['en_us'] = array(
'DevDetail_SessionInfo_LastIP' => 'Last IP',
'DevDetail_SessionInfo_StaticIP' => 'Static IP',
'DevDetail_EveandAl_Title' => 'Events & Alerts config',
'DevDetail_EveandAl_ScanCycle' => 'Scan Cycle',
'DevDetail_EveandAl_ScanCycle' => 'Scan device',
'DevDetail_EveandAl_AlertAllEvents' => 'Alert All Events',
'DevDetail_EveandAl_AlertDown' => 'Alert Down',
'DevDetail_EveandAl_Skip' => 'Skip repeated notifications during',
'DevDetail_EveandAl_NewDevice' => 'New Device',
'DevDetail_EveandAl_Archived' => 'Archived',
'DevDetail_EveandAl_RandomMAC' => 'Random MAC',
'DevDetail_EveandAl_ScanCycle_a' => 'Scan Device (1 min)',
'DevDetail_EveandAl_ScanCycle_z' => 'Don&#39;t Scan Device (0 min)',
'DevDetail_EveandAl_ScanCycle_a' => 'Scan Device',
'DevDetail_EveandAl_ScanCycle_z' => 'Don&#39;t Scan Device',
'DevDetail_button_Delete' => 'Delete Device',
'DevDetail_button_DeleteEvents' => 'Delete Events',
'DevDetail_button_DeleteEvents_Warning' => 'Are you sure you want to delete all Events of this device?<br><br>(this will clear the <b>Events history</b> and the <b>Sessions</b> and might help with constant (persistent) notifications)',

View File

@@ -179,8 +179,8 @@ $lang['es_es'] = array(
'DevDetail_EveandAl_NewDevice' => 'Nuevo dispositivo',
'DevDetail_EveandAl_Archived' => 'Archivada',
'DevDetail_EveandAl_RandomMAC' => 'MAC al azar',
'DevDetail_EveandAl_ScanCycle_a' => 'Escanear Dispositivo (1 min)',
'DevDetail_EveandAl_ScanCycle_z' => 'No Escanear Dispositivo (0 min)',
'DevDetail_EveandAl_ScanCycle_a' => 'Escanear Dispositivo',
'DevDetail_EveandAl_ScanCycle_z' => 'No Escanear Dispositivo',
'DevDetail_button_Delete' => 'Eliminar dispositivo',
'DevDetail_button_Reset' => 'Restablecer cambios',
'DevDetail_button_Save' => 'Guardar',