mirror of
https://github.com/unraid/webgui.git
synced 2026-01-28 20:49:04 -06:00
Merge pull request #305 from bergware/master
Make disk spin up/down inline without refresh of complete page
This commit is contained in:
@@ -71,10 +71,10 @@ function resetSorting() {
|
||||
$.post('/plugins/dynamix.docker.manager/include/UserPrefs.php',{reset:true},function(){loadlist();});
|
||||
}
|
||||
function listview() {
|
||||
if ($.cookie('docker_listview_mode')=='basic') {
|
||||
$('.docker_readmore').readmore({maxHeight:32,moreLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-down'></i></a>",lessLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-up'></i></a>"});
|
||||
} else {
|
||||
if ($.cookie('docker_listview_mode')=='advanced') {
|
||||
$('.docker_readmore').readmore('destroy');
|
||||
} else {
|
||||
$('.docker_readmore').readmore({maxHeight:32,moreLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-down'></i></a>",lessLink:"<a href='#' style='text-align:center'><i class='fa fa-chevron-up'></i></a>"});
|
||||
}
|
||||
}
|
||||
function loadlist(update) {
|
||||
|
||||
@@ -110,7 +110,7 @@ function rmContainer(container, image, id) {
|
||||
confirmButtonText:"Yes, delete it!",
|
||||
showLoaderOnConfirm:true
|
||||
},function(){
|
||||
$('#'+id).find('i').removeClass().addClass('iconstatus fa fa-trash orange-text');
|
||||
$('#'+id).find('i').removeClass('fa-play fa-square').addClass('fa-refresh fa-spin');
|
||||
if ($("#removeimagechk").prop('checked')) {
|
||||
eventControl({action:"remove_all", container:id, image:image},'loadlist');
|
||||
} else {
|
||||
@@ -130,12 +130,12 @@ function rmImage(image, imageName) {
|
||||
confirmButtonText:"Yes, delete it!",
|
||||
showLoaderOnConfirm:true
|
||||
},function(){
|
||||
$('#'+image).find('i').removeClass().addClass('iconstatus fa fa-trash orange-text');
|
||||
$('#'+image).find('i').removeClass('fa-play fa-square').addClass('fa-refresh fa-spin');
|
||||
eventControl({action:"remove_image", image:image},'loadlist');
|
||||
});
|
||||
}
|
||||
function eventControl(params, spin) {
|
||||
if (spin) $('#'+params['container']).find('i').addClass('fa-spin');
|
||||
if (spin) $('#'+params['container']).find('i').removeClass('fa-play fa-square').addClass('fa-refresh fa-spin');
|
||||
$.post(eventURL, params, function(data) {
|
||||
if (data.success === true) {
|
||||
if (spin) setTimeout(spin+'()',500); else location=window.location.href;
|
||||
@@ -151,17 +151,17 @@ function eventControl(params, spin) {
|
||||
}
|
||||
function startAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='false') $('#'+ct.id).find('i').addClass('fa-spin');
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='false') $('#'+ct.id).find('i').removeClass('fa-square').addClass('fa-refresh fa-spin');
|
||||
$.post('/plugins/dynamix.docker.manager/include/ContainerManager.php',{action:'start'},function(){loadlist();});
|
||||
}
|
||||
function stopAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='true') $('#'+ct.id).find('i').addClass('fa-spin');
|
||||
for (var i=0,ct; ct=docker[i]; i++) if (ct.state=='true') $('#'+ct.id).find('i').removeClass('fa-play').addClass('fa-refresh fa-spin');
|
||||
$.post('/plugins/dynamix.docker.manager/include/ContainerManager.php',{action:'stop'},function(){loadlist();});
|
||||
}
|
||||
function checkAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
$(".updatecolumn").html("<span style=\"color:#267CA8;white-space:nowrap;\"><i class=\"fa fa-spin fa-refresh\"></i> checking...</span>");
|
||||
$(".updatecolumn").html("<span style='color:#267CA8'><i class='fa fa-refresh fa-spin'></i> checking...</span>");
|
||||
$.post('/plugins/dynamix.docker.manager/include/DockerUpdate.php',{check:true},function(u){loadlist(u);});
|
||||
}
|
||||
function updateAll() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function ajaxVMDispatch(params, spin){
|
||||
if (spin) $('#vm-'+params['uuid']).find('i').addClass('fa-spin');
|
||||
if (spin) $('#vm-'+params['uuid']).find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
|
||||
$.post("/plugins/dynamix.vm.manager/include/VMajax.php", params, function(data) {
|
||||
if (data.error) {
|
||||
swal({
|
||||
@@ -85,7 +85,7 @@ function addVMContext(name, uuid, template, state, vncurl, log){
|
||||
type:"warning",
|
||||
showCancelButton:true
|
||||
},function(){
|
||||
$('#vm-'+uuid).find('i').removeClass().addClass('iconstatus fa fa-trash orange-text');
|
||||
$('#vm-'+uuid).find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
|
||||
ajaxVMDispatch({action:"domain-undefine",uuid:uuid}, "loadlist");
|
||||
});
|
||||
}});
|
||||
@@ -98,7 +98,7 @@ function addVMContext(name, uuid, template, state, vncurl, log){
|
||||
type:"warning",
|
||||
showCancelButton:true
|
||||
},function(){
|
||||
$('#vm-'+uuid).find('i').removeClass().addClass('iconstatus fa fa-trash orange-text');
|
||||
$('#vm-'+uuid).find('i').removeClass('fa-play fa-square fa-pause').addClass('fa-refresh fa-spin');
|
||||
ajaxVMDispatch({action:"domain-delete",uuid:uuid}, "loadlist");
|
||||
});
|
||||
}});
|
||||
@@ -108,12 +108,12 @@ function addVMContext(name, uuid, template, state, vncurl, log){
|
||||
}
|
||||
function startAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state!='running') $('#vm-'+vm.id).find('i').addClass('fa-spin');
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state!='running') $('#vm-'+vm.id).find('i').removeClass('fa-square').addClass('fa-refresh fa-spin');
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMManager.php',{action:'start'}, function(){loadlist();});
|
||||
}
|
||||
function stopAll() {
|
||||
$('input[type=button]').prop('disabled',true);
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state=='running') $('#vm-'+vm.id).find('i').addClass('fa-spin');
|
||||
for (var i=0,vm; vm=kvm[i]; i++) if (vm.state=='running') $('#vm-'+vm.id).find('i').removeClass('fa-play').addClass('fa-refresh fa-spin');
|
||||
$.post('/plugins/dynamix.vm.manager/include/VMManager.php',{action:'stop'}, function(){loadlist();});
|
||||
}
|
||||
function vncOpen() {
|
||||
|
||||
@@ -15,8 +15,22 @@ Tag="database"
|
||||
*/
|
||||
?>
|
||||
<script>
|
||||
var timer = null;
|
||||
|
||||
function toggle_state(device,name,action) {
|
||||
var event = null;
|
||||
var button = null;
|
||||
if (name) {
|
||||
if (name.match(/^(parity|disk)/)!==null) event = 'array_status';
|
||||
else if (name.match(/^cache/)!==null) event = 'cache_status';
|
||||
else if (name.match(/^flash/)!==null) event = 'boot_status';
|
||||
else event = 'open_status';
|
||||
$('#dev-'+name).removeClass('fa-sort-up fa-sort-down').addClass('fa-refresh fa-spin');
|
||||
} else if (device!='Clear') {
|
||||
$('[id^="dev-"]').removeClass('fa-sort-up fa-sort-down').addClass('fa-refresh fa-spin');
|
||||
button = '[id^=button-]';
|
||||
}
|
||||
pauseEvents(event);
|
||||
$.post('/webGui/include/ToggleState.php',{device:device,name:name,action:action,state:'<?=$var['mdState']?>',csrf:'<?=$var['csrf_token']?>'},function(){resumeEvents(event);if (button) $(button).prop('disabled',false);});
|
||||
}
|
||||
function display_diskio() {
|
||||
if ($.cookie('diskio')===undefined) {
|
||||
$('span.number').show(); $('span.diskio').hide();
|
||||
@@ -40,17 +54,11 @@ function array_status() {
|
||||
$.post('/webGui/include/DeviceList.php',{path:'<?=$path?>',device:'array'},function(data) {
|
||||
if (data) {$('#array_devices').html(data); display_diskio();}
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
<?if ($tabbed):?>
|
||||
if ($('#tab1').is(':checked')) timer = setTimeout(array_status,3000);
|
||||
<?else:?>
|
||||
setTimeout(array_status,3000);
|
||||
<?endif;?>
|
||||
timers.array_status = setTimeout(array_status,3000);
|
||||
<?endif;?>
|
||||
});
|
||||
}
|
||||
<?if ($var['fsState']=='Started' && $tabbed):?>
|
||||
$('#tab1').bind({click:function() {clearTimeout(timer); array_status(); $('i.toggle').show('slow');}});
|
||||
<?else:?>
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
$('#tab1').bind({click:function() {$('i.toggle').show('slow');}});
|
||||
<?endif;?>
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ $(function(){
|
||||
if ($var['mdResyncAction']=="check"):?>
|
||||
<tr><td></td><td><input type="submit" name="cmdCheck" value="Check"></td><td><strong>Check</strong> will start <strong>Read-Check</strong> of all array disks.</td></tr>
|
||||
<? elseif (strstr($var['mdResyncAction'],"check")):?>
|
||||
<tr><td>Parity is valid.</td><td><input type="submit" name="cmdCheck" value="Check"></td><td><strong>Check</strong> will start <strong>Parity-Check</strong>. <a href='/Scheduler'>(Schedule)</a>
|
||||
<tr><td>Parity is valid.</td><td><input type="submit" name="cmdCheck" value="Check"></td><td><strong>Check</strong> will start <strong>Parity-Check</strong>. <a href="/Main/Scheduler"<?if ($tabbed):?> onclick="$.cookie('one','tab1',{path:'/'})"<?endif;?>>(Schedule)</a>
|
||||
<br><input type="checkbox" name="optionCorrect" value="correct" checked><small>Write corrections to parity</small></td></tr>
|
||||
<? endif;?>
|
||||
<tr><td></td><td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,600,false)"></td>
|
||||
@@ -432,15 +432,12 @@ $(function(){
|
||||
</table>
|
||||
</form>
|
||||
<?if ($var['fsState']=="Started"):?>
|
||||
<form name="otherOps" method="POST" action="/update.htm" target="progressFrame">
|
||||
<input type="hidden" name="startState" value="<?=$var['mdState']?>">
|
||||
<table class="array_status">
|
||||
<tr><td></td><td><input type="submit" name="cmdSpindownAll" value="Spin Down"<?=$parity?' disabled':''?>><input type="submit" name="cmdSpinupAll" value="Spin Up"<?=$parity?' disabled':''?>></td>
|
||||
<tr><td></td><td><input type="button" id="button-down" onclick="$('[id^=button-]').prop('disabled',true);toggle_state('down')" value="Spin Down"<?=$parity?' disabled':''?>><input type="button" id="button-up" onclick="$('[id^=button-]').prop('disabled',true);toggle_state('up')" value="Spin Up"<?=$parity?' disabled':''?>></td>
|
||||
<td><strong>Spin Down</strong> will immediately spin down all disks.<br><strong>Spin Up</strong> will immediately spin up all disks.</td></tr>
|
||||
<tr><td></td><td><input type="submit" name="clearStatistics" value="Clear Statistics"></td><td><strong>Clear Statistics</strong> will immediately clear all disk statistics.</td></tr>
|
||||
<tr><td></td><td><input type="button" value="Clear Statistics" onclick="toggle_state('Clear')"></td><td><strong>Clear Statistics</strong> will immediately clear all disk statistics.</td></tr>
|
||||
<tr><td></td><td class="line" colspan="2"></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<?if ($var['shareCacheEnabled']=="yes" && is_dir("/mnt/cache")):?>
|
||||
<form name="mover_schedule" method="POST" action="/update.htm" target="progressFrame">
|
||||
<table class="array_status">
|
||||
@@ -448,7 +445,7 @@ $(function(){
|
||||
<?if ($mover):?>
|
||||
<td><input type="submit" name="cmdStartMover" value="Move now" disabled></td><td>Disabled - Mover is running.</td>
|
||||
<?else:?>
|
||||
<td><input type="submit" name="cmdStartMover" value="Move now"></td><td><strong>Move now</strong> will immediately invoke the Mover. <a href='/Scheduler'>(Schedule)</a></td>
|
||||
<td><input type="submit" name="cmdStartMover" value="Move now"></td><td><strong>Move now</strong> will immediately invoke the Mover. <a href="/Main/Scheduler"<?if ($tabbed):?> onclick="$.cookie('one','tab2',{path:'/'})"<?endif;?>>(Schedule)</a></td>
|
||||
<?endif;?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -19,17 +19,11 @@ function boot_status() {
|
||||
$.post('/webGui/include/DeviceList.php',{path:'<?=$path?>',device:'flash'},function(data) {
|
||||
if (data) {$('#boot_device').html(data); display_diskio();}
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
<?if ($tabbed):?>
|
||||
if ($('#tab3').is(':checked')) timer = setTimeout(boot_status,3000);
|
||||
<?else:?>
|
||||
setTimeout(boot_status,3000);
|
||||
<?endif;?>
|
||||
timers.boot_status = setTimeout(boot_status,3000);
|
||||
<?endif;?>
|
||||
});
|
||||
}
|
||||
<?if ($var['fsState']=='Started' && $tabbed):?>
|
||||
$('#tab3').bind({click:function() {clearTimeout(timer); boot_status(); $('i.toggle').show('slow');}});
|
||||
<?else:?>
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
$('#tab3').bind({click:function() {$('i.toggle').show('slow');}});
|
||||
<?endif;?>
|
||||
|
||||
|
||||
@@ -20,17 +20,11 @@ function cache_status() {
|
||||
$.post('/webGui/include/DeviceList.php',{path:'<?=$path?>',device:'cache'},function(data) {
|
||||
if (data) {$('#cache_device').html(data); display_diskio();}
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
<?if ($tabbed):?>
|
||||
if ($('#tab2').is(':checked')) timer = setTimeout(cache_status,3000);
|
||||
<?else:?>
|
||||
setTimeout(cache_status,3000);
|
||||
<?endif;?>
|
||||
timers.cache_status = setTimeout(cache_status,3000);
|
||||
<?endif;?>
|
||||
});
|
||||
}
|
||||
<?if ($var['fsState']=='Started' && $tabbed):?>
|
||||
$('#tab2').bind({click:function() {clearTimeout(timer); cache_status(); $('i.toggle').show('slow');}});
|
||||
<?else:?>
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
$('#tab2').bind({click:function() {$('i.toggle').show('slow');}});
|
||||
<?endif;?>
|
||||
|
||||
|
||||
@@ -23,17 +23,11 @@ function open_status() {
|
||||
$.post('/webGui/include/DeviceList.php',{path:'<?=addslashes(htmlspecialchars($path))?>',device:'open'},function(data) {
|
||||
if (data) {$('#open_devices').html(data); display_diskio();}
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
<?if ($tabbed):?>
|
||||
if ($('<?=$tabX?>').is(':checked')) timer = setTimeout(open_status,3000);
|
||||
<?else:?>
|
||||
setTimeout(open_status,3000);
|
||||
<?endif;?>
|
||||
timers.open_status = setTimeout(open_status,3000);
|
||||
<?endif;?>
|
||||
});
|
||||
}
|
||||
<?if ($var['fsState']=='Started' && $tabbed):?>
|
||||
$('<?=$tabX?>').bind({click:function() {clearTimeout(timer); open_status(); $('i.toggle').show('slow');}});
|
||||
<?else:?>
|
||||
<?if ($var['fsState']=='Started'):?>
|
||||
$('<?=$tabX?>').bind({click:function() {$('i.toggle').show('slow');}});
|
||||
<?endif;?>
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ if (strstr('gray,azure',$display['theme'])) {
|
||||
</style>
|
||||
|
||||
<script src="<?autov('/webGui/javascript/dynamix.js')?>"></script>
|
||||
<script src="<?autov('/webGui/javascript/NchanSubscriber.js')?>"></script>
|
||||
<script>
|
||||
Shadowbox.init({skipSetup:true});
|
||||
|
||||
@@ -57,15 +56,15 @@ var before = new Date();
|
||||
// page timer events
|
||||
var timers = {};
|
||||
|
||||
function pauseEvents(){
|
||||
function pauseEvents(id){
|
||||
$.each(timers, function(i, timer) {
|
||||
clearTimeout(timer);
|
||||
if (!id || i==id) clearTimeout(timer);
|
||||
});
|
||||
}
|
||||
function resumeEvents(){
|
||||
var startDelay = 50;
|
||||
function resumeEvents(id,delay){
|
||||
var startDelay = delay||50;
|
||||
$.each(timers, function(i, timer) {
|
||||
timers[i] = setTimeout(i + '()', startDelay);
|
||||
if (!id || i==id) timers[i] = setTimeout(i+'()', startDelay);
|
||||
startDelay += 50;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ function device_info(&$disk,$online) {
|
||||
$type = $disk['type']=='Flash' || $disk['type']=='New' ? $disk['type'] : 'Device';
|
||||
$action = strpos($disk['color'],'blink')===false ? 'down' : 'up';
|
||||
if ($var['fsState']=='Started' && $type!='Flash' && strpos($disk['status'],'_NP')===false) {
|
||||
$cmd = $type=='New' ? "cmd=/webGui/scripts/hd_parm&arg1=$action&arg2=$name" : "cmdSpin$action=$name";
|
||||
$ctrl = "<a href='update.htm?$cmd&csrf_token={$var['csrf_token']}' title='Click to spin $action device' class='none' target='progressFrame' onclick=\"$.removeCookie('one',{path:'/'});\"><i class='fa fa-sort-$action spacing'></i></a>";
|
||||
$ctrl = "<i id='dev-$name' class='fa fa-sort-$action fa-fw' style='cursor:pointer' title='Click to spin $action device' onclick=\"toggle_state('$type','$name','$action')\"></i>";
|
||||
} else
|
||||
$ctrl = '';
|
||||
switch ($disk['color']) {
|
||||
|
||||
40
plugins/dynamix/include/ToggleState.php
Normal file
40
plugins/dynamix/include/ToggleState.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2012-2018, 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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$device = $_POST['device'];
|
||||
$name = $_POST['name'];
|
||||
$action = $_POST['action'];
|
||||
$state = $_POST['state'];
|
||||
$csrf = $_POST['csrf'];
|
||||
|
||||
function emhttpd($cmd) {
|
||||
global $state, $csrf;
|
||||
$ch = curl_init("http://127.0.0.1/update.htm?$cmd&startState=$state&csrf_token=$csrf");
|
||||
curl_setopt_array($ch, [CURLOPT_UNIX_SOCKET_PATH => '/var/run/emhttpd.socket', CURLOPT_RETURNTRANSFER => true]);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
switch ($device) {
|
||||
case 'New':
|
||||
$cmd = $action=='up' ? 'S0' : ($action=='down' ? 'y' : false);
|
||||
if ($cmd && $name) exec("/usr/sbin/hdparm -$cmd /dev/$name >/dev/null 2>&1");
|
||||
break;
|
||||
case 'Clear':
|
||||
emhttpd("clearStatistics=true");
|
||||
break;
|
||||
default:
|
||||
if ($name) emhttpd("cmdSpin$action=$name"); else emhttpd("cmdSpin{$device}All=true");
|
||||
break;
|
||||
}
|
||||
?>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user