Notification rework + docs + devDetails

This commit is contained in:
Jokob-sk
2023-10-08 16:28:15 +11:00
parent 122bb29e99
commit 43c57f00d0
9 changed files with 17 additions and 103 deletions

View File

@@ -1,6 +1,6 @@
## Icons overview
Icons are used to visually distinguish devices in the app in most of the device listing tables and the [network tree](/docs/NETWORK_TREE.md). Currently only free [Font Awesome](https://fontawesome.com/search?o=r&m=free) icons (up-to v 6.4.0) are supported (I have an unblockable [sponsorship goal](https://github.com/sponsors/jokob-sk) to add the material design icon pack).
Icons are used to visually distinguish devices in the app in most of the device listing tables and the [network tree](/docs/NETWORK_TREE.md). Currently only free [Font Awesome](https://fontawesome.com/search?o=r&m=free) icons (up-to v 6.4.0) are supported.
![Raspberry Pi with a brand icon](/docs/img/ICONS/devices-icons.png)
@@ -8,6 +8,8 @@ Icons are used to visually distinguish devices in the app in most of the device
You can assign icons individually on each device in the Details tab.
![preview](/docs/img/ICONS/device_icons_preview.gif)
![Raspberry Pi device details](/docs/img/ICONS/device-icon.png)
- You can click into the `Icon` field or click the Pencil (2) icon in the above screenshot to enter any text. Only [free Font Awesome](https://fontawesome.com/search?o=r&m=free) icons in the following format will work:

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -718,6 +718,10 @@ input[readonly] {
}
/* Devices */
#txtIconFA {
min-width: 18px;
}
.drp-edit
{
cursor: pointer;

View File

@@ -146,7 +146,10 @@
<div class="form-group">
<label class="col-sm-3 control-label"><?= lang('DevDetail_MainInfo_Name');?></label>
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtName" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtName');"></i></span>
</div>
</div>
</div>
@@ -156,6 +159,7 @@
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtOwner" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtOwner');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down "></span></button>
@@ -172,6 +176,7 @@
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtDeviceType" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtDeviceType');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false" >
<span class="fa fa-caret-down"></span></button>
@@ -227,6 +232,7 @@
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtGroup" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtGroup');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down"></span>
@@ -244,6 +250,7 @@
<div class="col-sm-9">
<div class="input-group">
<input class="form-control" id="txtLocation" type="text" value="--">
<span class="input-group-addon"><i class="fa fa-pencil pointer" onclick="editDrp('txtLocation');"></i></span>
<div class="input-group-btn">
<button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="fa fa-caret-down"></span></button>
@@ -1818,9 +1825,3 @@ function toggleNetworkConfiguration(disable)
}
</script>
<style>
#txtIconFA {
min-width: 18px;
}
</style>

View File

@@ -36,9 +36,6 @@ def main():
db = DB() # instance of class DB
db.open()
# parser = argparse.ArgumentParser(description='APPRISE publisher Plugin')
# values = parser.parse_args()
# Initialize the Plugin obj output file
plugin_objects = Plugin_Objects(RESULT_FILE)

View File

@@ -112,7 +112,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
const settingGroups = [];
const settingKeyOfLists = [];
// core groups are the ones not generated by plugins
const settingCoreGroups = ['General', 'Email', 'Webhooks', 'Apprise', 'NTFY', 'PUSHSAFER', 'MQTT', 'DynDNS', 'API'];
const settingCoreGroups = ['General'];
// Loop through the settingsArray and collect unique settingGroups

View File

@@ -70,12 +70,6 @@ WEBHOOK_PAYLOAD = 'json'
WEBHOOK_REQUEST_METHOD = 'GET'
WEBHOOK_SECRET = ''
# Apprise
REPORT_APPRISE = False
APPRISE_HOST = ''
APPRISE_URL = ''
APPRISE_PAYLOAD = 'html'
# NTFY
REPORT_NTFY = False
NTFY_HOST = 'https://ntfy.sh'

View File

@@ -1,58 +0,0 @@
import json
import subprocess
import conf
from helper import noti_obj
from logger import logResult, mylog
#-------------------------------------------------------------------------------
def check_config():
if conf.APPRISE_URL == '' or conf.APPRISE_HOST == '':
mylog('none', ['[Check Config] Error: Apprise service not set up correctly. Check your pialert.conf APPRISE_* variables.'])
return False
else:
return True
#-------------------------------------------------------------------------------
def send(msg: noti_obj):
html = msg.html
text = msg.text
payloadData = ''
# limit = 1024 * 1024 # 1MB limit (1024 bytes * 1024 bytes = 1MB)
limit = conf.APPRISE_SIZE
# truncate size
if conf.APPRISE_PAYLOAD == 'html':
if len(msg.html) > limit:
payloadData = msg.html[:limit] + " <h1> (text was truncated)</h1>"
else:
payloadData = msg.html
if conf.APPRISE_PAYLOAD == 'text':
if len(msg.text) > limit:
payloadData = msg.text[:limit] + " (text was truncated)"
else:
payloadData = msg.text
# Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
_json_payload = {
"urls": conf.APPRISE_URL,
"title": "Pi.Alert Notifications",
"format": conf.APPRISE_PAYLOAD,
"body": payloadData
}
try:
# try runnning a subprocess
p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), conf.APPRISE_HOST], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, stderr = p.communicate()
# write stdout and stderr into .log files for debugging if needed
logResult (stdout, stderr) # TO-DO should be changed to mylog
# Log the stdout and stderr
mylog('debug', [stdout, stderr]) # TO-DO should be changed to mylog
except subprocess.CalledProcessError as e:
# An error occurred, handle it
mylog('none', [e.output])

View File

@@ -28,8 +28,6 @@ from publishers.email import (check_config as email_check_config,
send as send_email )
from publishers.ntfy import (check_config as ntfy_check_config,
send as send_ntfy )
from publishers.apprise import (check_config as apprise_check_config,
send as send_apprise)
from publishers.webhook import (check_config as webhook_check_config,
send as send_webhook)
from publishers.pushsafer import (check_config as pushsafer_check_config,
@@ -265,8 +263,6 @@ def get_notifications (db):
return noti_obj(final_json, final_text, final_html)
# mylog('minimal', ['[Notification] Udating API files'])
# send_api()
@@ -307,28 +303,6 @@ def get_notifications (db):
# mylog('verbose', ['[Notification] No changes to report'])
# #-------------------------------------------------------------------------------
# def check_config(service):
# if service == 'email':
# return email_check_config()
# if service == 'apprise':
# return apprise_check_config()
# if service == 'webhook':
# return webhook_check_config()
# if service == 'ntfy':
# return ntfy_check_config ()
# if service == 'pushsafer':
# return pushsafer_check_config()
# if service == 'mqtt':
# return mqtt_check_config()
#-------------------------------------------------------------------------------
# Replacing table headers
def format_table (html, thValue, props, newThValue = ''):