airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sma...@apache.org
Subject [06/18] airavata-php-gateway git commit: AIRAVATA-2152 Support for deleting user compute resources prefs
Date Fri, 28 Oct 2016 20:04:52 GMT
AIRAVATA-2152 Support for deleting user compute resources prefs


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/17425c08
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/17425c08
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/17425c08

Branch: refs/heads/develop
Commit: 17425c084ef45a9cf7f98884f98b7507c5cfaa93
Parents: 6555a6e
Author: Marcus Christie <marc.christie@gmail.com>
Authored: Fri Oct 14 11:57:19 2016 -0400
Committer: Marcus Christie <machrist@iu.edu>
Committed: Fri Oct 28 15:04:29 2016 -0400

----------------------------------------------------------------------
 app/controllers/AccountController.php           | 10 +++-
 app/libraries/URPUtilities.php                  |  8 +++
 app/routes.php                                  |  1 +
 .../account/user-compute-resources.blade.php    | 54 +++++++++++++-----
 .../user-compute-resource-preferences.blade.php | 58 +++++++++++---------
 5 files changed, 91 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/17425c08/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 1fe9d80..bf069db 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -562,7 +562,6 @@ class AccountController extends BaseController
 
     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.");
@@ -576,4 +575,13 @@ class AccountController extends BaseController
             return Redirect::to("account/user-compute-resources")->with("message","Compute
Resource Account Settings have been updated.");
         }
     }
