AIRAVATA-2152 Initial UI for adding UserComputeResourcePreference
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/4068347c Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/4068347c Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/4068347c Branch: refs/heads/develop Commit: 4068347c2f916ad9c02c8f65c6d75c3dd860516d Parents: 0be549c Author: Marcus Christie <[email protected]> Authored: Thu Oct 13 10:25:55 2016 -0400 Committer: Marcus Christie <[email protected]> Committed: Fri Oct 28 15:02:17 2016 -0400 ---------------------------------------------------------------------- app/controllers/AccountController.php | 9 +++++++++ app/libraries/URPUtilities.php | 18 ++++++++++++++++++ app/routes.php | 3 ++- app/views/account/dashboard.blade.php | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4068347c/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 183a427..35f8235 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -467,6 +467,7 @@ class AccountController extends BaseController Session::put("notice-seen", true); } + // TODO: maybe move the UserResourceProfile stuff to its own controller? public function getCredentialStore() { $userResourceProfile = URPUtilities::get_or_create_user_resource_profile(); @@ -550,4 +551,12 @@ class AccountController extends BaseController "tokens" => $tokens )); } + + public function modifyUserCRP() { + + if( URPUtilities::add_or_update_user_CRP( Input::all()) ) + { + return Redirect::to("account/user-compute-resources")->with("message","Compute Resource Account Settings have been saved."); + } + } } http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4068347c/app/libraries/URPUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php index 68aef94..005b5cf 100644 --- a/app/libraries/URPUtilities.php +++ b/app/libraries/URPUtilities.php @@ -2,6 +2,7 @@ use Airavata\API\Error\AiravataSystemException; use Airavata\Model\AppCatalog\UserResourceProfile\UserResourceProfile; +use Airavata\Model\AppCatalog\UserResourceProfile\UserComputeResourcePreference; class URPUtilities { @@ -69,6 +70,23 @@ class URPUtilities return $credentialSummaryMap; } + public static function add_or_update_user_CRP($inputs) + { + $timeDifference = Session::get("user_timezone"); + $addOrSubtract = "-"; + if( $timeDifference > 0) + $addOrSubtract = "+"; + $inputs = Input::all(); + if( $inputs["reservationStartTime"] != "") + $inputs["reservationStartTime"] = strtotime( $addOrSubtract . " " . Session::get("user_timezone") . " hours", strtotime( $inputs["reservationStartTime"]) ) * 1000; + if( $inputs["reservationEndTime"] != "") + $inputs["reservationEndTime"] = strtotime( $addOrSubtract . " " . Session::get("user_timezone") . " hours", strtotime($inputs["reservationEndTime"]) ) * 1000; + + $userComputeResourcePreference = new UserComputeResourcePreference($inputs); + $userId = Session::get('username'); + + return Airavata::addUserComputeResourcePreference(Session::get('authz-token'), $userId, $inputs["gatewayId"], $inputs["computeResourceId"], $userComputeResourcePreference); + } // Only used for testing public static function delete_user_resource_profile() http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4068347c/app/routes.php ---------------------------------------------------------------------- diff --git a/app/routes.php b/app/routes.php index e0bc801..8227064 100755 --- a/app/routes.php +++ b/app/routes.php @@ -53,7 +53,8 @@ Route::post("account/set-default-credential", "AccountController@setDefaultCrede Route::post("account/add-credential", "AccountController@addCredential"); Route::post("account/delete-credential", "AccountController@deleteCredential"); -Route::get("account/computeResources", "AccountController@getComputeResources"); +Route::get("account/user-compute-resources", "AccountController@getComputeResources"); +Route::post("account/add-user-crp", "AccountController@modifyUserCRP"); /* * The following routes will not work without logging in. http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/4068347c/app/views/account/dashboard.blade.php ---------------------------------------------------------------------- diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php index 740dded..038dbbb 100644 --- a/app/views/account/dashboard.blade.php +++ b/app/views/account/dashboard.blade.php @@ -391,7 +391,7 @@ <p>Use these settings if you have your own compute and/or storage resource accounts that you would like to use.</p> - <a href="{{URL::to('/')}}/account/computeResources"> + <a href="{{URL::to('/')}}/account/user-compute-resources"> <div class=" col-md-4 well"> <div class="col-md-12"> <span class="glyphicon glyphicon-briefcase console-icon"></span>
