mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 09:39:58 -06:00
Simplify notifications
- Make View, History and Acknowledge the main actions - Remove submenus
This commit is contained in:
@@ -546,34 +546,32 @@ function digits(number) {
|
||||
if (number < 100) return 'two';
|
||||
return 'three';
|
||||
}
|
||||
function openNotifier(filter) {
|
||||
function openNotifier() {
|
||||
$.post('/webGui/include/Notify.php',{cmd:'get',csrf_token:csrf_token},function(msg) {
|
||||
$.each($.parseJSON(msg), function(i, notify) {
|
||||
if (notify.importance==filter) {
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description, {
|
||||
group: notify.importance,
|
||||
header: notify.event+': '+notify.timestamp,
|
||||
theme: notify.file,
|
||||
sticky: true,
|
||||
beforeOpen: function(e,m,o){if ($('div.jGrowl-notification').hasClass(notify.file)) return(false);},
|
||||
afterOpen: function(e,m,o){if (notify.link) $(e).css('cursor','pointer');},
|
||||
click: function(e,m,o){if (notify.link) location.replace(notify.link);},
|
||||
close: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});}
|
||||
});
|
||||
}
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description,{
|
||||
group: notify.importance,
|
||||
header: notify.event+': '+notify.timestamp,
|
||||
theme: notify.file,
|
||||
sticky: true,
|
||||
beforeOpen: function(e,m,o){if ($('div.jGrowl-notification').hasClass(notify.file)) return(false);},
|
||||
afterOpen: function(e,m,o){if (notify.link) $(e).css('cursor','pointer');},
|
||||
click: function(e,m,o){if (notify.link) location.replace(notify.link);},
|
||||
close: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
function closeNotifier(filter) {
|
||||
function closeNotifier() {
|
||||
$.post('/webGui/include/Notify.php',{cmd:'get',csrf_token:csrf_token},function(msg) {
|
||||
$.each($.parseJSON(msg), function(i, notify) {
|
||||
if (notify.importance==filter) $.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});
|
||||
});
|
||||
$('div.jGrowl').find('.'+filter).find('div.jGrowl-close').trigger('click');
|
||||
$('div.jGrowl').find('div.jGrowl-close').trigger('click');
|
||||
});
|
||||
}
|
||||
function viewHistory(filter) {
|
||||
location.replace('/Tools/NotificationsArchive?filter='+filter);
|
||||
function viewHistory() {
|
||||
location.replace('/Tools/NotificationsArchive');
|
||||
}
|
||||
function flashReport() {
|
||||
$.post('/webGui/include/Report.php',{cmd:'config'},function(check){
|
||||
@@ -873,7 +871,7 @@ defaultPage.on('message', function(msg,meta) {
|
||||
case 2:
|
||||
// notifications
|
||||
var bell1 = 0, bell2 = 0, bell3 = 0;
|
||||
$.each($.parseJSON(msg), function(i, notify) {
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
switch (notify.importance) {
|
||||
case 'alert' : bell1++; break;
|
||||
case 'warning': bell2++; break;
|
||||
@@ -881,7 +879,7 @@ defaultPage.on('message', function(msg,meta) {
|
||||
}
|
||||
<?if ($notify['display']==0):?>
|
||||
if (notify.show) {
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description, {
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description,{
|
||||
group: notify.importance,
|
||||
header: notify.event+': '+notify.timestamp,
|
||||
theme: notify.file,
|
||||
@@ -893,14 +891,10 @@ defaultPage.on('message', function(msg,meta) {
|
||||
}
|
||||
<?endif;?>
|
||||
});
|
||||
$('#bell').removeClass('red-orb yellow-orb green-orb').prop('title',"<?=_('Alerts')?> ["+bell1+']\n'+"<?=_('Warnings')?> ["+bell2+']\n'+"<?=_('Notices')?> ["+bell3+']');;
|
||||
$('#bell').removeClass('red-orb yellow-orb green-orb').prop('title',"<?=_('Alerts')?> ["+bell1+']\n'+"<?=_('Warnings')?> ["+bell2+']\n'+"<?=_('Notices')?> ["+bell3+']');
|
||||
if (bell1) $('#bell').addClass('red-orb'); else
|
||||
if (bell2) $('#bell').addClass('yellow-orb'); else
|
||||
if (bell3) $('#bell').addClass('green-orb');
|
||||
|
||||
if (bell1) $('#dropdown-board li.dropdown-submenu:eq(0)').removeClass('disabled'); else $('#dropdown-board li.dropdown-submenu:eq(0)').addClass('disabled').find('.dropdown-menu').hide();
|
||||
if (bell2) $('#dropdown-board li.dropdown-submenu:eq(1)').removeClass('disabled'); else $('#dropdown-board li.dropdown-submenu:eq(1)').addClass('disabled').find('.dropdown-menu').hide();
|
||||
if (bell3) $('#dropdown-board li.dropdown-submenu:eq(2)').removeClass('disabled'); else $('#dropdown-board li.dropdown-submenu:eq(2)').addClass('disabled').find('.dropdown-menu').hide();
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -1081,9 +1075,9 @@ $(function() {
|
||||
var opts = [];
|
||||
context.settings({above:false});
|
||||
opts.push({header:"<?=_('Notifications')?>"});
|
||||
opts.push({text:"<?=_('Alerts')?>",icon:'fa-bell-o',subMenu:[{text:"<?=_('View')?>",icon:'fa-folder-open-o',action:function(e){e.preventDefault();openNotifier('alert');}},{text:"<?=_('History')?>",icon:'fa-file-text-o',action:function(e){e.preventDefault();viewHistory('alert');}},{text:"<?=_('Acknowledge')?>",icon:'fa-check-square-o',action:function(e){e.preventDefault();closeNotifier('alert');}}]});
|
||||
opts.push({text:"<?=_('Warnings')?>",icon:'fa-star-o',subMenu:[{text:"<?=_('View')?>",icon:'fa-folder-open-o',action:function(e){e.preventDefault();openNotifier('warning');}},{text:"<?=_('History')?>",icon:'fa-file-text-o',action:function(e){e.preventDefault();viewHistory('warning');}},{text:"<?=_('Acknowledge')?>",icon:'fa-check-square-o',action:function(e){e.preventDefault();closeNotifier('warning');}}]});
|
||||
opts.push({text:"<?=_('Notices')?>",icon:'fa-sun-o',subMenu:[{text:"<?=_('View')?>",icon:'fa-folder-open-o',action:function(e){e.preventDefault();openNotifier('normal');}},{text:"<?=_('History')?>",icon:'fa-file-text-o',action:function(e){e.preventDefault();viewHistory('normal');}},{text:"<?=_('Acknowledge')?>",icon:'fa-check-square-o',action:function(e){e.preventDefault();closeNotifier('normal');}}]});
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user