airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [3/3] airavata-php-gateway git commit: fixing AIRAVATA-1753
Date Fri, 10 Jul 2015 20:13:36 GMT
fixing AIRAVATA-1753


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

Branch: refs/heads/master
Commit: 78186b81898c5cd04b7735f04645f04eb0acd9c4
Parents: c18fccf
Author: Supun Nakandala <scnakandala@apache.org>
Authored: Sat Jul 11 01:43:00 2015 +0530
Committer: Supun Nakandala <scnakandala@apache.org>
Committed: Sat Jul 11 01:43:00 2015 +0530

----------------------------------------------------------------------
 app/controllers/AdminController.php        | 14 ++++++
 app/controllers/ComputeResource.php        |  4 +-
 app/controllers/ExperimentController.php   |  2 +-
 app/libraries/CRUtilities.php              |  4 +-
 app/routes.php                             |  4 ++
 app/views/admin/manage-resources.blade.php | 63 ++++++++++++++++++++-----
 6 files changed, 75 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78186b81/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index dab564d..06b86de 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -172,4 +172,18 @@ class AdminController extends BaseController {
             return View::make("partials/experiment-container", array("expContainer" =>
$expContainer, "expStates" => $expStates));
         }
     }
+
+    public function enableComputeResource(){
+        $resourceId = Input::get("resourceId");
+        $computeResource = CRUtilities::get_compute_resource($resourceId);
+        $computeResource->enabled = true;
+        CRUtilities::register_or_update_compute_resource($computeResource, true);
+    }
+
+    public function disableComputeResource(){
+        $resourceId = Input::get("resourceId");
+        $computeResource = CRUtilities::get_compute_resource($resourceId);
+        $computeResource->enabled = false;
+        CRUtilities::register_or_update_compute_resource($computeResource, true);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78186b81/app/controllers/ComputeResource.php
----------------------------------------------------------------------
diff --git a/app/controllers/ComputeResource.php b/app/controllers/ComputeResource.php
index 79a2305..40319c4 100755
--- a/app/controllers/ComputeResource.php
+++ b/app/controllers/ComputeResource.php
@@ -24,11 +24,13 @@ class ComputeResource extends BaseController
 
         $hostAliases = Input::get("hostaliases");
         $ips = Input::get("ips");
+        //Compute resource is by default enabled
         $computeDescription = array(
             "hostName" => trim(Input::get("hostname")),
             "hostAliases" => array_unique(array_filter($hostAliases)),
             "ipAddresses" => array_unique(array_filter($ips)),
-            "resourceDescription" => Input::get("description")
+            "resourceDescription" => Input::get("description"),
+            "enabled" => true
         );
         $computeResource = CRUtilities::register_or_update_compute_resource($computeDescription);
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78186b81/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index 2ce8aff..b262ec3 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -172,7 +172,7 @@ class ExperimentController extends BaseController
 
         $expVal = ExperimentUtilities::get_experiment_values($experiment, $project);
         $expVal["jobState"] = ExperimentUtilities::get_job_status($experiment);
-        //var_dump( $expVal); exit;
+
         $computeResources = CRUtilities::create_compute_resources_select($experiment->applicationId,
$expVal['scheduling']->resourceHostId);
 
         $experimentInputs = array(

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78186b81/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 16df103..aa36ed1 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -291,7 +291,7 @@ class CRUtilities
         else {
             $crObjects = array();
             foreach ($crNames as $id => $crName) {
-                $crObjects[] = Airavata::getComputeResource($id);
+                array_push($crObjects, Airavata::getComputeResource($id));
             }
             return $crObjects;
         }
@@ -302,7 +302,7 @@ class CRUtilities
     {
         $appDeployments = Airavata::getAllApplicationDeployments(Session::get("gateway_id"));
 
-        return array('crObjects' => CRUtilities::getAllCRObjects(true),
+        return array('crObjects' => CRUtilities::getAllCRObjects(),
             'appDeployments' => $appDeployments
         );
     }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/78186b81/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index c3c3b66..e5f6f65 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -184,6 +184,10 @@ Route::post("admin/check-roles", "AdminController@getRoles");
 
 Route::post("admin/delete-role", "AdminController@deleteRole");
 
+Route::post("admin/enable-cr", "AdminController@enableComputeResource");
+
+Route::post("admin/disable-cr", "AdminController@disableComputeResource");
+
 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/78186b81/app/views/admin/manage-resources.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-resources.blade.php b/app/views/admin/manage-resources.blade.php
index 852d833..8316ce7 100644
--- a/app/views/admin/manage-resources.blade.php
+++ b/app/views/admin/manage-resources.blade.php
@@ -24,6 +24,7 @@
             @endif
         </div>
         <div class="container-fluid">
+            <div class="success-message"></div>
             <div class="col-md-12">
 <!--                <h1 class="text-center well alert alert-danger">Proposed(Dummy)
UI for maintaining availability of-->
 <!--                    Resources. More fields can be added.</h1>-->
@@ -34,25 +35,27 @@
                         <th>ID</th>
                         <th>Name</th>
                         <th>
-                            Status
+                            Enabled
                         </th>
                     </tr>
-                    @foreach( (array)$resources as $resourceId => $resourceName )
+                    @foreach( (array)$resources as $resource)
+                    <?php
+                        $resourceId = $resource->computeResourceId;
+                        $resourceName = $resource->hostName;
+                        $enabled = $resource->enabled;
+                    ?>
                     <tr class="user-row">
                         <td>{{ $resourceId }}</td>
                         <td>{{ $resourceName }}</td>
                         <td>
-                            <!--This is a random selection -->
-                            @if( strpos( $resourceName, "a") )
-                            <div class="btn-group btn-toggle">
-                                <button class="btn btn-xs btn-default">ON</button>
-                                <button class="btn btn-xs btn-danger active">Switch
OFF</button>
+                            @if(!$enabled)
+                            <div class="checkbox">
+                                <input class="resource-status" resourceId="{{$resourceId}}"
type="checkbox">
                             </div>
                             @else
-                            <div class="btn-group btn-toggle">
-                                <button class="btn btn-xs btn-success active">Switch
ON</button>
-                                <button class="btn btn-xs btn-default">OFF</button>
-                            </div>
+                            <div class="checkbox">
+                                <input class="resource-status" type="checkbox" resourceId="{{$resourceId}}"
checked>
+                             </div>
                             @endif
                         </td>
                     </tr>
@@ -67,4 +70,40 @@
 
 @section('scripts')
 @parent
-@stop
\ No newline at end of file
+<script>
+    $('.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-cr",
+                data: {
+                    'resourceId': $resourceId
+                },
+                async: true,
+                success: function (data) {
+                    console.log("enabled cr " + $resourceId);
+                    $(".success-message").html("<span class='alert alert-success col-md-12'>Successfully
enabled compute resource</span>");
+                }
+            });
+        } else {
+            //disabled compute resource
+            $resourceId = $this.attr("resourceId");
+            $.ajax({
+                type: 'POST',
+                url: "{{URL::to('/')}}/admin/disable-cr",
+                data: {
+                    'resourceId': $resourceId
+                },
+                async: true,
+                success: function (data) {
+                    console.log("disabled cr " + $resourceId);
+                    $(".success-message").html("<span class='alert alert-success col-md-12'>Successfully
disabled compute resource</span>");
+                }
+            });
+        }
+    });
+</script>
+@stop


Mime
View raw message