mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffa1059b26 | ||
|
|
53eafb8c7b | ||
|
|
63b5346308 | ||
|
|
9b87b4dfe4 | ||
|
|
5e250c3950 | ||
|
|
ee8979aa09 | ||
|
|
9dc9cd3f2b | ||
|
|
2f2063c515 | ||
|
|
2568703376 | ||
|
|
4072bbf406 | ||
|
|
10757f0717 | ||
|
|
b77f727ed5 | ||
|
|
fa21d28c90 | ||
|
|
7cc9abf477 | ||
|
|
62f76f8bae | ||
|
|
e4a1fe741b | ||
|
|
0394461e2e | ||
|
|
b72405806e | ||
|
|
044949dc88 | ||
|
|
14665230ff | ||
|
|
0fb4150c96 | ||
|
|
018c43cdc4 | ||
|
|
3b34a42f10 | ||
|
|
faf12f4d18 | ||
|
|
85e07c639d | ||
|
|
097e5e738e | ||
|
|
af93a12b8f | ||
|
|
228078c07b | ||
|
|
f8014f1bf4 | ||
|
|
b6abdcb357 | ||
|
|
8d1696bc19 |
@@ -81,14 +81,16 @@ Linux distributions.
|
||||
- One-step Automated Update:
|
||||
#### `curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_update.sh | bash`
|
||||
|
||||
|
||||
## Device Management
|
||||
# Uninstall process
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
- [Unistall process](docs/UNINSTALL.md)
|
||||
|
||||
|
||||
# Device Management
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
- [Device Management instructions](docs/DEVICE_MANAGEMENT.md)
|
||||
|
||||
|
||||
|
||||
## Other useful info
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
|
||||
|
||||
@@ -167,8 +167,7 @@ def check_internet_IP ():
|
||||
def get_internet_IP ():
|
||||
# BUGFIX #46 - curl http://ipv4.icanhazip.com repeatedly is very slow
|
||||
# Using 'dig'
|
||||
dig_args = ['dig', '+short', '-4', 'myip.opendns.com',
|
||||
'@resolver1.opendns.com']
|
||||
dig_args = ['dig', '+short', '-4', 'myip.opendns.com', '@resolver1.opendns.com']
|
||||
cmd_output = subprocess.check_output (dig_args, universal_newlines=True)
|
||||
|
||||
## BUGFIX #12 - Query IPv4 address (not IPv6)
|
||||
@@ -446,20 +445,22 @@ def query_ScanCycle_Data (pOpenCloseDB = False):
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def execute_arpscan (pRetries):
|
||||
# Prepara command arguments
|
||||
arpscan_args = ['sudo', 'arp-scan', '--localnet', '--ignoredups',
|
||||
'--retry=' + str(pRetries)]
|
||||
|
||||
# #101 - arp-scan subnet configuration
|
||||
# Prepare command arguments
|
||||
subnets = SCAN_SUBNETS.strip().split()
|
||||
arpscan_args = ['sudo', 'arp-scan', '--ignoredups', '--retry=' + str(pRetries)] + subnets
|
||||
# arpscan_args = ['sudo', 'arp-scan', SCAN_SUBNETS, '--ignoredups', '--retry=' + str(pRetries)]
|
||||
# print (arpscan_args)
|
||||
|
||||
# TESTING - Fast Scan
|
||||
# arpscan_args = ['sudo', 'arp-scan', '--localnet', '--ignoredups',
|
||||
# '--retry=1']
|
||||
# arpscan_args = ['sudo', 'arp-scan', '--localnet', '--ignoredups', '--retry=1']
|
||||
|
||||
# DEBUG - arp-scan command
|
||||
# print (" ".join (arpscan_args))
|
||||
|
||||
# Execute command
|
||||
arpscan_output = subprocess.check_output (arpscan_args,
|
||||
universal_newlines=True)
|
||||
arpscan_output = subprocess.check_output (arpscan_args, universal_newlines=True)
|
||||
|
||||
# Search IP + MAC + Vendor as regular expresion
|
||||
re_ip = r'(?P<ip>((2[0-5]|1[0-9]|[0-9])?[0-9]\.){3}((2[0-5]|1[0-9]|[0-9])?[0-9]))'
|
||||
@@ -576,6 +577,26 @@ def save_scanned_devices (p_arpscan_devices, p_cycle_interval):
|
||||
(int(startTime.strftime('%s')) - 60 * p_cycle_interval),
|
||||
cycle) )
|
||||
|
||||
# Check Internet connectivity
|
||||
internet_IP = get_internet_IP()
|
||||
# TESTING - Force IP
|
||||
# internet_IP = ""
|
||||
if internet_IP != "" :
|
||||
sql.execute ("""INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod)
|
||||
VALUES (?, 'Internet', ?, Null, 'queryDNS') """, (cycle, internet_IP) )
|
||||
|
||||
# #76 Add Local MAC of default local interface
|
||||
#local_mac_cmd = ["bash -lc ifconfig `ip route list default | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
local_mac_cmd = ["/sbin/ifconfig `ip route list default | awk {'print $5'}` | grep ether | awk '{print $2}'"]
|
||||
local_mac = subprocess.Popen (local_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].strip()
|
||||
|
||||
local_ip_cmd = ["ip route list default | awk {'print $7'}"]
|
||||
local_ip = subprocess.Popen (local_ip_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].strip()
|
||||
|
||||
sql.execute ("INSERT INTO CurrentScan (cur_ScanCycle, cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) "+
|
||||
"VALUES ( ?, ?, ?, Null, 'local_MAC') ", (cycle, local_mac, local_ip) )
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def print_scan_stats ():
|
||||
# Devices Detected
|
||||
@@ -919,7 +940,8 @@ def update_devices_names ():
|
||||
|
||||
# Devices without name
|
||||
print (' Trying to resolve devices without name...', end='')
|
||||
for device in sql.execute ("SELECT * FROM Devices WHERE dev_Name IN ('(unknown)','') ") :
|
||||
# BUGFIX #97 - Updating name of Devices w/o IP
|
||||
for device in sql.execute ("SELECT * FROM Devices WHERE dev_Name IN ('(unknown)','') AND dev_LastIP <> '-'") :
|
||||
# Resolve device name
|
||||
newName = resolve_device_name (device['dev_MAC'], device['dev_LastIP'])
|
||||
|
||||
@@ -955,11 +977,14 @@ def resolve_device_name (pMAC, pIP):
|
||||
if len(pMACstr) != 17 or len(mac) != 12 :
|
||||
return -2
|
||||
|
||||
# DEBUG
|
||||
# print (pMAC, pIP)
|
||||
|
||||
# Resolve name with DIG
|
||||
dig_args = ['dig', '+short', '-x', pIP]
|
||||
newName = subprocess.check_output (dig_args, universal_newlines=True)
|
||||
|
||||
# Check if Eliminate local domain
|
||||
# Check returns
|
||||
newName = newName.strip()
|
||||
if len(newName) == 0 :
|
||||
return -2
|
||||
@@ -987,7 +1012,8 @@ def void_ghost_disconnections ():
|
||||
print_log ('Void - 1 Connect ghost events')
|
||||
sql.execute ("""UPDATE Events SET eve_PairEventRowid = Null,
|
||||
eve_EventType ='VOIDED - ' || eve_EventType
|
||||
WHERE eve_EventType = 'Connected'
|
||||
WHERE eve_MAC != 'Internet'
|
||||
AND eve_EventType = 'Connected'
|
||||
AND eve_DateTime = ?
|
||||
AND eve_MAC IN (
|
||||
SELECT Events.eve_MAC
|
||||
@@ -1006,7 +1032,8 @@ def void_ghost_disconnections ():
|
||||
# Void connect paired events
|
||||
print_log ('Void - 2 Paired events')
|
||||
sql.execute ("""UPDATE Events SET eve_PairEventRowid = Null
|
||||
WHERE eve_PairEventRowid IN (
|
||||
WHERE eve_MAC != 'Internet'
|
||||
AND eve_PairEventRowid IN (
|
||||
SELECT Events.RowID
|
||||
FROM CurrentScan, Devices, ScanCycles, Events
|
||||
WHERE cur_ScanCycle = ?
|
||||
@@ -1024,7 +1051,8 @@ def void_ghost_disconnections ():
|
||||
print_log ('Void - 3 Disconnect ghost events')
|
||||
sql.execute ("""UPDATE Events SET eve_PairEventRowid = Null,
|
||||
eve_EventType = 'VOIDED - '|| eve_EventType
|
||||
WHERE ROWID IN (
|
||||
WHERE eve_MAC != 'Internet'
|
||||
AND ROWID IN (
|
||||
SELECT Events.RowID
|
||||
FROM CurrentScan, Devices, ScanCycles, Events
|
||||
WHERE cur_ScanCycle = ?
|
||||
|
||||
@@ -35,3 +35,16 @@ PIHOLE_ACTIVE = False
|
||||
PIHOLE_DB = '/etc/pihole/pihole-FTL.db'
|
||||
DHCP_ACTIVE = False
|
||||
DHCP_LEASES = '/etc/pihole/dhcp.leases'
|
||||
|
||||
# arp-scan options & samples
|
||||
#
|
||||
# Scan local network (default)
|
||||
# SCAN_SUBNETS = '--localnet'
|
||||
#
|
||||
# Scan two subnets
|
||||
# SCAN_SUBNETS = '192.168.11.0/24 192.168.144.0/24'
|
||||
#
|
||||
# Scan using interface eth0
|
||||
# SCAN_SUBNETS = '--localnet --interface=eth0'
|
||||
|
||||
SCAN_SUBNETS = '--localnet'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
VERSION = '2.70'
|
||||
VERSION = '3.00'
|
||||
VERSION_YEAR = '2021'
|
||||
VERSION_DATE = '2021-02-01'
|
||||
VERSION_DATE = '2021-04-21'
|
||||
|
||||
BIN
db/pialert.db
BIN
db/pialert.db
Binary file not shown.
@@ -22,6 +22,9 @@ Estimated time: 20'
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
`curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_update.sh | bash`
|
||||
|
||||
## Uninstall process
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
- [Unistall process](./UNINSTALL.md)
|
||||
|
||||
## Installation process (step by step)
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
@@ -317,7 +320,6 @@ block is not necessary
|
||||
|
||||
- [Device Management instructions](./DEVICE_MANAGEMENT.md)
|
||||
|
||||
|
||||
### License
|
||||
GPL 3.0
|
||||
[Read more here](../LICENSE.txt)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
The latest versions of some operating systems (IOS and Android) incorporate a
|
||||
new & interesting functionality to improve privacy: **Random MACs**.
|
||||
|
||||
This functionality allows you to **hide the true MAC** of the device and
|
||||
This functionality allows you to **hide the real MAC** of the device and
|
||||
**assign a random MAC** when we connect to WIFI networks.
|
||||
|
||||
This behavior is especially useful when connecting to WIFI's that we do not
|
||||
|
||||
64
docs/UNINSTALL.md
Normal file
64
docs/UNINSTALL.md
Normal file
@@ -0,0 +1,64 @@
|
||||
# Pi.Alert Uninstallation Guide
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
Estimated time: 5'
|
||||
|
||||
|
||||
## One-step Automated Uninstall:
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
`curl -sSL https://github.com/pucherot/Pi.Alert/raw/main/install/pialert_uninstall.sh | bash`
|
||||
|
||||
## Uninstallation process (step by step)
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
|
||||
1.1 - Remove Pi.Alert files
|
||||
```
|
||||
rm -r "~/pialert"
|
||||
```
|
||||
|
||||
1.2 - Remove Pi.Alert web front
|
||||
```
|
||||
sudo rm "/var/www/html/pialert"
|
||||
```
|
||||
|
||||
1.3 - Remove lighttpd Pi.Alert config
|
||||
```
|
||||
sudo rm "/etc/lighttpd/conf-available/pialert_front.conf"
|
||||
sudo rm "/etc/lighttpd/conf-enabled/pialert_front.conf"
|
||||
```
|
||||
|
||||
1.4 - Remove lighttpd Pi.Alert cache
|
||||
```
|
||||
sudo rm -r /var/cache/lighttpd/compress/pialert
|
||||
```
|
||||
|
||||
1.5 - Remove Pi.Alert DNS entry
|
||||
```
|
||||
sudo sed -i '/pi.alert/d' /etc/pihole/custom.list
|
||||
sudo pihole restartdns
|
||||
```
|
||||
|
||||
1.6 - Remove Pi.Alert crontab jobs
|
||||
```
|
||||
crontab -l 2>/dev/null | sed ':a;N;$!ba;s/#-------------------------------------------------------------------------------\n# Pi.Alert\n# Open Source Network Guard \/ WIFI & LAN intrusion detector \n#\n# pialert.cron - Back module. Crontab jobs\n#-------------------------------------------------------------------------------\n# Puche 2021 pi.alert.application@gmail.com GNU GPLv3\n#-------------------------------------------------------------------------------//g' | crontab -
|
||||
crontab -l 2>/dev/null | sed '/pialert.py/d' | crontab -
|
||||
```
|
||||
|
||||
### Uninstallation Notes
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
- If you installed Pi-hole during the Pi.Alert installation process,
|
||||
|
||||
Pi-hole will still be available after uninstalling Pi.Alert
|
||||
|
||||
|
||||
- lighttpd, PHP, arp-scan & Python have not been uninstalled
|
||||
|
||||
They may be required by other software
|
||||
|
||||
You can uninstall them manually with command 'apt-get remove XX'
|
||||
|
||||
### License
|
||||
GPL 3.0
|
||||
[Read more here](../LICENSE.txt)
|
||||
|
||||
### Contact
|
||||
pi.alert.application@gmail.com
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
| Version | Description |
|
||||
| ------- | --------------------------------------------------------------- |
|
||||
| v3.00 | Major set of New features & Enhancements |
|
||||
| v2.70 | New features & Usability improvements in the web prontal |
|
||||
| v2.61 | Bug fixing |
|
||||
| v2.60 | Improved the compability of installation process (Ubuntu) |
|
||||
@@ -13,6 +14,25 @@
|
||||
| v2.50 | First public release |
|
||||
|
||||
|
||||
## Pi.Alert v3.00
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
**PENDING UPDATE DOC**
|
||||
- `arp-scan` config options: interface, several subnets. #101 #15
|
||||
- Next/previos button while editing devices #66 #37
|
||||
- Internet presence/sessions monitoring #63
|
||||
- Logical delete / archive / hide Device #93
|
||||
- Flag to mark device with random MAC's #87
|
||||
- New Device Types predefined in combobox #92
|
||||
- Ask before leave the page with unsaved changes #104
|
||||
- Option to don't mark devices as new during installation #94
|
||||
- Uninstall script #62
|
||||
- Fixed: Error updating name of devices w/o IP #97
|
||||
- Fixed: Deleted devices reappear #84
|
||||
- Fixed: Device running Pi.Alert must be marked as "on-line" #76
|
||||
- Fixed: Incorrect calculation of presence hours #102
|
||||
- Fixed: Problem redirect to homepage clicking in logo #103
|
||||
|
||||
|
||||
## Pi.Alert v2.70
|
||||
<!--- --------------------------------------------------------------------- --->
|
||||
- Added Client names resolution #43
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.text-gray-20 {
|
||||
color: rgba(192,192,192,20%);
|
||||
}
|
||||
|
||||
.text-aqua-20 {
|
||||
color: rgba(0,192,239,20%);
|
||||
}
|
||||
@@ -151,6 +155,13 @@
|
||||
margin-bottom: 1.3em;
|
||||
}
|
||||
|
||||
.pa-small-box-footer {
|
||||
color: white !important;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
.pa-small-box-aqua {
|
||||
border-top: 3px solid #00c0ef;
|
||||
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1);
|
||||
@@ -169,8 +180,6 @@
|
||||
color: #00c0ef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
.pa-small-box-green {
|
||||
border-top: 3px solid #00a65a;
|
||||
@@ -228,7 +237,26 @@
|
||||
color: #dd4b39;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
.pa-small-box-gray {
|
||||
border-top: 3px solid #a0a0a0;
|
||||
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.pa-small-box-gray .inner {
|
||||
color: #a0a0a0;
|
||||
background-color:#FFFFFF;
|
||||
}
|
||||
|
||||
.pa-small-box-gray .inner h3 {
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
.pa-small-box-gray .icon {
|
||||
color: #a0a0a0;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
Customized Box Borders
|
||||
----------------------------------------------------------------------------- */
|
||||
@@ -304,6 +332,29 @@
|
||||
color: #B0B0B0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
Customized buttons
|
||||
----------------------------------------------------------------------------- */
|
||||
.pa-btn {
|
||||
padding: 10px;
|
||||
min-width: 90px;
|
||||
}
|
||||
|
||||
.pa-btn-delete {
|
||||
border-color:#ffb060;
|
||||
background-color:#ffd080;
|
||||
}
|
||||
|
||||
.pa-btn-delete:hover {
|
||||
border-color:#ffb060;
|
||||
background-color:#ffb060;
|
||||
}
|
||||
|
||||
.pa-btn-records, .pa-btn-records:hover, .pa-btn-records:focus, .pa-btn-records:active {
|
||||
border-color:#ddd;
|
||||
background-color:#f4f4f4;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
||||
@@ -42,15 +42,10 @@
|
||||
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: $('#tabDetails').trigger('click')">
|
||||
<div class="small-box bg-aqua pa-small-box-aqua">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Current Status</h4>
|
||||
<h3 id="deviceStatus" style="margin-left: 0em"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="small-box bg-aqua pa-small-box-aqua pa-small-box-2">
|
||||
<div class="inner"> <h3 id="deviceStatus" style="margin-left: 0em"> -- </h3> </div>
|
||||
<div class="icon"> <i id="deviceStatusIcon" class=""></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Current Status <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -58,15 +53,10 @@
|
||||
<!-- top small box 2 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: $('#tabSessions').trigger('click');">
|
||||
<div class="small-box bg-green pa-small-box-green">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Sessions</h4>
|
||||
<h3 id="deviceSessions"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="small-box bg-green pa-small-box-green pa-small-box-2">
|
||||
<div class="inner"> <h3 id="deviceSessions"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-plug"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Sesions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -74,15 +64,10 @@
|
||||
<!-- top small box 3 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: $('#tabPresence').trigger('click')">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow">
|
||||
|
||||
<div class="inner">
|
||||
<h4 id="deviceEventsTitle"> Presence </h4>
|
||||
<h3 id="deviceEvents" style="margin-left: 0em"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="deviceEvents" style="margin-left: 0em"> -- </h3> </div>
|
||||
<div id="deviceEventsIcon" class="icon"> <i class="fa fa-calendar"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Presence <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -90,15 +75,10 @@
|
||||
<!-- top small box 4 ------------------------------------------------------ -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: $('#tabEvents').trigger('click');">
|
||||
<div class="small-box bg-red pa-small-box-red">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Down Alerts</h4>
|
||||
<h3 id="deviceDownAlerts"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="small-box bg-red pa-small-box-red pa-small-box-2">
|
||||
<div class="inner"> <h3 id="deviceDownAlerts"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-warning"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -111,13 +91,28 @@
|
||||
<div class="col-lg-12 col-sm-12 col-xs-12">
|
||||
<!-- <div class="box-transparent"> -->
|
||||
|
||||
|
||||
<div id="navDevice" class="nav-tabs-custom">
|
||||
<ul class="nav nav-tabs" style="fon t-size:16px;">
|
||||
<li> <a id="tabDetails" href="#panDetails" data-toggle="tab"> Details </a></li>
|
||||
<li> <a id="tabSessions" href="#panSessions" data-toggle="tab"> Sessions </a></li>
|
||||
<li> <a id="tabPresence" href="#panPresence" data-toggle="tab"> Presence </a></li>
|
||||
<li> <a id="tabEvents" href="#panEvents" data-toggle="tab"> Events </a></li>
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn btn-default" style="padding: 10px; min-width: 30px;"
|
||||
id="btnPrevious" onclick="previousRecord()"> <i class="fa fa-chevron-left"></i> </button>
|
||||
|
||||
<div class="btn pa-btn-records" style="padding: 10px; min-width: 30px; margin-left: 1px;"
|
||||
id="txtRecord" > 0 / 0 </div>
|
||||
|
||||
<button type="button" class="btn btn-default" style="padding: 10px; min-width: 30px; margin-left: 1px;"
|
||||
id="btnNext" onclick="nextRecord()"> <i class="fa fa-chevron-right"></i> </button>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<div class="tab-content" style="min-height: 430px">
|
||||
|
||||
<!-- tab page 1 ------------------------------------------------------------ -->
|
||||
@@ -318,8 +313,8 @@
|
||||
<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')"> Scan 1' every 5'</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','15 min');"> Scan 12' every 15'</a></li>
|
||||
<li><a href="javascript:void(0)" onclick="setTextValue('txtScanCycle','1 min')"> Scan 1 min every 5 min</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');"> Don't Scan</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -372,14 +367,42 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Archived -->
|
||||
<div class="form-group">
|
||||
<label class="col-sm-5 control-label">Archived:</label>
|
||||
<div class="col-sm-7" style="padding-top:6px;">
|
||||
<input class="checkbox blue hidden" id="chkArchived" type="checkbox">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Randomized MAC -->
|
||||
<div class="form-group" >
|
||||
<label class="col-sm-5 control-label">Random MAC:</label>
|
||||
<div class="col-sm-7" style="padding-top:6px;">
|
||||
<span id="iconRandomMACinactive" data-toggle="tooltip" data-placement="right" title="Random MAC is Inactive">
|
||||
<i style="font-size: 24px;" class="text-gray glyphicon glyphicon-random"></i>     </span>
|
||||
|
||||
<span id="iconRandomMACactive" data-toggle="tooltip" data-placement="right" title="Random MAC is Active" class="hidden">
|
||||
<i style="font-size: 24px;" class="text-yellow glyphicon glyphicon-random"></i>     </span>
|
||||
|
||||
<a href="https://github.com/pucherot/Pi.Alert/blob/main/docs/RAMDOM_MAC.md" target="_blank" style="color: #777;">
|
||||
<i class="fa fa-info-circle"></i> </a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Buttons -->
|
||||
<div class="col-xs-12">
|
||||
<button type="button" class="btn btn-primary pull-right" style="padding: 10px; min-width: 90px;" id="btnSave" onclick="setDeviceData()"> Save </button>
|
||||
<button type="button" class="btn btn-default pull-right" style="padding: 10px; min-width: 90px; margin-right:10px;" id="btnRestore" onclick="getDeviceData(true)"> Reset Changes </button>
|
||||
<button type="button" class="btn bg-default pull-right" style="padding: 10px; min-width: 90px; margin-right:10px; background-color:#ffd080;" id="btnDelete" onclick="askDeleteDevice()"> Delete Device </button>
|
||||
<div class="pull-right">
|
||||
<button type="button" class="btn btn-default pa-btn pa-btn-delete" style="margin-left:0px;"
|
||||
id="btnDelete" onclick="askDeleteDevice()"> Delete Device </button>
|
||||
<button type="button" class="btn btn-default pa-btn" style="margin-left:6px;"
|
||||
id="btnRestore" onclick="getDeviceData(true)"> Reset Changes </button>
|
||||
<button type="button" disabled class="btn btn-primary pa-btn" style="margin-left:6px; "
|
||||
id="btnSave" onclick="setDeviceData()" > Save </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -488,13 +511,15 @@
|
||||
<script>
|
||||
|
||||
var mac = '';
|
||||
var devicesList = [];
|
||||
var pos = -1;
|
||||
var parPeriod = 'Front_Details_Period';
|
||||
var parTab = 'Front_Details_Tab';
|
||||
var parSessionsRows = 'Front_Details_Sessions_Rows';
|
||||
var parEventsRows = 'Front_Details_Events_Rows';
|
||||
var parEventsHide = 'Front_Details_Events_Hide';
|
||||
var period = '1 month';
|
||||
var tab = 'tabDetails'
|
||||
var tab = '#panDetails'
|
||||
var sessionsRows = 10;
|
||||
var eventsRows = 10;
|
||||
var eventsHide = true;
|
||||
@@ -558,10 +583,20 @@ function main () {
|
||||
initializeDatatables();
|
||||
initializeCalendar();
|
||||
|
||||
// Read Cookies
|
||||
devicesList = getCookie('devicesList');
|
||||
deleteCookie ('devicesList');
|
||||
if (devicesList != '') {
|
||||
devicesList = JSON.parse (devicesList);
|
||||
} else {
|
||||
devicesList = [];
|
||||
}
|
||||
|
||||
|
||||
// query data
|
||||
getDeviceData(true);
|
||||
getSessionsPresenceEvents();
|
||||
|
||||
|
||||
// Force re-render calendar on tab change
|
||||
// (bugfix for render error at left panel)
|
||||
$(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (nav) {
|
||||
@@ -570,6 +605,13 @@ function main () {
|
||||
}
|
||||
});
|
||||
|
||||
// Ask before exit without saving data
|
||||
window.onbeforeunload = function(){
|
||||
if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) {
|
||||
return 'Are you sure you want to discard unsaved changes?';
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -578,6 +620,7 @@ function main () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function initializeTabs () {
|
||||
// Activate panel
|
||||
@@ -619,7 +662,7 @@ function initializeiCheck () {
|
||||
radioClass: 'iradio_flat-red',
|
||||
increaseArea: '20%'
|
||||
});
|
||||
|
||||
|
||||
// When toggle iCheck
|
||||
$('input').on('ifToggled', function(event){
|
||||
// Hide / Show Events
|
||||
@@ -629,6 +672,11 @@ function initializeiCheck () {
|
||||
} else {
|
||||
// Activate save & restore
|
||||
activateSaveRestoreData();
|
||||
|
||||
// Ask skip notifications
|
||||
if (event.currentTarget.id == 'chkArchived' ) {
|
||||
askSkipNotifications();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -896,7 +944,7 @@ function periodChanged () {
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function getDeviceData (updatePanelData=false) {
|
||||
function getDeviceData (readAllData=false) {
|
||||
// stop timer
|
||||
stopTimerRefreshData();
|
||||
|
||||
@@ -905,6 +953,15 @@ function getDeviceData (updatePanelData=false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Deactivate next previous buttons
|
||||
if (readAllData) {
|
||||
$('#btnPrevious').attr ('disabled','');
|
||||
$('#btnPrevious').addClass ('text-gray50');
|
||||
$('#btnNext').attr ('disabled','');
|
||||
$('#btnNext').addClass ('text-gray50');
|
||||
$("body").css ("cursor", "progress");
|
||||
}
|
||||
|
||||
// get data from server
|
||||
$.get('php/server/devices.php?action=getDeviceData&mac='+ mac + '&period='+ period, function(data) {
|
||||
|
||||
@@ -912,8 +969,15 @@ function getDeviceData (updatePanelData=false) {
|
||||
|
||||
// check device exists
|
||||
if (deviceData['dev_MAC'] == null) {
|
||||
$('#pageTitle').html ('Device not found: <small>'+ mac +'</small>');
|
||||
|
||||
// Status
|
||||
$('#deviceStatus').html ('--');
|
||||
$('#deviceStatus')[0].className = 'text-gray';
|
||||
$('#deviceStatusIcon')[0].className = '';
|
||||
|
||||
$('#deviceSessions').html ('--');
|
||||
$('#deviceDownAlerts').html ('--');
|
||||
$('#deviceEvents').html ('--');
|
||||
|
||||
$('#txtMAC').val ('--');
|
||||
$('#txtName').val ('--');
|
||||
$('#txtOwner').val ('--');
|
||||
@@ -935,11 +999,23 @@ function getDeviceData (updatePanelData=false) {
|
||||
$('#chkAlertEvents').iCheck ('uncheck')
|
||||
$('#chkAlertDown').iCheck ('uncheck')
|
||||
$('#txtSkipRepeated').val ('--');
|
||||
$('#chkNewDevice').iCheck ('uncheck')
|
||||
$('#chkNewDevice').iCheck ('uncheck');
|
||||
$('#chkArchived').iCheck ('uncheck');
|
||||
|
||||
$('#iconRandomMACactive').addClass ('hidden');
|
||||
$('#iconRandomMACinactive').removeClass ('hidden');
|
||||
|
||||
// Deactivate controls
|
||||
$('#panDetails :input').attr('disabled', true);
|
||||
|
||||
// Check if device is deleted o no exists in this session
|
||||
if (pos == -1) {
|
||||
devicesList = [];
|
||||
$('#pageTitle').html ('Device not found: <small>'+ mac +'</small>');
|
||||
} else {
|
||||
$('#pageTitle').html ('Device deleted');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// Name
|
||||
@@ -949,7 +1025,7 @@ function getDeviceData (updatePanelData=false) {
|
||||
} else {
|
||||
$('#pageTitle').html (deviceData['dev_Name'] + ' ('+ deviceData['dev_Owner'] +')');
|
||||
}
|
||||
|
||||
|
||||
// Status
|
||||
$('#deviceStatus').html (deviceData['dev_Status']);
|
||||
switch (deviceData['dev_Status']) {
|
||||
@@ -976,14 +1052,19 @@ function getDeviceData (updatePanelData=false) {
|
||||
}
|
||||
|
||||
// Device info
|
||||
if (updatePanelData) {
|
||||
if (readAllData) {
|
||||
// Activate controls
|
||||
$('#panDetails :input').attr('disabled', false);
|
||||
|
||||
mac =deviceData['dev_MAC'];
|
||||
|
||||
$('#txtMAC').val (deviceData['dev_MAC']);
|
||||
$('#txtName').val (deviceData['dev_Name']);
|
||||
$('#txtOwner').val (deviceData['dev_Owner']);
|
||||
$('#txtDeviceType').val (deviceData['dev_DeviceType']);
|
||||
$('#txtVendor').val (deviceData['dev_Vendor']);
|
||||
|
||||
if (deviceData['dev_Favorite'] == 1) {$('#chkFavorite').iCheck('check');}
|
||||
if (deviceData['dev_Favorite'] == 1) {$('#chkFavorite').iCheck('check');} else {$('#chkFavorite').iCheck('uncheck');}
|
||||
$('#txtGroup').val (deviceData['dev_Group']);
|
||||
$('#txtLocation').val (deviceData['dev_Location']);
|
||||
$('#txtComments').val (deviceData['dev_Comments']);
|
||||
@@ -992,27 +1073,94 @@ function getDeviceData (updatePanelData=false) {
|
||||
$('#txtLastConnection').val (deviceData['dev_LastConnection']);
|
||||
$('#txtLastIP').val (deviceData['dev_LastIP']);
|
||||
$('#txtStatus').val (deviceData['dev_Status']);
|
||||
if (deviceData['dev_StaticIP'] == 1) {$('#chkStaticIP').iCheck('check');}
|
||||
if (deviceData['dev_StaticIP'] == 1) {$('#chkStaticIP').iCheck('check');} else {$('#chkStaticIP').iCheck('uncheck');}
|
||||
|
||||
$('#txtScanCycle').val (deviceData['dev_ScanCycle'] +' min');
|
||||
if (deviceData['dev_AlertEvents'] == 1) {$('#chkAlertEvents').iCheck('check');}
|
||||
if (deviceData['dev_AlertDeviceDown'] == 1) {$('#chkAlertDown').iCheck('check');}
|
||||
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']));
|
||||
if (deviceData['dev_NewDevice'] == 1) {$('#chkNewDevice').iCheck('check');}
|
||||
if (deviceData['dev_NewDevice'] == 1) {$('#chkNewDevice').iCheck('check');} else {$('#chkNewDevice').iCheck('uncheck');}
|
||||
if (deviceData['dev_Archived'] == 1) {$('#chkArchived').iCheck('check');} else {$('#chkArchived').iCheck('uncheck');}
|
||||
|
||||
if (deviceData['dev_RandomMAC'] == 1) {$('#iconRandomMACactive').removeClass ('hidden');
|
||||
$('#iconRandomMACinactive').addClass ('hidden'); }
|
||||
else {$('#iconRandomMACactive').addClass ('hidden');
|
||||
$('#iconRandomMACinactive').removeClass ('hidden'); };
|
||||
deactivateSaveRestoreData ();
|
||||
}
|
||||
|
||||
// Check if device is part of the devicesList
|
||||
pos = devicesList.indexOf (deviceData['rowid']);
|
||||
if (pos == -1) {
|
||||
devicesList =[deviceData['rowid']];
|
||||
pos=0;
|
||||
}
|
||||
}
|
||||
|
||||
// Record number
|
||||
$('#txtRecord').html (pos+1 +' / '+ devicesList.length);
|
||||
|
||||
// Deactivate previous button
|
||||
if (pos <= 0) {
|
||||
$('#btnPrevious').attr ('disabled','');
|
||||
$('#btnPrevious').addClass ('text-gray50');
|
||||
} else {
|
||||
$('#btnPrevious').removeAttr ('disabled');
|
||||
$('#btnPrevious').removeClass ('text-gray50');
|
||||
}
|
||||
|
||||
// Deactivate next button
|
||||
if (pos >= (devicesList.length-1)) {
|
||||
$('#btnNext').attr ('disabled','');
|
||||
$('#btnNext').addClass ('text-gray50');
|
||||
} else {
|
||||
$('#btnNext').removeAttr ('disabled');
|
||||
$('#btnNext').removeClass ('text-gray50');
|
||||
}
|
||||
|
||||
// Timer for refresh data
|
||||
$("body").css("cursor", "default");
|
||||
newTimerRefreshData (getDeviceData);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function setDeviceData () {
|
||||
function previousRecord () {
|
||||
// Save Changes
|
||||
if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) {
|
||||
setDeviceData (previousRecord);
|
||||
return;
|
||||
}
|
||||
|
||||
// Previous Record
|
||||
if (pos > 0) {
|
||||
pos--;
|
||||
mac = devicesList[pos].toString();
|
||||
getDeviceData (true);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function nextRecord () {
|
||||
// Save Changes
|
||||
if ( ! document.getElementById('btnSave').hasAttribute('disabled') ) {
|
||||
setDeviceData (nextRecord);
|
||||
return;
|
||||
}
|
||||
|
||||
// Next Record
|
||||
if (pos < (devicesList.length-1) ) {
|
||||
pos++;
|
||||
mac = devicesList[pos].toString();
|
||||
getDeviceData (true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function setDeviceData (refreshCallback='') {
|
||||
// Check MAC
|
||||
if (mac == '') {
|
||||
return;
|
||||
@@ -1034,14 +1182,48 @@ function setDeviceData () {
|
||||
+ '&alertdown=' + ($('#chkAlertDown')[0].checked * 1)
|
||||
+ '&skiprepeated=' + $('#txtSkipRepeated').val().split(' ')[0]
|
||||
+ '&newdevice=' + ($('#chkNewDevice')[0].checked * 1)
|
||||
+ '&archived=' + ($('#chkArchived')[0].checked * 1)
|
||||
, function(msg) {
|
||||
|
||||
// deactivate button
|
||||
deactivateSaveRestoreData ();
|
||||
showMessage (msg);
|
||||
|
||||
// Callback fuction
|
||||
if (typeof refreshCallback == 'function') {
|
||||
refreshCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function askSkipNotifications () {
|
||||
// Check MAC
|
||||
if (mac == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// When Archived
|
||||
if ($('#chkArchived')[0].checked && $('#txtScanCycle').val().split(' ')[0] != "0") {
|
||||
// Ask skip notifications
|
||||
showModalDefault ('Device Archived', 'Do you want to skip all notifications for this device?',
|
||||
'Cancel', 'Ok', 'skipNotifications');
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function skipNotifications () {
|
||||
// Check MAC
|
||||
if (mac == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set cycle 0
|
||||
$('#txtScanCycle').val ('0 min');
|
||||
activateSaveRestoreData();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function askDeleteDevice () {
|
||||
// Check MAC
|
||||
@@ -1050,7 +1232,7 @@ function askDeleteDevice () {
|
||||
}
|
||||
|
||||
// Ask delete device
|
||||
showModal ('Delete Device', 'Are you sure you want to delete this device?',
|
||||
showModalWarning ('Delete Device', 'Are you sure you want to delete this device?<br>(maybe you prefer to archive it)',
|
||||
'Cancel', 'Delete', 'deleteDevice');
|
||||
}
|
||||
|
||||
|
||||
@@ -27,65 +27,67 @@
|
||||
<!-- top small box 1 ------------------------------------------------------- -->
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('all');">
|
||||
<div class="small-box bg-aqua pa-small-box-aqua">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Total Devices</h4>
|
||||
<h3 id="devicesAll"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-laptop"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-aqua pa-small-box-aqua pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesAll"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-laptop text-aqua-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> All Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- top small box 2 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('connected');">
|
||||
<div class="small-box bg-green pa-small-box-green">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Connected</h4>
|
||||
<h3 id="devicesConnected"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-plug"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-green pa-small-box-green pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesConnected"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-plug text-green-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Connected <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 3 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow">
|
||||
|
||||
<div class="inner">
|
||||
<h4>New Devices</h4>
|
||||
<h3 id="devicesNew"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="ion ion-plus-round"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('favorites');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesFavorites"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-star text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Favorites <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 4 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesNew"> -- </h3> </div>
|
||||
<div class="icon"> <i class="ion ion-plus-round text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> New Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 5 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('down');">
|
||||
<div class="small-box bg-red pa-small-box-red">
|
||||
<div class="small-box bg-red pa-small-box-red pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesDown"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-warning text-red-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="inner">
|
||||
<h4>Down Alerts</h4>
|
||||
<h3 id="devicesDown"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-warning"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<!-- top small box 6 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('archived');">
|
||||
<div class="small-box bg-gray pa-small-box-gray pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesArchived"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-eye-slash text-gray-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Archived <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -110,15 +112,17 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Owner</th>
|
||||
<th>Device type</th>
|
||||
<th>Type</th>
|
||||
<th>Favorite</th>
|
||||
<th>Group</th>
|
||||
<th>First Session</th>
|
||||
<th>Last Session</th>
|
||||
<th>Last IP</th>
|
||||
<th>MAC</th>
|
||||
<th>Status</th>
|
||||
<th>MAC</th>
|
||||
<th>Last IP Order</th>
|
||||
<th>Rowid</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
@@ -187,8 +191,8 @@ function main () {
|
||||
// query data
|
||||
getDevicesTotals();
|
||||
getDevicesList (deviceStatus);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -209,15 +213,16 @@ function initializeDatatable () {
|
||||
// 'order' : [[3,'desc'], [0,'asc']],
|
||||
|
||||
'columnDefs' : [
|
||||
{visible: false, targets: [9, 10] },
|
||||
{className: 'text-center', targets: [3, 8] },
|
||||
{width: '0px', targets: 8 },
|
||||
{orderData: [10], targets: 7 },
|
||||
{visible: false, targets: [10, 11, 12] },
|
||||
{className: 'text-center', targets: [3, 8, 9] },
|
||||
{width: '80px', targets: [5, 6] },
|
||||
{width: '0px', targets: 9 },
|
||||
{orderData: [11], targets: 7 },
|
||||
|
||||
// Device Name
|
||||
{targets: [0],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[9] +'" class="">'+ cellData +'</a></b>');
|
||||
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[10] +'" class="">'+ cellData +'</a></b>');
|
||||
} },
|
||||
|
||||
// Favorite
|
||||
@@ -236,18 +241,29 @@ function initializeDatatable () {
|
||||
$(td).html (translateHTMLcodes (cellData));
|
||||
} },
|
||||
|
||||
// Status color
|
||||
// Random MAC
|
||||
{targets: [8],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
if (cellData == 1){
|
||||
$(td).html ('<i data-toggle="tooltip" data-placement="right" title="Random MAC" style="font-size: 16px;" class="text-yellow glyphicon glyphicon-random"></i>');
|
||||
} else {
|
||||
$(td).html ('');
|
||||
}
|
||||
} },
|
||||
|
||||
// Status color
|
||||
{targets: [9],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
switch (cellData) {
|
||||
case 'Down': color='red'; break;
|
||||
case 'New': color='yellow'; break;
|
||||
case 'On-line': color='green'; break;
|
||||
case 'Off-line': color='gray text-white'; break;
|
||||
case 'Archived': color='gray text-white'; break;
|
||||
default: color='aqua'; break;
|
||||
};
|
||||
|
||||
$(td).html ('<a href="deviceDetails.php?mac='+ rowData[9] +'" class="badge bg-'+ color +'">'+ cellData +'</a>');
|
||||
$(td).html ('<a href="deviceDetails.php?mac='+ rowData[10] +'" class="badge bg-'+ color +'">'+ cellData +'</a>');
|
||||
} },
|
||||
],
|
||||
|
||||
@@ -259,13 +275,18 @@ function initializeDatatable () {
|
||||
}
|
||||
});
|
||||
|
||||
// Save Parameters rows & order when changed
|
||||
// Save cookie Rows displayed, and Parameters rows & order
|
||||
$('#tableDevices').on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parTableRows, len);
|
||||
} );
|
||||
|
||||
$('#tableDevices').on( 'order.dt', function () {
|
||||
setParameter (parTableOrder, JSON.stringify (table.order()) );
|
||||
setCookie ('devicesList',JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
} );
|
||||
|
||||
$('#tableDevices').on( 'search.dt', function () {
|
||||
setCookie ('devicesList', JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
} );
|
||||
};
|
||||
|
||||
@@ -281,8 +302,10 @@ function getDevicesTotals () {
|
||||
|
||||
$('#devicesAll').html (totalsDevices[0].toLocaleString());
|
||||
$('#devicesConnected').html (totalsDevices[1].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesFavorites').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[4].toLocaleString());
|
||||
$('#devicesArchived').html (totalsDevices[5].toLocaleString());
|
||||
|
||||
// Timer for refresh data
|
||||
newTimerRefreshData (getDevicesTotals);
|
||||
@@ -297,12 +320,13 @@ function getDevicesList (status) {
|
||||
|
||||
// Define color & title for the status selected
|
||||
switch (deviceStatus) {
|
||||
case 'all': tableTitle = 'Total Devices'; color = 'aqua'; break;
|
||||
case 'connected': tableTitle = 'Connected Devices'; color = 'green'; break;
|
||||
case 'new': tableTitle = 'New Devices'; color = 'yellow'; break;
|
||||
case 'down': tableTitle = 'Down Alerts'; color = 'red'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
default: tableTitle = 'Devices'; boxClass = ''; break;
|
||||
case 'all': tableTitle = 'All Devices'; color = 'aqua'; break;
|
||||
case 'connected': tableTitle = 'Connected Devices'; color = 'green'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
case 'new': tableTitle = 'New Devices'; color = 'yellow'; break;
|
||||
case 'down': tableTitle = 'Down Alerts'; color = 'red'; break;
|
||||
case 'archived': tableTitle = 'Archived Devices'; color = 'gray'; break;
|
||||
default: tableTitle = 'Devices'; color = 'gray'; break;
|
||||
}
|
||||
|
||||
// Set title and color
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
<div class="small-box bg-aqua pa-small-box-aqua pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsAll"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-bolt text-aqua-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> All events <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> All events <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -55,8 +54,7 @@
|
||||
<div class="small-box bg-green pa-small-box-green pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsSessions"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-plug text-green-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -67,8 +65,7 @@
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsMissing"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-exchange text-yellow-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> Missing Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Missing Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -79,8 +76,7 @@
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsVoided"> -- </h3> </div>
|
||||
<div class="icon text-aqua-20"> <i class="fa fa-exclamation-circle text-yellow-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> Voided Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Voided Sessions <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -91,8 +87,7 @@
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsNewDevices"> -- </h3> </div>
|
||||
<div class="icon"> <i class="ion ion-plus-round text-yellow-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> New Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> New Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -103,8 +98,7 @@
|
||||
<div class="small-box bg-red pa-small-box-red pa-small-box-2">
|
||||
<div class="inner"> <h3 id="eventsDown"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-warning text-red-20"></i> </div>
|
||||
|
||||
<div class="small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
144
front/index.php
144
front/index.php
@@ -27,65 +27,67 @@
|
||||
<!-- top small box 1 ------------------------------------------------------- -->
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('all');">
|
||||
<div class="small-box bg-aqua pa-small-box-aqua">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Total Devices</h4>
|
||||
<h3 id="devicesAll"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-laptop"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-aqua pa-small-box-aqua pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesAll"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-laptop text-aqua-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> All Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- top small box 2 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('connected');">
|
||||
<div class="small-box bg-green pa-small-box-green">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Connected</h4>
|
||||
<h3 id="devicesConnected"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-plug"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-green pa-small-box-green pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesConnected"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-plug text-green-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Connected <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 3 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow">
|
||||
|
||||
<div class="inner">
|
||||
<h4>New Devices</h4>
|
||||
<h3 id="devicesNew"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="ion ion-plus-round"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('favorites');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesFavorites"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-star text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Favorites <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 4 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesNew"> -- </h3> </div>
|
||||
<div class="icon"> <i class="ion ion-plus-round text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> New Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 5 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('down');">
|
||||
<div class="small-box bg-red pa-small-box-red">
|
||||
<div class="small-box bg-red pa-small-box-red pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesDown"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-warning text-red-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="inner">
|
||||
<h4>Down Alerts</h4>
|
||||
<h3 id="devicesDown"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-warning"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<!-- top small box 6 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesList('archived');">
|
||||
<div class="small-box bg-gray pa-small-box-gray pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesArchived"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-eye-slash text-gray-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Archived <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -110,15 +112,17 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Owner</th>
|
||||
<th>Device type</th>
|
||||
<th>Type</th>
|
||||
<th>Favorite</th>
|
||||
<th>Group</th>
|
||||
<th>First Session</th>
|
||||
<th>Last Session</th>
|
||||
<th>Last IP</th>
|
||||
<th>MAC</th>
|
||||
<th>Status</th>
|
||||
<th>MAC</th>
|
||||
<th>Last IP Order</th>
|
||||
<th>Rowid</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
@@ -187,8 +191,8 @@ function main () {
|
||||
// query data
|
||||
getDevicesTotals();
|
||||
getDevicesList (deviceStatus);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -209,15 +213,16 @@ function initializeDatatable () {
|
||||
// 'order' : [[3,'desc'], [0,'asc']],
|
||||
|
||||
'columnDefs' : [
|
||||
{visible: false, targets: [9, 10] },
|
||||
{className: 'text-center', targets: [3, 8] },
|
||||
{width: '0px', targets: 8 },
|
||||
{orderData: [10], targets: 7 },
|
||||
{visible: false, targets: [10, 11, 12] },
|
||||
{className: 'text-center', targets: [3, 8, 9] },
|
||||
{width: '80px', targets: [5, 6] },
|
||||
{width: '0px', targets: 9 },
|
||||
{orderData: [11], targets: 7 },
|
||||
|
||||
// Device Name
|
||||
{targets: [0],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[9] +'" class="">'+ cellData +'</a></b>');
|
||||
$(td).html ('<b><a href="deviceDetails.php?mac='+ rowData[10] +'" class="">'+ cellData +'</a></b>');
|
||||
} },
|
||||
|
||||
// Favorite
|
||||
@@ -236,18 +241,29 @@ function initializeDatatable () {
|
||||
$(td).html (translateHTMLcodes (cellData));
|
||||
} },
|
||||
|
||||
// Status color
|
||||
// Random MAC
|
||||
{targets: [8],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
if (cellData == 1){
|
||||
$(td).html ('<i data-toggle="tooltip" data-placement="right" title="Random MAC" style="font-size: 16px;" class="text-yellow glyphicon glyphicon-random"></i>');
|
||||
} else {
|
||||
$(td).html ('');
|
||||
}
|
||||
} },
|
||||
|
||||
// Status color
|
||||
{targets: [9],
|
||||
'createdCell': function (td, cellData, rowData, row, col) {
|
||||
switch (cellData) {
|
||||
case 'Down': color='red'; break;
|
||||
case 'New': color='yellow'; break;
|
||||
case 'On-line': color='green'; break;
|
||||
case 'Off-line': color='gray text-white'; break;
|
||||
case 'Archived': color='gray text-white'; break;
|
||||
default: color='aqua'; break;
|
||||
};
|
||||
|
||||
$(td).html ('<a href="deviceDetails.php?mac='+ rowData[9] +'" class="badge bg-'+ color +'">'+ cellData +'</a>');
|
||||
$(td).html ('<a href="deviceDetails.php?mac='+ rowData[10] +'" class="badge bg-'+ color +'">'+ cellData +'</a>');
|
||||
} },
|
||||
],
|
||||
|
||||
@@ -259,13 +275,18 @@ function initializeDatatable () {
|
||||
}
|
||||
});
|
||||
|
||||
// Save Parameters rows & order when changed
|
||||
// Save cookie Rows displayed, and Parameters rows & order
|
||||
$('#tableDevices').on( 'length.dt', function ( e, settings, len ) {
|
||||
setParameter (parTableRows, len);
|
||||
} );
|
||||
|
||||
$('#tableDevices').on( 'order.dt', function () {
|
||||
setParameter (parTableOrder, JSON.stringify (table.order()) );
|
||||
setCookie ('devicesList',JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
} );
|
||||
|
||||
$('#tableDevices').on( 'search.dt', function () {
|
||||
setCookie ('devicesList', JSON.stringify (table.column(12, { 'search': 'applied' }).data().toArray()) );
|
||||
} );
|
||||
};
|
||||
|
||||
@@ -281,8 +302,10 @@ function getDevicesTotals () {
|
||||
|
||||
$('#devicesAll').html (totalsDevices[0].toLocaleString());
|
||||
$('#devicesConnected').html (totalsDevices[1].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesFavorites').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[4].toLocaleString());
|
||||
$('#devicesArchived').html (totalsDevices[5].toLocaleString());
|
||||
|
||||
// Timer for refresh data
|
||||
newTimerRefreshData (getDevicesTotals);
|
||||
@@ -297,12 +320,13 @@ function getDevicesList (status) {
|
||||
|
||||
// Define color & title for the status selected
|
||||
switch (deviceStatus) {
|
||||
case 'all': tableTitle = 'Total Devices'; color = 'aqua'; break;
|
||||
case 'connected': tableTitle = 'Connected Devices'; color = 'green'; break;
|
||||
case 'new': tableTitle = 'New Devices'; color = 'yellow'; break;
|
||||
case 'down': tableTitle = 'Down Alerts'; color = 'red'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
default: tableTitle = 'Devices'; boxClass = ''; break;
|
||||
case 'all': tableTitle = 'All Devices'; color = 'aqua'; break;
|
||||
case 'connected': tableTitle = 'Connected Devices'; color = 'green'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
case 'new': tableTitle = 'New Devices'; color = 'yellow'; break;
|
||||
case 'down': tableTitle = 'Down Alerts'; color = 'red'; break;
|
||||
case 'archived': tableTitle = 'Archived Devices'; color = 'gray'; break;
|
||||
default: tableTitle = 'Devices'; color = 'gray'; break;
|
||||
}
|
||||
|
||||
// Set title and color
|
||||
|
||||
@@ -13,20 +13,98 @@ var modalCallbackFunction = '';
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModal (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
function setCookie (cookie, value, expirationHours='') {
|
||||
// Calc expiration date
|
||||
var expires = '';
|
||||
if (typeof expirationHours === 'number') {
|
||||
expires = ';expires=' + new Date(Date.now() + expirationHours *60*60*1000).toUTCString();
|
||||
}
|
||||
|
||||
// Save Cookie
|
||||
document.cookie = cookie + "=" + value + expires;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function getCookie (cookie) {
|
||||
// Array of cookies
|
||||
var allCookies = document.cookie.split(';');
|
||||
|
||||
// For each cookie
|
||||
for (var i = 0; i < allCookies.length; i++) {
|
||||
var currentCookie = allCookies[i].trim();
|
||||
|
||||
// If the current cookie is the correct cookie
|
||||
if (currentCookie.indexOf (cookie +'=') == 0) {
|
||||
// Return value
|
||||
return currentCookie.substring (cookie.length+1);
|
||||
}
|
||||
}
|
||||
|
||||
// Return empty (not found)
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function deleteCookie (cookie) {
|
||||
document.cookie = cookie + '=;expires=Thu, 01 Jan 1970 00:00:00 UTC';
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function deleteAllCookies() {
|
||||
// Array of cookies
|
||||
var allCookies = document.cookie.split(";");
|
||||
|
||||
// For each cookie
|
||||
for (var i = 0; i < allCookies.length; i++) {
|
||||
var cookie = allCookies[i].trim();
|
||||
var eqPos = cookie.indexOf("=");
|
||||
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
|
||||
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalDefault (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
// set captions
|
||||
$('#modal-title').html (title);
|
||||
$('#modal-message').html (message);
|
||||
$('#modal-cancel').html (btnCancel);
|
||||
$('#modal-OK').html (btnOK);
|
||||
modalCallbackFunction = callbackFunction;
|
||||
$('#modal-default-title').html (title);
|
||||
$('#modal-default-message').html (message);
|
||||
$('#modal-default-cancel').html (btnCancel);
|
||||
$('#modal-default-OK').html (btnOK);
|
||||
modalCallbackFunction = callbackFunction;
|
||||
|
||||
// Show modal
|
||||
$('#modal-default').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalWarning (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
// set captions
|
||||
$('#modal-warning-title').html (title);
|
||||
$('#modal-warning-message').html (message);
|
||||
$('#modal-warning-cancel').html (btnCancel);
|
||||
$('#modal-warning-OK').html (btnOK);
|
||||
modalCallbackFunction = callbackFunction;
|
||||
|
||||
// Show modal
|
||||
$('#modal-warning').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function modalOK () {
|
||||
function modalDefaultOK () {
|
||||
// Hide modal
|
||||
$('#modal-default').modal('hide');
|
||||
|
||||
// timer to execute function
|
||||
window.setTimeout( function() {
|
||||
window[modalCallbackFunction]();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function modalWarningOK () {
|
||||
// Hide modal
|
||||
$('#modal-warning').modal('hide');
|
||||
|
||||
|
||||
@@ -57,19 +57,22 @@ function getDeviceData() {
|
||||
$mac = $_REQUEST['mac'];
|
||||
|
||||
// Device Data
|
||||
$sql = 'SELECT *,
|
||||
$sql = 'SELECT rowid, *,
|
||||
CASE WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
|
||||
WHEN dev_PresentLastScan=1 THEN "On-line"
|
||||
ELSE "Off-line" END as dev_Status
|
||||
FROM Devices
|
||||
WHERE dev_MAC="'. $mac .'"';
|
||||
WHERE dev_MAC="'. $mac .'" or cast(rowid as text)="'. $mac. '"';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_ASSOC);
|
||||
$deviceData = $row;
|
||||
$mac = $deviceData['dev_MAC'];
|
||||
|
||||
$deviceData['dev_FirstConnection'] = formatDate ($row['dev_FirstConnection']); // Date formated
|
||||
$deviceData['dev_LastConnection'] = formatDate ($row['dev_LastConnection']); // Date formated
|
||||
|
||||
$deviceData['dev_RandomMAC'] = ( in_array($mac[1], array("2","6","A","E","a","e")) ? 1 : 0);
|
||||
|
||||
// Count Totals
|
||||
$condition = ' WHERE eve_MAC="'. $mac .'" AND eve_DateTime >= '. $periodDate;
|
||||
|
||||
@@ -89,16 +92,16 @@ function getDeviceData() {
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_Events'] = $row[0];
|
||||
|
||||
// Donw Alerts
|
||||
// Down Alerts
|
||||
$sql = 'SELECT COUNT(*) FROM Events '. $condition .' AND eve_EventType = "Device Down"';
|
||||
$result = $db->query($sql);
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$deviceData['dev_DownAlerts'] = $row[0];
|
||||
|
||||
// Presence hours
|
||||
$sql = 'SELECT SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now")))
|
||||
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
||||
ELSE ses_DateTimeConnection END)) *24
|
||||
$sql = 'SELECT CAST(( MAX (0, SUM (julianday (IFNULL (ses_DateTimeDisconnection, DATETIME("now","localtime")))
|
||||
- julianday (CASE WHEN ses_DateTimeConnection < '. $periodDate .' THEN '. $periodDate .'
|
||||
ELSE ses_DateTimeConnection END)) *24 )) AS INT)
|
||||
FROM Sessions
|
||||
WHERE ses_MAC="'. $mac .'"
|
||||
AND ses_DateTimeConnection IS NOT NULL
|
||||
@@ -136,7 +139,8 @@ function setDeviceData() {
|
||||
dev_AlertEvents = "'. quotes($_REQUEST['alertevents']) .'",
|
||||
dev_AlertDeviceDown = "'. quotes($_REQUEST['alertdown']) .'",
|
||||
dev_SkipRepeated = "'. quotes($_REQUEST['skiprepeated']) .'",
|
||||
dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'"
|
||||
dev_NewDevice = "'. quotes($_REQUEST['newdevice']) .'",
|
||||
dev_Archived = "'. quotes($_REQUEST['archived']) .'"
|
||||
WHERE dev_MAC="' . $_REQUEST['mac'] .'"';
|
||||
// update Data
|
||||
$result = $db->query($sql);
|
||||
@@ -177,15 +181,20 @@ function getDevicesTotals() {
|
||||
global $db;
|
||||
|
||||
// All
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices ');
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('all'));
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$devices = $row[0];
|
||||
|
||||
// Connected
|
||||
// On-Line
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected') );
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$connected = $row[0];
|
||||
|
||||
// Favorites
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('favorites') );
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$favorites = $row[0];
|
||||
|
||||
// New
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new') );
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
@@ -194,10 +203,14 @@ function getDevicesTotals() {
|
||||
// Down Alerts
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down'));
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$devicesDownAlert = $row[0];
|
||||
$downAlert = $row[0];
|
||||
|
||||
echo (json_encode (array ($devices, $connected, $newDevices,
|
||||
$devicesDownAlert)));
|
||||
// Archived
|
||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('archived'));
|
||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||
$archived = $row[0];
|
||||
|
||||
echo (json_encode (array ($devices, $connected, $favorites, $newDevices, $downAlert, $archived)));
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +223,7 @@ function getDevicesList() {
|
||||
// SQL
|
||||
$condition = getDeviceCondition ($_REQUEST['status']);
|
||||
|
||||
$sql = 'SELECT *, CASE
|
||||
$sql = 'SELECT rowid, *, CASE
|
||||
WHEN dev_AlertDeviceDown=1 AND dev_PresentLastScan=0 THEN "Down"
|
||||
WHEN dev_NewDevice=1 THEN "New"
|
||||
WHEN dev_PresentLastScan=1 THEN "On-line"
|
||||
@@ -230,9 +243,11 @@ function getDevicesList() {
|
||||
formatDate ($row['dev_FirstConnection']),
|
||||
formatDate ($row['dev_LastConnection']),
|
||||
$row['dev_LastIP'],
|
||||
( in_array($row['dev_MAC'][1], array("2","6","A","E","a","e")) ? 1 : 0),
|
||||
$row['dev_Status'],
|
||||
$row['dev_MAC'], // MAC (hidden)
|
||||
formatIPlong ($row['dev_LastIP']) // IP orderable
|
||||
formatIPlong ($row['dev_LastIP']), // IP orderable
|
||||
$row['rowid'] // Rowid (hidden)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -332,6 +347,7 @@ function getDeviceTypes() {
|
||||
UNION SELECT 2 as dev_Order, "Server"
|
||||
UNION SELECT 2 as dev_Order, "Singleboard Computer (SBC)"
|
||||
|
||||
UNION SELECT 3 as dev_Order, "Domotic"
|
||||
UNION SELECT 3 as dev_Order, "Game Console"
|
||||
UNION SELECT 3 as dev_Order, "SmartTV"
|
||||
UNION SELECT 3 as dev_Order, "TV Decoder"
|
||||
@@ -346,6 +362,8 @@ function getDeviceTypes() {
|
||||
UNION SELECT 5 as dev_Order, "NAS"
|
||||
UNION SELECT 5 as dev_Order, "PLC"
|
||||
UNION SELECT 5 as dev_Order, "Router"
|
||||
UNION SELECT 5 as dev_Order, "USB LAN Adapter"
|
||||
UNION SELECT 5 as dev_Order, "USB WIFI Adapter"
|
||||
|
||||
UNION SELECT 10 as dev_Order, "Other"
|
||||
|
||||
@@ -451,12 +469,13 @@ function getLocations() {
|
||||
//------------------------------------------------------------------------------
|
||||
function getDeviceCondition ($deviceStatus) {
|
||||
switch ($deviceStatus) {
|
||||
case 'all': return ''; break;
|
||||
case 'connected': return 'WHERE dev_PresentLastScan=1'; break;
|
||||
case 'new': return 'WHERE dev_NewDevice=1'; break;
|
||||
case 'down': return 'WHERE dev_AlertDeviceDown=1 AND dev_PresentLastScan=0'; break;
|
||||
case 'favorites': return 'WHERE dev_Favorite=1'; break;
|
||||
default: return 'WHERE 1=0'; break;
|
||||
case 'all': return 'WHERE dev_Archived=0'; break;
|
||||
case 'connected': return 'WHERE dev_Archived=0 AND dev_PresentLastScan=1'; break;
|
||||
case 'favorites': return 'WHERE dev_Archived=0 AND dev_Favorite=1'; break;
|
||||
case 'new': return 'WHERE dev_Archived=0 AND dev_NewDevice=1'; break;
|
||||
case 'down': return 'WHERE dev_Archived=0 AND dev_AlertDeviceDown=1 AND dev_PresentLastScan=0'; break;
|
||||
case 'archived': return 'WHERE dev_Archived=1'; break;
|
||||
default: return 'WHERE 1=0'; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
<!-- ----------------------------------------------------------------------- -->
|
||||
<!-- Logo -->
|
||||
<a href="/" class="logo">
|
||||
<a href="." class="logo">
|
||||
<!-- mini logo for sidebar mini 50x50 pixels -->
|
||||
<span class="logo-mini">P<b>a</b></span>
|
||||
<!-- logo for regular state and mobile devices -->
|
||||
@@ -140,7 +140,7 @@
|
||||
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<div class="user-panel">
|
||||
<a href="/" class="logo">
|
||||
<a href="." class="logo">
|
||||
<img src="img/pialertLogoGray80.png" class="img-responsive" alt="Pi.Alert Logo"/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -154,7 +154,6 @@
|
||||
<li class="header">MAIN MENU</li>
|
||||
-->
|
||||
|
||||
<!-- Optionally, you can add icons to the links -->
|
||||
<li class=" <?php if (in_array (basename($_SERVER['SCRIPT_NAME']), array('devices.php', 'deviceDetails.php') ) ){ echo 'active'; } ?>">
|
||||
<a href="devices.php"><i class="fa fa-laptop"></i> <span>Devices</span></a>
|
||||
</li>
|
||||
@@ -177,14 +176,18 @@
|
||||
<i class="fa fa-angle-left pull-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<ul class="treeview-menu">
|
||||
<li><a href="#">Scan Cycles</a></li>
|
||||
<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 -->
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
|
||||
@@ -7,6 +7,30 @@
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
#--------------------------------------------------------------------------- -->
|
||||
|
||||
|
||||
<!-- Modal Default -->
|
||||
<div class="modal fade" id="modal-default" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header" style="background-color: #d0d0d0;">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 id="modal-default-title" class="modal-title"> Modal Default Title </h4>
|
||||
</div>
|
||||
|
||||
<div id="modal-default-message" class="modal-body"> Modal Default message </div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="modal-default-cancel" type="button" class="btn btn-default pull-left" style="min-width: 80px;" data-dismiss="modal"> Cancel </button>
|
||||
<button id="modal-default-OK" type="button" class="btn btn-primary" style="min-width: 80px;" onclick="modalDefaultOK()"> OK </button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modal warning -->
|
||||
<div class="modal modal-warning fade" id="modal-warning" style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
@@ -14,22 +38,24 @@
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 id="modal-title" class="modal-title"> Modal Title </h4>
|
||||
<h4 id="modal-warning-title" class="modal-title"> Modal Title </h4>
|
||||
</div>
|
||||
|
||||
<div id="modal-message" class="modal-body"> Modal message </div>
|
||||
<div id="modal-warning-message" class="modal-body"> Modal message </div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button id="modal-cancel" type="button" class="btn btn-outline pull-left" data-dismiss="modal"> Cancel </button>
|
||||
<button id="modal-OK" type="button" class="btn btn-outline" onclick="modalOK()"> OK </button>
|
||||
<button id="modal-warning-cancel" type="button" class="btn btn-outline pull-left" style="min-width: 80px;" data-dismiss="modal"> Cancel </button>
|
||||
<button id="modal-warning-OK" type="button" class="btn btn-outline" style="min-width: 80px;" onclick="modalWarningOK()"> OK </button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Alert float -->
|
||||
<div id="notification" class="alert alert-dimissible pa_alert_notification">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<div id="alert-message"> Alert message </div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<!-- Content header--------------------------------------------------------- -->
|
||||
<section class="content-header">
|
||||
<h1 id="pageTitle">
|
||||
Presence by Devices
|
||||
Presence by Device
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
@@ -27,66 +27,67 @@
|
||||
<!-- top small box 1 ------------------------------------------------------- -->
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('all');">
|
||||
<div class="small-box bg-aqua pa-small-box-aqua">
|
||||
|
||||
<div class="inner">
|
||||
<h4>All Devices</h4>
|
||||
<h3 id="devicesAll"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-laptop"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-aqua pa-small-box-aqua pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesAll"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-laptop text-aqua-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> All Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 2 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('connected');">
|
||||
<div class="small-box bg-green pa-small-box-green">
|
||||
|
||||
<div class="inner">
|
||||
<h4>Connected</h4>
|
||||
<h3 id="devicesConnected"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-plug"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="small-box bg-green pa-small-box-green pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesConnected"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-plug text-green-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Connected <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 3 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow">
|
||||
|
||||
<div class="inner">
|
||||
<h4>New Devices</h4>
|
||||
<h3 id="devicesNew"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="ion ion-plus-round"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('favorites');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesFavorites"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-star text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Favorites <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- top small box 4 ------------------------------------------------------- -->
|
||||
<div class="col-lg-3 col-sm-6 col-xs-6">
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('new');">
|
||||
<div class="small-box bg-yellow pa-small-box-yellow pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesNew"> -- </h3> </div>
|
||||
<div class="icon"> <i class="ion ion-plus-round text-yellow-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> New Devices <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- top small box 5 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('down');">
|
||||
<div class="small-box bg-red pa-small-box-red">
|
||||
<div class="small-box bg-red pa-small-box-red pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesDown"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-warning text-red-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Down Alerts <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="inner">
|
||||
<h4>Down Alerts</h4>
|
||||
<h3 id="devicesDown"> -- </h3>
|
||||
</div>
|
||||
|
||||
<div class="icon"> <i class="fa fa-warning"></i> </div>
|
||||
<div class="small-box-footer"> Details <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
<!-- top small box 6 ------------------------------------------------------- -->
|
||||
<div class="col-lg-2 col-sm-4 col-xs-6">
|
||||
<a href="#" onclick="javascript: getDevicesPresence('archived');">
|
||||
<div class="small-box bg-gray pa-small-box-gray pa-small-box-2">
|
||||
<div class="inner"> <h3 id="devicesHidden"> -- </h3> </div>
|
||||
<div class="icon"> <i class="fa fa-eye-slash text-gray-20"></i> </div>
|
||||
<div class="small-box-footer pa-small-box-footer"> Hidden <i class="fa fa-arrow-circle-right"></i> </div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -295,8 +296,10 @@ function getDevicesTotals () {
|
||||
|
||||
$('#devicesAll').html (totalsDevices[0].toLocaleString());
|
||||
$('#devicesConnected').html (totalsDevices[1].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesFavorites').html (totalsDevices[2].toLocaleString());
|
||||
$('#devicesNew').html (totalsDevices[3].toLocaleString());
|
||||
$('#devicesDown').html (totalsDevices[4].toLocaleString());
|
||||
$('#devicesHidden').html (totalsDevices[5].toLocaleString());
|
||||
|
||||
// Timer for refresh data
|
||||
newTimerRefreshData (getDevicesTotals);
|
||||
@@ -311,12 +314,13 @@ function getDevicesPresence (status) {
|
||||
|
||||
// Defini color & title for the status selected
|
||||
switch (deviceStatus) {
|
||||
case 'all': tableTitle = 'Total Devices'; color = 'aqua'; break;
|
||||
case 'all': tableTitle = 'All Devices'; color = 'aqua'; break;
|
||||
case 'connected': tableTitle = 'Connected Devices'; color = 'green'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
case 'new': tableTitle = 'New Devices'; color = 'yellow'; break;
|
||||
case 'down': tableTitle = 'Down Alerts'; color = 'red'; break;
|
||||
case 'favorites': tableTitle = 'Favorites'; color = 'yellow'; break;
|
||||
default: tableTitle = 'Devices'; boxClass = ''; break;
|
||||
case 'archived': tableTitle = 'Archived Devices'; color = 'gray'; break;
|
||||
default: tableTitle = 'Devices'; color = 'gray'; break;
|
||||
}
|
||||
|
||||
// Set title and color
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
|
||||
USE_PYTHON_VERSION=0
|
||||
PYTHON_BIN=python
|
||||
|
||||
FIRST_SCAN_KNOWN=true
|
||||
|
||||
REPORT_MAIL=False
|
||||
REPORT_TO=user@gmail.com
|
||||
@@ -104,7 +106,7 @@ ask_config() {
|
||||
PIHOLE_INSTALL=false
|
||||
if $PIHOLE_ACTIVE ; then
|
||||
msgbox "Pi-hole is already installed in this system." \
|
||||
"Perfect: Pi-hole Installation not necessary"
|
||||
"Perfect: Pi-hole Installation is not necessary"
|
||||
else
|
||||
ask_yesno "Pi-hole is not installed." \
|
||||
"Do you want to install Pi-hole before installing Pi.Alert ?" "YES"
|
||||
@@ -167,6 +169,11 @@ ask_config() {
|
||||
USE_PYTHON_VERSION=$ANSWER
|
||||
fi
|
||||
|
||||
# Ask first scan options
|
||||
ask_yesno "First Scan options" \
|
||||
"Do you want to mark the new devices as known devices during the first scan?" "YES"
|
||||
FIRST_SCAN_KNOWN=$ANSWER
|
||||
|
||||
# Ask e-mail notification config
|
||||
MAIL_REPORT=false
|
||||
ask_yesno "Pi.Alert can notify you by e-mail when a network event occurs" \
|
||||
@@ -216,7 +223,7 @@ ask_config() {
|
||||
fi
|
||||
|
||||
# Final config message
|
||||
msgbox "Configuration finished. To updete the configuration, edit file:" \
|
||||
msgbox "Configuration finished. To update the configuration, edit file:" \
|
||||
"$PIALERT_HOME/config/pialert.conf"
|
||||
|
||||
msgbox "" "The installation will start now"
|
||||
@@ -377,7 +384,7 @@ install_python() {
|
||||
print_msg "- Using Python 3"
|
||||
else
|
||||
print_msg "- Installing Python 3..."
|
||||
sudo apt-get install python -y 2>&1 >> "$LOG"
|
||||
sudo apt-get install python3 -y 2>&1 >> "$LOG"
|
||||
fi
|
||||
PYTHON_BIN="python3"
|
||||
else
|
||||
@@ -499,16 +506,22 @@ set_pialert_parameter() {
|
||||
test_pialert() {
|
||||
print_msg "- Testing Pi.Alert HW vendors database update process..."
|
||||
print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..."
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 | tee -ai "$LOG"
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py update_vendors_silent 2>&1 | tee -ai "$LOG"
|
||||
|
||||
echo ""
|
||||
print_msg "- Testing Pi.Alert Internet IP Lookup..."
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG"
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py internet_IP 2>&1 | tee -ai "$LOG"
|
||||
|
||||
echo ""
|
||||
print_msg "- Testing Pi.Alert Network scan..."
|
||||
print_msg "*** PLEASE WAIT A COUPLE OF MINUTES..."
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG"
|
||||
stdbuf -i0 -o0 -e0 $PYTHON_BIN $PIALERT_HOME/back/pialert.py 1 2>&1 | tee -ai "$LOG"
|
||||
|
||||
if $FIRST_SCAN_KNOWN ; then
|
||||
echo ""
|
||||
print_msg "- Set devices as Known devices..."
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "UPDATE Devices SET dev_NewDevice=0, dev_AlertEvents=0" 2>&1 >> "$LOG"
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
207
install/pialert_uninstall.sh
Normal file
207
install/pialert_uninstall.sh
Normal file
@@ -0,0 +1,207 @@
|
||||
#!/bin/bash
|
||||
# ------------------------------------------------------------------------------
|
||||
# Pi.Alert
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
#
|
||||
# pialert_uninstall.sh - Uninstallation script
|
||||
# ------------------------------------------------------------------------------
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Variables
|
||||
# ------------------------------------------------------------------------------
|
||||
COLS=70
|
||||
ROWS=12
|
||||
|
||||
INSTALL_DIR=~
|
||||
PIALERT_HOME="$INSTALL_DIR/pialert"
|
||||
|
||||
LIGHTTPD_CONF_DIR="/etc/lighttpd"
|
||||
WEBROOT="/var/www/html"
|
||||
|
||||
LOG="pialert_uninstall_`date +"%Y-%m-%d_%H-%M"`.log"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Main
|
||||
# ------------------------------------------------------------------------------
|
||||
main() {
|
||||
print_superheader "Pi.Alert Uninstallation"
|
||||
log "`date`"
|
||||
log "Logfile: $LOG"
|
||||
|
||||
# Ask uninstallation
|
||||
ask_yesno "This script will uninstall Pi.Alert from this system.\nUninstall path: $PIALERT_HOME" \
|
||||
"Do you want to continue ?"
|
||||
if ! $ANSWER ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msgbox "" "The uninstallation process will start now"
|
||||
|
||||
# Uninstall prrocess
|
||||
print_header "Removing files"
|
||||
sudo rm -r "$PIALERT_HOME" 2>&1 >> "$LOG"
|
||||
sudo rm "$WEBROOT/pialert" 2>&1 >> "$LOG"
|
||||
sudo rm "$LIGHTTPD_CONF_DIR/conf-available/pialert_front.conf" 2>&1 >> "$LOG"
|
||||
sudo rm "$LIGHTTPD_CONF_DIR/conf-enabled/pialert_front.conf" 2>&1 >> "$LOG"
|
||||
sudo rm -r /var/cache/lighttpd/compress/pialert 2>&1 >> "$LOG"
|
||||
|
||||
# Removing
|
||||
print_header "Removing Pi.Alert DNS name"
|
||||
if [ -f /etc/pihole/custom.list ] ; then
|
||||
sudo sed -i '/pi.alert/d' /etc/pihole/custom.list 2>&1 >> "$LOG"
|
||||
sudo pihole restartdns 2>&1 >> "$LOG"
|
||||
fi
|
||||
|
||||
# Uninstall crontab jobs
|
||||
print_header "Removing crontab jobs"
|
||||
crontab -l 2>/dev/null | sed '/pialert.py/d' | sed ':a;N;$!ba;s/#-------------------------------------------------------------------------------\n# Pi.Alert\n# Open Source Network Guard \/ WIFI & LAN intrusion detector \n#\n# pialert.cron - Back module. Crontab jobs\n#-------------------------------------------------------------------------------\n# Puche 2021 pi.alert.application@gmail.com GNU GPLv3\n#-------------------------------------------------------------------------------//g' | crontab -
|
||||
|
||||
# final message
|
||||
print_header "Uninstallation process finished"
|
||||
print_msg "Note1: If you installed Pi-hole during the Pi.Alert installation process"
|
||||
print_msg " Pi-hole will still be available after uninstalling Pi.Alert"
|
||||
print_msg ""
|
||||
print_msg "Note2: lighttpd, PHP, arp-scan & Python have not been uninstalled."
|
||||
print_msg " They may be required by other software"
|
||||
print_msg " You can uninstall them manually with command 'apt-get remove XX'"
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ASK
|
||||
# ------------------------------------------------------------------------------
|
||||
msgbox() {
|
||||
LINE1=$(printf "%*s" $(((${#1}+$COLS-5)/2)) "$1")
|
||||
LINE2=$(printf "%*s" $(((${#2}+$COLS-5)/2)) "$2")
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
whiptail --title "Pi.Alert Installation" --msgbox "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
BUTTON=$?
|
||||
ask_cancel
|
||||
ANSWER=true
|
||||
done
|
||||
}
|
||||
|
||||
ask_yesno() {
|
||||
LINE1=$(printf "%*s" $(((${#1}+$COLS-5)/2)) "$1")
|
||||
LINE2=$(printf "%*s" $(((${#2}+$COLS-5)/2)) "$2")
|
||||
|
||||
if [ "$3" = "YES" ]; then
|
||||
DEF_BUTTON=""
|
||||
else
|
||||
DEF_BUTTON="--defaultno"
|
||||
fi
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
whiptail --title "Pi.Alert Installation" --yesno $DEF_BUTTON "$LINE1\\n\\n$LINE2" $ROWS $COLS
|
||||
BUTTON=$?
|
||||
ask_cancel
|
||||
done
|
||||
|
||||
if [ "$BUTTON" = "0" ] ; then
|
||||
ANSWER=true
|
||||
else
|
||||
ANSWER=false
|
||||
fi
|
||||
}
|
||||
|
||||
ask_option() {
|
||||
MENU_ARGS=("$@")
|
||||
MENU_ARGS=("${MENU_ARGS[@]:1}")
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
ANSWER=$(whiptail --title "Pi.Alert Installation" --menu "$1" $ROWS $COLS "${MENU_ARGS[@]}" 3>&2 2>&1 1>&3 )
|
||||
BUTTON=$?
|
||||
ask_cancel CANCEL
|
||||
done
|
||||
}
|
||||
|
||||
ask_input() {
|
||||
LINE1=$(printf "%*s" $(((${#1}+$COLS-5)/2)) "$1")
|
||||
LINE2=$(printf "%*s" $(((${#2}+$COLS-5)/2)) "$2")
|
||||
|
||||
END_DIALOG=false
|
||||
while ! $END_DIALOG ; do
|
||||
ANSWER=$(whiptail --title "Pi.Alert Installation" --inputbox "$LINE1\\n\\n$LINE2" $ROWS $COLS "$3" 3>&2 2>&1 1>&3 )
|
||||
BUTTON=$?
|
||||
ask_cancel CANCEL
|
||||
|
||||
if $END_DIALOG && [ "$ANSWER" = "" ] ; then
|
||||
msgbox "" "You must enter a value"
|
||||
END_DIALOG=false
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ask_cancel() {
|
||||
LINE0="Do you want to cancel the installation process"
|
||||
LINE0=$(printf "\n\n%*s" $(((${#LINE0}+$COLS-5)/2)) "$LINE0")
|
||||
|
||||
if [ "$BUTTON" = "1" ] && [ "$1" = "CANCEL" ] ; then BUTTON="255"; fi
|
||||
|
||||
if [ "$BUTTON" = "255" ] ; then
|
||||
whiptail --title "Pi.Alert Installation" --yesno --defaultno "$LINE0" $ROWS $COLS
|
||||
|
||||
if [ "$?" = "0" ] ; then
|
||||
process_error "Installation Aborted by User"
|
||||
fi
|
||||
else
|
||||
END_DIALOG=true
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Log
|
||||
# ------------------------------------------------------------------------------
|
||||
log() {
|
||||
echo "$1" | tee -a "$LOG"
|
||||
}
|
||||
|
||||
log_no_screen () {
|
||||
echo "$1" >> "$LOG"
|
||||
}
|
||||
|
||||
log_only_screen () {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
print_msg() {
|
||||
log_no_screen ""
|
||||
log "$1"
|
||||
}
|
||||
|
||||
print_superheader() {
|
||||
log ""
|
||||
log "############################################################"
|
||||
log " $1"
|
||||
log "############################################################"
|
||||
}
|
||||
|
||||
print_header() {
|
||||
log ""
|
||||
log "------------------------------------------------------------"
|
||||
log " $1"
|
||||
log "------------------------------------------------------------"
|
||||
}
|
||||
|
||||
process_error() {
|
||||
log ""
|
||||
log "************************************************************"
|
||||
log "************************************************************"
|
||||
log "** ERROR UNINSTALLING PI.ALERT **"
|
||||
log "************************************************************"
|
||||
log "************************************************************"
|
||||
log ""
|
||||
|
||||
# msgbox "****** ERROR UNINSTALLING Pi.ALERT ******" "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
main
|
||||
exit 0
|
||||
@@ -51,8 +51,9 @@ main() {
|
||||
# Create backup
|
||||
# ------------------------------------------------------------------------------
|
||||
create_backup() {
|
||||
print_msg "- Deleting previous Pi.Alert backups..."
|
||||
rm "$INSTALL_DIR/"pialert_update_backup_*.tar 2>/dev/null || :
|
||||
# Previous backups are not deleted
|
||||
# print_msg "- Deleting previous Pi.Alert backups..."
|
||||
# rm "$INSTALL_DIR/"pialert_update_backup_*.tar 2>/dev/null || :
|
||||
|
||||
print_msg "- Creating new Pi.Alert backup..."
|
||||
cd "$INSTALL_DIR"
|
||||
@@ -128,6 +129,10 @@ update_config() {
|
||||
if ! grep -Fq QUERY_MYIP_SERVER "$PIALERT_HOME/config/pialert.conf" ; then
|
||||
echo "QUERY_MYIP_SERVER = 'http://ipv4.icanhazip.com'" >> "$PIALERT_HOME/config/pialert.conf"
|
||||
fi
|
||||
|
||||
if ! grep -Fq SCAN_SUBNETS "$PIALERT_HOME/config/pialert.conf" ; then
|
||||
echo "SCAN_SUBNETS = '--localnet'" >> "$PIALERT_HOME/config/pialert.conf"
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -138,6 +143,9 @@ update_db() {
|
||||
sudo chgrp -R www-data $PIALERT_HOME/db 2>&1 >> "$LOG"
|
||||
chmod -R 770 $PIALERT_HOME/db 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Installing sqlite3..."
|
||||
sudo apt-get install sqlite3 -y 2>&1 >> "$LOG"
|
||||
|
||||
print_msg "- Checking 'Parameters' table..."
|
||||
TAB=`sqlite3 $PIALERT_HOME/db/pialert.db "SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='Parameters' COLLATE NOCASE;"` 2>&1 >> "$LOG"
|
||||
if [ "$TAB" == "0" ] ; then
|
||||
@@ -159,6 +167,16 @@ update_db() {
|
||||
print_msg " - Adding column 'Location' to 'Devices'..."
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "ALTER TABLE Devices ADD COLUMN dev_Location STRING(250) COLLATE NOCASE;" 2>&1 >> "$LOG"
|
||||
fi
|
||||
|
||||
COL=`sqlite3 $PIALERT_HOME/db/pialert.db "SELECT COUNT(*) FROM PRAGMA_TABLE_INFO ('Devices') WHERE name='dev_Archived' COLLATE NOCASE";` 2>&1 >> "$LOG"
|
||||
if [ "$COL" == "0" ] ; then
|
||||
print_msg " - Adding column 'Archived / Hidden' to 'Devices'..."
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "ALTER TABLE Devices ADD COLUMN dev_Archived BOOLEAN NOT NULL DEFAULT (0) CHECK (dev_Archived IN (0, 1) );" 2>&1 >> "$LOG"
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "CREATE INDEX IDX_dev_Archived ON Devices (dev_Archived);" 2>&1 >> "$LOG"
|
||||
fi
|
||||
|
||||
print_msg "- Cheking Internet scancycle..."
|
||||
sqlite3 $PIALERT_HOME/db/pialert.db "UPDATE Devices set dev_ScanCycle=1, dev_AlertEvents=1, dev_AlertDeviceDown=1 WHERE dev_MAC='Internet' AND dev_ScanCycle=0;" 2>&1 >> "$LOG"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user