You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2016/02/09 16:55:34 UTC

[06/50] [abbrv] airavata-php-gateway git commit: Added ability for Super admin to be able to enable/disable Storage Resources

Added ability for Super admin to be able to enable/disable Storage Resources


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

Branch: refs/heads/master
Commit: 78cc9ab9b5a50106def252b8c8747f7c47960fb1
Parents: 2d92d70
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Tue Jan 26 16:15:20 2016 -0500
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Tue Jan 26 16:15:20 2016 -0500

----------------------------------------------------------------------
 app/controllers/AdminController.php         | 17 +++++++++
 app/routes.php                              |  4 +++
 app/views/project/summary.blade.php         |  1 +
 app/views/resource/browse.blade.php         | 12 +------
 app/views/storage-resource/browse.blade.php | 46 ++++++++++++++++++++++++
 5 files changed, 69 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78cc9ab9/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 23096f1..4a91f41 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -234,6 +234,23 @@ class AdminController extends BaseController {
         CRUtilities::register_or_update_compute_resource($computeResource, true);
     }
 
+    public function enableStorageResource(){
+		$this->beforeFilter('verifyadmin');
+        $resourceId = Input::get("resourceId");
+        $storageResource = SRUtilities::get_storage_resource($resourceId);
+        $storageResource->enabled = true;
+        SRUtilities::register_or_update_storage_resource($storageResource, true);
+    }
+
+    public function disableStorageResource(){
+		$this->beforeFilter('verifyadmin');
+        $resourceId = Input::get("resourceId");
+        $storageResource = SRUtilities::get_storage_resource($resourceId);
+        $storageResource->enabled = false;
+        SRUtilities::register_or_update_storage_resource($storageResource, true);
+    }
+
+
 	public function createSSH(){
 		$this->beforeFilter('verifyadmin');
 		$newToken = AdminUtilities::create_ssh_token();

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78cc9ab9/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 7557a42..a180cba 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -246,6 +246,10 @@ Route::post("admin/enable-cr", "AdminController@enableComputeResource");
 
 Route::post("admin/disable-cr", "AdminController@disableComputeResource");
 
+Route::post("admin/enable-sr", "AdminController@enableStorageResource");
+
+Route::post("admin/disable-sr", "AdminController@disableStorageResource");
+
 Route::post("admin/add-roles-to-user", "AdminController@addRolesToUser");
 
 Route::post("admin/remove-role-from-user", "AdminController@removeRoleFromUser");

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78cc9ab9/app/views/project/summary.blade.php
----------------------------------------------------------------------
diff --git a/app/views/project/summary.blade.php b/app/views/project/summary.blade.php
index a28f4d0..ad94095 100755
--- a/app/views/project/summary.blade.php
+++ b/app/views/project/summary.blade.php
@@ -93,6 +93,7 @@
             case 'EXECUTING':
             case 'CANCELING':
             case 'COMPLETED':
+            case 'FAILED':
                 echo '<a href="' . URL::to('/') . '/experiment/summary?expId=' .
                         $experiment->experimentId . '">' . $experiment->experimentName . '</a>';
                 break;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78cc9ab9/app/views/resource/browse.blade.php
----------------------------------------------------------------------
diff --git a/app/views/resource/browse.blade.php b/app/views/resource/browse.blade.php
index 792f9b5..707a0fd 100644
--- a/app/views/resource/browse.blade.php
+++ b/app/views/resource/browse.blade.php
@@ -69,23 +69,13 @@
                         <td>{{ $crId }}</td>
                         @if(Session::has("admin"))
                         <td>
-                            @if(!$enabled)
                             <div class="checkbox">
-                                <input class="resource-status" resourceId="{{$crId}}" type="checkbox"
-                                @if(!Session::has("super-admin"))
-                                   disabled="disabled"
-                                @endif
-                                >
-                            </div>
-                            @else
-                            <div class="checkbox">
-                                <input class="resource-status" type="checkbox" resourceId="{{$crId}}" checked
+                                <input class="resource-status" type="checkbox" resourceId="{{$crId}}" @if($enabled) checked @endif
                                    @if(!Session::has("super-admin"))
                                        disabled="disabled"
                                    @endif
                                    >
                             </div>
-                            @endif
                         </td>
                         <td><a href="{{URL::to('/')}}/cr/view?crId={{ $crId }}" title="View">
                                 <span class="glyphicon glyphicon-list"></span>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78cc9ab9/app/views/storage-resource/browse.blade.php
----------------------------------------------------------------------
diff --git a/app/views/storage-resource/browse.blade.php b/app/views/storage-resource/browse.blade.php
index 025e991..e99d1ed 100644
--- a/app/views/storage-resource/browse.blade.php
+++ b/app/views/storage-resource/browse.blade.php
@@ -48,6 +48,9 @@
                         <tr>
                             <th>Id</th>
                             <th>Hostname</th>
+                            @if(Session::has("admin"))
+                            <th>Enabled</th>
+                            @endif
                             <th>View</th>
                             @if(Session::has("super-admin"))
                             <th>Delete</th>
@@ -58,11 +61,21 @@
                         <?php
                             $srId = $resource->storageResourceId;
                             $hostName = $resource->hostName;
+                            $enabled = $resource->enabled;
                         ?>
                         <tr id="srDetails">
                             <td>{{ $srId }}</td>
                             <td>{{ $hostName }}</td>
                             <td>
+                            <div class="checkbox">
+                                <input class="storage-resource-status" type="checkbox" resourceId="{{$srId}}" @if($enabled) checked @endif
+                                   @if(!Session::has("super-admin"))
+                                       disabled="disabled"
+                                   @endif
+                                   >
+                            </div>
+                        </td>
+                            <td>
                                 <a href="{{URL::to('/')}}/sr/edit?srId={{ $srId }}" title="Edit">
                                 <span class="glyphicon glyphicon-list"></span>
                                 </a>
@@ -146,5 +159,38 @@
         $(".delete-sr-id").html("'" + $(this).data("delete-sr-id") + "'");
         $(".delete-srId").val($(this).data("srid"));
     });
+
+    $('.storage-resource-status').click(function() {
+        var $this = $(this);
+        if ($this.is(':checked')) {
+            //enable compute resource
+            $resourceId = $this.attr("resourceId");
+            $.ajax({
+                type: 'POST',
+                url: "{{URL::to('/')}}/admin/enable-sr",
+                data: {
+                    'resourceId': $resourceId
+                },
+                async: true,
+                success: function (data) {
+                    $(".success-message").html("<span class='alert alert-success col-md-12'>Successfully enabled Storage Resource</span>");
+                }
+            });
+        } else {
+            //disabled compute resource
+            $resourceId = $this.attr("resourceId");
+            $.ajax({
+                type: 'POST',
+                url: "{{URL::to('/')}}/admin/disable-sr",
+                data: {
+                    'resourceId': $resourceId
+                },
+                async: true,
+                success: function (data) {
+                    $(".success-message").html("<span class='alert alert-success col-md-12'>Successfully disabled Storage Resource</span>");
+                }
+            });
+        }
+    });
 </script>
 @stop
\ No newline at end of file