mirror of
https://github.com/unraid/webgui.git
synced 2026-01-20 08:30:14 -06:00
Merge pull request #1269 from bergware/master
Notifications: fixes and enhancements
This commit is contained in:
@@ -208,6 +208,7 @@ i.vpn{font-size:1.4rem!important;cursor:pointer}
|
||||
i.indent{display:inline-block;width:18px}
|
||||
i.f32{font-size:32px!important}
|
||||
i.f14{font-size:1.4rem!important}
|
||||
i.fa.orb{margin-left:0}
|
||||
i[class^="icon-"]{font-size:1.6rem;margin-right:8px}
|
||||
i[class^="icon-u-"]{font-size:inherit}
|
||||
i#mycase[class^="case-"]{font-size:128px}
|
||||
@@ -827,9 +828,9 @@ function loadlist(init) {
|
||||
}
|
||||
$.post('/webGui/include/DashboardApps.php',{display:'<?=$display['dashapps']?>',docker:'<?=$dockerd?>',vms:'<?=$libvirtd?>'},function(d) {
|
||||
var data = d.split('\0');
|
||||
$('#docker_view').find('tr.updated').remove();
|
||||
$('#docker_view tr.updated').remove();
|
||||
$('#docker_view').append(data[0]);
|
||||
$('#vm_view').find('tr.updated').remove();
|
||||
$('#vm_view tr.updated').remove();
|
||||
$('#vm_view').append(data[1]);
|
||||
if ($.cookie('my_apps')!=null) $('span.apps.stopped').hide(0,noApps());
|
||||
if ($.cookie('my_vms')!=null) $('span.vms.stopped').hide(0,noVMs());
|
||||
@@ -1068,12 +1069,12 @@ function addProperties() {
|
||||
});
|
||||
}
|
||||
function showContent() {
|
||||
var count = {'db-box1':$('table#db-box1').find('tbody').length, 'db-box2':$('table#db-box2').find('tbody').length, 'db-box3':$('table#db-box3').find('tbody').length}
|
||||
var count = {'db-box1':$('table#db-box1 tbody').length, 'db-box2':$('table#db-box2 tbody').length, 'db-box3':$('table#db-box3 tbody').length}
|
||||
var inactive = $.cookie('inactive_content');
|
||||
if (inactive) {
|
||||
inactive = inactive.split(';');
|
||||
for (var n=0,x; x=inactive[n]; n++) {
|
||||
var tbody = $('table.dashboard').find('tbody[sort="'+x+'"]');
|
||||
var tbody = $('table.dashboard tbody[sort="'+x+'"]');
|
||||
var id = tbody.parent().prop('id');
|
||||
count[id]--;
|
||||
tbody.hide();
|
||||
@@ -1150,10 +1151,10 @@ function LockButton() {
|
||||
if ($.cookie('lockbutton') == null) {
|
||||
$.cookie('lockbutton','lockbutton');
|
||||
<?if ($themes1):?>
|
||||
$('div.nav-item.LockButton').find('a').prop('title',"_(Lock sortable items)_");
|
||||
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock red-text').addClass('icon-u-lock-open green-text');
|
||||
$('div.nav-item.LockButton a').prop('title',"_(Lock sortable items)_");
|
||||
$('div.nav-item.LockButton b').removeClass('icon-u-lock red-text').addClass('icon-u-lock-open green-text');
|
||||
<?endif;?>
|
||||
$('div.nav-item.LockButton').find('span').text("_(Lock sortable items)_");
|
||||
$('div.nav-item.LockButton span').text("_(Lock sortable items)_");
|
||||
$('#db-box1,#db-box2,#db-box3').sortable({connectWith:'#db-box1,#db-box2,#db-box3'});
|
||||
$('table.dashboard').sortable({helper:sortableHelper,items:'.sortable',cursor:'grab',delay:100,opacity:0.5,zIndex:9999,forcePlaceholderSize:true,
|
||||
receive:function(e,ui){
|
||||
@@ -1171,10 +1172,10 @@ function LockButton() {
|
||||
} else {
|
||||
$.removeCookie('lockbutton');
|
||||
<?if ($themes1):?>
|
||||
$('div.nav-item.LockButton').find('a').prop('title',"_(Unlock sortable items)_");
|
||||
$('div.nav-item.LockButton').find('b').removeClass('icon-u-lock-open green-text').addClass('icon-u-lock red-text');
|
||||
$('div.nav-item.LockButton a').prop('title',"_(Unlock sortable items)_");
|
||||
$('div.nav-item.LockButton b').removeClass('icon-u-lock-open green-text').addClass('icon-u-lock red-text');
|
||||
<?endif;?>
|
||||
$('div.nav-item.LockButton').find('span').text("_(Unlock sortable items)_");
|
||||
$('div.nav-item.LockButton span').text("_(Unlock sortable items)_");
|
||||
$('table.dashboard').sortable('destroy');
|
||||
}
|
||||
}
|
||||
@@ -1220,7 +1221,7 @@ dashboard.on('message',function(msg,meta) {
|
||||
var data = part[0].split('\0');
|
||||
var info = moreInfo(data,"_(Array)_");
|
||||
// array devices
|
||||
$('#array_list').find('tr.updated').remove();
|
||||
$('#array_list tr.updated').remove();
|
||||
$('#array_list').append(data[0]);
|
||||
$('#array_info').parent().css('display',info?'':'none');
|
||||
$('#array_info').html(info);
|
||||
@@ -1230,7 +1231,7 @@ dashboard.on('message',function(msg,meta) {
|
||||
for (var i=0,t; t=text[i]; i++) {
|
||||
var data = t.split('\0');
|
||||
var info = moreInfo(data,"_(Cache)_");
|
||||
$('#pool_list'+i).find('tr.updated').remove();
|
||||
$('#pool_list'+i+' tr.updated').remove();
|
||||
$('#pool_list'+i).append(t);
|
||||
$('#pool_info'+i).parent().css('display',info?'':'none');
|
||||
$('#pool_info'+i).html(info);
|
||||
@@ -1240,7 +1241,7 @@ dashboard.on('message',function(msg,meta) {
|
||||
// unassigned devices
|
||||
var data = part[2].split('\0');
|
||||
var info = moreInfo(data,"_(Unassigned)_");
|
||||
$('#devs_list').find('tr.updated').remove();
|
||||
$('#devs_list tr.updated').remove();
|
||||
$('#devs_list').append(data[0]);
|
||||
$('#devs_info').parent().css('display',info?'':'none');
|
||||
$('#devs_info').html(info);
|
||||
|
||||
@@ -23,9 +23,14 @@ $filters = mk_option(0,'',_('No filter')).mk_option(0,'alert',_('Alerts')).mk_op
|
||||
<style>
|
||||
select.filter{margin:0}
|
||||
span.right{margin-top:-6px;font-size:1.3rem!important;padding:0!important}
|
||||
i.red-text{font-size:1.6rem}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
var rows = [];
|
||||
var filter = "<?=unscript($_GET['filter']??'')?>";
|
||||
var files = -1;
|
||||
|
||||
Array.prototype.remove = function() {
|
||||
var val, a = arguments, L = a.length, ax;
|
||||
while (L && this.length) {
|
||||
@@ -47,27 +52,42 @@ function resize(bind) {
|
||||
}
|
||||
}
|
||||
<?endif;?>
|
||||
function archiveList(init=false,filter='') {
|
||||
function archiveList(init) {
|
||||
clearTimeout(timers.archivelist);
|
||||
timers.archive = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
|
||||
$.get('/webGui/include/NotificationsArchive.php',{filter:"<?=unscript($_GET['filter']??'')?>"||filter},function(data) {
|
||||
$.get('/webGui/include/NotificationsArchive.php',{filter:filter},function(data) {
|
||||
clearTimeout(timers.archive);
|
||||
if (data) $('#archive_list').html(data);
|
||||
if (init) {
|
||||
<?if ($display['resize']):?>
|
||||
resize();
|
||||
<?endif;?>
|
||||
$('#archive_table').tablesorter({headers:{5:{sorter:false}},textAttribute:'data'});
|
||||
} else {
|
||||
$('#archive_table').trigger('update');
|
||||
data = data.split('\0');
|
||||
if (data[1]>0) $('#deleteAll').show(); else $('#deleteAll').hide();
|
||||
if (files != data[1]) {
|
||||
files = data[1];
|
||||
$('#archive_list').html(data[0]);
|
||||
if (init) {
|
||||
<?if ($display['resize']):?>
|
||||
resize();
|
||||
<?endif;?>
|
||||
$('#archive_table').tablesorter({headers:{5:{sorter:false}},textAttribute:'data'});
|
||||
} else {
|
||||
$('#archive_table').trigger('update');
|
||||
}
|
||||
$('#archive_list .tablesorter-childRow td').hide();
|
||||
for (var i=0; i<rows.length; i++) $('#archive_list .tablesorter-childRow.row'+rows[i]+' td').show();
|
||||
}
|
||||
$('#archive_list .tablesorter-childRow td').hide();
|
||||
for (var i = 0; i < rows.length; i++) $('#archive_list .tablesorter-childRow.row'+rows[i]+' td').show();
|
||||
$('div.spinner.fixed').hide('slow');
|
||||
setTimeout(archiveList,30000);
|
||||
timers.archivelist = setTimeout(archiveList,3000);
|
||||
});
|
||||
}
|
||||
function askConfirmation() {
|
||||
swal({title:"_(Are you sure)_?",text:"_(This will delete all notification files)_!",type:"warning",html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){$.post('/webGui/include/DeleteLogFile.php',{log:'*.notify'},function(){archiveList();});});
|
||||
swal({
|
||||
title:"_(Are you sure)_?",
|
||||
text: filter=='' ? "_(This will delete all notification files)_!" : "_(This will delete the selected notification files)_!",
|
||||
type:"warning",
|
||||
html:true,
|
||||
showCancelButton:true,
|
||||
confirmButtonText:"_(Proceed)_",
|
||||
cancelButtonText:"_(Cancel)_"
|
||||
},
|
||||
function(){$.post('/webGui/include/DeleteLogFile.php',{log:'*.notify',filter:filter},function(){$('#deleteAll').hide();archiveList();});});
|
||||
}
|
||||
function openClose(row) {
|
||||
var extra = '#archive_list .tablesorter-childRow.row'+row+' td';
|
||||
@@ -80,7 +100,8 @@ function openClose(row) {
|
||||
}
|
||||
}
|
||||
$(function(){
|
||||
$('span.left').append("<span class='right'><select class='filter narrow' onchange='archiveList(false,this.value)'><?=$filters?></select></span>");
|
||||
$('span.left').append("<span class='right'><select class='filter narrow' onchange='filter=this.value;archiveList()'><?=$filters?></select></span>");
|
||||
$('select.filter').val(filter);
|
||||
archiveList(true);
|
||||
<?if ($display['resize']):?>
|
||||
$(window).bind('resize',function(){resize(true);});
|
||||
@@ -90,7 +111,7 @@ $(function(){
|
||||
// Adjust the width of thead cells when window resizes
|
||||
</script>
|
||||
<table class="tablesorter left shift" id="archive_table">
|
||||
<thead><tr><th>_(Time)_</th><th>_(Event)_</th><th>_(Subject)_</th><th>_(Description)_</th><th>_(Importance)_</th><th><?if ($files):?><a href="#" onclick="askConfirmation();return false" title="_(Delete all notifications)_"><i class="fa fa-trash"></i></a><?endif;?></th></tr></thead>
|
||||
<thead><tr><th>_(Time)_</th><th>_(Event)_</th><th>_(Subject)_</th><th>_(Description)_</th><th>_(Importance)_</th><th><a id="deleteAll" href="#" onclick="askConfirmation();return false" title="_(Delete all notifications)_" style="display:none"><i class="fa fa-trash-o red-text"></i></a></th></tr></thead>
|
||||
<tbody id="archive_list"><tr><td colspan="6"></td></tr></tbody>
|
||||
</table>
|
||||
<input type="button" value="_(Done)_" onclick="done()">
|
||||
|
||||
@@ -89,7 +89,7 @@ if ($themes2) {
|
||||
}
|
||||
$notes = '/var/tmp/unRAIDServer.txt';
|
||||
if (!file_exists($notes)) file_put_contents($notes,shell_exec("$docroot/plugins/dynamix.plugin.manager/scripts/plugin changes $docroot/plugins/unRAIDServer/unRAIDServer.plg"));
|
||||
$notes = " <span class='fa fa-info-circle fa-fw big blue-text' title='"._('View Release Notes')."' onclick=\"openChanges('showchanges $notes','"._('Release Notes')."')\"></span>";
|
||||
$notes = " <span class='big blue-text fa fa-info-circle fa-fw' title='"._('View Release Notes')."' onclick=\"openChanges('showchanges $notes','"._('Release Notes')."')\"></span>";
|
||||
?>
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -15,11 +15,26 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$dynamix = parse_plugin_cfg('dynamix',true);
|
||||
$killfiles = [];
|
||||
if (strpos($_POST['log'],'*')===false) $killfiles = [ realpath("{$dynamix['notify']['path']}/archive/{$_POST['log']}") ]; else $killfiles = glob("{$dynamix['notify']['path']}/archive/{$_POST['log']}",GLOB_NOSORT);
|
||||
foreach ($killfiles as $killfile) {
|
||||
if (strpos($killfile, "{$dynamix['notify']['path']}/archive/") === 0) {
|
||||
@unlink($killfile);
|
||||
}
|
||||
$unread = $dynamix['notify']['path']."/unread/";
|
||||
$archive = $dynamix['notify']['path']."/archive";
|
||||
$log = $_POST['log']??'';
|
||||
$filter = $_POST['filter']??false;
|
||||
$files = strpos($log,'*')===false ? [realpath("$archive/$log")] : glob("$archive/$log",GLOB_NOSORT);
|
||||
|
||||
function delete_file(...$file) {
|
||||
array_map('unlink',array_filter($file,'file_exists'));
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
// check file path
|
||||
if (strncmp($file,$archive,strlen($archive))!==0) continue;
|
||||
$list = $unread.basename($file);
|
||||
if (!$filter) {
|
||||
// delete all files
|
||||
delete_file($file,$list);
|
||||
} else {
|
||||
// delete selective files
|
||||
if (exec("grep -om1 'importance=$filter' ".escapeshellarg($file))) delete_file($file,$list);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -19,17 +19,18 @@ require_once "$docroot/webGui/include/Secure.php";
|
||||
require_once "$docroot/webGui/include/Wrappers.php";
|
||||
|
||||
$dynamix = parse_plugin_cfg('dynamix',true);
|
||||
$filter = unscript($_GET['filter']??'');
|
||||
$files = glob("{$dynamix['notify']['path']}/archive/*.notify", GLOB_NOSORT);
|
||||
$filter = unscript($_GET['filter']??false);
|
||||
$files = glob("{$dynamix['notify']['path']}/archive/*.notify",GLOB_NOSORT);
|
||||
|
||||
usort($files, function($a,$b){return filemtime($b)-filemtime($a);});
|
||||
|
||||
$row = 1; $empty = true;
|
||||
$row = 1; $rows = 0;
|
||||
foreach ($files as $file) {
|
||||
$fields = explode(PHP_EOL, file_get_contents($file));
|
||||
$fields = file($file,FILE_IGNORE_NEW_LINES);
|
||||
if ($filter && $filter != substr($fields[4],11)) continue;
|
||||
$empty = false;
|
||||
$rows++;
|
||||
$archive = basename($file);
|
||||
if ($extra = count($fields)>6) {
|
||||
if ($extra = count($fields)>5) {
|
||||
$td_ = "<td data='*' rowspan='3'><a href='#' onclick='openClose($row)'>"; $_td = "</a></td>";
|
||||
} else {
|
||||
$td_ = "<td data='*' style='white-space:nowrap'>"; $_td = "</td>";
|
||||
@@ -41,12 +42,13 @@ foreach ($files as $file) {
|
||||
$tag = ($c<4) ? "" : " data='".str_replace(['alert','warning','normal'],['0','1','2'],$text)."'";
|
||||
echo (!$c++) ? "<tr>".str_replace('*',$text,$td_).date($dynamix['notify']['date'].' '.$dynamix['notify']['time'],$text)."$_td" : "<td$tag>"._($text)."</td>";
|
||||
}
|
||||
echo "<td><a href='#' onclick='$.post(\"/webGui/include/DeleteLogFile.php\",{log:\"$archive\"},function(){archiveList();});return false' title=\""._('Delete notification')."\"><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
echo "<td><a href='#' onclick='$(this).hide();$.post(\"/webGui/include/DeleteLogFile.php\",{log:\"$archive\"},function(){archiveList();});return false' title=\""._('Delete notification')."\"><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
if ($extra) {
|
||||
$text = explode('=',$field,2)[1];
|
||||
echo "<tr class='tablesorter-childRow row$row'><td colspan='4'>$text</td><td></td></tr><tr class='tablesorter-childRow row$row'><td colspan='5'></td></tr>";
|
||||
$row++;
|
||||
}
|
||||
}
|
||||
if ($empty) echo "<tr><td></td><td colspan='4' style='text-align:center;padding-top:12px'><em>"._("No notifications present")."</em></td><td></td></tr>";
|
||||
if ($rows==0) echo "<tr><td colspan='6' style='padding-top:12px'><center><em>"._("No notifications present")."</em></center></td></tr>";
|
||||
echo "\0$rows";
|
||||
?>
|
||||
|
||||
@@ -48,7 +48,7 @@ case 'get':
|
||||
break;
|
||||
case 'hide':
|
||||
$file = $_POST['file']??'';
|
||||
if (file_exists($file) && $file==realpath($file) && pathinfo($file)['extension']=='notify') chmod($file,0000);
|
||||
if (file_exists($file) && $file==realpath($file) && pathinfo($file)['extension']=='notify') chmod($file,0400);
|
||||
break;
|
||||
case 'archive':
|
||||
$file = $_POST['file']??'';
|
||||
|
||||
@@ -206,7 +206,7 @@ case "identify":
|
||||
echo "<tr><td>"._('Manufacturing date').":</td><td><input type='date' class='narrow' value='".($info['date']??'')."' onchange='disklog(\"$disk\",\"date\",this.value)'></td></tr>";
|
||||
echo "<tr><td>"._('Date of purchase').":</td><td><input type='date' class='narrow' value='".($info['purchase']??'')."' onchange='disklog(\"$disk\",\"purchase\",this.value)'></td></tr>";
|
||||
echo "<tr><td>"._('Warranty period').":</td><td><select class='noframe' onchange='disklog(\"$disk\",\"warranty\",this.value)'><option value=''>"._('unknown')."</option>";
|
||||
foreach ($periods as $period) echo "<option value='$period'".($info['warranty']??''==$period?" selected":"").">$period "._('months')."</option>";
|
||||
foreach ($periods as $period) echo "<option value='$period'".(($info['warranty']??'')==$period?" selected":"").">$period "._('months')."</option>";
|
||||
echo "</select></td></tr>";
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -232,7 +232,7 @@ case 'get':
|
||||
$fields = file($file,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$time = true;
|
||||
$output[$i]['file'] = basename($file);
|
||||
$output[$i]['show'] = fileperms($file)==32768 ? 0 : 1;
|
||||
$output[$i]['show'] = (fileperms($file) & 0x0FFF)==0400 ? 0 : 1;
|
||||
foreach ($fields as $field) {
|
||||
if (!$field) continue;
|
||||
[$key,$val] = array_pad(explode('=', $field),2,'');
|
||||
@@ -246,9 +246,8 @@ case 'get':
|
||||
|
||||
case 'archive':
|
||||
if ($argc != 3) exit(usage());
|
||||
if (strpos(realpath("$unread/{$argv[2]}"), $unread.'/') === 0) {
|
||||
@unlink("$unread/{$argv[2]}");
|
||||
}
|
||||
$file = $argv[2];
|
||||
if (strpos(realpath("$unread/$file"),$unread.'/')===0) @unlink("$unread/$file");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user