Files
webgui/emhttp/plugins/dynamix/NotificationsArchive.page
Tom Mortensen f9ec00b488 repo reorg
2023-06-02 12:49:33 -07:00

115 lines
4.2 KiB
Plaintext

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'));
?>
<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(_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>
<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><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()">