mirror of
https://github.com/unraid/webgui.git
synced 2026-02-26 12:18:56 -06:00
@@ -323,6 +323,12 @@ _(Favorites enabled)_:
|
||||
|
||||
:display_favorites_enabled_help:
|
||||
|
||||
_(Allow realtime updates on inactive browsers)_:
|
||||
: <select name='liveUpdate'>
|
||||
<?=mk_option($display['liveUpdate'],"no",_('No'))?>
|
||||
<?=mk_option($display['liveUpdate'],"yes",_('Yes'))?>
|
||||
</select>
|
||||
|
||||
<input type="submit" name="#default" value="_(Default)_" onclick="filename='reset'">
|
||||
: <input type="submit" name="#apply" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</form>
|
||||
|
||||
@@ -35,6 +35,7 @@ headermetacolor=""
|
||||
headerdescription="yes"
|
||||
showBannerGradient="yes"
|
||||
favorites="yes"
|
||||
liveUpdate="no"
|
||||
[parity]
|
||||
mode="0"
|
||||
hour="0 0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2025, Lime Technology
|
||||
* Copyright 2012-2025, Bergware International.
|
||||
/* Copyright 2005-2024, Lime Technology
|
||||
* Copyright 2012-2024, 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,
|
||||
@@ -105,11 +105,14 @@ if (!file_exists($notes)) file_put_contents($notes,shell_exec("$docroot/plugins/
|
||||
<script>
|
||||
String.prototype.actionName = function(){return this.split(/[\\/]/g).pop();}
|
||||
String.prototype.channel = function(){return this.split(':')[1].split(',').findIndex((e)=>/\[\d\]/.test(e));}
|
||||
NchanSubscriber.prototype.monitor = function(){nchanSubs.push(this);}
|
||||
|
||||
NchanSubscriber.prototype.monitor = function(){subscribers.push(this);}
|
||||
|
||||
Shadowbox.init({skipSetup:true});
|
||||
context.init();
|
||||
|
||||
// list of nchan subscribers to start/stop at focus change
|
||||
var subscribers = [];
|
||||
|
||||
// server uptime
|
||||
var uptime = <?=strtok(exec("cat /proc/uptime"),' ')?>;
|
||||
var expiretime = <?=_var($var,'regTy')=='Trial'||strstr(_var($var,'regTy'),'expired')?_var($var,'regTm2'):0?>;
|
||||
@@ -134,10 +137,6 @@ var csrf_token = "<?=_var($var,'csrf_token')?>";
|
||||
// form has unsaved changes indicator
|
||||
var formHasUnsavedChanges = false;
|
||||
|
||||
// list of nchan subscribers to start/stop after inactivity
|
||||
var nchanSubs = [];
|
||||
var nchanPaused = false;
|
||||
|
||||
// docker progess indicators
|
||||
var progress_dots = [], progress_span = [];
|
||||
function pauseEvents(id) {
|
||||
@@ -145,45 +144,16 @@ function pauseEvents(id) {
|
||||
if (!id || i==id) clearTimeout(timer);
|
||||
});
|
||||
}
|
||||
|
||||
function resumeEvents(id, delay) {
|
||||
function resumeEvents(id,delay) {
|
||||
var startDelay = delay||50;
|
||||
$.each(timers, function(i, timer) {
|
||||
$.each(timers, function(i,timer) {
|
||||
if (!id || i==id) timers[i] = setTimeout(i+'()', startDelay);
|
||||
startDelay += 50;
|
||||
});
|
||||
}
|
||||
|
||||
<?if (isset($myPage['Load']) && $myPage['Load'] > 0):?>
|
||||
function nchanStart() {
|
||||
if (nchanPaused !== false) {
|
||||
removeBannerWarning(nchanPaused);
|
||||
nchanSubs.forEach(function(nchan) {nchan.start();});
|
||||
timers.reload = setTimeout(nchanStop,<?=$myPage['Load']*60000?>);
|
||||
nchanPaused = false;
|
||||
}
|
||||
function plus(value,single,plural,last) {
|
||||
return value>0 ? (value+' '+(value==1?single:plural)+(last?'':', ')) : '';
|
||||
}
|
||||
|
||||
function nchanStop() {
|
||||
if (nchanPaused === false && nchanSubs.length > 0) {
|
||||
nchanSubs.forEach(function(nchan) {nchan.stop();});
|
||||
nchanPaused = addBannerWarning("<?=_('Live Updates Paused')?>",false,true);
|
||||
}
|
||||
}
|
||||
|
||||
$(window).click(function() {nchanStart();});
|
||||
|
||||
document.addEventListener('visibilitychange',function(e) {
|
||||
if (document.hidden) nchanStop(); else nchanStart();
|
||||
});
|
||||
|
||||
timers.reload = setTimeout(nchanStop,<?=$myPage['Load']*60000?>);
|
||||
<?endif;?>
|
||||
|
||||
function plus(value, single, plural, last) {
|
||||
return value > 0 ? (value+' '+(value==1?single:plural)+(last?'':', ')) : '';
|
||||
}
|
||||
|
||||
function updateTime() {
|
||||
var now = new Date();
|
||||
var days = parseInt(uptime/86400);
|
||||
@@ -213,7 +183,6 @@ function updateTime() {
|
||||
}
|
||||
setTimeout(updateTime,1000);
|
||||
}
|
||||
|
||||
function refresh(top) {
|
||||
if (typeof top === 'undefined') {
|
||||
for (var i=0,element; element=document.querySelectorAll('input,button,select')[i]; i++) {element.disabled = true;}
|
||||
@@ -224,13 +193,11 @@ function refresh(top) {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function initab(page) {
|
||||
$.removeCookie('one');
|
||||
$.removeCookie('tab');
|
||||
if (page != null) location.replace(page);
|
||||
}
|
||||
|
||||
function settab(tab) {
|
||||
<?switch ($myPage['name']):?>
|
||||
<?case'Main':?>
|
||||
@@ -246,7 +213,6 @@ function settab(tab) {
|
||||
$.cookie('one',tab);
|
||||
<?endswitch;?>
|
||||
}
|
||||
|
||||
function done(key) {
|
||||
var url = location.pathname.split('/');
|
||||
var path = '/'+url[1];
|
||||
@@ -254,21 +220,18 @@ function done(key) {
|
||||
$.removeCookie('one');
|
||||
location.replace(path);
|
||||
}
|
||||
|
||||
function chkDelete(form, button) {
|
||||
button.value = form.confirmDelete.checked ? "<?=_('Delete')?>" : "<?=_('Apply')?>";
|
||||
button.disabled = false;
|
||||
}
|
||||
|
||||
function makeWindow(name, height, width) {
|
||||
var top = (screen.height - height)/2;
|
||||
function makeWindow(name,height,width) {
|
||||
var top = (screen.height-height)/2;
|
||||
if (top < 0) {top = 0; height = screen.availHeight;}
|
||||
var left = (screen.width - width)/2;
|
||||
var left = (screen.width-width)/2;
|
||||
if (left < 0) {left = 0; width = screen.availWidth;}
|
||||
return window.open('',name,'resizeable=yes,scrollbars=yes,height='+height+',width='+width+',top='+top+',left='+left);
|
||||
}
|
||||
|
||||
function openBox(cmd, title, height, width, load, func, id) {
|
||||
function openBox(cmd,title,height,width,load,func,id) {
|
||||
// open shadowbox window (run in foreground)
|
||||
// included for legacy purposes, replaced by openPlugin
|
||||
var uri = cmd.split('?');
|
||||
@@ -276,8 +239,7 @@ function openBox(cmd, title, height, width, load, func, id) {
|
||||
var options = load ? (func ? {modal:true,onClose:function(){setTimeout(func+'('+'"'+(id||'')+'")');}} : {modal:true,onClose:function(){location.reload();}}) : {modal:false};
|
||||
Shadowbox.open({content:run, player:'iframe', title:title, height:Math.min(screen.availHeight,800), width:Math.min(screen.availWidth,1200), options:options});
|
||||
}
|
||||
|
||||
function openWindow(cmd, title, height, width) {
|
||||
function openWindow(cmd,title,height,width) {
|
||||
// open regular window (run in background)
|
||||
// included for legacy purposes, replaced by openTerminal
|
||||
var window_name = title.replace(/ /g,"_");
|
||||
@@ -291,11 +253,10 @@ function openWindow(cmd, title, height, width) {
|
||||
form_html += '</form>';
|
||||
var form = $(form_html);
|
||||
$('body').append(form);
|
||||
makeWindow(window_name, height, width);
|
||||
makeWindow(window_name,height,width);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
function openTerminal(tag, name, more) {
|
||||
function openTerminal(tag,name,more) {
|
||||
if (/MSIE|Edge/.test(navigator.userAgent)) {
|
||||
swal({title:"_(Unsupported Feature)_",text:"_(Sorry, this feature is not supported by MSIE/Edge)_.<br>_(Please try a different browser)_",type:'error',html:true,animation:'none',confirmButtonText:"_(Ok)_"});
|
||||
return;
|
||||
@@ -306,9 +267,8 @@ function openTerminal(tag, name, more) {
|
||||
var socket = ['ttyd','syslog'].includes(tag) ? '/webterminal/'+tag+'/' : '/logterminal/'+name+(more=='.log'?more:'')+'/';
|
||||
$.get('/webGui/include/OpenTerminal.php',{tag:tag,name:name,more:more},function(){setTimeout(function(){tty_window.location=socket; tty_window.focus();},200);});
|
||||
}
|
||||
|
||||
function bannerAlert(text, cmd, plg, func, start) {
|
||||
$.post('/webGui/include/StartCommand.php',{cmd:cmd, pid:1},function(pid) {
|
||||
function bannerAlert(text,cmd,plg,func,start) {
|
||||
$.post('/webGui/include/StartCommand.php',{cmd:cmd,pid:1},function(pid) {
|
||||
if (pid == 0) {
|
||||
if ($(".upgrade_notice").hasClass('done') || timers.bannerAlert == null) {
|
||||
forcedBanner = false;
|
||||
@@ -343,8 +303,7 @@ function bannerAlert(text, cmd, plg, func, start) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openPlugin(cmd, title, plg, func, start=0, button=0) {
|
||||
function openPlugin(cmd,title,plg,func,start=0,button=0) {
|
||||
// start = 0 : run command only when not already running (default)
|
||||
// start = 1 : run command unconditionally
|
||||
// button = 0 : show CLOSE button (default)
|
||||
@@ -367,8 +326,7 @@ function openPlugin(cmd, title, plg, func, start=0, button=0) {
|
||||
$('button.confirm').prop('disabled',button!=0);
|
||||
});
|
||||
}
|
||||
|
||||
function openDocker(cmd, title, plg, func, start=0, button=0) {
|
||||
function openDocker(cmd,title,plg,func,start=0,button=0) {
|
||||
// start = 0 : run command only when not already running (default)
|
||||
// start = 1 : run command unconditionally
|
||||
// button = 0 : hide CLOSE button (default)
|
||||
@@ -391,8 +349,7 @@ function openDocker(cmd, title, plg, func, start=0, button=0) {
|
||||
$('button.confirm').prop('disabled',button==0);
|
||||
});
|
||||
}
|
||||
|
||||
function openVMAction(cmd, title, plg, func, start=0, button=0) {
|
||||
function openVMAction(cmd,title,plg,func,start=0,button=0) {
|
||||
// start = 0 : run command only when not already running (default)
|
||||
// start = 1 : run command unconditionally
|
||||
// button = 0 : hide CLOSE button (default)
|
||||
@@ -415,7 +372,6 @@ function openVMAction(cmd, title, plg, func, start=0, button=0) {
|
||||
$('button.confirm').prop('disabled',button==0);
|
||||
});
|
||||
}
|
||||
|
||||
function abortOperation(pid) {
|
||||
swal({title:"<?=_('Abort background operation')?>",text:"<?=_('This may leave an unknown state')?>",html:true,animation:'none',type:'warning',showCancelButton:true,confirmButtonText:"<?=_('Proceed')?>",cancelButtonText:"<?=_('Cancel')?>"},function(){
|
||||
$.post('/webGui/include/StartCommand.php',{kill:pid},function() {
|
||||
@@ -429,8 +385,7 @@ function abortOperation(pid) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function openChanges(cmd, title, nchan, button=0) {
|
||||
function openChanges(cmd,title,nchan,button=0) {
|
||||
$('div.spinner.fixed').show();
|
||||
// button = 0 : hide CLOSE button (default)
|
||||
// button = 1 : show CLOSE button
|
||||
@@ -446,8 +401,7 @@ function openChanges(cmd, title, nchan, button=0) {
|
||||
$('button.confirm').text("<?=_('Done')?>").prop('disabled',false).show();
|
||||
});
|
||||
}
|
||||
|
||||
function openAlert(cmd, title, func) {
|
||||
function openAlert(cmd,title,func) {
|
||||
$.post('/webGui/include/StartCommand.php',{cmd:cmd,start:2},function(data) {
|
||||
$('div.spinner.fixed').hide();
|
||||
swal({title:title,text:"<pre id='swalbody'></pre><hr>",html:true,animation:'none',showCancelButton:true,closeOnConfirm:false,confirmButtonText:"<?=_('Proceed')?>",cancelButtonText:"<?=_('Cancel')?>"},function(proceed){
|
||||
@@ -457,7 +411,6 @@ function openAlert(cmd, title, func) {
|
||||
$('pre#swalbody').html(data);
|
||||
});
|
||||
}
|
||||
|
||||
function openDone(data) {
|
||||
if (data == '_DONE_') {
|
||||
$('div.spinner.fixed').hide();
|
||||
@@ -472,7 +425,6 @@ function openDone(data) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function openError(data) {
|
||||
if (data == '_ERROR_') {
|
||||
$('div.spinner.fixed').hide();
|
||||
@@ -481,20 +433,16 @@ function openError(data) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function showStatus(name, plugin, job) {
|
||||
function showStatus(name,plugin,job) {
|
||||
$.post('/webGui/include/ProcessStatus.php',{name:name,plugin:plugin,job:job},function(status){$(".tabs").append(status);});
|
||||
}
|
||||
|
||||
function showFooter(data, id) {
|
||||
if (id !== undefined) $('#'+id).remove();
|
||||
$('#copyright').prepend(data);
|
||||
}
|
||||
|
||||
function showNotice(data) {
|
||||
$('#user-notice').html(data.replace(/<a>(.*)<\/a>/,"<a href='/Plugins'>$1</a>"));
|
||||
}
|
||||
|
||||
function escapeQuotes(form) {
|
||||
$(form).find('input[type=text]').each(function(){$(this).val($(this).val().replace(/"/g,'\\"'));});
|
||||
}
|
||||
@@ -524,7 +472,7 @@ function addBannerWarning(text, warning=true, noDismiss=false, forced=false) {
|
||||
return arrayEntry;
|
||||
}
|
||||
|
||||
function dismissBannerWarning(entry, cookieText) {
|
||||
function dismissBannerWarning(entry,cookieText) {
|
||||
$.cookie(cookieText,"true",{expires:30}); // reset after 1 month
|
||||
removeBannerWarning(entry);
|
||||
}
|
||||
@@ -572,14 +520,12 @@ function removeRebootNotice(message="<?=_('You must reboot for changes to take e
|
||||
function showUpgradeChanges() { /** @note can likely be removed, not used in webgui or api repos */
|
||||
openChanges("showchanges /tmp/plugins/unRAIDServer.txt","<?=_('Release Notes')?>");
|
||||
}
|
||||
|
||||
function showUpgrade(text, noDismiss=false) { /** @note can likely be removed, not used in webgui or api repos */
|
||||
function showUpgrade(text,noDismiss=false) { /** @note can likely be removed, not used in webgui or api repos */
|
||||
if ($.cookie('os_upgrade')==null) {
|
||||
if (osUpgradeWarning) removeBannerWarning(osUpgradeWarning);
|
||||
osUpgradeWarning = addBannerWarning(text.replace(/<a>(.+?)<\/a>/,"<a href='#' onclick='openUpgrade()'>$1</a>").replace(/<b>(.*)<\/b>/,"<a href='#' onclick='document.rebootNow.submit()'>$1</a>"),false,noDismiss);
|
||||
}
|
||||
}
|
||||
|
||||
function hideUpgrade(set) { /** @note can likely be removed, not used in webgui or api repos */
|
||||
removeBannerWarning(osUpgradeWarning);
|
||||
if (set)
|
||||
@@ -587,7 +533,6 @@ function hideUpgrade(set) { /** @note can likely be removed, not used in webgui
|
||||
else
|
||||
$.removeCookie('os_upgrade');
|
||||
}
|
||||
|
||||
function confirmUpgrade(confirm) {
|
||||
if (confirm) {
|
||||
swal({title:"<?=_('Update')?> Unraid OS",text:"<?=_('Do you want to update to the new version')?>?",type:'warning',html:true,animation:'none',showCancelButton:true,closeOnConfirm:false,confirmButtonText:"<?=_('Proceed')?>",cancelButtonText:"<?=_('Cancel')?>"},function(){
|
||||
@@ -597,7 +542,6 @@ function confirmUpgrade(confirm) {
|
||||
openPlugin("plugin update unRAIDServer.plg","<?=_('Update')?> Unraid OS");
|
||||
}
|
||||
}
|
||||
|
||||
function openUpgrade() {
|
||||
hideUpgrade();
|
||||
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{cmd:'alert'},function(data) {
|
||||
@@ -610,13 +554,11 @@ function openUpgrade() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function digits(number) {
|
||||
if (number < 10) return 'one';
|
||||
if (number < 100) return 'two';
|
||||
return 'three';
|
||||
}
|
||||
|
||||
function openNotifier() {
|
||||
$.post('/webGui/include/Notify.php',{cmd:'get',csrf_token:csrf_token},function(msg) {
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
@@ -633,7 +575,6 @@ function openNotifier() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function closeNotifier() {
|
||||
$.post('/webGui/include/Notify.php',{cmd:'get',csrf_token:csrf_token},function(msg) {
|
||||
$.each($.parseJSON(msg), function(i, notify){
|
||||
@@ -642,17 +583,14 @@ function closeNotifier() {
|
||||
$('div.jGrowl').find('div.jGrowl-close').trigger('click');
|
||||
});
|
||||
}
|
||||
|
||||
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>");
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
let tab;
|
||||
<?switch ($myPage['name']):?>
|
||||
@@ -784,7 +722,8 @@ foreach ($buttons as $button) {
|
||||
unset($buttons,$button);
|
||||
|
||||
// Build page content
|
||||
echo "<div class='tabs'>";
|
||||
// Reload page every X minutes during extended viewing?
|
||||
if (isset($myPage['Load']) && $myPage['Load']>0) echo "\n<script>timers.reload = setInterval(function(){if (nchanPaused === false)location.reload();},".($myPage['Load']*60000).");</script>\n";echo "<div class='tabs'>";
|
||||
$tab = 1;
|
||||
$pages = [];
|
||||
if (!empty($myPage['text'])) $pages[$myPage['name']] = $myPage;
|
||||
@@ -969,7 +908,7 @@ defaultPage.on('message', function(msg,meta) {
|
||||
case 'warning': bell2++; break;
|
||||
case 'normal' : bell3++; break;
|
||||
}
|
||||
<?if ($notify['display'] == 0):?>
|
||||
<?if ($notify['display']==0):?>
|
||||
if (notify.show) {
|
||||
$.jGrowl(notify.subject+'<br>'+notify.description,{
|
||||
group: notify.importance,
|
||||
@@ -1296,6 +1235,76 @@ $('body').on('click','a,.ca_href', function(e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Start & stop live updates when window loses focus
|
||||
var nchanPaused = false;
|
||||
var blurTimer = false;
|
||||
|
||||
$(window).focus(function() {
|
||||
nchanFocusStart();
|
||||
});
|
||||
|
||||
// Stop nchan on loss of focus
|
||||
<? if ( $display['liveUpdate'] == "no" ):?>
|
||||
$(window).blur(function() {
|
||||
blurTimer = setTimeout(function(){
|
||||
nchanFocusStop();
|
||||
},30000);
|
||||
});
|
||||
<?endif;?>
|
||||
|
||||
document.addEventListener("visibilitychange", (event) => {
|
||||
<? if ( $display['liveUpdate'] == "no" ):?>
|
||||
if (document.hidden) {
|
||||
nchanFocusStop();
|
||||
}
|
||||
<?else:?>
|
||||
if (document.hidden) {
|
||||
nchanFocusStop();
|
||||
} else {
|
||||
nchanFocusStart();
|
||||
}
|
||||
<?endif;?>
|
||||
});
|
||||
|
||||
function nchanFocusStart() {
|
||||
if ( blurTimer !== false ) {
|
||||
clearTimeout(blurTimer);
|
||||
blurTimer = false;
|
||||
}
|
||||
|
||||
if (nchanPaused !== false ) {
|
||||
removeBannerWarning(nchanPaused);
|
||||
nchanPaused = false;
|
||||
|
||||
try {
|
||||
pageFocusFunction();
|
||||
} catch(error) {}
|
||||
|
||||
subscribers.forEach(function(e) {
|
||||
e.start();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function nchanFocusStop(banner=true) {
|
||||
if ( subscribers.length ) {
|
||||
if ( nchanPaused === false ) {
|
||||
var newsub = subscribers;
|
||||
subscribers.forEach(function(e) {
|
||||
try {
|
||||
e.stop();
|
||||
} catch(err) {
|
||||
newsub.splice(newsub.indexOf(e,1));
|
||||
}
|
||||
});
|
||||
subscribers = newsub;
|
||||
if ( banner && subscribers.length ) {
|
||||
nchanPaused = addBannerWarning("<?=_('Live Updates Paused');?>",false,true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user