Merge pull request #167 from bergware/6.4-wip

Hide Format button when wrong encryption key is ignored
This commit is contained in:
tom mortensen
2017-09-13 13:00:56 -07:00
committed by GitHub
3 changed files with 45 additions and 17 deletions

View File

@@ -15,6 +15,8 @@ Tag="snowflake-o"
*/
?>
<?
$hide = '/var/tmp/hide_format_button.tmp';
function maintenance_mode() {
echo "<tr>";
echo "<td></td>";
@@ -39,10 +41,14 @@ var ask1 = <?=$confirm['stop'] ? 'true' : 'false'?>;
var ask2 = <?=$confirm['down'] ? 'true' : 'false'?>;
var ctrl = "<span class='status'><a style='cursor:pointer' class='tooltip_diskio' title='Toggle reads/writes display' onclick='toggle_diskio();return false'><i class='toggle fa'></i></a></span>";
function verify(form) {
swal({title:'Found wrong encryption key',text:'Format unmountable disk(s) and ERASE ALL data?',type:'warning',showCancelButton:true},function(){
$(form).append('<input type="hidden" name="cmdFormat" value="Format">');
form.submit();
function verify(form,hide) {
swal({title:'Found wrong encryption key',text:'Format unmountable disk(s) and erase all data?',type:'warning',confirmButtonText:'Format',cancelButtonText:'Ignore',showCancelButton:true},function(p){
if (p) {
$(form).append('<input type="hidden" name="cmdFormat" value="Format">');
form.submit();
} else {
$.post('/webGui/include/HideFormatButton.php',{hide:hide},function(){refresh();});
}
});
}
function tab0() {
@@ -80,9 +86,9 @@ function parity_warning(form) {
function stop_array(form) {
$(form).append('<input type="hidden" name="cmdStop" value="Stop">');
if (ask1) {
swal({title:'Proceed?',text:'This will stop the array',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmdStop"]').remove();});
swal({title:'Proceed?',text:'This will stop the array',type:'warning',showCancelButton:true},function(p){if (p) $.post('/webGui/include/HideFormatButton.php',{hide:'no'},function(){form.submit();}); else $('input[name="cmdStop"]').remove();});
} else {
form.submit();
$.post('/webGui/include/HideFormatButton.php',{hide:'no'},function(){form.submit();});
}
}
function stop_parity(form,text) {
@@ -144,17 +150,18 @@ toggle_diskio(true);
<td><input type="button" value="Stop" onclick="stop_array(this.form)"<?if ($parity||$mover):?> disabled<?endif;?>></td>
<td><strong>Stop</strong> will take the array off-line.<?=$parity?"<br>$parity":($mover?"<br>$mover":"")?></td>
</tr>
<? if ($var['fsNumUnmountable']>0):?>
<? if ($var['fsNumUnmountable']>0 && !file_exists($hide)):?>
<tr>
<td><strong>Unmountable disk<?=$var['fsNumUnmountable']==1?'':'s'?> present:</strong><br>
<? $verify = false;
$yesno = 'yes';
foreach ($disks as $disk) if (strpos($disk['fsStatus'],'Unmountable')!==false) {
echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";
if (strpos($disk['fsStatus'],'Wrong')!==false) $verify = true;
if (strpos($disk['fsStatus'],'Wrong')!==false) $verify = true; else $yesno = 'no';
}
?> </td>
<? if ($verify):?>
<td><input type="button" id="cmdFormat" value="Format" disabled onclick="verify(this.form)"><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
<td><input type="button" id="cmdFormat" value="Format" disabled onclick="verify(this.form,'<?=$yesno?>')"><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
<? else:?>
<td><input type="submit" id="cmdFormat" name="cmdFormat" value="Format" disabled><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
<? endif;?>

View File

@@ -215,7 +215,7 @@ btrfs filesystem show:
: <?echo "<pre>".shell_exec("/sbin/btrfs filesystem show {$disk['uuid']}")."</pre>";?>
<?endif;?>
<?if (strpos($disk['fsType'],"btrfs")):?>
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-balance-scale"></i>Balance Status</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
<?if ($disk['fsStatus']=="Mounted"):?>
@@ -261,12 +261,12 @@ btrfs balance status:
<?else:?>
&nbsp;
: <input type="submit" value="Balance" disabled>**Balance** is only available when array is Started.
: <input type="submit" value="Balance" disabled><?=!preg_match('/^cache\d+$/',$disk['name']) ? "<b>Balance</b> is only available when array is Started." : "See Cache Settings."?>
<?endif;?>
</form>
<?endif;?>
<?if (strpos($disk['fsType'],"btrfs")):?>
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-paint-brush"></i>Scrub Status</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
<?if ($disk['fsStatus']=="Mounted"):?>
@@ -303,12 +303,12 @@ btrfs scrub status:
<?else:?>
&nbsp;
: <input type="submit" value="Scrub" disabled>**Scrub** is only available when array is Started.
: <input type="submit" value="Scrub" disabled><?=!preg_match('/^cache\d+$/',$disk['name']) ? "<b>Scrub</b> is only available when array is Started." : "See Cache Settings."?>
<?endif;?>
</form>
<?endif?>
<?if (strpos($disk['fsType'],"btrfs")):?>
<?if (strpos($disk['fsType'],"btrfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>Check Filesystem Status</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
<?if ($var['fsState']=="Started" && $var['startMode']=='Maintenance'):?>
@@ -351,12 +351,12 @@ btrfs check status:
<?else:?>
&nbsp;
: <input type="submit" value="Check" disabled>**Check** is only available when array is Started in **Maintenance** mode.
: <input type="submit" value="Check" disabled><?=!preg_match('/^cache\d+$/',$disk['name']) ? "<b>Check</b> is only available when array is Started in <b>Maintenance</b> mode." : "See Cache Settings."?>
<?endif;?>
</form>
<?endif;?>
<?if (strpos($disk['fsType'],"reiserfs")):?>
<?if (strpos($disk['fsType'],"reiserfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>Check Filesystem Status</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
<?if ($var['fsState']=="Started" && $var['startMode']=='Maintenance'):?>
@@ -405,7 +405,7 @@ reiserfsck status:
<?endif;?>
</form>
<?endif;?>
<?if (strpos($disk['fsType'],"xfs")):?>
<?if (strpos($disk['fsType'],"xfs")!==false):?>
<div id="title" class="nocontrol"><span class="left"><i class="title fa fa-shield"></i>Check Filesystem Status</span></div>
<form markdown="1" method="POST" action="/update.php" target="progressFrame">
<?if ($var['fsState']=="Started" && $var['startMode']=='Maintenance'):?>

View File

@@ -0,0 +1,21 @@
<?PHP
/* Copyright 2005-2017, Lime Technology
* Copyright 2012-2017, 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.
*/
?>
<?
$hide = '/var/tmp/hide_format_button.tmp';
$flag = file_exists($hide);
switch ($_POST['hide']) {
case 'yes': if (!$flag) touch($hide); break;
case 'no' : if ($flag) unlink($hide); break;
}
?>