From 27cf32f8456031851c00652f84b951bd8af97c04 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 12:20:47 +0100 Subject: [PATCH 01/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 22 +++++++++++++++----- plugins/dynamix/include/DeleteLogFile.php | 25 +++++++++++++++-------- plugins/dynamix/include/Notify.php | 2 +- plugins/dynamix/scripts/notify | 2 +- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index 285cf7250..e4d0a169a 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -24,8 +24,11 @@ $filters = mk_option(0,'',_('No filter')).mk_option(0,'alert',_('Alerts')).mk_op select.filter{margin:0} span.right{margin-top:-6px;font-size:1.3rem!important;padding:0!important} + - +
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
From 7af9b92b63d1501c0b215bec9f96ace4e939a980 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 14:49:31 +0100 Subject: [PATCH 06/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 5 +++-- plugins/dynamix/scripts/notify | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index 0bb9527ec..eb73691eb 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -57,6 +57,7 @@ function archiveList(init) { $.get('/webGui/include/NotificationsArchive.php',{filter:filter},function(data) { clearTimeout(timers.archive); 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]); @@ -70,8 +71,8 @@ function archiveList(init) { } $('#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'); } + $('div.spinner.fixed').hide('slow'); setTimeout(archiveList,3000); }); } @@ -109,7 +110,7 @@ $(function(){ // Adjust the width of thead cells when window resizes - +
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
diff --git a/plugins/dynamix/scripts/notify b/plugins/dynamix/scripts/notify index aa3fa077a..a2b28dd07 100755 --- a/plugins/dynamix/scripts/notify +++ b/plugins/dynamix/scripts/notify @@ -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; } From 08a33bbb7b332337590ddb8946a6183358339317 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 15:35:15 +0100 Subject: [PATCH 07/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 9 +++------ plugins/dynamix/include/DeleteLogFile.php | 10 ++++++++-- plugins/dynamix/include/NotificationsArchive.php | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index eb73691eb..5bd8bf2d5 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -29,7 +29,7 @@ i.red-text{font-size:1.6rem} - +
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
_(Wait)_
diff --git a/plugins/dynamix/include/DeleteLogFile.php b/plugins/dynamix/include/DeleteLogFile.php index 01a97e2f5..99c2d0dd7 100644 --- a/plugins/dynamix/include/DeleteLogFile.php +++ b/plugins/dynamix/include/DeleteLogFile.php @@ -15,20 +15,26 @@ $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'; require_once "$docroot/webGui/include/Wrappers.php"; $dynamix = parse_plugin_cfg('dynamix',true); +$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 - @unlink($file); + delete_file($file,$list); } else { // delete selective files - if (exec("grep -om1 'importance=$filter' ".escapeshellarg($file))) @unlink($file); + if (exec("grep -om1 'importance=$filter' ".escapeshellarg($file))) delete_file($file,$list); } } ?> diff --git a/plugins/dynamix/include/NotificationsArchive.php b/plugins/dynamix/include/NotificationsArchive.php index 25a03d139..3437f0d1f 100644 --- a/plugins/dynamix/include/NotificationsArchive.php +++ b/plugins/dynamix/include/NotificationsArchive.php @@ -49,6 +49,6 @@ foreach ($files as $file) { $row++; } } -if ($rows==0) echo ""._("No notifications present").""; +if ($rows==0) echo "
"._("No notifications present")."
"; echo "\0$rows"; ?> From 282355b403a4db9d389e137b51724bc856c95649 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 16:42:33 +0100 Subject: [PATCH 08/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 10 +++++++--- plugins/dynamix/include/NotificationsArchive.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index 5bd8bf2d5..8c8f4a4a7 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -70,9 +70,13 @@ function archiveList(init) { $('#archive_list .tablesorter-childRow td').hide(); for (var i=0; i"); + $('span.left').append(""); $('select.filter').val(filter); archiveList(true); diff --git a/plugins/dynamix/include/NotificationsArchive.php b/plugins/dynamix/include/NotificationsArchive.php index 3437f0d1f..51b1cabd6 100644 --- a/plugins/dynamix/include/NotificationsArchive.php +++ b/plugins/dynamix/include/NotificationsArchive.php @@ -42,7 +42,7 @@ foreach ($files as $file) { $tag = ($c<4) ? "" : " data='".str_replace(['alert','warning','normal'],['0','1','2'],$text)."'"; echo (!$c++) ? "".str_replace('*',$text,$td_).date($dynamix['notify']['date'].' '.$dynamix['notify']['time'],$text)."$_td" : ""._($text).""; } - echo ""; + echo ""; if ($extra) { $text = explode('=',$field,2)[1]; echo "$text"; From 5c55043daab76da3afa04083ebe3ef27cee1c584 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 16:47:49 +0100 Subject: [PATCH 09/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index 8c8f4a4a7..5e2067f6f 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -53,7 +53,9 @@ function resize(bind) { } function archiveList(init) { + timers.archive = setTimeout(function(){$('div.spinner.fixed').show('slow');},500); $.get('/webGui/include/NotificationsArchive.php',{filter:filter},function(data) { + clearTimeout(timers.archive); data = data.split('\0'); if (data[1]>0) $('#deleteAll').show(); else $('#deleteAll').hide(); if (files != data[1]) { @@ -70,6 +72,7 @@ function archiveList(init) { $('#archive_list .tablesorter-childRow td').hide(); for (var i=0; i - +
_(Time)__(Event)__(Subject)__(Description)__(Importance)_
_(Wait)_
From be2dbed1caf35b8cf463c27813274d90bd1fff6f Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 17:06:19 +0100 Subject: [PATCH 10/20] Notifications: fixes and enhancements --- plugins/dynamix/include/NotificationsArchive.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/include/NotificationsArchive.php b/plugins/dynamix/include/NotificationsArchive.php index 51b1cabd6..eb15a6343 100644 --- a/plugins/dynamix/include/NotificationsArchive.php +++ b/plugins/dynamix/include/NotificationsArchive.php @@ -42,7 +42,7 @@ foreach ($files as $file) { $tag = ($c<4) ? "" : " data='".str_replace(['alert','warning','normal'],['0','1','2'],$text)."'"; echo (!$c++) ? "".str_replace('*',$text,$td_).date($dynamix['notify']['date'].' '.$dynamix['notify']['time'],$text)."$_td" : ""._($text).""; } - echo ""; + echo ""; if ($extra) { $text = explode('=',$field,2)[1]; echo "$text"; From e39d0c57c840525de743018c151c751f2bdfcf83 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 17:13:03 +0100 Subject: [PATCH 11/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index 5e2067f6f..e19dc710b 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -90,7 +90,7 @@ function askConfirmation() { confirmButtonText:"_(Proceed)_", cancelButtonText:"_(Cancel)_" }, - function(){$.post('/webGui/include/DeleteLogFile.php',{log:'*.notify',filter:filter},function(){reloadList();});}); + function(){$.post('/webGui/include/DeleteLogFile.php',{log:'*.notify',filter:filter},function(){$('#deleteAll').hide();reloadList();});}); } function openClose(row) { var extra = '#archive_list .tablesorter-childRow.row'+row+' td'; From a129fcab6caaf04b9abe6045fc02365d350d903f Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 18 Feb 2023 17:18:02 +0100 Subject: [PATCH 12/20] Notifications: fixes and enhancements --- plugins/dynamix/NotificationsArchive.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix/NotificationsArchive.page b/plugins/dynamix/NotificationsArchive.page index e19dc710b..bd6644bad 100644 --- a/plugins/dynamix/NotificationsArchive.page +++ b/plugins/dynamix/NotificationsArchive.page @@ -29,7 +29,7 @@ i.red-text{font-size:1.6rem}