Merge pull request #2204 from unraid/feat/remove-legacy-notifications

feat: remove NotificationsArchive page and related files
This commit is contained in:
tom mortensen
2025-05-24 20:58:23 -07:00
committed by GitHub
6 changed files with 0 additions and 207 deletions
@@ -1,124 +0,0 @@
Menu="UNRAID-OS"
Title="Archived Notifications"
Icon="icon-archive"
Tag="archive"
---
<?PHP
/* Copyright 2005-2023, Lime Technology
* Copyright 2012-2023, Bergware International.
* Copyright 2012, Andrew Hamer-Adams, http://www.pixeleyes.co.nz.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$files = count(glob("{$notify['path']}/archive/*.notify", GLOB_NOSORT));
$filters = mk_option(0,'',_('No filter')).mk_option(0,'alert',_('Alerts')).mk_option(0,'warning',_('Warnings')).mk_option(0,'normal',_('Notices'));
?>
<script>
var rows = [];
var filter = "<?=unscript(_var($_GET,'filter'))?>";
var files = -1;
Array.prototype.remove = function() {
var val, a = arguments, L = a.length, ax;
while (L && this.length) {
val = a[--L];
while ((ax = this.indexOf(val)) !== -1) this.splice(ax, 1);
}
return this;
};
<?if (_var($display,'resize')):?>
function resize() {
$('#archive_list').height(Math.max(window.innerHeight-340,330));
$('#archive_table thead,#archive_table tbody').removeClass('fixed');
$('#archive_table thead tr th').each(function(){$(this).width($(this).width());});
$('#archive_table tbody tr td').each(function(){$(this).width($(this).width());});
$('#archive_table thead,#archive_table tbody').addClass('fixed');
}
<?endif;?>
function archiveList(init) {
clearTimeout(timers.archivelist);
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]) {
files = data[1];
$('#archive_list').html(data[0]);
<?if (_var($display,'resize')):?>
resize();
<?endif;?>
if (init) {
<?if (_var($display,'resize')):?>
$(window).bind('resize',function(){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();
}
$('div.spinner.fixed').hide('slow');
timers.archivelist = setTimeout(archiveList,3000);
});
}
function askConfirmation() {
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';
if ($(extra).is(":visible")) {
$(extra).hide();
rows.remove(row);
} else {
$(extra).show();
rows.push(row);
}
}
$(function(){
$('span.left').append("<span class='right'><select class='filter narrow' onchange='filter=this.value;archiveList()'><?=$filters?></select></span>");
$('select.filter').val(filter);
archiveList(true);
});
// Adjust the width of thead cells when window resizes
</script>
<div class="TableContainer">
<table class="unraid tablesorter left shift" id="archive_table">
<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>
</div>
<input type="button" value="_(Done)_" onclick="done()">
@@ -271,13 +271,6 @@ $(function() {
addBannerWarning("<?=_('System notifications are')?> <b><?=_('disabled')?></b>. <?=_('Click')?> <a href='/Settings/Notifications'><?=_('here')?></a> <?=_('to change notification settings')?>.",true,true);
<?endif;?>
<?endif;?>
var opts = [];
context.settings({above:false});
opts.push({header:"<?=_('Notifications')?>"});
opts.push({text:"<?=_('View')?>",icon:'fa-folder-open-o',action:function(e){e.preventDefault();openNotifier();}});
opts.push({text:"<?=_('History')?>",icon:'fa-file-text-o',action:function(e){e.preventDefault();viewHistory();}});
opts.push({text:"<?=_('Acknowledge')?>",icon:'fa-check-square-o',action:function(e){e.preventDefault();closeNotifier();}});
context.attach('#board',opts);
if (location.pathname.search(/\/(AddVM|UpdateVM|AddContainer|UpdateContainer)/)==-1) {
$('blockquote.inline_help').each(function(i) {
$(this).attr('id','helpinfo'+i);
@@ -486,10 +486,6 @@ function digits(number) {
return 'three';
}
function viewHistory() {
location.replace('/Tools/NotificationsArchive');
}
function flashReport() {
$.post('/webGui/include/Report.php',{cmd:'config'},function(check){
if (check>0) addBannerWarning("<?=_('Your flash drive is corrupted or offline').'. '._('Post your diagnostics in the forum for help').'.'?> <a target='_blank' href='https://docs.unraid.net/go/changing-the-flash-device/'><?=_('See also here')?></a>");
@@ -71,12 +71,6 @@
<? endforeach; ?>
<? unset($buttonPages, $button); ?>
<div class="nav-user show">
<a id="board" href="#" class="hand">
<b id="bell" class="icon-u-bell system"></b>
</a>
</div>
<? if ($themeHelper->isSidebarTheme()): ?>
</div>
<? endif; ?>
@@ -1,55 +0,0 @@
<?PHP
/* 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,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
require_once "$docroot/webGui/include/Secure.php";
require_once "$docroot/webGui/include/Wrappers.php";
// add translations
$_SERVER['REQUEST_URI'] = 'tools';
require_once "$docroot/webGui/include/Translations.php";
$dynamix = parse_plugin_cfg('dynamix',true);
$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; $rows = 0;
foreach ($files as $file) {
$fields = file($file,FILE_IGNORE_NEW_LINES);
if ($filter && $filter != substr($fields[4],11)) continue;
$rows++;
$archive = basename($file);
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>";
}
$c = 0;
foreach ($fields as $field) {
if ($c==5) break;
$text = $field ? (explode('=',$field,2)[1]??"") : "-";
$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='$(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 ($rows==0) echo "<tr><td colspan='6' style='padding-top:12px'><center><em>"._("No notifications present")."</em></center></td></tr>";
echo "\0$rows";
?>
@@ -1,11 +0,0 @@
select.filter {
margin: 0;
}
span.right {
margin-top: -6px;
font-size: 1.3rem !important;
padding: 0 !important;
}
i.red-text {
font-size: 1.6rem;
}