You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/02/01 13:36:31 UTC
[02/21] airavata-php-gateway git commit: AIRAVATA-1397 Display max
upload file size in form
AIRAVATA-1397 Display max upload file size in form
Also no longer using 'server-allowed'file-size' from pga_config.php.
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/d0af4e3b
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/d0af4e3b
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/d0af4e3b
Branch: refs/heads/dreg-gateway
Commit: d0af4e3b43c72cfb4c9c405cfe8f39202f439a19
Parents: 65ef21b
Author: Marcus Christie <ma...@apache.org>
Authored: Wed Jan 11 10:16:45 2017 -0500
Committer: Marcus Christie <ma...@apache.org>
Committed: Wed Jan 11 10:18:57 2017 -0500
----------------------------------------------------------------------
app/config/pga_config.php.template | 5 ----
app/controllers/ExperimentController.php | 26 ++++++++++++++-------
app/libraries/ExperimentUtilities.php | 15 ++++++++----
app/views/experiment/edit.blade.php | 1 +
app/views/partials/experiment-inputs.blade.php | 4 ++--
public/css/bootstrap.min.css | 18 ++++++++++++++
6 files changed, 49 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 7a18f5a..ac378f6 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -114,11 +114,6 @@ return array(
'gateway-id' => 'default',
/**
- * Maximum size of a file which is allowed to upload to the server
- */
- 'server-allowed-file-size' => 64,
-
- /**
* absolute path of the data dir
*/
'experiment-data-absolute-path' => '/var/www/experimentData',
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 5f1533f..7bfd8c5 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -50,13 +50,6 @@ class ExperimentController extends BaseController
if( Input::has("savedExp"))
$savedExp = true;
- // Condition added to deal with php ini default value set for post_max_size issue.
- $allowedFileSize = Config::get('pga_config.airavata')["server-allowed-file-size"];
- $serverLimit = intval( ini_get( 'post_max_size') );
- if( $serverLimit < $allowedFileSize)
- $allowedFileSize = $serverLimit;
-
-
$experimentInputs = array(
"clonedExp" => $clonedExp,
"savedExp" => $savedExp,
@@ -72,7 +65,7 @@ class ExperimentController extends BaseController
"computeResources" => $computeResources,
"resourceHostId" => null,
"advancedOptions" => Config::get('pga_config.airavata')["advanced-experiment-options"],
- "allowedFileSize" => $allowedFileSize
+ "allowedFileSize" => $this->getAllowedFileSize()
);
if(Config::get('pga_config.airavata')["data-sharing-enabled"]){
@@ -299,7 +292,7 @@ class ExperimentController extends BaseController
"userDN" => $experiment->userConfigurationData->userDN,
"userHasComputeResourcePreference" => $userHasComputeResourcePreference,
"useUserCRPref" => $experiment->userConfigurationData->useUserCRPref,
- "allowedFileSize" => Config::get('pga_config.airavata')["server-allowed-file-size"],
+ "allowedFileSize" => $this->getAllowedFileSize(),
'experiment' => $experiment,
"queueDefaults" => $queueDefaults,
'computeResources' => $computeResources,
@@ -503,6 +496,21 @@ class ExperimentController extends BaseController
return Response::json(array("success" => false, "error" => "Error: failed to update sharing: " . $ex->getMessage()));
}
}
+
+ private function getAllowedFileSize()
+ {
+ // Condition added to deal with php ini default value set for post_max_size issue.
+ // NOTE: the following assumes that upload_max_filesize and
+ // post_max_size are in megabytes (for example, if
+ // upload_max_filesize is 8M then $allowedFileSize is 8, but the 'M'
+ // is assumed and not considered)
+ $allowedFileSize = intval( ini_get( 'upload_max_filesize' ) );
+ $serverLimit = intval( ini_get( 'post_max_size' ) );
+ if( $serverLimit < $allowedFileSize) {
+ $allowedFileSize = $serverLimit;
+ }
+ return $allowedFileSize;
+ }
}
?>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index d939f7d..a4fee3b 100755
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -753,9 +753,10 @@ class ExperimentUtilities
* Create form inputs to accept the inputs to the given application
* @param $id
* @param $isRequired
+ * @param $allowedFileSize maximum file size in megabytes
* @internal param $required
*/
- public static function create_inputs($id, $isRequired)
+ public static function create_inputs($id, $isRequired, $allowedFileSize)
{
$inputs = AppUtilities::get_application_inputs($id);
@@ -812,8 +813,11 @@ class ExperimentUtilities
<label for="experiment-input">' . $input->name . '</label>
<div data-file-id="' . $input->sanitizedFormName . '" class="readBytesButtons btn btn-default btn-xs"
data-toggle="modal" style="float: right">view file</div>
- <input class="file-input" type="file" name="' . $input->sanitizedFormName .
- '" id="' . $input->sanitizedFormName . '" ' . $required . '>
+ <div class="file-upload-container">
+ <input class="file-input" type="file" name="' . $input->sanitizedFormName .
+ '" id="' . $input->sanitizedFormName . '" ' . $required . '>
+ <div class="file-upload-max-size">Max Upload Size: ' . $allowedFileSize .'M</div>
+ </div>
<p class="help-block">' . $input->userFriendlyDescription . '</p>
</div>';
break;
@@ -830,7 +834,10 @@ class ExperimentUtilities
if($appInterface->hasOptionalFileInputs){
echo '<div>
<label>Optional Input Files</label>
- <input type="file" class="file-input" id="optInputFiles" name="optInputFiles[]" multiple onchange="javascript:updateList()" >
+ <div class="file-upload-container">
+ <input type="file" class="file-input" id="optInputFiles" name="optInputFiles[]" multiple onchange="javascript:updateList()" >
+ <div class="file-upload-max-size">Max Upload Size: ' . $allowedFileSize .'M</div>
+ </div>
<div id="optFileList"></div>
</div>';
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/app/views/experiment/edit.blade.php
----------------------------------------------------------------------
diff --git a/app/views/experiment/edit.blade.php b/app/views/experiment/edit.blade.php
index bfa5331..52e035b 100755
--- a/app/views/experiment/edit.blade.php
+++ b/app/views/experiment/edit.blade.php
@@ -39,6 +39,7 @@
This experiment is connected with an Application which is currently not deployed on any Resource. The experiment cannot be launched at the moment.
</p>
@endif
+ <input type="hidden" id="allowedFileSize" value="{{ $expInputs['allowedFileSize'] }}"/>
</form>
</div>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/app/views/partials/experiment-inputs.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/experiment-inputs.blade.php b/app/views/partials/experiment-inputs.blade.php
index c2c85f8..dfe9d6c 100644
--- a/app/views/partials/experiment-inputs.blade.php
+++ b/app/views/partials/experiment-inputs.blade.php
@@ -41,9 +41,9 @@
{{ ExperimentUtilities::list_input_files($expInputs['experiment']->experimentInputs) }}
<hr/>
</div>
- {{ ExperimentUtilities::create_inputs($expInputs['application'], false) }}
+ {{ ExperimentUtilities::create_inputs($expInputs['application'], false, $expInputs['allowedFileSize']) }}
@else
- {{ ExperimentUtilities::create_inputs($expInputs['application'], true) }}
+ {{ ExperimentUtilities::create_inputs($expInputs['application'], true, $expInputs['allowedFileSize']) }}
@endif
</div>
<!-- Modal to view file inputs-->
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/d0af4e3b/public/css/bootstrap.min.css
----------------------------------------------------------------------
diff --git a/public/css/bootstrap.min.css b/public/css/bootstrap.min.css
index 69ea7f4..0f7ca0c 100644
--- a/public/css/bootstrap.min.css
+++ b/public/css/bootstrap.min.css
@@ -144,4 +144,22 @@ body{
top: 0px;
bottom: 0px;
right: 0px;
+}
+
+.file-upload-container {
+ position: relative;
+ padding-right: 120px;
+}
+.file-upload-container > input[type="file"] {
+ width: 100%;
+}
+.file-upload-container > .file-upload-max-size {
+ position: absolute;
+ right: 0px;
+ top: 50%;
+ /* negative one half of the height of this element (which is approx. font-size * line-height) */
+ margin-top: calc( -1/2 * (12px * 1.42) );
+ font-size: 12px;
+ font-style: italic;
+ color: #737373;
}
\ No newline at end of file