mirror of
https://github.com/unraid/webgui.git
synced 2026-05-08 05:12:14 -05:00
Add support for "Notify My Android" notifications
This commit is contained in:
@@ -78,7 +78,7 @@ $fields = ['Event','Subject','Timestamp','Description','Importance','Content'];
|
||||
$xml_file = "webGui/include/NotificationAgents.xml";
|
||||
$xml = @simplexml_load_file($xml_file) or die("Failed to open $xml_file");
|
||||
foreach ($xml->Agent as $agent) {
|
||||
$name = $agent->Name;
|
||||
$name = str_replace(' ','_',$agent->Name);
|
||||
$enabledAgent = agent_fullname("$name.sh", "enabled");
|
||||
$disabledAgent = agent_fullname("$name.sh", "disabled");
|
||||
if (is_file($disabledAgent)) {
|
||||
@@ -101,7 +101,7 @@ foreach ($xml->Agent as $agent) {
|
||||
}
|
||||
}
|
||||
foreach (explode(PHP_EOL,(String) $agent->Script) as $line) if (trim($line)) $script .= trim($line)."{1}";
|
||||
echo '<div id="title" style="position:relative;margin:0px;top:-21px;"><span class="left"><img src="/plugins/dynamix/icons/'.strtolower($name).'.png" class="icon" style="height:16px;width:16px;">'.$name.'</span><span class="status">'.(is_file($enabledAgent) ? '<span class="green">Enabled</span>' : '<span class="red">Disabled</span>').'</span></div>';
|
||||
echo '<div id="title" style="position:relative;margin:0px;top:-21px;"><span class="left"><img src="/plugins/dynamix/icons/'.strtolower(str_replace('_','',$name)).'.png" class="icon" style="height:16px;width:16px;">'.str_replace('_',' ',$name).'</span><span class="status">'.(is_file($enabledAgent) ? '<span class="green">Enabled</span>' : '<span class="red">Disabled</span>').'</span></div>';
|
||||
echo '<form method="POST" name="'.$name.'" action="/update.php" target="progressFrame">';
|
||||
echo '<input type="hidden" name="#include" value="/webGui/include/update.file.php">';
|
||||
echo '<input type="hidden" name="#file" value="'.$file.'">';
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -123,4 +123,41 @@
|
||||
]]>
|
||||
</Script>
|
||||
</Agent>
|
||||
<Agent>
|
||||
<Name>Notify My Android</Name>
|
||||
<Variables>
|
||||
<Variable Help="The API key can be found [a href='https://www.notifymyandroid.com/account.jsp' target='_blank'] [u]here[/u].[/a]" Desc="API key" Default="">API_KEY</Variable>
|
||||
<Variable Help="Application name, e.g., unRAID Server." Desc="Application Name" Default="unRAID Server">APP_NAME</Variable>
|
||||
<Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable>
|
||||
<Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
|
||||
</Variables>
|
||||
<Script>
|
||||
<![CDATA[
|
||||
#!/bin/bash
|
||||
##########
|
||||
{0}
|
||||
##########
|
||||
MESSAGE=$(echo -e "$MESSAGE")
|
||||
case "$IMPORTANCE" in
|
||||
'normal' )
|
||||
PRIORITY="0"
|
||||
;;
|
||||
'warning' )
|
||||
PRIORITY="1"
|
||||
;;
|
||||
'alert' )
|
||||
PRIORITY="2"
|
||||
;;
|
||||
esac
|
||||
|
||||
curl -k -s \
|
||||
-d "apikey=$API_KEY" \
|
||||
-d "application=$APP_NAME" \
|
||||
-d "event=$TITLE" \
|
||||
-d "description=$MESSAGE" \
|
||||
-d "priority=$PRIORITY" \
|
||||
https://www.notifymyandroid.com/publicapi/notify 2>&1
|
||||
]]>
|
||||
</Script>
|
||||
</Agent>
|
||||
</Agents>
|
||||
|
||||
Reference in New Issue
Block a user