Skip to content

Commit

Permalink
2020.04.14c
Browse files Browse the repository at this point in the history
  • Loading branch information
dorgan committed Apr 15, 2020
1 parent f1d3ac7 commit 3e41bda
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions archive/networkstats-2020.04.14c-x86_64-1.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3824e09de095d3d9a305416c0bb30918 networkstats-2020.04.14c-x86_64-1.txz
Binary file added archive/networkstats-2020.04.14c-x86_64-1.txz
Binary file not shown.
5 changes: 4 additions & 1 deletion networkstats.plg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "networkstats">
<!ENTITY author "Donald Organ">
<!ENTITY version "2020.04.14b">
<!ENTITY version "2020.04.14c">
<!ENTITY launch "Settings/NetworkStats">
<!ENTITY branch "master">
<!ENTITY gitURL "https://raw.githubusercontent.com/dorgan/Unraid-&name;/&branch;">
Expand All @@ -25,6 +25,9 @@

<CHANGES>
##&name;
###2020.04.14c
- Added the ability to set an alias (friendly name) for each interface

###2020.04.14b
- Correcting PHP syntax issue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if (file_exists($cfg_file)) {
$selectedInterfaces = '';
}


$active = (intval(trim(shell_exec( "[ -f /proc/`cat /var/run/vnstat/vnstat.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" ))) === 1);
$running = '<span class="green" id="serviceStatus">Running <a href="/plugins/' . $plugin .'/service.php?action=stop" class="xhr">stop</a></span>';
$stopped = '<span class="orange" id="serviceStatus">Stopped <a href="/plugins/' . $plugin .'/service.php?action=start" class="xhr">start</a></span>';
Expand All @@ -29,14 +28,32 @@ function prepareSettings(form) {
if (interfaces.length) interfaces += ',';
interfaces += item.value;
item.selected = false;
$('#alias-' + item.value).toggle();
}
}
item = form.interfaces.options[0];
item.value = interfaces;
item.selected = true;
}
$(function(){
$('#interfaces').dropdownchecklist({emptyText:'None', width:<?=strstr('gray,azure',$display['theme'])?300:300?>, firstItemChecksAll: true, explicitClose:'...close'});
$('#interfaces').dropdownchecklist({
emptyText:'None',
width:<?=strstr('gray,azure',$display['theme'])?300:300?>,
firstItemChecksAll: true,
explicitClose:'...close',
onItemClick: function(checkbox, selector) {
var val = checkbox[0].value;
if (val !== "") {
$('#alias-' + val ).toggle(100);
} else {
if (checkbox[0].checked === true) {
$('.interface-alias-row').show(100);
} else {
$('.$interface-alias-row').hide(100);
}
}
}
});
$('.hxr').on('click', function(e) {
e.preventDefault();
$.get($(this).attr('href'), function(data) {
Expand All @@ -62,6 +79,20 @@ foreach( $interfaces as $interface) {
?>
</select>
</div>
<h3>Aliases</h3>
<table border="0" cellspacing="4">
<?php
$selectedInterfaces = explode(',', $selectedInterfaces);
foreach($interfaces as $interface) {
$interface = str_replace(':', '', $interface);
echo('<tr id="alias-' . $interface . '" class="interface-alias-row" style="display:' . (in_array($interface, $selectedInterfaces)? 'block' : 'none') . '">');
$key = 'alias-' . $interface;
$alias = (isset($cfg[$key]) ? $cfg[$key] : '' );
echo( '<td width="150"><label for="alias-' .$interface .'-value">' . $interface .'</label> :</td><td><input name="' . $key . '" id="alias-' . $interface . '-value" value="' . $alias . '"/></td>');
echo('</tr>');
}
?>
</table>
<div>
<h4>
<span class="" id="notify-status">VNSTAT Daemon: <?=$status;?></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
Menu="Stats:3"
Title="Network Stats"
Icon="icons/networkstats.png"
---
<?php
$plugin = "networkstats";
$active = (intval(trim(shell_exec( "[ -f /proc/`cat /var/run/vnstat/vnstat.pid 2> /dev/null`/exe ] && echo 1 || echo 0 2> /dev/null" ))) === 1);
Expand All @@ -18,7 +14,17 @@ $vnstat = '/plugins/' . $plugin . '/vnstat.php';
<table border="0">
<?php
foreach ($interfaces as $interface) {
echo ('<tr><td><img src="' .$vnstat .'?i=' . $interface .'&s=y"></td><td><img src="' . $vnstat . '?i=' . $interface .'&style=3&dh=h" /></td></tr>');
$aliasKey = 'alias-' . $interface;
if (isset($cfg[$aliasKey])) {
$alias = trim($cfg[$aliasKey]);
if (empty($alias)) {
$cfg[$aliasKey] = null;
$alias = null;
}
} else {
$alias = null;
}
echo ('<tr><td><img src="' .$vnstat .'?i=' . $interface .'&s=y' . (!is_null($alias) ? '&header=' . urlencode($alias) : '' ) . '"></td><td><img src="' . $vnstat . '?i=' . $interface .'&style=3&dh=h' . (!is_null($alias) ? '&header=' . urlencode($cfg[$aliasKey]) . ' / hourly' : '') .'" /></td></tr>');
}
?>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
$file = tmpfile();
$name = stream_get_meta_data($file);
$cmd = 'vnstati' . (!isset($_GET['s']) ? ' --style ' . $_GET['style'] . ' -' . $_GET['dh'] : ' -s ') . ' -i ' . $_GET['i'] . ' -o ' .$name['uri'];
$cmd = 'vnstati' . (!isset($_GET['s']) ? ' --style ' . $_GET['style'] . ' -' . $_GET['dh'] : ' -s ') . ' -i ' . $_GET['i'] . ' -o ' .$name['uri'] . (isset($_GET['header']) ? ' --headertext "' . urldecode($_GET['header']) . '"' : '');
$output = shell_exec($cmd);
$size = filesize(stream_get_meta_data($file)['uri']);
if (!isset($_GET['debug'])) {
Expand Down

0 comments on commit 3e41bda

Please sign in to comment.