mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
code cleanup
This commit is contained in:
@@ -163,10 +163,8 @@ PRINT_LOG = False
|
||||
TIMEZONE = 'Europe/Berlin'
|
||||
PIALERT_WEB_PROTECTION = False
|
||||
PIALERT_WEB_PASSWORD = '8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92'
|
||||
INCLUDED_SECTIONS = ['internet', 'new_devices', 'down_devices', 'events'] # Specifies which events trigger notifications.
|
||||
# Remove the event type(s) you don't want to get notified on
|
||||
# Overrides device-specific settings in the UI.
|
||||
SCAN_CYCLE_MINUTES = 5 # delay between scans
|
||||
INCLUDED_SECTIONS = ['internet', 'new_devices', 'down_devices', 'events']
|
||||
SCAN_CYCLE_MINUTES = 5
|
||||
|
||||
SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0']
|
||||
|
||||
@@ -188,11 +186,8 @@ REPORT_DASHBOARD_URL = 'http://pi.alert/'
|
||||
# ----------------------
|
||||
REPORT_WEBHOOK = False
|
||||
WEBHOOK_URL = ''
|
||||
WEBHOOK_PAYLOAD = 'json' # webhook payload data format for the "body > attachements > text" attribute
|
||||
# in https://github.com/jokob-sk/Pi.Alert/blob/main/docs/webhook_json_sample.json
|
||||
# supported values: 'json', 'html' or 'text'
|
||||
# e.g.: for discord use 'html'
|
||||
WEBHOOK_REQUEST_METHOD = 'GET' # POST, GET...
|
||||
WEBHOOK_PAYLOAD = 'json'
|
||||
WEBHOOK_REQUEST_METHOD = 'GET'
|
||||
|
||||
# Apprise settings
|
||||
#-----------------------
|
||||
@@ -234,8 +229,8 @@ DDNS_UPDATE_URL = 'https://api.dynu.com/nic/update?'
|
||||
|
||||
# PIHOLE settings
|
||||
# ----------------------
|
||||
PIHOLE_ACTIVE = False # if enabled you need to map '/etc/pihole/pihole-FTL.db' in docker-compose.yml
|
||||
DHCP_ACTIVE = False # if enabled you need to map '/etc/pihole/dhcp.leases' in docker-compose.yml
|
||||
PIHOLE_ACTIVE = False
|
||||
DHCP_ACTIVE = False
|
||||
|
||||
# keep 90 days of network activity if not specified how many days to keep
|
||||
DAYS_TO_KEEP_EVENTS = 90
|
||||
|
||||
@@ -220,7 +220,8 @@ if ($_REQUEST['mac'] == 'Internet') { $DevDetail_Tap_temp = "Tools"; } else { $D
|
||||
<input class="form-control" id="txtGroup" type="text" value="--">
|
||||
<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="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>
|
||||
|
||||
@@ -84,11 +84,19 @@ function deleteAllCookies() {
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalOk (title, message) {
|
||||
function showModalOk (title, message, callbackFunction = null) {
|
||||
// set captions
|
||||
$('#modal-ok-title').html (title);
|
||||
$('#modal-ok-message').html (message);
|
||||
|
||||
if(callbackFunction!= null)
|
||||
{
|
||||
$("#modal-ok-OK").click(function()
|
||||
{
|
||||
callbackFunction()
|
||||
});
|
||||
}
|
||||
|
||||
// Show modal
|
||||
$('#modal-ok').modal('show');
|
||||
}
|
||||
|
||||
@@ -708,10 +708,10 @@ window.onload = function asyncFooter()
|
||||
{
|
||||
scrollDown();
|
||||
|
||||
$("#lastCommit").append('<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/jokob-sk/pi.alert/main?logo=github">');
|
||||
$("#lastCommit").append('<a href="https://github.com/jokob-sk/Pi.Alert/commits" target="_blank"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/jokob-sk/pi.alert/main?logo=github"></a>');
|
||||
|
||||
$("#lastDockerUpdate").append(
|
||||
'<img alt="Docker last pushed" src="https://img.shields.io/badge/dynamic/json?color=blue&label=Last%20pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&?link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert">');
|
||||
'<a href="https://hub.docker.com/r/jokobsk/pi.alert/tags" target="_blank"><img alt="Docker last pushed" src="https://img.shields.io/badge/dynamic/json?color=blue&label=Last%20pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&?link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert"></a>');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ $lang['en_us'] = array(
|
||||
'Login_Remember' => 'Remember',
|
||||
'Login_Remember_small' => '(valid for 7 days)',
|
||||
'Login_Submit' => 'Log in',
|
||||
'Login_Psw_run' => 'To change password run:',
|
||||
'Login_Psw_run' => 'To change the password run:',
|
||||
'Login_Psw_new' => 'new_password',
|
||||
'Login_Psw_folder' => 'in the config folder.',
|
||||
'Login_Psw_alert' => 'Password Alert!',
|
||||
@@ -446,7 +446,7 @@ the scan will take hours to complete instead of seconds.
|
||||
'PIALERT_WEB_PROTECTION_name' => 'Enable login',
|
||||
'PIALERT_WEB_PROTECTION_description' => 'When enabled a login dialog is displayed. Read below carefully if you get locked out of your instance.',
|
||||
'PIALERT_WEB_PASSWORD_name' => 'Login password',
|
||||
'PIALERT_WEB_PASSWORD_description' => 'The default password is <code>123456</code>. To change password run <code>/home/pi/pialert/back/pialert-cli</code> in the container',
|
||||
'PIALERT_WEB_PASSWORD_description' => 'The default password is <code>123456</code>. To change the password run <code>/home/pi/pialert/back/pialert-cli</code> in the container',
|
||||
'INCLUDED_SECTIONS_name' => 'Notify on',
|
||||
'INCLUDED_SECTIONS_description' => 'Specifies which events trigger notifications. Remove the event type(s) you don\'t want to get notified on. This setting overrides device-specific settings in the UI. (CTRL + Click to select / deselect).',
|
||||
'SCAN_CYCLE_MINUTES_name' => 'Scan cycle delay',
|
||||
@@ -482,7 +482,7 @@ the scan will take hours to complete instead of seconds.
|
||||
'WEBHOOK_URL_name' => 'Target URL',
|
||||
'WEBHOOK_URL_description' => 'Target URL starting with <code>http://</code> or <code>https://</code>.',
|
||||
'WEBHOOK_PAYLOAD_name' => 'Payload type',
|
||||
'WEBHOOK_PAYLOAD_description' => 'The Webhook payload data format for the "body > attachements > text" attribute in the payload json. See an example of the payload <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/webhook_json_sample.json">here</a>. (e.g.: for discord use <code>\'html\'</code>)',
|
||||
'WEBHOOK_PAYLOAD_description' => 'The Webhook payload data format for the <code>body</code> > <code>attachments</code> > <code>text</code> attribute in the payload json. See an example of the payload <a target="_blank" href="https://github.com/jokob-sk/Pi.Alert/blob/main/docs/webhook_json_sample.json">here</a>. (e.g.: for discord use <code>html</code>)',
|
||||
'WEBHOOK_REQUEST_METHOD_name' => 'Request method',
|
||||
'WEBHOOK_REQUEST_METHOD_description' => 'The HTTP request method to be used for the webhook call.',
|
||||
|
||||
@@ -525,9 +525,9 @@ the scan will take hours to complete instead of seconds.
|
||||
'MQTT_PASSWORD_name' => 'MQTT password',
|
||||
'MQTT_PASSWORD_description' => 'Password used to login into your MQTT broker instance.',
|
||||
'MQTT_QOS_name' => 'MQTT Quality of Service',
|
||||
'MQTT_QOS_description' => 'Quality of service setting for MQTT message sending. 0 - Low quality to 2 - High quality. The higher the quality the longer the delay.',
|
||||
'MQTT_QOS_description' => 'Quality of service setting for MQTT message sending. <code>0</code> - Low quality to <code>2</code> - High quality. The higher the quality the longer the delay.',
|
||||
'MQTT_DELAY_SEC_name' => 'MQTT delay per device',
|
||||
'MQTT_DELAY_SEC_description' => 'A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~2s to update a sensor config on the broker). Tested with 2-3 seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn\'t affect subsequent scans or notifications.',
|
||||
'MQTT_DELAY_SEC_description' => 'A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~<code>2</code>s to update a sensor config on the broker). Tested with <code>2</code>-<code>3</code> seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn\'t affect subsequent scans or notifications.',
|
||||
|
||||
//DynDNS
|
||||
'DDNS_ACTIVE_name' => 'Enable DynDNS',
|
||||
|
||||
@@ -517,7 +517,7 @@ the scan will take hours to complete instead of seconds.
|
||||
'MQTT_QOS_name' => 'MQTT Quality of Service',
|
||||
'MQTT_QOS_description' => 'Quality of service setting for MQTT message sending. 0 - Low quality to 2 - High quality. The higher the quality the longer the delay.',
|
||||
'MQTT_DELAY_SEC_name' => 'MQTT delay per device',
|
||||
'MQTT_DELAY_SEC_description' => 'A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~2s to update a sensor config on the broker). Tested with 2-3 seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn\'t affect subsequent scans or notifications.',
|
||||
'MQTT_DELAY_SEC_description' => 'A little hack - delay adding to the queue in case the process is restarted and previous publish processes aborted (it takes ~<code>2</code>s to update a sensor config on the broker). Tested with <code>2</code>-<code>3</code> seconds of delay. This delay is only applied when devices are created (during the first notification loop). It doesn\'t affect subsequent scans or notifications.',
|
||||
|
||||
//DynDNS
|
||||
'DDNS_ACTIVE_name' => 'Enable DynDNS',
|
||||
|
||||
@@ -57,8 +57,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
|
||||
$db->close();
|
||||
|
||||
echo "<script>if(".count($settings)." != 46)alert('".lang("settings_missing")."')</script>";
|
||||
|
||||
?>
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
<div class="content-wrapper">
|
||||
@@ -242,6 +240,15 @@ echo "<script>if(".count($settings)." != 46)alert('".lang("settings_missing")."'
|
||||
?>
|
||||
|
||||
<script>
|
||||
|
||||
// number of settings has to be equal to
|
||||
var settingsNumber = 46;
|
||||
|
||||
if(<?php echo count($settings)?> != settingsNumber)
|
||||
{
|
||||
showModalOk('WARNING', '<?php echo lang("settings_missing")?>');
|
||||
}
|
||||
|
||||
function addInterface()
|
||||
{
|
||||
ipMask = $('#ipMask').val();
|
||||
@@ -249,9 +256,11 @@ echo "<script>if(".count($settings)." != 46)alert('".lang("settings_missing")."'
|
||||
|
||||
full = ipMask + " --interface=" + ipInterface;
|
||||
|
||||
console.log(full)
|
||||
|
||||
if(ipMask == "" || ipInterface == "")
|
||||
{
|
||||
modalDefaultOK ('Validation error', 'Specify both, the network mask and the interface');
|
||||
showModalOk ('Validation error', 'Specify both, the network mask and the interface');
|
||||
} else {
|
||||
$('#SCAN_SUBNETS').append($('<option disabled></option>').attr('value', full).text(full));
|
||||
|
||||
@@ -302,9 +311,13 @@ echo "<script>if(".count($settings)." != 46)alert('".lang("settings_missing")."'
|
||||
return settingsArray;
|
||||
}
|
||||
|
||||
|
||||
function saveSettings() {
|
||||
$.ajax({
|
||||
if(<?php echo count($settings)?> != settingsNumber)
|
||||
{
|
||||
showModalOk('WARNING', '<?php echo lang("settings_missing")?>');
|
||||
} else
|
||||
{
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "../php/server/util.php",
|
||||
data: { function: 'savesettings', settings: collectSettings() },
|
||||
@@ -312,7 +325,9 @@ echo "<script>if(".count($settings)." != 46)alert('".lang("settings_missing")."'
|
||||
// $("#result").html(data);
|
||||
// console.log(data);
|
||||
showModalOk ('Result', data );
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user