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:56 UTC

[28/50] [abbrv] airavata-php-gateway git commit: Removed already selected Compute Resources when adding preferences of a new resource.

Removed already selected Compute Resources when adding preferences of a new resource.


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

Branch: refs/heads/master
Commit: bbafbcc942fab4214da77dce2aac24cad15a2db8
Parents: 93c1b32
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Mon Feb 1 15:03:57 2016 -0500
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Mon Feb 1 15:03:57 2016 -0500

----------------------------------------------------------------------
 app/controllers/AdminController.php      | 23 +++++++++++++++++++----
 app/libraries/CRUtilities.php            |  8 ++++++--
 app/views/admin/manage-gateway.blade.php |  6 +++---
 3 files changed, 28 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/bbafbcc9/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index a78c3ad..10f5e20 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -57,18 +57,33 @@ class AdminController extends BaseController {
     	//only for super admin
 		//Session::put("super-admin", true);
 		$crData = CRUtilities::getEditCRData();
-		$gateways = CRUtilities::getAllGatewayProfilesData();
+		$gatewaysInfo = CRUtilities::getAllGatewayProfilesData();
+		$gateways = $gatewaysInfo["gateways"];
 		$tokens = AdminUtilities::get_all_ssh_tokens();
 		$srData = SRUtilities::getEditSRData();
+		$allCRs = CRUtilities::getAllCRObjects();
+		$allSRs = SRUtilities::getAllSRObjects();
+
+		foreach( (array)$allCRs as $index => $cr){
+			if( ! in_array($cr->computeResourceId, $gatewaysInfo["selectedCRs"]) )
+			$unselectedCRs[] = $cr;
+		}
+
+		foreach( (array)$allSRs as $index => $sr){
+			if( ! in_array($sr->storageResourceId, $gatewaysInfo["selectedSRs"]) )
+			$unselectedSRs[] = $sr;
+		}
 
 		//$dsData = CRUtilities::getAllDataStoragePreferences( $gateways);
 		$gatewayData = array( 
 								"gateways" => $gateways, 
-								"computeResources" => CRUtilities::getAllCRObjects(),
+								"computeResources" => $allCRs,
 								"crData" => $crData,
-								"storageResources" => SRUtilities::getAllSRObjects(),
+								"storageResources" => $allSRs,
 								"srData" => $srData,
-								"tokens" => $tokens
+								"tokens" => $tokens,
+								"unselectedCRs" => $unselectedCRs,
+								"unselectedSRs" => $unselectedSRs
 							);
 		$view = "admin/manage-gateway";
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/bbafbcc9/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 669004d..e2c8daa 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -447,7 +447,8 @@ class CRUtilities
         else {
             $gateways[0] = Airavata::getGateway(Session::get('authz-token'), Session::get("gateway_id"));
         }
-
+        $selectedCRs = array();
+        $selectedSRs = array();
         $gatewayProfiles = Airavata::getAllGatewayResourceProfiles(Session::get('authz-token'));
         //var_dump( $gatewayProfiles); exit;
         //$gatewayProfileIds = array("GatewayTest3_57726e98-313f-4e7c-87a5-18e69928afb5", "GatewayTest4_4fd9fb28-4ced-4149-bdbd-1f276077dad8");
@@ -458,9 +459,11 @@ class CRUtilities
                 if ($gw->gatewayId == $gp->gatewayID) {
                     foreach ((array)$gp->computeResourcePreferences as $i => $crp) {
                         $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = Airavata::getComputeResource(Session::get('authz-token'), $crp->computeResourceId);
+                        $selectedCRs[] = $crp->computeResourceId;
                     }
                     foreach( (array)$gp->storagePreferences as $j => $srp){
                         $gatewayProfiles[$index]->storagePreferences[$j]->srDetails = Airavata::getStorageResource( Session::get('authz-token'), $srp->storageResourceId);
+                        $selectedSRs[] = $srp->storageResourceId;
                     }
                     $gateways[$key]->profile = $gatewayProfiles[$index];
                 }
@@ -468,7 +471,8 @@ class CRUtilities
         }
         //var_dump( $gatewayProfiles[0]->computeResourcePreferences[0]->crDetails); exit;
 
-        return $gateways;
+        $gatewaysInfo = array( "gateways" =>$gateways, "selectedCRs" => $selectedCRs, "selectedSRs" => $selectedSRs);
+        return $gatewaysInfo;
     }
 
     public static function updateGatewayProfile( $data){

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/bbafbcc9/app/views/admin/manage-gateway.blade.php
----------------------------------------------------------------------
diff --git a/app/views/admin/manage-gateway.blade.php b/app/views/admin/manage-gateway.blade.php
index e776797..a962dc0 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -36,7 +36,7 @@
             @if( Session::has('super-admin'))
             <div class="row">
                 <div class="col-md-6">
-                    <h3>Other Gateway Preferences</h3>
+                    <h3>All Gateway Preferences</h3>
                 </div>
                 <div class="col-md-6" style="margin-top:2%">
                     <input type="text" class="col-md-12 filterinput" placeholder="Search by Gateway Name"/>
@@ -117,7 +117,7 @@
             <div class="input-group">
                 <select name="computeResourceId" class="cr-select form-control">
                     <option value="">Select a compute Resource and set its preferences</option>
-                    @foreach( (array)$computeResources as $index => $cr)
+                    @foreach( (array)$unselectedCRs as $index => $cr)
                     <option value="{{ $cr->computeResourceId}}">{{ $cr->hostName }}</option>
                     @endforeach
                 </select>
@@ -136,7 +136,7 @@
             <div class="input-group">
                 <select name="storageResourceId" class="sr-select form-control">
                     <option value="">Select a Data Storage Resource and set its preferences</option>
-                    @foreach( (array)$storageResources as $index => $sr)
+                    @foreach( (array)$unselectedSRs as $index => $sr)
                         <option value="{{ $sr->storageResourceId}}">{{ $sr->hostName }}</option>
                     @endforeach
                 </select>