You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/10/28 20:04:49 UTC
[03/18] airavata-php-gateway git commit: AIRAVATA-2152 Initial UI for
updating UserComputeResourcePreferences
AIRAVATA-2152 Initial UI for updating UserComputeResourcePreferences
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/5940f9be
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/5940f9be
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/5940f9be
Branch: refs/heads/develop
Commit: 5940f9be2bace0cb9e3997047d34cb564d652b27
Parents: 4068347
Author: Marcus Christie <ma...@gmail.com>
Authored: Thu Oct 13 16:06:27 2016 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Fri Oct 28 15:03:36 2016 -0400
----------------------------------------------------------------------
app/controllers/AccountController.php | 19 +++++++-
app/libraries/URPUtilities.php | 11 +++--
app/routes.php | 3 +-
.../account/user-compute-resources.blade.php | 46 ++++++++++++++++++++
.../user-compute-resource-preferences.blade.php | 5 +++
5 files changed, 79 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5940f9be/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 35f8235..1fe9d80 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -539,6 +539,14 @@ class AccountController extends BaseController
public function getComputeResources(){
$userResourceProfile = URPUtilities::get_or_create_user_resource_profile();
$allCRs = CRUtilities::getAllCRObjects();
+ foreach( $allCRs as $index => $crObject)
+ {
+ $allCRsById[$crObject->computeResourceId] = $crObject;
+ }
+ // Add crDetails to each UserComputeResourcePreference
+ foreach ($userResourceProfile->userComputeResourcePreferences as $index => $userCompResPref) {
+ $userCompResPref->crDetails = $allCRsById[$userCompResPref->computeResourceId];
+ }
// TODO: actually get all of the user's credential store tokens, including description
$tokens = array(
$userResourceProfile->credentialStoreToken => "Default SSH Key"
@@ -552,11 +560,20 @@ class AccountController extends BaseController
));
}
- public function modifyUserCRP() {
+ public function addUserComputeResourcePreference() {
+ // TODO: flash message isn't setup in the view
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.");
}
}
+
+ public function updateUserComputeResourcePreference() {
+
+ if( URPUtilities::add_or_update_user_CRP( Input::all(), true ) )
+ {
+ return Redirect::to("account/user-compute-resources")->with("message","Compute Resource Account Settings have been updated.");
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5940f9be/app/libraries/URPUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php
index 005b5cf..026b06e 100644
--- a/app/libraries/URPUtilities.php
+++ b/app/libraries/URPUtilities.php
@@ -70,7 +70,7 @@ class URPUtilities
return $credentialSummaryMap;
}
- public static function add_or_update_user_CRP($inputs)
+ public static function add_or_update_user_CRP($inputs, $update = false)
{
$timeDifference = Session::get("user_timezone");
$addOrSubtract = "-";
@@ -84,8 +84,13 @@ class URPUtilities
$userComputeResourcePreference = new UserComputeResourcePreference($inputs);
$userId = Session::get('username');
-
- return Airavata::addUserComputeResourcePreference(Session::get('authz-token'), $userId, $inputs["gatewayId"], $inputs["computeResourceId"], $userComputeResourcePreference);
+ if ($update)
+ {
+ return Airavata::updateUserComputeResourcePreference(Session::get('authz-token'), $userId, $inputs["gatewayId"], $inputs["computeResourceId"], $userComputeResourcePreference);
+ } else
+ {
+ return Airavata::addUserComputeResourcePreference(Session::get('authz-token'), $userId, $inputs["gatewayId"], $inputs["computeResourceId"], $userComputeResourcePreference);
+ }
}
// Only used for testing
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5940f9be/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 8227064..b8b5aeb 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -54,7 +54,8 @@ Route::post("account/add-credential", "AccountController@addCredential");
Route::post("account/delete-credential", "AccountController@deleteCredential");
Route::get("account/user-compute-resources", "AccountController@getComputeResources");
-Route::post("account/add-user-crp", "AccountController@modifyUserCRP");
+Route::post("account/add-user-crp", "AccountController@addUserComputeResourcePreference");
+Route::post("account/update-user-crp", "AccountController@updateUserComputeResourcePreference");
/*
* The following routes will not work without logging in.
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5940f9be/app/views/account/user-compute-resources.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/user-compute-resources.blade.php b/app/views/account/user-compute-resources.blade.php
index 7838623..f460a53 100644
--- a/app/views/account/user-compute-resources.blade.php
+++ b/app/views/account/user-compute-resources.blade.php
@@ -18,6 +18,52 @@
</button>
</div>
</div>
+ <div class="row">
+ <div class="col-md-12">
+ <div class="panel-group" id="accordion">
+ @foreach( (array)$userResourceProfile->userComputeResourcePreferences as $indexUserCRP => $user_crp )
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h4 class="panel-title">
+ <a class="accordion-toggle collapsed"
+ data-toggle="collapse" data-parent="#accordion"
+ href="#collapse-user-crp-{{$indexUserCRP}}">
+ HOSTNAME TODO: {{$user_crp->computeResourceId}}
+ </a>
+ <div class="pull-right col-md-2 fade">
+ <span class="glyphicon glyphicon-remove remove-compute-resource"
+ style="cursor:pointer;" data-toggle="modal"
+ data-target="#remove-compute-resource-block"
+ data-cr-name="TODO"
+ data-cr-id="{{$user_crp->computeResourceId}}"
+ data-gp-id="{{ $userResourceProfile->gatewayID }}"></span>
+ </div>
+ </h4>
+ </div>
+ <div id="collapse-user-crp-{{$indexUserCRP}}"
+ class="panel-collapse collapse">
+ <div class="panel-body">
+ <form class="set-cr-preference" action="{{URL::to('/')}}/account/update-user-crp"
+ method="POST">
+ <input type="hidden" name="gatewayId" id="gatewayId"
+ value="{{$userResourceProfile->gatewayID}}">
+ <input type="hidden" name="computeResourceId"
+ id="gatewayId"
+ value="{{$user_crp->computeResourceId}}">
+
+ <div class="form-horizontal">
+ @include('partials/user-compute-resource-preferences',
+ array('computeResource' => $user_crp->crDetails,
+ 'preferences'=>$user_crp, 'show'=>true))
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ @endforeach
+ </div>
+ </div>
+ </div>
</div>
<div class="add-user-compute-resource-block hide">
<div class="well">
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5940f9be/app/views/partials/user-compute-resource-preferences.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/user-compute-resource-preferences.blade.php b/app/views/partials/user-compute-resource-preferences.blade.php
index e930e53..f045bd0 100644
--- a/app/views/partials/user-compute-resource-preferences.blade.php
+++ b/app/views/partials/user-compute-resource-preferences.blade.php
@@ -1,3 +1,8 @@
+<!-- partial template variables:
+ computeResource - (required, ComputeResourceDescription) the compute resource object
+ preferences - (optional, UserComputeResourcePreference) the saved preference data
+ show - (optional, boolean)
+-->
<!-- String replace is done as Jquery creates problems when using period(.) in id or class. -->
<div id="cr-{{ str_replace( '.', "_", $computeResource->computeResourceId) }}" class="@if(isset( $show) ) @if( !$show) hide @endif @else hide @endif">
<h3 class="text-center">Set Preferences</h3>