mirror of
https://github.com/unraid/webgui.git
synced 2026-05-12 15:20:29 -05:00
Merge pull request #1735 from unraid/feat-array-optional
Allow the Array to be optional
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Menu="Main:1"
|
||||
Title="Array Devices"
|
||||
Tag="database"
|
||||
Cond="(_var($var,'SYS_ARRAY_SLOTS') > 0 || $var['fsState']=='Stopped')"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
@@ -18,53 +19,6 @@ Tag="database"
|
||||
$power = _var($display,'power') && in_array('nvme',array_column(main_filter($disks),'transport')) ? _('Power').' / ' : '';
|
||||
?>
|
||||
<script>
|
||||
String.prototype.no_tilde = function(){return this.replace('<?=$_tilde_?>','<?=$_proxy_?>');}
|
||||
String.prototype.master = function(){return this.split('<?=$_tilde_?>')[0];}
|
||||
|
||||
function toggle_state(device,name,action) {
|
||||
var button = null;
|
||||
if (name) {
|
||||
var group = name.replace(/(\d+|\*)$/,'');
|
||||
if (name.slice(-1)!='*') {
|
||||
// single device
|
||||
$('#dev-'+name.no_tilde()).removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
} else {
|
||||
if (group=='disk') {
|
||||
// array devices
|
||||
$('[id^="dev-parity"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
$('[id^="dev-disk"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
} else {
|
||||
// pool devices
|
||||
$('[id^="dev-'+group.master()+'"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
}
|
||||
}
|
||||
} else if (device!='Clear') {
|
||||
// all devices
|
||||
$('[id^="dev-"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
button = '[id^=button-]';
|
||||
}
|
||||
devices.stop();
|
||||
$.post('/webGui/include/ToggleState.php',{device:device,name:name,action:action},function(){setTimeout(function(){devices.start();},1000);if (button) $(button).prop('disabled',false);});
|
||||
}
|
||||
function display_diskio() {
|
||||
if ($.cookie('diskio')===undefined) {
|
||||
$('span.number').show(); $('span.diskio').hide();
|
||||
} else {
|
||||
$('span.diskio').show(); $('span.number').hide();
|
||||
}
|
||||
}
|
||||
function toggle_diskio(init) {
|
||||
if (!init) {
|
||||
if ($.cookie('diskio')===undefined) $.cookie('diskio','diskio',{expires:3650}); else $.removeCookie('diskio');
|
||||
}
|
||||
if ($.cookie('diskio')===undefined) {
|
||||
$('i.toggle').removeClass('fa-tachometer').addClass('fa-list');
|
||||
} else {
|
||||
$('i.toggle').removeClass('fa-list').addClass('fa-tachometer');
|
||||
}
|
||||
display_diskio();
|
||||
}
|
||||
|
||||
<?if (_var($var,'fsState')=="Started"):?>
|
||||
$('#tab1').bind({click:function() {$('i.toggle').show('slow');}});
|
||||
<?endif;?>
|
||||
|
||||
@@ -86,6 +86,52 @@ var ctrl = '<span class="status <?=$tabbed?"":"vhshift"?>"><a style="cursor:poin
|
||||
var recall = null;
|
||||
var recover = null;
|
||||
|
||||
String.prototype.no_tilde = function(){return this.replace('<?=$_tilde_?>','<?=$_proxy_?>');}
|
||||
String.prototype.master = function(){return this.split('<?=$_tilde_?>')[0];}
|
||||
|
||||
function toggle_state(device,name,action) {
|
||||
var button = null;
|
||||
if (name) {
|
||||
var group = name.replace(/(\d+|\*)$/,'');
|
||||
if (name.slice(-1)!='*') {
|
||||
// single device
|
||||
$('#dev-'+name.no_tilde()).removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
} else {
|
||||
if (group=='disk') {
|
||||
// array devices
|
||||
$('[id^="dev-parity"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
$('[id^="dev-disk"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
} else {
|
||||
// pool devices
|
||||
$('[id^="dev-'+group.master()+'"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
}
|
||||
}
|
||||
} else if (device!='Clear') {
|
||||
// all devices
|
||||
$('[id^="dev-"]').removeClass('fa-circle fa-square fa-warning fa-times').addClass('fa-refresh fa-spin');
|
||||
button = '[id^=button-]';
|
||||
}
|
||||
devices.stop();
|
||||
$.post('/webGui/include/ToggleState.php',{device:device,name:name,action:action},function(){setTimeout(function(){devices.start();},1000);if (button) $(button).prop('disabled',false);});
|
||||
}
|
||||
function display_diskio() {
|
||||
if ($.cookie('diskio')===undefined) {
|
||||
$('span.number').show(); $('span.diskio').hide();
|
||||
} else {
|
||||
$('span.diskio').show(); $('span.number').hide();
|
||||
}
|
||||
}
|
||||
function toggle_diskio(init) {
|
||||
if (!init) {
|
||||
if ($.cookie('diskio')===undefined) $.cookie('diskio','diskio',{expires:3650}); else $.removeCookie('diskio');
|
||||
}
|
||||
if ($.cookie('diskio')===undefined) {
|
||||
$('i.toggle').removeClass('fa-tachometer').addClass('fa-list');
|
||||
} else {
|
||||
$('i.toggle').removeClass('fa-list').addClass('fa-tachometer');
|
||||
}
|
||||
display_diskio();
|
||||
}
|
||||
function base64(str) {
|
||||
return window.btoa(unescape(encodeURIComponent(str)));
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ $conf = glob('/etc/wireguard/wg*.conf');
|
||||
$wireguard = is_executable('/usr/bin/wg') && count($conf);
|
||||
$started = _var($var,'fsState')=='Started';
|
||||
$sleep = isset($display['sleep']);
|
||||
$poolsOnly = (_var($var,'SYS_ARRAY_SLOTS') == 0 ) ? true : false;
|
||||
$array_size = $array_used = 0;
|
||||
$extra_size = $extra_used = 0;
|
||||
$cache_size = $cache_used = [];
|
||||
@@ -573,6 +574,7 @@ if (!$group) {
|
||||
|
||||
<div class='tile' id='tile3'>
|
||||
<table id='db-box3' class='dashboard'>
|
||||
<?if (!$poolsOnly):?>
|
||||
<tbody title="_(Parity Information)_">
|
||||
<tr><td><i class='icon-health f32'></i><div class='section'>_(Parity)_<br>
|
||||
<span class='parity'></span><br></div>
|
||||
@@ -592,6 +594,7 @@ if (!$group) {
|
||||
<tr><td id='array_info'></td></tr>
|
||||
<tr class='header'><td><span class='w26'>_(Device)_</span><span class='w18'>_(Status)_</span><span class='w18'>_(Temp)_<?=$power?></span><span class='w18'>_(SMART)_</span><span class='w18'>_(Utilization)_</span></td></tr>
|
||||
</tbody>
|
||||
<?endif;?>
|
||||
|
||||
<?$i=0?>
|
||||
<?foreach ($pools as $pool):
|
||||
@@ -1605,21 +1608,25 @@ dashboard.on('message',function(msg,meta) {
|
||||
case 2:
|
||||
if (!update2) break;
|
||||
var get = JSON.parse(msg);
|
||||
var info = moreInfo(get.disk,"_(Array)_");
|
||||
// array devices
|
||||
$('#array_list tr.updated').remove();
|
||||
$('#array_list').append(get.disk[0]).hideMe();
|
||||
$('#array_info').parent().css({'display':info?'':'none'});
|
||||
$('#array_info').html(info);
|
||||
smartMenu('#array_list');
|
||||
if(document.getElementById('array_list') != null) {
|
||||
var info = moreInfo(get.disk,"_(Array)_");
|
||||
// array devices
|
||||
$('#array_list tr.updated').remove();
|
||||
$('#array_list').append(get.disk[0]).hideMe();
|
||||
$('#array_info').parent().css({'display':info?'':'none'});
|
||||
$('#array_info').html(info);
|
||||
smartMenu('#array_list');
|
||||
}
|
||||
// pool devices
|
||||
for (let i=0; i < get.pool.length; i++) {
|
||||
var info = moreInfo(get.pool[i],"_(Pool)_");
|
||||
$('#pool_list'+i+' tr.updated').remove();
|
||||
$('#pool_list'+i).append(get.pool[i][0]).hideMe();
|
||||
$('#pool_info'+i).parent().css({'display':info?'':'none'});
|
||||
$('#pool_info'+i).html(info);
|
||||
smartMenu('#pool_list'+i);
|
||||
if(get.pool) {
|
||||
for (let i=0; i < get.pool.length; i++) {
|
||||
var info = moreInfo(get.pool[i],"_(Pool)_");
|
||||
$('#pool_list'+i+' tr.updated').remove();
|
||||
$('#pool_list'+i).append(get.pool[i][0]).hideMe();
|
||||
$('#pool_info'+i).parent().css({'display':info?'':'none'});
|
||||
$('#pool_info'+i).html(info);
|
||||
smartMenu('#pool_list'+i);
|
||||
}
|
||||
}
|
||||
<?if ($devs):?>
|
||||
// unassigned devices
|
||||
|
||||
@@ -341,7 +341,8 @@ function array_slots() {
|
||||
$echo[] = "<input type='hidden' name='csrf_token' value='"._var($var,'csrf_token')."'>";
|
||||
$echo[] = "<input type='hidden' name='changeSlots' value='apply'>";
|
||||
$echo[] = "<select class='narrow' name='SYS_ARRAY_SLOTS' onChange='devices.start();this.form.submit()'>";
|
||||
for ($n=$min; $n<=$max; $n++) {
|
||||
for ($n=0; $n<=$max; $n++) {
|
||||
if ($n>0 && $n<$min) continue; // allow 0, but skip parity drives
|
||||
$selected = $n==_var($var,'SYS_ARRAY_SLOTS') ? ' selected' : '';
|
||||
$echo[] = "<option value='$n'{$selected}>$n</option>";
|
||||
}
|
||||
@@ -431,15 +432,18 @@ while (true) {
|
||||
|
||||
$a = 'array_devices';
|
||||
$echo[$a] = [];
|
||||
$poolsOnly = (_var($var,'SYS_ARRAY_SLOTS') == 0) ? true : false;
|
||||
if (_var($var,'fsState')=='Stopped') {
|
||||
foreach ($Parity as $disk) $echo[$a][] = array_offline($disk);
|
||||
if (!$poolsOnly) foreach ($Parity as $disk) $echo[$a][] = array_offline($disk);
|
||||
$echo[$a][] = "<tr class='tr_last'><td colspan='10'></td></tr>";
|
||||
foreach ($Data as $disk) $echo[$a][] = array_offline($disk);
|
||||
if (!$poolsOnly) foreach ($Data as $disk) $echo[$a][] = array_offline($disk);
|
||||
$echo[$a][] = "<tr class='tr_last'><td>"._('Slots').":</td><td colspan='8'>".array_slots()."</td><td></td></tr>";
|
||||
} else {
|
||||
foreach ($Parity as $disk) if ($disk['status']!='DISK_NP_DSBL') $echo[$a][] = array_online($disk);
|
||||
foreach ($Data as $disk) $echo[$a][] = array_online($disk);
|
||||
if (_var($display,'total') && _var($var,'mdNumDisks',0)>1) $echo[$a][] = show_totals(sprintf(_('Array of %s devices'),my_word($var['mdNumDisks'])),true,'disk*');
|
||||
if (!$poolsOnly) {
|
||||
foreach ($Parity as $disk) if ($disk['status']!='DISK_NP_DSBL') $echo[$a][] = array_online($disk);
|
||||
foreach ($Data as $disk) $echo[$a][] = array_online($disk);
|
||||
if (_var($display,'total') && _var($var,'mdNumDisks',0)>1) $echo[$a][] = show_totals(sprintf(_('Array of %s devices'),my_word($var['mdNumDisks'])),true,'disk*');
|
||||
}
|
||||
}
|
||||
$echo[$a] = implode($echo[$a]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user