Global status, CSS/JS fixes
This commit is contained in:
@@ -517,7 +517,8 @@ def main ():
|
||||
reporting = False
|
||||
|
||||
# Header
|
||||
file_print('[', time_now.replace (microsecond=0), '] Loop start ')
|
||||
updateState("Process: Start")
|
||||
file_print('[', time_now.replace (microsecond=0), '] Process: Start')
|
||||
|
||||
# Timestamp
|
||||
startTime = time_now
|
||||
@@ -562,7 +563,8 @@ def main ():
|
||||
cycle = ""
|
||||
|
||||
# Footer
|
||||
file_print('[', time_now.replace (microsecond=0), '] Loop end')
|
||||
updateState("Process: Wait")
|
||||
file_print('[', time_now.replace (microsecond=0), '] Process: Wait')
|
||||
else:
|
||||
# do something
|
||||
cycle = ""
|
||||
@@ -578,6 +580,7 @@ def check_internet_IP ():
|
||||
reporting = False
|
||||
|
||||
# Header
|
||||
updateState("Scanning: Internet IP")
|
||||
file_print('[', startTime, '] Check Internet IP:')
|
||||
|
||||
# Get Internet IP
|
||||
@@ -746,6 +749,7 @@ def check_IP_format (pIP):
|
||||
#===============================================================================
|
||||
def cleanup_database ():
|
||||
# Header
|
||||
updateState("Maintenance: DB cleanup")
|
||||
file_print('[', startTime, '] Cleanup Database:' )
|
||||
|
||||
openDB()
|
||||
@@ -770,6 +774,7 @@ def cleanup_database ():
|
||||
#===============================================================================
|
||||
def update_devices_MAC_vendors (pArg = ''):
|
||||
# Header
|
||||
updateState("Maintenance: Update HW Vendors")
|
||||
file_print('[', startTime, '] Update HW Vendors:' )
|
||||
|
||||
# Update vendors DB (iab oui)
|
||||
@@ -889,6 +894,7 @@ def scan_network ():
|
||||
# # devtest end
|
||||
|
||||
# Header
|
||||
updateState("Scanning: Network")
|
||||
file_print('[', startTime, '] Scan Devices:' )
|
||||
file_print(' ScanCycle:', cycle)
|
||||
|
||||
@@ -923,7 +929,7 @@ def scan_network ():
|
||||
reporting = read_DHCP_leases () or reporting
|
||||
|
||||
# Load current scan data
|
||||
file_print('Processing scan results')
|
||||
file_print(' Processing scan results')
|
||||
save_scanned_devices (arpscan_devices, cycle_interval)
|
||||
|
||||
# Print stats
|
||||
@@ -932,7 +938,7 @@ def scan_network ():
|
||||
print_log ('Stats end')
|
||||
|
||||
# Create Events
|
||||
file_print('Updating DB Info')
|
||||
file_print(' Updating DB Info')
|
||||
file_print(' Sessions Events (connect / discconnect)')
|
||||
insert_events()
|
||||
|
||||
@@ -1756,7 +1762,7 @@ def email_reporting ():
|
||||
deviceUrl = REPORT_DASHBOARD_URL + '/deviceDetails.php?mac='
|
||||
|
||||
# Reporting section
|
||||
file_print('Check if something to report')
|
||||
file_print(' Check if something to report')
|
||||
openDB()
|
||||
|
||||
# prepare variables for JSON construction
|
||||
@@ -1941,38 +1947,42 @@ def email_reporting ():
|
||||
|
||||
# Send Mail
|
||||
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'):
|
||||
file_print(' Sending report by email')
|
||||
updateState("Sending: Email")
|
||||
file_print(' Sending report by Email')
|
||||
send_email (mail_text, mail_html)
|
||||
else :
|
||||
file_print(' Skip mail')
|
||||
if REPORT_APPRISE and check_config('apprise'):
|
||||
updateState("Sending: Apprise")
|
||||
file_print(' Sending report by Apprise')
|
||||
send_apprise (mail_html)
|
||||
else :
|
||||
file_print(' Skip Apprise')
|
||||
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)
|
||||
else :
|
||||
file_print(' Skip webhook')
|
||||
if REPORT_NTFY and check_config('ntfy'):
|
||||
updateState("Sending: NTFY")
|
||||
file_print(' Sending report by NTFY')
|
||||
send_ntfy (mail_text)
|
||||
else :
|
||||
file_print(' Skip NTFY')
|
||||
if REPORT_PUSHSAFER and check_config('pushsafer'):
|
||||
updateState("Sending: PUSHSAFER")
|
||||
file_print(' Sending report by PUSHSAFER')
|
||||
send_pushsafer (mail_text)
|
||||
else :
|
||||
file_print(' Skip PUSHSAFER')
|
||||
# Update MQTT entities
|
||||
if REPORT_MQTT and check_config('mqtt'):
|
||||
updateState("Sending: MQTT")
|
||||
file_print(' Establishing MQTT thread')
|
||||
# mqtt_thread_up = True # prevent this code to be run multiple times concurrently
|
||||
# start_mqtt_thread ()
|
||||
mqtt_start()
|
||||
else :
|
||||
file_print(' Skip MQTT')
|
||||
@@ -2338,10 +2348,10 @@ def mqtt_create_client():
|
||||
global mqtt_connected_to_broker
|
||||
|
||||
if rc == 0:
|
||||
file_print("Connected to broker")
|
||||
file_print(" Connected to broker")
|
||||
mqtt_connected_to_broker = True # Signal connection
|
||||
else:
|
||||
file_print("Connection failed")
|
||||
file_print(" Connection failed")
|
||||
mqtt_connected_to_broker = False
|
||||
|
||||
|
||||
@@ -2546,7 +2556,7 @@ def upgradeDB ():
|
||||
|
||||
sql.execute("""
|
||||
CREATE TABLE "Parameters" (
|
||||
"par_ID" INTEGER,
|
||||
"par_ID" TEXT,
|
||||
"par_Value" TEXT
|
||||
);
|
||||
""")
|
||||
@@ -2561,7 +2571,8 @@ def upgradeDB ():
|
||||
('Front_Details_Period', '1 day'),
|
||||
('Front_Devices_Order', '[[3,"desc"],[0,"asc"]]'),
|
||||
('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)
|
||||
@@ -2570,6 +2581,16 @@ def upgradeDB ():
|
||||
# don't hog DB access
|
||||
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
|
||||
#===============================================================================
|
||||
@@ -2597,7 +2618,7 @@ def to_binary_sensor(input):
|
||||
#===============================================================================
|
||||
# UTIL
|
||||
#===============================================================================
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def sanitize_string(input):
|
||||
if isinstance(input, bytes):
|
||||
|
||||
@@ -560,6 +560,35 @@ height: 50px;
|
||||
|
||||
/*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 {
|
||||
padding: 3px;
|
||||
width:100%;
|
||||
@@ -579,7 +608,7 @@ height: 50px;
|
||||
|
||||
.setting_name
|
||||
{
|
||||
width:19%;
|
||||
/* width:19%; */
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
@@ -588,10 +617,10 @@ height: 50px;
|
||||
width:46%;
|
||||
}
|
||||
|
||||
.setting_input
|
||||
/* .setting_input
|
||||
{
|
||||
width:35%;
|
||||
}
|
||||
} */
|
||||
|
||||
.center
|
||||
{
|
||||
|
||||
@@ -229,7 +229,6 @@ function main () {
|
||||
|
||||
if (Number.isInteger (result) ) {
|
||||
tableRows = result;
|
||||
|
||||
}
|
||||
|
||||
// get parameter value
|
||||
|
||||
@@ -11,6 +11,23 @@
|
||||
var timerRefreshData = ''
|
||||
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='') {
|
||||
|
||||
@@ -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
|
||||
window.onload = function asyncFooter()
|
||||
{
|
||||
|
||||
@@ -49,6 +49,8 @@ function getParameter() {
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$value = $row[0];
|
||||
|
||||
// displayMessage ($value);
|
||||
|
||||
echo (json_encode ($value));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,7 @@
|
||||
</div>
|
||||
<!-- ./wrapper -->
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- REQUIRED JS SCRIPTS -->
|
||||
|
||||
<!-- jQuery 3 -->
|
||||
<script src="lib/AdminLTE/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<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 -->
|
||||
<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 -->
|
||||
<link rel="stylesheet" href="lib/AdminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css">
|
||||
@@ -127,30 +132,33 @@ if ($ENABLED_DARKMODE === True) {
|
||||
$BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/boxed-bg-dark.png\');"';
|
||||
} else { $BACKGROUND_IMAGE_PATCH='style="background-image: url(\'img/background.png\');"';}
|
||||
?>
|
||||
|
||||
|
||||
<!-- Servertime to the right of the hostname -->
|
||||
<script>
|
||||
|
||||
var pia_servertime = new Date(<?php echo date("Y, n, j, G, i, s") ?>);
|
||||
|
||||
function show_pia_servertime() {
|
||||
if (!document.getElementById) {
|
||||
return;
|
||||
function updateState(){
|
||||
getParam("state","Back_App_State")
|
||||
setTimeout("updateState()", 5000);
|
||||
}
|
||||
var pia_hour = pia_servertime.getHours();
|
||||
var pia_minute = pia_servertime.getMinutes();
|
||||
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",()=>{
|
||||
function show_pia_servertime() {
|
||||
|
||||
// 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+')';
|
||||
}
|
||||
|
||||
setTimeout("show_pia_servertime()", 1000);
|
||||
}
|
||||
|
||||
document.addEventListener("visibilitychange",()=>{
|
||||
if(document.visibilityState==="visible"){
|
||||
window.location.href = window.location.href.split('#')[0];
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -184,7 +192,8 @@ document.addEventListener("visibilitychange",()=>{
|
||||
<!-- Navbar Right Menu -->
|
||||
<div class="navbar-custom-menu">
|
||||
<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 -->
|
||||
<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>
|
||||
<!-- /.sidebar -->
|
||||
</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 class="table_cell setting_input" >';
|
||||
|
||||
// render different input types based on the set type
|
||||
// render different input types based on the settings type
|
||||
$input = "";
|
||||
|
||||
// text - textbox
|
||||
@@ -272,7 +272,6 @@ $db->close();
|
||||
var settingsArray = [];
|
||||
|
||||
// generate javascript to collect values
|
||||
// multiselect, select, password
|
||||
<?php
|
||||
|
||||
$noConversion = array('text', 'integer', 'password', 'readonly', 'selecttext', 'selectinteger', "multiselect");
|
||||
|
||||
Reference in New Issue
Block a user