You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by nd...@apache.org on 2016/09/01 22:32:53 UTC
airavata-php-gateway git commit: Gateway Requests modifications and
fixes for: AIRAVATA-2074, AIRAVATA-2047, AIRAVATA-2046, AIRAVATA-2044,
AIRAVATA-2045,
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop c5958ab21 -> 97a9da56b
Gateway Requests modifications and fixes for: AIRAVATA-2074, AIRAVATA-2047, AIRAVATA-2046, AIRAVATA-2044, AIRAVATA-2045,
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/97a9da56
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/97a9da56
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/97a9da56
Branch: refs/heads/develop
Commit: 97a9da56bcaf780208cd909d2266f467b332cf75
Parents: c5958ab
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Thu Sep 1 15:32:13 2016 -0700
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Thu Sep 1 15:32:13 2016 -0700
----------------------------------------------------------------------
app/controllers/AdminController.php | 16 +++++-
app/libraries/AdminUtilities.php | 45 ++++++++-------
app/libraries/CRUtilities.php | 12 ++--
app/libraries/CommonUtilities.php | 15 +++++
app/views/account/dashboard.blade.php | 2 +-
app/views/admin/manage-gateway.blade.php | 80 +++++++++++++++++++++------
6 files changed, 122 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 3d3e30a..b66b5a4 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -155,8 +155,20 @@ class AdminController extends BaseController {
public function updateGatewayRequest(){
- //first step of adding tenant and changing gateway request status to Approved.
- AdminUtilities::update_gateway( Input::get("gateway_id"), Input::all());
+ //first step of adding tenant and changing gateway request status to Approved.
+ $returnVal = AdminUtilities::update_gateway( Input::get("gateway_id"), Input::all());
+ if( Request::ajax()){
+ return $returnVal;
+ }
+ else{
+ if( $returnVal == 1)
+ Session::put("message", "Request has been updated");
+ else
+ Session::put("message", "An error has occurred while updating your request. Please try again or contact admin to report the issue.");
+
+ return Redirect::to("admin/dashboard");
+
+ }
//return 1;
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 7a3ccc9..d958dba 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -56,37 +56,42 @@ class AdminUtilities
public static function update_gateway( $gatewayId, $gatewayData){
$gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
- $gateway->gatewayName = $gatewayData["gatewayName"];
- $gateway->gatewayAcronym = $gatewayData["gatewayAcronym"];
- $gateway->domain = 'airavata.'. $gatewayData["gatewayAcronym"];
- $gateway->gatewayURL = $gatewayData["gatewayURL"];
- $gateway->gatewayName = $gatewayData["gatewayName"];
- $gateway->declinedReason = $gatewayData["declinedReason"];
-
+ if( isset( $gatewayData["cancelRequest"]))
+ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::CANCELLED;
+ else{
+ $gateway->gatewayName = $gatewayData["gatewayName"];
+ $gateway->gatewayAcronym = $gatewayData["gatewayAcronym"];
+ $gateway->domain = 'airavata.'. $gatewayData["gatewayAcronym"];
+ $gateway->gatewayURL = $gatewayData["gatewayURL"];
+ $gateway->gatewayName = $gatewayData["gatewayName"];
+ $gateway->declinedReason = $gatewayData["declinedReason"];
+ }
+
if( isset($gatewayData["createTenant"])){
- if( AdminUtilities::add_tenant( $gateway) ){
+ if( AdminUtilities::add_tenant( $gateway) )
$gateway->gatewayApprovalStatus = GatewayApprovalStatus::CREATED;
- return Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway);
- }
- else{
- //Need to find a better way for this.
- // retun echo "Tenant Name is already in use";
- return -1;
- }
}
elseif( isset( $gatewayData["denyRequest"])){
-
$gateway->gatewayApprovalStatus = GatewayApprovalStatus::DENIED;
- Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway);
}
- elseif( isset( $gatewayData["oauthClientId"])){
- // var_dump("oc"); exit;
+ elseif( isset( $gatewayData["updateGateway"])){
$gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED;
$gateway->oauthClientId = $gatewayData["oauthClientId"];
$gateway->oauthClientSecret = $gatewayData["oauthClientSecret"];
- Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway);
+ }
+ elseif( isset( $gatewayData["deactivateGateway"])){
+ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::DEACTIVATED;
+ }
+
+ if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway) ){
+ return 1;
+ }
+ else{
+ //Need to find a better way for this.
+ // retun echo "Tenant Name is already in use";
+ return -1;
}
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 365eb37..b7b03bd 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -454,12 +454,7 @@ class CRUtilities
$allCRArray = array();
$allSRArray = array();
- if (Session::has("super-admin"))
-
- $gateways = Airavata::getAllGateways(Session::get('authz-token'));
- else {
- $gateways[0] = Airavata::getGateway(Session::get('authz-token'), Session::get("gateway_id"));
- }
+ $gateways = CRUtilities::getAllGateways();
foreach( $allCRs as $index => $crObject)
{
@@ -509,8 +504,11 @@ class CRUtilities
public static function getAllGateways()
{
- if (Session::has("super-admin"))
+ if (Session::has("super-admin")){
$gateways = Airavata::getAllGateways(Session::get('authz-token'));
+ //sort with creation time
+ usort($gateways, CommonUtilities::arrSortObjsByKey('requestCreationTime', 'DESC'));
+ }
else {
$gateways[0] = Airavata::getGateway(Session::get('authz-token'), Session::get("gateway_id"));
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/app/libraries/CommonUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php
index 55db6a5..337d973 100644
--- a/app/libraries/CommonUtilities.php
+++ b/app/libraries/CommonUtilities.php
@@ -352,5 +352,20 @@ class CommonUtilities
public static function get_notice_priorities(){
return NotificationPriority::$__names;
}
+
+ public static function arrSortObjsByKey($key, $order = 'DESC') {
+ return function($a, $b) use ($key, $order) {
+ // Swap order if necessary
+ if ($order == 'DESC') {
+ list($a, $b) = array($b, $a);
+ }
+ // Check data type
+ if (is_numeric($a->$key)) {
+ return $a->$key - $b->$key; // compare numeric
+ } else {
+ return strnatcasecmp($a->$key, $b->$key); // compare string
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/app/views/account/dashboard.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php
index 6267b8b..65b3bff 100644
--- a/app/views/account/dashboard.blade.php
+++ b/app/views/account/dashboard.blade.php
@@ -48,7 +48,7 @@
-->
</div>
@elseif( $gateway["approvalStatus"] == "REQUESTED")
- <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gatewayId}}&status=4">
+ <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gatewayId}}&cancelRequest=true">
<button type="button" class="btn btn-danger">Cancel Request</button>
</a>
@endif
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/97a9da56/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 bcbbb1d..1c0792f 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -89,23 +89,32 @@
</thead>
<tbody>
@foreach( $gateways as $indexGP => $gp )
+ @if( $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "REQUESTED")
<tr>
<td>{{$gp->gatewayName }}</td>
<td>{{ $gp->gatewayAdminFirstName }} {{ $gp->gatewayAdminLastName }} </td>
<td>{{ $gp->gatewayURL }}</td>
<td>{{ $gp->reviewProposalDescription}}</td>
<td>{{ $gp->gatewayPublicAbstract}}</td>
- @if( $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "REQUESTED")
- <td>
+ <td>Status: {{$gatewayApprovalStatuses[$gp->gatewayApprovalStatus] }}<br/>
<input type="button" class="btn btn-primary start-approval" data-gatewayobject="{{htmlentities(json_encode( $gp))}}" value="View"/>
- <input type="button" class="btn btn-danger deny-approval" data-gatewayid="{{$gp->gatewayId}}" value="Deny"/>
- </td>
- @else
- <td>{{$gatewayApprovalStatuses[$gp->gatewayApprovalStatus]}}
- @if( $gp->declinedReason != "")<br/><br/>Comment: {{$gp->declinedReason}} @endif
- </td>
- @endif
+ </td>
</tr>
+ @endif
+ @endforeach
+ @foreach( $gateways as $indexGP => $gp )
+ @if( $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] != "REQUESTED")
+ <tr>
+ <td>{{$gp->gatewayName }}</td>
+ <td>{{ $gp->gatewayAdminFirstName }} {{ $gp->gatewayAdminLastName }} </td>
+ <td>{{ $gp->gatewayURL }}</td>
+ <td>{{ $gp->reviewProposalDescription}}</td>
+ <td>{{ $gp->gatewayPublicAbstract}}</td>
+ <td>Status: {{$gatewayApprovalStatuses[$gp->gatewayApprovalStatus] }}<br/>
+ <input type="button" class="btn btn-primary start-approval" data-gatewayobject="{{htmlentities(json_encode( $gp))}}" value="View"/>
+ </td>
+ </tr>
+ @endif
@endforeach
<!-- foreach code ends -->
</tbody>
@@ -128,7 +137,13 @@
<div class="panel-group super-admin-gateways-view" id="accordion1">
@foreach( $gateways as $indexGP => $gp )
- @include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
+ @if( $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "APPROVED" ||
+ $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "ACTIVE" ||
+ $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "CREATED")
+
+ @include('partials/gateway-preferences-block', array("gp" => $gp, "accName" => "accordion1"))
+
+ @endif
@endforeach
</div>
</div>
@@ -280,11 +295,11 @@
</div>
<input type="hidden" class="gatewayid-for-approval" name="gateway_id">
</div>
- <div class="modal-footer">
- <button type="submit" name="status" class="btn btn-primary notCreatedGateway create-tenant" value="createTenant">Create Tenant</button>
- <button type="submit" name="status" class="btn btn-danger notCreatedGateway deny-request" value="deny">Deny Request</button>
- <button type="submit" name="status" class="btn btn-primary createdGateway" value="updateGateway">Update Gateway Information</button>
- <button type="submit" name="status" class="btn btn-danger createdGateway" value="cancelGateway">Cancel Gateway</button>
+ <div class="modal-footer submit-actions">
+ <button type="submit" name="status" class="btn btn-primary notCreatedGateway update-gateway" value="createTenant">Create Tenant</button>
+ <button type="submit" name="status" class="btn btn-danger notCreatedGateway update-gateway" value="denyRequest">Deny Request</button>
+ <button type="submit" name="status" class="btn btn-primary createdGateway update-gateway" value="updateGateway">Update Gateway Information</button>
+ <button type="submit" name="status" class="btn btn-danger createdGateway update-gateway" value="deactivateGateway">Deactivate Gateway</button>
</div>
</form>
@@ -544,6 +559,9 @@
}
$(".start-approval").click( function(){
+ $(".fail-alert").remove();
+ $(".success-alert").remove();
+
var gatewayObject = $(this).data("gatewayobject");
var gatewayId = gatewayObject.gatewayId;
var gatewayApprovalStatuses = $.parseJSON( $(".gatewayApprovalStatuses").val() );
@@ -563,6 +581,7 @@
$(".oauthClientId").val( gatewayObject.oauthClientId);
$(".oauthClientSecret").val( gatewayObject.oauthClientSecret);
$(".declinedReason").val( gatewayObject.declinedReason);
+ $(".declinedReason").html( gatewayObject.declinedReason);
$(".gatewayApprovalStatus").val(gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus]);
$(".onTenantComplete").addClass("hide");
@@ -578,16 +597,41 @@
$("#approve-gateway").modal("show");
});
- $(".create-tenant").click( function( ev){
+ $(".update-gateway").click( function( ev){
ev.preventDefault();
+ $(this).prepend( "<img class='loading-gif' src='<?php echo URL::to('/'); ?>/assets/ajax-loader.gif'/>");
+ $(".fail-alert").remove();
+ $(".success-alert").remove();
+ var updateVal = $(this).val();
var updateGatewayData = $("#update-gateway-request").serializeArray();
- updateGatewayData.push({name:'createTenant', value: true});
+
+ updateGatewayData.push({name: updateVal, value: true});
+
$.ajax({
url: "{{URL::to('/')}}/admin/update-gateway-request",
method: "GET",
data: updateGatewayData
}).done( function( data){
- console.log( data);
+ $(".loading-gif").remove();
+ if( data == -1 ){
+ if( updateVal == "createTenant"){
+ $(".submit-actions").after("<div class='alert alert-danger fail-alert'>Tenant creation has failed as Tenant with the same Domain name- airavata." + $(".gatewayAcronym").val() + " already exists in Identity Server. Please change Gateway Acronym and try again.");
+ }
+ else{
+ $(".submit-actions").after("<div class='alert alert-danger fail-alert'>Error updating Gateway. Please try again.");
+ }
+ }
+ else if( data == 1){
+ if( updateVal == "createTenant"){
+ $(".submit-actions").after("<div class='alert alert-success success-alert'>Tenant has been created with domain name- airavata." + $(".gatewayAcronym").val());
+ }
+ else{
+ $(".submit-actions").after("<div class='alert alert-success success-alert'>Gateway has been updated successfully.");
+ }
+ $(".createdGateway").removeClass("hide");
+ $(".notCreatedGateway").addClass("hide");
+
+ }
//$(".onTenantComplete").removeClass("hide");
//$(".onTenantLoad").addClass("hide");
//$(".onTenantComplete").removeClass("hide");