mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 09:39:58 -06:00
feat: add tweaks for the Unraid API
- enables API support for 7.2 - do not merge before the API is integrated, will break notifications - includes authentication fix for now
This commit is contained in:
@@ -71,32 +71,7 @@ defaultPage.on('message', function(msg,meta) {
|
||||
$('#statusbar').html(status);
|
||||
break;
|
||||
case 2:
|
||||
// notifications
|
||||
var bell1 = 0, bell2 = 0, bell3 = 0;
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
switch (notify.importance) {
|
||||
case 'alert' : bell1++; break;
|
||||
case 'warning': bell2++; break;
|
||||
case 'normal' : bell3++; break;
|
||||
}
|
||||
<?if ($notify['display']==0):?>
|
||||
if (notify.show) {
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description,{
|
||||
group: notify.importance,
|
||||
header: notify.event+': '+notify.timestamp,
|
||||
theme: notify.file,
|
||||
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:'hide',file:"<?=$notify['path'].'/unread/'?>"+notify.file,csrf_token:csrf_token}<?if ($notify['life']==0):?>,function(){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});}<?endif;?>);}
|
||||
});
|
||||
}
|
||||
<?endif;?>
|
||||
});
|
||||
$('#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');
|
||||
// notifications - moved to the Unraid API
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is used to fix the session for the Unraid web interface when booted in GUI mode.
|
||||
* This can be deleted if GUI mode authentication is enabled.
|
||||
*/
|
||||
|
||||
function is_localhost()
|
||||
{
|
||||
// Use the peer IP, not the Host header which can be spoofed
|
||||
return $_SERVER['REMOTE_ADDR'] === '127.0.0.1' || $_SERVER['REMOTE_ADDR'] === '::1';
|
||||
}
|
||||
function is_good_session()
|
||||
{
|
||||
return isset($_SESSION) && isset($_SESSION['unraid_user']) && isset($_SESSION['unraid_login']);
|
||||
}
|
||||
if (is_localhost() && !is_good_session()) {
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
session_destroy();
|
||||
}
|
||||
session_start();
|
||||
$_SESSION['unraid_login'] = time();
|
||||
$_SESSION['unraid_user'] = 'root';
|
||||
session_write_close();
|
||||
my_logger("Unraid GUI-boot: created root session for localhost request.");
|
||||
}
|
||||
?>
|
||||
@@ -1,9 +1,5 @@
|
||||
<div id="header" class="<?=$display['banner']?>">
|
||||
<div class="logo">
|
||||
<a href="https://unraid.net" target="_blank">
|
||||
<?readfile("$docroot/webGui/images/UN-logotype-gradient.svg")?>
|
||||
</a>
|
||||
|
||||
<unraid-i18n-host>
|
||||
<unraid-header-os-version></unraid-header-os-version>
|
||||
</unraid-i18n-host>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<uui-toaster rich-colors close-button position="<?= ($notify['position'] === 'center') ? 'top-center' : $notify['position'] ?>"></uui-toaster>
|
||||
Reference in New Issue
Block a user