Repository: airavata-php-gateway Updated Branches: refs/heads/master ba5b1a112 -> 98cacd5d3
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/libraries/utilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/utilities.php b/app/libraries/utilities.php index 56d460e..0d428d9 100644 --- a/app/libraries/utilities.php +++ b/app/libraries/utilities.php @@ -1399,12 +1399,14 @@ public static function create_nav_bar() 'Project' => array ( array('label' => 'Create', 'url' => URL::to('/') . '/project/create', "nav-active" => "project"), - array('label' => 'Search', 'url' => URL::to('/') . '/project/search', "nav-active"=> "project") + array('label' => 'Search', 'url' => URL::to('/') . '/project/search', "nav-active"=> "project"), + array('label' => 'Browse', 'url' => URL::to('/') . '/project/browse', "nav-active" => "project") ), 'Experiment' => array ( array('label' => 'Create', 'url' => URL::to('/') . '/experiment/create', "nav-active" => "experiment"), - array('label' => 'Search', 'url' => URL::to('/') . '/experiment/search', "nav-active" => "experiment") + array('label' => 'Search', 'url' => URL::to('/') . '/experiment/search', "nav-active" => "experiment"), + array('label' => 'Browse', 'url' => URL::to('/') . '/experiment/browse', "nav-active" => "experiment") ) ); @@ -1856,6 +1858,98 @@ public static function get_experiment_values( $experiment, $project, $forSearch } + public static function get_all_user_projects_with_pagination($limit, $offset) + { + $airavataclient = Session::get("airavataClient");; + + $projects = array(); + + try + { + $projects = $airavataclient->getAllUserProjectsWithPagination( Session::get("gateway_id"), + Session::get("username"), $limit, $offset); + } + catch (InvalidRequestException $ire) + { + Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('<p>You have not created any projects yet, so no results will be returned!</p> + <p>Click <a href="create_project.php">here</a> to create a new project.</p>'); + } + else + { + Utilities::print_error_message('There was a problem with Airavata. Please try again later, or report a bug using the link in the Help menu.'); + //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage()); + } + + return $projects; + } + + + + public static function get_projsearch_results_with_pagination( $searchKey, $searchValue, $limit, $offset) + { + $airavataclient = Session::get("airavataClient"); + + $projects = array(); + + try + { + switch ( $searchKey) + { + case 'project-name': + $projects = $airavataclient->searchProjectsByProjectNameWithPagination( Session::get("gateway_id"), + Session::get("username"), $searchValue, $limit, $offset); + break; + case 'project-description': + $projects = $airavataclient->searchProjectsByProjectDescWithPagination( Session::get("gateway_id"), + Session::get("username"), $searchValue, $limit, $offset); + break; + } + } + catch (InvalidRequestException $ire) + { + Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('<p>You have not created any projects yet, so no results will be returned!</p> + <p>Click <a href="create_project.php">here</a> to create a new project.</p>'); + } + else + { + Utilities::print_error_message('There was a problem with Airavata. Please try again later, or report a bug using the link in the Help menu.'); + //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage()); + } + + return $projects; + } + + public static function get_projsearch_results( $searchKey, $searchValue) { $airavataclient = Session::get("airavataClient");; @@ -1929,7 +2023,83 @@ public static function create_options($values, $labels, $disabled) } } -/** + /** + * Get results of the user's search of experiments with pagination + * @return array|null + */ + public static function get_expsearch_results_with_pagination( $inputs, $limit, $offset) + { + $airavataclient = Session::get("airavataClient"); + $experiments = array(); + + try + { + switch ( $inputs["search-key"]) + { + case 'experiment-name': + $experiments = $airavataclient->searchExperimentsByNameWithPagination( + Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); + break; + case 'experiment-description': + $experiments = $airavataclient->searchExperimentsByDescWithPagination( + Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); + break; + case 'application': + $experiments = $airavataclient->searchExperimentsByApplicationWithPagination( + Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset); + break; + case 'creation-time': + $experiments = $airavataclient->searchExperimentsByCreationTimeWithPagination( + Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000, + strtotime( $inputs["to-date"])*1000 , $limit, $offset); + break; + case '': + } + } + catch (InvalidRequestException $ire) + { + Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('<p>You have not created any experiments yet, so no results will be returned!</p> + <p>Click <a href="create_experiment.php">here</a> to create an experiment, or + <a href="create_project.php">here</a> to create a new project.</p>'); + } + else + { + Utilities::print_error_message('There was a problem with Airavata. Please try again later or report a bug using the link in the Help menu.'); + //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage()); + } + + //get values of all experiments + $expContainer = array(); + $expNum = 0; + foreach( $experiments as $experiment) + { + $expValue = Utilities::get_experiment_values( $experiment, Utilities::get_project($experiment->projectID), true ); + $expContainer[$expNum]['experiment'] = $experiment; + if( $expValue["experimentStatusString"] == "FAILED") + $expValue["editable"] = false; + $expContainer[$expNum]['expValue'] = $expValue; + $expNum++; + } + + return $expContainer; + } + + /** * Get results of the user's search of experiments * @return array|null */ @@ -2000,6 +2170,65 @@ public static function get_expsearch_results( $inputs) return $expContainer; } + /** + * Get results of the user's all experiments with pagination. + * Results are ordered creation time DESC + * @return array|null + */ + public static function get_all_user_experiments_with_pagination($limit, $offset) + { + $airavataclient = Session::get("airavataClient"); + $experiments = array(); + + try + { + $experiments = $airavataclient->getAllUserExperimentsWithPagination( + Session::get('gateway_id'), Session::get('username'), $limit, $offset + ); + } + catch (InvalidRequestException $ire) + { + Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage()); + } + catch (AiravataClientException $ace) + { + Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage()); + } + catch (AiravataSystemException $ase) + { + if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR + { + Utilities::print_info_message('<p>You have not created any experiments yet, so no results will be returned!</p> + <p>Click <a href="create_experiment.php">here</a> to create an experiment, or + <a href="create_project.php">here</a> to create a new project.</p>'); + } + else + { + Utilities::print_error_message('There was a problem with Airavata. Please try again later or report a bug using the link in the Help menu.'); + //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage()); + } + } + catch (TTransportException $tte) + { + Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage()); + } + + //get values of all experiments + $expContainer = array(); + $expNum = 0; + foreach( $experiments as $experiment) + { + $expValue = Utilities::get_experiment_values( $experiment, Utilities::get_project($experiment->projectID), true ); + $expContainer[$expNum]['experiment'] = $experiment; + if( $expValue["experimentStatusString"] == "FAILED") + $expValue["editable"] = false; + $expContainer[$expNum]['expValue'] = $expValue; + $expNum++; + } + + return $expContainer; + } + public static function getExpStates(){ return ExperimentState::$__names; } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index ffcde73..086efe3 100755 --- a/app/routes.php +++ b/app/routes.php @@ -54,6 +54,10 @@ Route::get("project/edit", "ProjectController@editView"); Route::post("project/edit", "ProjectController@editSubmit"); +Route::get("project/browse", "ProjectController@browseView"); + +Route::post("project/browse", "ProjectController@browseView"); + /* * Experiment Routes */ @@ -78,6 +82,9 @@ Route::post("experiment/cancel", "ExperimentController@expCancel"); Route::get("experiment/getQueueView", "ExperimentController@getQueueView"); +Route::get("experiment/browse", "ExperimentController@browseView"); + +Route::post("experiment/browse", "ExperimentController@browseView"); /* * Compute Resources Routes */ http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/views/experiment/browse.blade.php ---------------------------------------------------------------------- diff --git a/app/views/experiment/browse.blade.php b/app/views/experiment/browse.blade.php new file mode 100755 index 0000000..f5d2a44 --- /dev/null +++ b/app/views/experiment/browse.blade.php @@ -0,0 +1,183 @@ +@extends('layout.basic') + +@section('content') + +<div class="container" style="max-width: 750px;"> +<h1>Browse Experiments</h1> + +<?php + +if (isset( $expContainer)) +{ +?> + <!-- Pagination handling--> + <form id="paginationForm" action="{{URL::to('/')}}/experiment/browse" method="post" class="form-inline" role="form"> + <div class="pull-right btn-toolbar" style="padding-bottom: 5px"> + <?php + if($pageNo!=1){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="prev" value="Previous"/>'; + } + if(sizeof($expContainer)>0){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="next" value="Next"/>'; + } + ?> + </div> + <div class="pull-left"> + <?php if (sizeof($expContainer) != 0) echo 'Showing results from ' . strval(($pageNo-1)*$limit + 1) + . ' to ' . strval($pageNo*$limit); ?> + </div> + <input type="hidden" name="pageNo" value="<?php echo($pageNo) ?>"/> + <div style="clear: both"></div> + </form> + +<?php + if (sizeof($expContainer) == 0) + { + if($pageNo==1){ + Utilities::print_warning_message('No results found. Please try again.'); + }else{ + Utilities::print_warning_message('No more results found.'); + } + } + else + { +?> + <div id="re" class="table-responsive"> + <table class="table"> + <tr> + <th>Name</th> + <th>Application</th> + <th>Description</th> + <!--<th>Resource</th>--> + <th>Creation Time</th> + <th> + <select class="form-control select-status"> + <option value="ALL">Status</option> + @foreach( $expStates as $index => $state) + <option value="{{ $state }}">{{ $state }}</option> + @endforeach + </select> + </th> + </tr> + + +<?php + foreach ($expContainer as $experiment) + { + $description = $experiment['experiment']->description; + if (strlen($description) > 17) // 17 is arbitrary + { + $description = substr($experiment['experiment']->description, 0, 17) . '<span class="text-muted">...</span>'; + } + + echo '<tr>'; + $addEditOption=""; + if( $experiment['expValue']['editable']) + $addEditOption = '<a href="'. URL::to('/') . '/experiment/edit?expId=' . $experiment['experiment']->experimentID . '" title="Edit"><span class="glyphicon glyphicon-pencil"></span></a>'; + + echo '<td>' . $experiment['experiment']->name . $addEditOption . '</td>'; + + echo '<td>' . $experiment['expValue']['applicationInterface']->applicationName . '</td>'; + + echo '<td>' . $description . '</td>'; + + //echo "<td>$computeResource->hostName</td>"; + echo '<td>' . date('Y-m-d H:i:s', $experiment['experiment']->creationTime/1000) . '</td>'; + + + switch ($experiment['expValue']['experimentStatusString']) + { + case 'CANCELING': + case 'CANCELED': + case 'UNKNOWN': + $textClass = 'text-warning'; + break; + case 'FAILED': + $textClass = 'text-danger'; + break; + case 'COMPLETED': + $textClass = 'text-success'; + break; + default: + $textClass = 'text-info'; + break; + } + + ?> + <td> + <a class="<?php echo $textClass; ?>" href="{{ URL::to('/') }}/experiment/summary?expId=<?php echo $experiment['experiment']->experimentID; ?>"> + <?php echo $experiment['expValue']['experimentStatusString']; ?> + </a> + </td> + + </tr> + + <?php + } + + echo ' + </table> + </div> + '; + } +} +?> +</div> + +@stop + +@section('scripts') + @parent + + <script type="text/javascript"> + + $(document).ready( function(){ + + /* script to make status select work on the UI side itself. */ + + $(".select-status").on("change", function(){ + selectedStatus = this.value; + + if( selectedStatus == "ALL") + { + $("table tr").slideDown(); + } + else + { + $("table tr").each(function(index) { + if (index != 0) { + + $row = $(this); + + var status = $.trim( $row.find("td:last").text() ); + if (status == selectedStatus ) + { + $(this).slideDown(); + } + else { + $(this).slideUp(); + } + } + }); + } + }); + }); + + function changeInputVisibility( selectedStatus) + { + if( selectedStatus == "creation-time") + { + $(".search-text-block").addClass("hide"); + $(".select-dates").removeClass("hide"); + $("#search-value").removeAttr("required"); + + } + else + { + $(".search-text-block").removeClass("hide"); + $(".select-dates").addClass("hide"); + $("#search-value").attr("required"); + } + } + </script> +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/views/experiment/search.blade.php ---------------------------------------------------------------------- diff --git a/app/views/experiment/search.blade.php b/app/views/experiment/search.blade.php index e33acd0..43c95d1 100755 --- a/app/views/experiment/search.blade.php +++ b/app/views/experiment/search.blade.php @@ -62,6 +62,31 @@ <button name="search" type="submit" class="btn btn-primary" value="Search"><span class="glyphicon glyphicon-search"></span> Search</button> <p class="help-block">You can use * as a wildcard character. Tip: search for * alone to retrieve all of your experiments.</p> + + <!-- Pagination Handling --> + <?php + if(isset( $expContainer)) + { + ?> + <div class="pull-right btn-toolbar" style="padding-bottom: 5px"> + <?php + if($pageNo!=1){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="prev" value="Previous"/>'; + } + if(sizeof($expContainer)>0){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="next" value="Next"/>'; + } + ?> + </div> + <div class="pull-left"> + <?php if (sizeof($expContainer) != 0) echo 'Showing results from ' . strval(($pageNo-1)*$limit + 1) + . ' to ' . strval($pageNo*$limit); ?> + </div> + <input type="hidden" name="pageNo" value="<?php echo($pageNo) ?>"/> + <div style="clear: both"></div> + <?php + } + ?> </form> @@ -73,14 +98,17 @@ if (isset( $expContainer)) { if (sizeof($expContainer) == 0) { - Utilities::print_warning_message('No results found. Please try again.'); + if($pageNo==1){ + Utilities::print_warning_message('No results found. Please try again.'); + }else{ + Utilities::print_warning_message('No more results found.'); + } } else { - ?> - <div class="table-responsive"> + <div id="re" class="table-responsive"> <table class="table"> <tr> <th>Name</th> @@ -258,8 +286,5 @@ if (isset( $expContainer)) $("#search-value").attr("required"); } } - - - </script> @stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/views/project/browse.blade.php ---------------------------------------------------------------------- diff --git a/app/views/project/browse.blade.php b/app/views/project/browse.blade.php new file mode 100755 index 0000000..58e4a62 --- /dev/null +++ b/app/views/project/browse.blade.php @@ -0,0 +1,102 @@ + +@extends('layout.basic') + +@section('page-header') + @parent +@stop + +@section('content') + + <div class="container" style="max-width: 750px;"> + + <h1>Browse Projects</h1> + <?php + + if (isset( $projects)) + { + ?> + + <!-- Pagination handling--> + <form id="paginationForm" action="{{URL::to('/')}}/project/browse" method="post" class="form-inline" role="form"> + <div class="pull-right btn-toolbar" style="padding-bottom: 5px"> + <?php + if($pageNo!=1){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="prev" value="Previous"/>'; + } + if(sizeof($projects)>0){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="next" value="Next"/>'; + } + ?> + </div> + <div class="pull-left"> + <?php if (sizeof($projects) != 0) echo 'Showing results from ' . strval(($pageNo-1)*$limit + 1) + . ' to ' . strval($pageNo*$limit); ?> + </div> + <input type="hidden" name="pageNo" value="<?php echo($pageNo) ?>"/> + <div style="clear: both"></div> + </form> + + <?php + /** + * get results + */ + + /** + * display results + */ + if (sizeof($projects) == 0) + { + Utilities::print_warning_message('No results found. Please try again.'); + } + else + { + ?> + <div class="table-responsive"> + <table class="table"> + + <tr> + + <th>Name</th> + <th>Creation Time</th> + <th>Experiments</th> + + </tr> + <?php + + foreach ($projects as $project) + { + + ?> + <tr> + <td> + <?php echo $project->name; ?> + <a href="{{URL::to('/')}}/project/edit?projId=<?php echo $project->projectID; ?>" title="Edit"> + <span class="glyphicon glyphicon-pencil"></span> + </a> + </td> + <td> + <?php echo date('Y-m-d H:i:s', $project->creationTime/1000); ?> + </td> + <td> + <a href="{{URL::to('/')}}/project/summary?projId=<?php echo $project->projectID; ?>"> + <span class="glyphicon glyphicon-list"></span> + </a> + <a href="{{URL::to('/')}}/project/summary?projId=<?php echo $project->projectID; ?>"> View</a> + </td> + </tr> + <?php + + } + + echo '</table>'; + echo '</div>'; + } + + } + + ?> + + + </div> + +@stop \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5be987ef/app/views/project/search.blade.php ---------------------------------------------------------------------- diff --git a/app/views/project/search.blade.php b/app/views/project/search.blade.php index 486fd9d..4737783 100755 --- a/app/views/project/search.blade.php +++ b/app/views/project/search.blade.php @@ -28,6 +28,31 @@ <button name="search" type="submit" class="btn btn-primary" value="Search"><span class="glyphicon glyphicon-search"></span> Search</button> <p class="help-block">You can use * as a wildcard character. Tip: search for * alone to retrieve all of your projects.</p> + + <!-- Pagination Handling --> + <?php + if(isset( $projects)) + { + ?> + <div class="pull-right btn-toolbar" style="padding-bottom: 5px"> + <?php + if($pageNo!=1){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="prev" value="Previous"/>'; + } + if(sizeof($projects)>0){ + echo '<input class="btn btn-primary btn-xs" type="submit" style="cursor: pointer" name="next" value="Next"/>'; + } + ?> + </div> + <div class="pull-left"> + <?php if (sizeof($projects) != 0) echo 'Showing results from ' . strval(($pageNo-1)*$limit + 1) + . ' to ' . strval($pageNo*$limit); ?> + </div> + <input type="hidden" name="pageNo" value="<?php echo($pageNo) ?>"/> + <div style="clear: both"></div> + <?php + } + ?> </form> @@ -47,7 +72,11 @@ */ if (sizeof($projects) == 0) { - Utilities::print_warning_message('No results found. Please try again.'); + if($pageNo==1){ + Utilities::print_warning_message('No results found. Please try again.'); + }else{ + Utilities::print_warning_message('No more results found.'); + } } else {
