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:56:14 UTC
[46/50] [abbrv] airavata-php-gateway git commit: Improving Gateway
Preferences performance by decreasing number of API calls
Improving Gateway Preferences performance by decreasing number of API calls
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/7e14dd6c
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/7e14dd6c
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/7e14dd6c
Branch: refs/heads/master
Commit: 7e14dd6cfc802c2a6c59a5d8ca9d4d6113ed0cc8
Parents: 7f73aeb
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Fri Feb 5 13:34:28 2016 -0500
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Fri Feb 5 13:34:28 2016 -0500
----------------------------------------------------------------------
app/controllers/AdminController.php | 12 +++----
app/libraries/CRUtilities.php | 25 +++++++++++---
app/views/admin/manage-gateway.blade.php | 49 ++++++++++++++-------------
public/js/gateway.js | 12 +++++--
4 files changed, 61 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7e14dd6c/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 10f5e20..c4278d9 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -60,16 +60,16 @@ class AdminController extends BaseController {
$gatewaysInfo = CRUtilities::getAllGatewayProfilesData();
$gateways = $gatewaysInfo["gateways"];
$tokens = AdminUtilities::get_all_ssh_tokens();
+
$srData = SRUtilities::getEditSRData();
- $allCRs = CRUtilities::getAllCRObjects();
- $allSRs = SRUtilities::getAllSRObjects();
+ $crData = CRUtilities::getEditCRData();
- foreach( (array)$allCRs as $index => $cr){
+ foreach( (array)$gatewaysInfo["allCRs"] as $crId => $cr){
if( ! in_array($cr->computeResourceId, $gatewaysInfo["selectedCRs"]) )
$unselectedCRs[] = $cr;
}
- foreach( (array)$allSRs as $index => $sr){
+ foreach( (array)$gatewaysInfo["allSRs"] as $index => $sr){
if( ! in_array($sr->storageResourceId, $gatewaysInfo["selectedSRs"]) )
$unselectedSRs[] = $sr;
}
@@ -77,9 +77,9 @@ class AdminController extends BaseController {
//$dsData = CRUtilities::getAllDataStoragePreferences( $gateways);
$gatewayData = array(
"gateways" => $gateways,
- "computeResources" => $allCRs,
+ "computeResources" => $gatewaysInfo["allCRs"],
"crData" => $crData,
- "storageResources" => $allSRs,
+ "storageResources" => $gatewaysInfo["allSRs"],
"srData" => $srData,
"tokens" => $tokens,
"unselectedCRs" => $unselectedCRs,
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7e14dd6c/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index e38a475..e2ee6e5 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -449,6 +449,19 @@ class CRUtilities
}
$selectedCRs = array();
$selectedSRs = array();
+ $allCRs = CRUtilities::getAllCRObjects();
+ $allSRs = SRUtilities::getAllSRObjects();
+ $allCRArray = array();
+ $allSRArray = array();
+ foreach( $allCRs as $index => $crObject)
+ {
+ $allCRArray[$crObject->computeResourceId] = $crObject;
+ }
+ foreach( $allSRs as $index => $srObject)
+ {
+ $allSRArray[$srObject->storageResourceId] = $srObject;
+ }
+
$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,14 +471,14 @@ 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);
+ $gatewayProfiles[$index]->computeResourcePreferences[$i]->crDetails = $allCRArray[ $crp->computeResourceId];
//had to add this condition since for super admin it takes CRs selected in all gateways.
if( $gp->gatewayID == Session::get("gateway_id"))
$selectedCRs[] = $crp->computeResourceId;
}
foreach( (array)$gp->storagePreferences as $j => $srp){
- $gatewayProfiles[$index]->storagePreferences[$j]->srDetails = Airavata::getStorageResource( Session::get('authz-token'), $srp->storageResourceId);
+ $gatewayProfiles[$index]->storagePreferences[$j]->srDetails = $allSRArray[ $srp->storageResourceId];
//had to add this condition since for super admin it takes SRs selected in all gateways.
if( $gp->gatewayID == Session::get("gateway_id"))
@@ -476,8 +489,12 @@ class CRUtilities
}
}
//var_dump( $gatewayProfiles[0]->computeResourcePreferences[0]->crDetails); exit;
-
- $gatewaysInfo = array( "gateways" =>$gateways, "selectedCRs" => $selectedCRs, "selectedSRs" => $selectedSRs);
+ $gatewaysInfo = array( "gateways" =>$gateways,
+ "selectedCRs" => $selectedCRs,
+ "selectedSRs" => $selectedSRs,
+ "allCRs" => $allCRs,
+ "allSRs" => $allSRs
+ );
return $gatewaysInfo;
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7e14dd6c/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 a648845..2c9d143 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -7,6 +7,18 @@
@section('content')
+
+
+<!-- contains all compute resource choices that might get selected on adding a new one to a gateway -->
+@foreach( (array)$computeResources as $index => $cr)
+@include('partials/compute-resource-preferences', array('computeResource' => $cr, 'crData' => $crData))
+@endforeach
+
+<!-- contains all storage resource choices that might get selected on adding a new one to a gateway -->
+@foreach( (array)$storageResources as $index => $sr)
+ @include('partials/storage-resource-preferences', array('storageResource' => $sr, 'srData' => $srData))
+@endforeach
+
<div id="wrapper">
<!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
@include( 'partials/dashboard-block')
@@ -91,11 +103,10 @@
</div>
<div class="panel-group" id="accordion1">
- @foreach( $gateways as $indexGP => $gp )
- <div class='super-admin-gateways-view'>
- @include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
- </div>
- @endforeach
+ <div class='super-admin-gateways-view'>
+ @foreach( $gateways as $indexGP => $gp )
+ @include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
+ @endforeach
</div>
</div>
@endif
@@ -123,7 +134,7 @@
</select>
<span class="input-group-addon remove-cr" style="cursor:pointer;">x</span>
</div>
- <div class="pref-space form-horizontal"></div>
+ <div class="cr-pref-space form-horizontal"></div>
</form>
</div>
</div>
@@ -142,7 +153,7 @@
</select>
<span class="input-group-addon remove-cr" style="cursor:pointer;">x</span>
</div>
- <div class="pref-space form-horizontal"></div>
+ <div class="sr-pref-space form-horizontal"></div>
</form>
</div>
</div>
@@ -208,7 +219,7 @@
<!-- Add a Gateway -->
<div class="modal fade" id="add-gateway-loading" tabindex="-1" role="dialog" aria-labelledby="add-modal"
aria-hidden="true" data-backdrop="static">
-<div class="modal-dialog">
+ <div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="text-center">Registering the gateway</h3>
@@ -221,16 +232,6 @@
</div>
</div>
-<!-- contains all compute resource choices that might get selected on adding a new one to a gateway -->
-@foreach( (array)$computeResources as $index => $cr)
-@include('partials/compute-resource-preferences', array('computeResource' => $cr, 'crData' => $crData))
-@endforeach
-
-<!-- contains all storage resource choices that might get selected on adding a new one to a gateway -->
-@foreach( (array)$storageResources as $index => $sr)
- @include('partials/storage-resource-preferences', array('storageResource' => $sr, 'srData' => $srData))
-@endforeach
-
@stop
@@ -318,12 +319,12 @@
$(e).attr("disabled", "true");
else
$(e).prop("readonly", "true");
- });
- elem.find("textarea").prop("readonly", "true");
- elem.find("select").attr("disabled", "true");
- elem.find(".hide").prop("readonly", "true");
- elem.find("button").attr("disabled", "true");
- elem.find(".glyphicon").hide();
+ });
+ elem.find("textarea").prop("readonly", "true");
+ elem.find("select").attr("disabled", "true");
+ elem.find(".hide").prop("readonly", "true");
+ elem.find("button").attr("disabled", "true");
+ elem.find(".glyphicon").hide();
}
</script>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7e14dd6c/public/js/gateway.js
----------------------------------------------------------------------
diff --git a/public/js/gateway.js b/public/js/gateway.js
index 1a53f85..d60326a 100644
--- a/public/js/gateway.js
+++ b/public/js/gateway.js
@@ -30,7 +30,13 @@ $(document).ready(function () {
//remove Compute Resource
$("body").on("click", ".remove-cr", function(){
$(this).parent().parent().parent().remove();
- $(this).parent().parent().parent().find(".pref-space").html("");
+ $(this).parent().parent().parent().find(".cr-pref-space").html("");
+ });
+
+ //remove Storage Resource
+ $("body").on("click", ".remove-cr", function(){
+ $(this).parent().parent().parent().remove();
+ $(this).parent().parent().parent().find(".sr-pref-space").html("");
});
@@ -50,14 +56,14 @@ $(document).ready(function () {
crId = $(this).val();
//This is done as Jquery creates problems when using period(.) in id or class.
crId = crId.replace(/\./g,"_");
- $(".pref-space").html($("#cr-" + crId).html());
+ $(".cr-pref-space").html($("#cr-" + crId).html());
});
$("body").on("change", ".sr-select", function(){
srId = $(this).val();
//This is done as Jquery creates problems when using period(.) in id or class.
srId = srId.replace(/\./g,"_");
- $(".pref-space").html($("#sr-" + srId).html());
+ $(".sr-pref-space").html($("#sr-" + srId).html());
});
$(".edit-gateway").click( function(){