From 57a4bc69ba39d6f030ca97011aefb6bb617929ee Mon Sep 17 00:00:00 2001 From: Daniel Stefan Haischt Date: Mon, 8 Jan 2007 02:34:06 +0000 Subject: * fix: output an Ajax compliant error message if the disk is still mounted --- packages/freenas/www/disks_manage_init.php | 27 +++++++++++++++-- packages/freenas/www/disks_mount.php | 47 +++++++++++++++--------------- packages/freenas/www/disks_mount_edit.php | 12 ++++---- 3 files changed, 54 insertions(+), 32 deletions(-) (limited to 'packages/freenas/www') diff --git a/packages/freenas/www/disks_manage_init.php b/packages/freenas/www/disks_manage_init.php index cfadcdaf..0d5642d9 100644 --- a/packages/freenas/www/disks_manage_init.php +++ b/packages/freenas/www/disks_manage_init.php @@ -486,7 +486,21 @@ if (! empty($_POST)) $notinitmbr= $_POST['notinitmbr']; /* Check if disk is mounted. */ - if(disks_check_mount_fullname($disk)) { + if(isAjax() && disks_check_mount_fullname($disk)) { + $statustxt = sprintf(gettext("The disk is currently mounted! Unmount this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); + + $divcontents = "
"; + $divcontents .= "
"; + $divcontents .= ""; + $divcontents .= "
  The following errors have occured:

    "; + $divcontents .= "
  • " . $statustxt . "
  • "; + $divcontents .= "

"; + + header("HTTP/1.0 500 Internal Server Error"); + header("Status: 500 Internal Server Error. {$statustxt}"); + echo $divcontents; + exit; + } else { $errormsg = sprintf(gettext("The disk is currently mounted! Unmount this disk first before proceeding."), "disks_mount_tools.php?disk={$disk}&action=umount"); $do_format = false; } @@ -630,11 +644,20 @@ function toggle_cmdout(image, totoggle) { "", { method : "post", parameters : Form.serialize($("iform")), - onSuccess : execFormatComplete + onSuccess : execFormatComplete, + onFailure : execFormatFailure } ); } + function execFormatFailure(req) { + if($('doFormatSubmit')) $('doFormatSubmit').style.visibility = 'visible'; + if($('loading')) $('loading').style.visibility = 'hidden'; + if($('inputerrors')) window.scrollTo(0, 0); + if($('inputerrors')) new Effect.Shake($('inputerrors')); + if($('inputerrors')) $('inputerrors').innerHTML = req.responseText; + } + function execFormatComplete(req) { $("formatOutputTD").innerHTML = req.responseText; $('loading').style.visibility = 'hidden'; diff --git a/packages/freenas/www/disks_mount.php b/packages/freenas/www/disks_mount.php index e8c7d4d5..c72b0d82 100644 --- a/packages/freenas/www/disks_mount.php +++ b/packages/freenas/www/disks_mount.php @@ -175,30 +175,29 @@ echo $pfSenseHead->getHTML();   - - - retry"; - } else { - $stat = gettext("OK"); - } - } - echo $stat; - ?> - - - - " width="17" height="17" border="0" alt="" /> - - - ');" title="" width="17" height="17" border="0" alt="" /> - - + + retry"; + } else { + $stat = gettext("OK"); + } + } + echo $stat; + ?> + + + + " width="17" height="17" border="0" alt="" /> + + + ');" title="" width="17" height="17" border="0" alt="" /> + + diff --git a/packages/freenas/www/disks_mount_edit.php b/packages/freenas/www/disks_mount_edit.php index b4cd7378..6b7a2248 100644 --- a/packages/freenas/www/disks_mount_edit.php +++ b/packages/freenas/www/disks_mount_edit.php @@ -116,7 +116,7 @@ if (! empty($_POST)) $pconfig = $_POST; /* input validation */ - $reqdfields = split(" ", "partition mdisk fstype"); + $reqdfields = split(" ", "partitionno mdisk fstype"); $reqdfieldsn = split(",", "Partition,Mdisk,Fstype"); do_input_validation_new($_POST, $reqdfields, $reqdfieldsn, &$error_bucket); @@ -134,7 +134,7 @@ if (! empty($_POST)) "field" => "desc"); } - $device=$_POST['mdisk'].$_POST['partition']; + $device=$_POST['mdisk'].$_POST['partitionno']; if ($device == $cfdevice ) { @@ -179,12 +179,12 @@ if (! empty($_POST)) { $mount = array(); $mount['mdisk'] = $_POST['mdisk']; - $mount['partition'] = $_POST['partition']; + $mount['partition'] = $_POST['partitionno']; $mount['fstype'] = $_POST['fstype']; $mount['desc'] = $_POST['desc']; /* if not sharename given, create one */ if (!$_POST['sharename']) - $mount['sharename'] = "disk_{$_POST['mdisk']}_part_{$_POST['partition']}"; + $mount['sharename'] = "disk_{$_POST['mdisk']}_part_{$_POST['partitionno']}"; else $mount['sharename'] = $_POST['sharename']; @@ -238,7 +238,7 @@ echo $pfSenseHead->getHTML(); - @@ -246,7 +246,7 @@ echo $pfSenseHead->getHTML(); - + -- cgit v1.2.3