Global status, CSS/JS fixes
This commit is contained in:
@@ -517,7 +517,8 @@ def main ():
|
|||||||
reporting = False
|
reporting = False
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
file_print('[', time_now.replace (microsecond=0), '] Loop start ')
|
updateState("Process: Start")
|
||||||
|
file_print('[', time_now.replace (microsecond=0), '] Process: Start')
|
||||||
|
|
||||||
# Timestamp
|
# Timestamp
|
||||||
startTime = time_now
|
startTime = time_now
|
||||||
@@ -562,7 +563,8 @@ def main ():
|
|||||||
cycle = ""
|
cycle = ""
|
||||||
|
|
||||||
# Footer
|
# Footer
|
||||||
file_print('[', time_now.replace (microsecond=0), '] Loop end')
|
updateState("Process: Wait")
|
||||||
|
file_print('[', time_now.replace (microsecond=0), '] Process: Wait')
|
||||||
else:
|
else:
|
||||||
# do something
|
# do something
|
||||||
cycle = ""
|
cycle = ""
|
||||||
@@ -578,6 +580,7 @@ def check_internet_IP ():
|
|||||||
reporting = False
|
reporting = False
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
|
updateState("Scanning: Internet IP")
|
||||||
file_print('[', startTime, '] Check Internet IP:')
|
file_print('[', startTime, '] Check Internet IP:')
|
||||||
|
|
||||||
# Get Internet IP
|
# Get Internet IP
|
||||||
@@ -746,6 +749,7 @@ def check_IP_format (pIP):
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def cleanup_database ():
|
def cleanup_database ():
|
||||||
# Header
|
# Header
|
||||||
|
updateState("Maintenance: DB cleanup")
|
||||||
file_print('[', startTime, '] Cleanup Database:' )
|
file_print('[', startTime, '] Cleanup Database:' )
|
||||||
|
|
||||||
openDB()
|
openDB()
|
||||||
@@ -770,6 +774,7 @@ def cleanup_database ():
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
def update_devices_MAC_vendors (pArg = ''):
|
def update_devices_MAC_vendors (pArg = ''):
|
||||||
# Header
|
# Header
|
||||||
|
updateState("Maintenance: Update HW Vendors")
|
||||||
file_print('[', startTime, '] Update HW Vendors:' )
|
file_print('[', startTime, '] Update HW Vendors:' )
|
||||||
|
|
||||||
# Update vendors DB (iab oui)
|
# Update vendors DB (iab oui)
|
||||||
@@ -889,6 +894,7 @@ def scan_network ():
|
|||||||
# # devtest end
|
# # devtest end
|
||||||
|
|
||||||
# Header
|
# Header
|
||||||
|
updateState("Scanning: Network")
|
||||||
file_print('[', startTime, '] Scan Devices:' )
|
file_print('[', startTime, '] Scan Devices:' )
|
||||||
file_print(' ScanCycle:', cycle)
|
file_print(' ScanCycle:', cycle)
|
||||||
|
|
||||||
@@ -1941,38 +1947,42 @@ def email_reporting ():
|
|||||||
|
|
||||||
# Send Mail
|
# Send Mail
|
||||||
if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != []:
|
if json_internet != [] or json_new_devices != [] or json_down_devices != [] or json_events != []:
|
||||||
file_print('\nChanges detected, sending reports')
|
file_print('Changes detected, sending reports')
|
||||||
|
|
||||||
if REPORT_MAIL and check_config('email'):
|
if REPORT_MAIL and check_config('email'):
|
||||||
file_print(' Sending report by email')
|
updateState("Sending: Email")
|
||||||
|
file_print(' Sending report by Email')
|
||||||
send_email (mail_text, mail_html)
|
send_email (mail_text, mail_html)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip mail')
|
file_print(' Skip mail')
|
||||||
if REPORT_APPRISE and check_config('apprise'):
|
if REPORT_APPRISE and check_config('apprise'):
|
||||||
|
updateState("Sending: Apprise")
|
||||||
file_print(' Sending report by Apprise')
|
file_print(' Sending report by Apprise')
|
||||||
send_apprise (mail_html)
|
send_apprise (mail_html)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip Apprise')
|
file_print(' Skip Apprise')
|
||||||
if REPORT_WEBHOOK and check_config('webhook'):
|
if REPORT_WEBHOOK and check_config('webhook'):
|
||||||
file_print(' Sending report by webhook')
|
updateState("Sending: Webhook")
|
||||||
|
file_print(' Sending report by Webhook')
|
||||||
send_webhook (json_final, mail_text)
|
send_webhook (json_final, mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip webhook')
|
file_print(' Skip webhook')
|
||||||
if REPORT_NTFY and check_config('ntfy'):
|
if REPORT_NTFY and check_config('ntfy'):
|
||||||
|
updateState("Sending: NTFY")
|
||||||
file_print(' Sending report by NTFY')
|
file_print(' Sending report by NTFY')
|
||||||
send_ntfy (mail_text)
|
send_ntfy (mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip NTFY')
|
file_print(' Skip NTFY')
|
||||||
if REPORT_PUSHSAFER and check_config('pushsafer'):
|
if REPORT_PUSHSAFER and check_config('pushsafer'):
|
||||||
|
updateState("Sending: PUSHSAFER")
|
||||||
file_print(' Sending report by PUSHSAFER')
|
file_print(' Sending report by PUSHSAFER')
|
||||||
send_pushsafer (mail_text)
|
send_pushsafer (mail_text)
|
||||||
else :
|
else :
|
||||||
file_print(' Skip PUSHSAFER')
|
file_print(' Skip PUSHSAFER')
|
||||||
# Update MQTT entities
|
# Update MQTT entities
|
||||||
if REPORT_MQTT and check_config('mqtt'):
|
if REPORT_MQTT and check_config('mqtt'):
|
||||||
|
updateState("Sending: MQTT")
|
||||||
file_print(' Establishing MQTT thread')
|
file_print(' Establishing MQTT thread')
|
||||||
# mqtt_thread_up = True # prevent this code to be run multiple times concurrently
|
|
||||||
# start_mqtt_thread ()
|
|
||||||
mqtt_start()
|
mqtt_start()
|
||||||
else :
|
else :
|
||||||
file_print(' Skip MQTT')
|
file_print(' Skip MQTT')
|
||||||
@@ -2546,7 +2556,7 @@ def upgradeDB ():
|
|||||||
|
|
||||||
sql.execute("""
|
sql.execute("""
|
||||||
CREATE TABLE "Parameters" (
|
CREATE TABLE "Parameters" (
|
||||||
"par_ID" INTEGER,
|
"par_ID" TEXT,
|
||||||
"par_Value" TEXT
|
"par_Value" TEXT
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
@@ -2561,7 +2571,8 @@ def upgradeDB ():
|
|||||||
('Front_Details_Period', '1 day'),
|
('Front_Details_Period', '1 day'),
|
||||||
('Front_Devices_Order', '[[3,"desc"],[0,"asc"]]'),
|
('Front_Devices_Order', '[[3,"desc"],[0,"asc"]]'),
|
||||||
('Front_Devices_Rows', '100'),
|
('Front_Devices_Rows', '100'),
|
||||||
('Front_Details_Tab', 'tabDetails')
|
('Front_Details_Tab', 'tabDetails'),
|
||||||
|
('Back_App_State', 'Initializing')
|
||||||
]
|
]
|
||||||
|
|
||||||
sql.executemany ("""INSERT INTO Parameters ("par_ID", "par_Value") VALUES (?, ?)""", params)
|
sql.executemany ("""INSERT INTO Parameters ("par_ID", "par_Value") VALUES (?, ?)""", params)
|
||||||
@@ -2570,6 +2581,16 @@ def upgradeDB ():
|
|||||||
# don't hog DB access
|
# don't hog DB access
|
||||||
closeDB ()
|
closeDB ()
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
def updateState(newState):
|
||||||
|
openDB()
|
||||||
|
|
||||||
|
sql.execute ("UPDATE Parameters SET par_Value='"+ newState +"' WHERE par_ID='Back_App_State'")
|
||||||
|
|
||||||
|
# don't hog DB access
|
||||||
|
closeDB ()
|
||||||
|
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Home Assistant UTILs
|
# Home Assistant UTILs
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -2597,7 +2618,7 @@ def to_binary_sensor(input):
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
# UTIL
|
# UTIL
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def sanitize_string(input):
|
def sanitize_string(input):
|
||||||
if isinstance(input, bytes):
|
if isinstance(input, bytes):
|
||||||
|
|||||||
@@ -560,6 +560,35 @@ height: 50px;
|
|||||||
|
|
||||||
/*settings*/
|
/*settings*/
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.setting_description {
|
||||||
|
/* color: red; */
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.setting_input{
|
||||||
|
width:70%;
|
||||||
|
/* background-color: red; */
|
||||||
|
}
|
||||||
|
.setting_name
|
||||||
|
{
|
||||||
|
width:30%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.setting_description {
|
||||||
|
/* color: rgb(0, 255, 106); */
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.setting_input{
|
||||||
|
width:35%;
|
||||||
|
/* background-color: rgb(0, 255, 106); */
|
||||||
|
}
|
||||||
|
.setting_name
|
||||||
|
{
|
||||||
|
width:19%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.table_row {
|
.table_row {
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
width:100%;
|
width:100%;
|
||||||
@@ -579,7 +608,7 @@ height: 50px;
|
|||||||
|
|
||||||
.setting_name
|
.setting_name
|
||||||
{
|
{
|
||||||
width:19%;
|
/* width:19%; */
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,10 +617,10 @@ height: 50px;
|
|||||||
width:46%;
|
width:46%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setting_input
|
/* .setting_input
|
||||||
{
|
{
|
||||||
width:35%;
|
width:35%;
|
||||||
}
|
} */
|
||||||
|
|
||||||
.center
|
.center
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ function main () {
|
|||||||
|
|
||||||
if (Number.isInteger (result) ) {
|
if (Number.isInteger (result) ) {
|
||||||
tableRows = result;
|
tableRows = result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get parameter value
|
// get parameter value
|
||||||
|
|||||||
@@ -11,6 +11,23 @@
|
|||||||
var timerRefreshData = ''
|
var timerRefreshData = ''
|
||||||
var modalCallbackFunction = '';
|
var modalCallbackFunction = '';
|
||||||
|
|
||||||
|
function getCache(key)
|
||||||
|
{
|
||||||
|
// check cache
|
||||||
|
if(sessionStorage.getItem(key))
|
||||||
|
{
|
||||||
|
return sessionStorage.getItem(key);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCache(key, data)
|
||||||
|
{
|
||||||
|
sessionStorage.setItem(key, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
function setCookie (cookie, value, expirationHours='') {
|
function setCookie (cookie, value, expirationHours='') {
|
||||||
|
|||||||
@@ -723,24 +723,6 @@ function initializeTabs () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCache(key)
|
|
||||||
{
|
|
||||||
// check cache
|
|
||||||
if(sessionStorage.getItem(key))
|
|
||||||
{
|
|
||||||
return sessionStorage.getItem(key);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCache(key, data)
|
|
||||||
{
|
|
||||||
sessionStorage.setItem(key, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// load footer asynchronously not to block the page load/other sections
|
// load footer asynchronously not to block the page load/other sections
|
||||||
window.onload = function asyncFooter()
|
window.onload = function asyncFooter()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ function getParameter() {
|
|||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||||
$value = $row[0];
|
$value = $row[0];
|
||||||
|
|
||||||
|
// displayMessage ($value);
|
||||||
|
|
||||||
echo (json_encode ($value));
|
echo (json_encode ($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- ./wrapper -->
|
<!-- ./wrapper -->
|
||||||
|
|
||||||
<!-- ----------------------------------------------------------------------- -->
|
|
||||||
<!-- REQUIRED JS SCRIPTS -->
|
|
||||||
|
|
||||||
<!-- jQuery 3 -->
|
|
||||||
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
|
|
||||||
|
|
||||||
<!-- Bootstrap 3.3.7 -->
|
<!-- Bootstrap 3.3.7 -->
|
||||||
<script src="lib/AdminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
<script src="lib/AdminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||||
|
|||||||
@@ -84,6 +84,11 @@ require 'php/templates/language/'.$pia_lang_selected.'.php';
|
|||||||
|
|
||||||
<!-- Tell the browser to be responsive to screen width -->
|
<!-- Tell the browser to be responsive to screen width -->
|
||||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||||
|
<!-- ----------------------------------------------------------------------- -->
|
||||||
|
<!-- REQUIRED JS SCRIPTS -->
|
||||||
|
|
||||||
|
<!-- jQuery 3 -->
|
||||||
|
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
|
||||||
|
|
||||||
<!-- Bootstrap 3.3.7 -->
|
<!-- Bootstrap 3.3.7 -->
|
||||||
<link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
<link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
||||||
@@ -127,23 +132,26 @@ if ($ENABLED_DARKMODE === True) {
|
|||||||
$BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/boxed-bg-dark.png\');"';
|
$BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/boxed-bg-dark.png\');"';
|
||||||
} else { $BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/background.png\');"';}
|
} else { $BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/background.png\');"';}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<!-- Servertime to the right of the hostname -->
|
<!-- Servertime to the right of the hostname -->
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var pia_servertime = new Date(<?php echo date("Y, n, j, G, i, s") ?>);
|
function updateState(){
|
||||||
|
getParam("state","Back_App_State")
|
||||||
|
setTimeout("updateState()", 5000);
|
||||||
|
}
|
||||||
|
|
||||||
function show_pia_servertime() {
|
function show_pia_servertime() {
|
||||||
if (!document.getElementById) {
|
|
||||||
return;
|
// datetime in timeZone in the "en-UK" locale
|
||||||
|
let time = new Date().toLocaleString("en-UK", { timeZone: "<?php echo $timeZone?>" });
|
||||||
|
|
||||||
|
if (document.getElementById) {
|
||||||
|
document.getElementById("PIA_Servertime_place").innerHTML = '('+time+')';
|
||||||
}
|
}
|
||||||
var pia_hour = pia_servertime.getHours();
|
|
||||||
var pia_minute = pia_servertime.getMinutes();
|
setTimeout("show_pia_servertime()", 1000);
|
||||||
var pia_second = pia_servertime.getSeconds();
|
|
||||||
pia_servertime.setSeconds(pia_second + 1);
|
|
||||||
if (pia_hour <= 9) { pia_hour = "0" + pia_hour; }
|
|
||||||
if (pia_minute <= 9) { pia_minute = "0" + pia_minute; }
|
|
||||||
if (pia_second <= 9) { pia_second = "0" + pia_second; } realtime_pia_servertime = "(" + pia_hour + ":" + pia_minute + ":" + pia_second + ")";
|
|
||||||
if (document.getElementById) { document.getElementById("PIA_Servertime_place").innerHTML = realtime_pia_servertime; } setTimeout("show_pia_servertime()", 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("visibilitychange",()=>{
|
document.addEventListener("visibilitychange",()=>{
|
||||||
@@ -184,7 +192,8 @@ document.addEventListener("visibilitychange",()=>{
|
|||||||
<!-- Navbar Right Menu -->
|
<!-- Navbar Right Menu -->
|
||||||
<div class="navbar-custom-menu">
|
<div class="navbar-custom-menu">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<!-- Server Status -->
|
||||||
|
<li><a onclick="setCache('activeMaintenanceTab', 'tab_Logging_id')" href="/maintenance.php#tab_Logging"><code id="state"></code></a></li>
|
||||||
<!-- Server Name -->
|
<!-- Server Name -->
|
||||||
<li><a style="pointer-events:none;"><?php echo gethostname();?> <span id="PIA_Servertime_place"></span></a></li>
|
<li><a style="pointer-events:none;"><?php echo gethostname();?> <span id="PIA_Servertime_place"></span></a></li>
|
||||||
|
|
||||||
@@ -297,3 +306,24 @@ document.addEventListener("visibilitychange",()=>{
|
|||||||
</section>
|
</section>
|
||||||
<!-- /.sidebar -->
|
<!-- /.sidebar -->
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
<script defer>
|
||||||
|
|
||||||
|
function getParam(targetId, key) {
|
||||||
|
// get parameter value
|
||||||
|
$.get('php/server/parameters.php?action=get¶meter='+ key, function(data) {
|
||||||
|
var result = data;
|
||||||
|
|
||||||
|
document.getElementById(targetId).innerHTML = result;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update server time in the header
|
||||||
|
show_pia_servertime()
|
||||||
|
|
||||||
|
// Update server state in the header
|
||||||
|
updateState()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ $db->close();
|
|||||||
'</div>
|
'</div>
|
||||||
<div class="table_cell setting_input" >';
|
<div class="table_cell setting_input" >';
|
||||||
|
|
||||||
// render different input types based on the set type
|
// render different input types based on the settings type
|
||||||
$input = "";
|
$input = "";
|
||||||
|
|
||||||
// text - textbox
|
// text - textbox
|
||||||
@@ -272,7 +272,6 @@ $db->close();
|
|||||||
var settingsArray = [];
|
var settingsArray = [];
|
||||||
|
|
||||||
// generate javascript to collect values
|
// generate javascript to collect values
|
||||||
// multiselect, select, password
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$noConversion = array('text', 'integer', 'password', 'readonly', 'selecttext', 'selectinteger', "multiselect");
|
$noConversion = array('text', 'integer', 'password', 'readonly', 'selecttext', 'selectinteger', "multiselect");
|
||||||
|
|||||||
Reference in New Issue
Block a user