+
+    public function deleteUserComputeResourcePreference() {
+        $computeResourceId = Input::get("rem-user-crId");
+        $result = URPUtilities::delete_user_CRP( $computeResourceId );
+        if( $result )
+        {
+            return Redirect::to("account/user-compute-resources")->with("message","Compute
Resource Account Settings have been deleted.");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/17425c08/app/libraries/URPUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php
index 026b06e..3da8f21 100644
--- a/app/libraries/URPUtilities.php
+++ b/app/libraries/URPUtilities.php
@@ -93,6 +93,14 @@ class URPUtilities
         }
     }
 
+    public static function delete_user_CRP($computeResourceId)
+    {
+        $userId = Session::get('username');
+        $gatewayId = Session::get('gateway_id');
+        $result = Airavata::deleteUserComputeResourcePreference(Session::get('authz-token'),
$userId, $gatewayId, $computeResourceId);
+        return $result;
+    }
+
     // Only used for testing
     public static function delete_user_resource_profile()
     {

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/17425c08/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index b8b5aeb..ffb6850 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -56,6 +56,7 @@ Route::post("account/delete-credential", "AccountController@deleteCredential");
 Route::get("account/user-compute-resources", "AccountController@getComputeResources");
 Route::post("account/add-user-crp", "AccountController@addUserComputeResourcePreference");
 Route::post("account/update-user-crp", "AccountController@updateUserComputeResourcePreference");
+Route::post("account/delete-user-crp", "AccountController@deleteUserComputeResourcePreference");
 
 /*
  * The following routes will not work without logging in.

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/17425c08/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 a8dbff7..a1a1f99 100644
--- a/app/views/account/user-compute-resources.blade.php
+++ b/app/views/account/user-compute-resources.blade.php
@@ -7,6 +7,9 @@ button.add-user-cr {
     margin-top: 10px;
     margin-bottom: 10px;
 }
+#user-cr-select-input-group {
+    margin-bottom: 10px;
+}
 </style>
 @stop
 
@@ -36,16 +39,8 @@ button.add-user-cr {
                     <a class="accordion-toggle collapsed"
                        data-toggle="collapse" data-parent="#accordion"
                        href="#collapse-user-crp-{{$indexUserCRP}}">
-                        HOSTNAME TODO: {{$user_crp->computeResourceId}}
+                        {{$user_crp->crDetails->hostName}}
                     </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}}"
@@ -62,7 +57,8 @@ button.add-user-cr {
                         <div class="form-horizontal">
                             @include('partials/user-compute-resource-preferences',
                             array('computeResource' => $user_crp->crDetails,
-                            'preferences'=>$user_crp, 'show'=>true))
+                            'preferences'=>$user_crp, 'show'=>true,
+                            'allowDelete'=>true))
                         </div>
                     </form>
                 </div>
@@ -73,12 +69,11 @@ button.add-user-cr {
 </div>
 <div class="add-user-compute-resource-block hide">
     <div class="well">
-        <!-- TODO: need to implement /add-user-crp -->
         <form action="{{URL::to('/')}}/account/add-user-crp" method="POST">
             <input type="hidden" name="gatewayId" id="gatewayId" value="{{$userResourceProfile->gatewayID}}">
 
-            <div class="input-group">
-                <select name="computeResourceId" class="cr-select form-control">
+            <div id="user-cr-select-input-group" class="input-group">
+                <select id="user-cr-select" name="computeResourceId" class="form-control">
                     <option value="">Select a Compute Resource and configure your account</option>
                     @foreach( (array)$unselectedCRs as $index => $cr)
                     <option value="{{ $cr->computeResourceId}}">{{ $cr->hostName
}}</option>
@@ -91,6 +86,33 @@ button.add-user-cr {
         </form>
     </div>
 </div>
+
+<div class="modal fade" id="remove-user-compute-resource-block" tabindex="-1" role="dialog"
aria-labelledby="add-modal"
+     aria-hidden="true">
+    <div class="modal-dialog">
+
+        <form action="{{URL::to('/')}}/account/delete-user-crp" method="POST">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h3 class="text-center">Remove Compute Resource Account Confirmation</h3>
+                </div>
+                <div class="modal-body">
+                    <input type="hidden" class="form-control remove-user-crId" name="rem-user-crId"/>
+
+                    Do you really want to remove your Compute Resource Account settings for
<span class="remove-user-cr-name"> </span>?
+                </div>
+                <div class="modal-footer">
+                    <div class="form-group">
+                        <input type="submit" class="btn btn-danger" value="Remove"/>
+                        <input type="button" class="btn btn-default" data-dismiss="modal"
value="Cancel"/>
+                    </div>
+                </div>
+            </div>
+
+        </form>
+    </div>
+</div>
+
 <pre>
     {{var_dump($userResourceProfile)}}
 </pre>
@@ -104,7 +126,11 @@ $('.add-user-cr').on('click', function(){
 
     $(this).after( $(".add-user-compute-resource-block").html() );
 });
-$("body").on("change", ".cr-select", function(){
+$(".remove-user-compute-resource").click( function(){
+	$(".remove-user-cr-name").html( $(this).data("cr-name") );
+	$(".remove-user-crId").val( $(this).data("cr-id") );
+});
+$("body").on("change", "#user-cr-select", function(){
     crId = $(this).val();
     //This is done as Jquery creates problems when using period(.) in id or class.
     crId = crId.replace(/\./g,"_");

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/17425c08/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 af70ecc..0e2036c 100644
--- a/app/views/partials/user-compute-resource-preferences.blade.php
+++ b/app/views/partials/user-compute-resource-preferences.blade.php
@@ -2,6 +2,7 @@
     computeResource - (required, ComputeResourceDescription) the compute resource object
     preferences - (optional, UserComputeResourcePreference) the saved preference data
     show - (optional, boolean)
+    allowDelete - (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">
@@ -96,37 +97,44 @@ if( isset( $preferences) && $preferences->reservationEndTime
!= '')
     $reservationEndTime = strtotime( $addOrSubtract . " " . Session::get("user_timezone")
. " hours", $preferences->reservationEndTime/1000);
 
 ?>
-<div class="form-group col-md-6">
-    <label class="control-label col-md-3">Reservation Start Time</label>
-
-    <div class="input-group date datetimepicker1">
-        <input type="text" name="reservationStartTime" class="form-control"
-               value="@if( isset( $preferences) )@if( trim($preferences->reservationStartTime)
!= '' || $preferences->reservationStartTime != null){{date('m/d/Y h:i:s A', intval( $reservationStartTime))}}@endif
@endif"/>
-        <span class="input-group-addon">
-            <span class="glyphicon glyphicon-calendar"></span>
-        </span>
+
+<div class="row">
+    <div class="form-group col-md-6">
+        <label class="control-label col-md-3">Reservation Start Time</label>
+
+        <div class="input-group date datetimepicker1">
+            <input type="text" name="reservationStartTime" class="form-control"
+                   value="@if( isset( $preferences) )@if( trim($preferences->reservationStartTime)
!= '' || $preferences->reservationStartTime != null){{date('m/d/Y h:i:s A', intval( $reservationStartTime))}}@endif
@endif"/>
+            <span class="input-group-addon">
+                <span class="glyphicon glyphicon-calendar"></span>
+            </span>
+        </div>
     </div>
-</div>
 
-<div class="form-group col-md-6">
-    <label class="control-label col-md-3">Reservation End Time</label>
+    <div class="form-group col-md-6">
+        <label class="control-label col-md-3">Reservation End Time</label>
 
-    <div class="input-group date datetimepicker2">
-        <input type="text" name="reservationEndTime" class="form-control"
-               value="@if( isset( $preferences) )@if( trim($preferences->reservationEndTime)
!= ''|| $preferences->reservationStartTime != null){{date('m/d/Y h:i:s A', intval($reservationEndTime))}}@endif
@endif"/>
-        <span class="input-group-addon">
-            <span class="glyphicon glyphicon-calendar"></span>
-        </span>
+        <div class="input-group date datetimepicker2">
+            <input type="text" name="reservationEndTime" class="form-control"
+                   value="@if( isset( $preferences) )@if( trim($preferences->reservationEndTime)
!= ''|| $preferences->reservationStartTime != null){{date('m/d/Y h:i:s A', intval($reservationEndTime))}}@endif
@endif"/>
+            <span class="input-group-addon">
+                <span class="glyphicon glyphicon-calendar"></span>
+            </span>
+        </div>
     </div>
 </div>
 
-<div class="form-group col-md-12 text-center">
-    <input type="submit" class="btn btn-primary submit-user-crp-form" value="Save"/>
-</div>
+<div class="row">
+    <div class="form-group col-md-12 text-center">
+        <input type="submit" class="btn btn-primary" value="Save"/>
+        <button type="button" class="btn btn-danger remove-user-compute-resource @if(isset(
$allowDelete ) ) @if( !$allowDelete) hide @endif @else hide @endif"
+            data-toggle="modal"
+            data-target="#remove-user-compute-resource-block"
+            data-cr-name="{{$computeResource->hostName}}"
+            data-cr-id="{{$computeResource->computeResourceId}}">
+            Remove
+        </button>
+    </div>
 </div>
 
-<div class="loading-gif text-center hide">
-    <img  src='{{URL::to('/')}}/assets/ajax-loader.gif'/>
 </div>
-<div class="col-md-offset-2 col-md-8 alert alert-success hide">Compute Resource Preferences
have been updated.</div>
-<div class="col-md-offset-2 col-md-8 alert alert-danger hide">An error has occurred.</div>
\ No newline at end of file


Mime
View raw message