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/08/30 08:08:43 UTC
airavata-php-gateway git commit: Changes for Reservation times and
Gateway Requests UI on super admin side.
Repository: airavata-php-gateway
Updated Branches:
refs/heads/develop ff0bbbddf -> 5fa7acedf
Changes for Reservation times and Gateway Requests UI on super admin side.
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/5fa7aced
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/5fa7aced
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/5fa7aced
Branch: refs/heads/develop
Commit: 5fa7acedfb960a3d3178e6063ac1d0787984dac1
Parents: ff0bbbd
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Tue Aug 30 01:08:05 2016 -0700
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Tue Aug 30 01:08:05 2016 -0700
----------------------------------------------------------------------
app/controllers/AdminController.php | 32 +----
app/libraries/AdminUtilities.php | 72 +++++-----
app/libraries/CRUtilities.php | 7 +-
app/views/account/dashboard.blade.php | 2 +-
app/views/admin/manage-gateway.blade.php | 141 ++++++++++++++++---
.../compute-resource-preferences.blade.php | 13 +-
6 files changed, 176 insertions(+), 91 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 1c84805..3d3e30a 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -155,35 +155,9 @@ class AdminController extends BaseController {
public function updateGatewayRequest(){
- $status = Input::get("status");
- $oauthData = array();
-
- if( $status == "Approve"){
- $status = 1;
-
- $oauthData["oauthClientId"] = Input::get("oauth-client-id");
- $oauthData["oauthClientSecret"] = Input::get("oauth-client-secret");
- }
- if( $status == "Deny")
- $status = 5;
-
- $comments = "";
- if( Input::has("comments"))
- $comments = Input::get("comments");
-
- if( Request::ajax()){
- //first step of adding tenant and changing gateway request status to Approved.
- AdminUtilities::update_gateway_status( Input::get("gateway_id"), $status, $oauthData, $comments, true);
- return 1;
- }
- else{
- //second step of changing gateway request status to active if tenant has been created and oauth credentials are entered.
- AdminUtilities::update_gateway_status( Input::get("gateway_id"), $status, $oauthData, $comments, false);
- if( Session::has("super-admin"))
- return Redirect::to("admin/dashboard/gateway");
- else
- return Redirect::to("admin/dashboard");
- }
+ //first step of adding tenant and changing gateway request status to Approved.
+ AdminUtilities::update_gateway( Input::get("gateway_id"), Input::all());
+ //return 1;
}
public function rolesView(){
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index c9544da..7a3ccc9 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -53,52 +53,56 @@ class AdminUtilities
return $gatewayApprovalStatusObject::$__names;
}
- public static function update_gateway_status( $gatewayId, $status, $oauthData, $comments = null, $tenantAdd = null){
- $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
- $gateway->gatewayApprovalStatus = intval( $status);
- if( count( $oauthData) != 0)
- {
- $gateway->oauthClientId = $oauthData["oauthClientId"];
- $gateway->oauthClientSecret = $oauthData["oauthClientSecret"];
- }
- if( $comments != null)
- $gateway->declinedReason = $comments;
+ public static function update_gateway( $gatewayId, $gatewayData){
- if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway) &&
- $tenantAdd == true){
-
- $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
-
+ $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["createTenant"])){
if( AdminUtilities::add_tenant( $gateway) ){
- Adminutilities::update_gateway_status( Input::get("gateway_id"), GatewayApprovalStatus::ACTIVE, $oauthData);
+ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::CREATED;
+ return Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway);
}
else{
//Need to find a better way for this.
- echo "Tenant Name is already in use";
+ // 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;
+
+ $gateway->gatewayApprovalStatus = GatewayApprovalStatus::APPROVED;
+ $gateway->oauthClientId = $gatewayData["oauthClientId"];
+ $gateway->oauthClientSecret = $gatewayData["oauthClientSecret"];
+ Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId, $gateway);
+ }
}
public static function add_tenant( $gateway){
-
- if( $gateway->gatewayApprovalStatus == GatewayApprovalStatus::APPROVED){
- $tenants = WSIS::getTenants();
- $tenantExists = false;
- foreach( $tenants as $tenant){
- if( $tenant->tenantDomain == $gateway->domain){
- $tenantExists = true;
- }
+ $tenants = WSIS::getTenants();
+ $tenantExists = false;
+ foreach( $tenants as $tenant){
+ if( $tenant->tenantDomain == $gateway->domain){
+ $tenantExists = true;
}
- if( !$tenantExists){
- $gatewayURL = $gateway->gatewayURL;
- $gatewayDomain = $gateway->domain;
- if( strpos($gateway->gatewayURL, "//") != false)
+ }
+ if( !$tenantExists){
+ $gatewayDomain = $gateway->domain;
- //finally create tenant
- return WSIS::createTenant(1, $gateway->identityServerUserName, $gateway->identityServerPasswordToken, $gateway->emailAddress, $gateway->gatewayAdminFirstName, $gateway->gatewayAdminLastName, $gatewayDomain);
- }
- else
- return false;
+ //finally create tenant
+ return WSIS::createTenant(1, $gateway->identityServerUserName, $gateway->identityServerPasswordToken, $gateway->emailAddress, $gateway->gatewayAdminFirstName, $gateway->gatewayAdminLastName, $gatewayDomain);
}
else
return false;
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 404c6e9..644f482 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -531,8 +531,11 @@ class CRUtilities
if( $timeDifference > 0)
$addOrSubtract = "+";
$inputs = Input::all();
- $inputs["reservationStartTime"] = strtotime( $inputs["reservationStartTime"]) * 1000;
- $inputs["reservationEndTime"] = strtotime($inputs["reservationEndTime"]) * 1000;
+ if( $inputs["reservationStartTime"] != "")
+ $inputs["reservationStartTime"] = strtotime( $inputs["reservationStartTime"]) * 1000;
+ if( $inputs["reservationEndTime"] != "")
+ $inputs["reservationEndTime"] = strtotime($inputs["reservationEndTime"]) * 1000;
+
$computeResourcePreferences = new computeResourcePreference($inputs);
if (Config::get('pga_config.airavata')['enable-app-catalog-cache']) {
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/app/views/account/dashboard.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php
index ea9220b..6267b8b 100644
--- a/app/views/account/dashboard.blade.php
+++ b/app/views/account/dashboard.blade.php
@@ -298,7 +298,7 @@
<span class="glyphicon glyphicon-sort console-icon"></span>
</div>
<div class="col-md-12">
- <h4>Gateway Profile</h4>
+ <h4>Gateway Management</h4>
</div>
</div>
</a>
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/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 f9c2d6f..3e8e8e0 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -97,7 +97,7 @@
<td>{{ $gp->gatewayPublicAbstract}}</td>
@if( $gatewayApprovalStatuses[$gp->gatewayApprovalStatus] == "REQUESTED")
<td>
- <input type="button" class="btn btn-primary start-approval" data-gatewayid="{{$gp->gatewayId}}" value="Approve"/>
+ <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
@@ -186,42 +186,105 @@
@if( Session::has("super-admin"))
<!-- Approve a Gateway request -->
+<input type="hidden" class="gatewayApprovalStatuses" value="{{ htmlentities( json_encode( $gatewayApprovalStatuses) ) }}"/>
<div class="modal fade" id="approve-gateway" tabindex="-1" role="dialog" aria-labelledby="add-modal"
aria-hidden="true" data-backdrop="static" >
<div class="modal-dialog">
<div class="modal-content">
- <form action="{{URL::to('/')}}/admin/update-gateway-request" method="GET">
+ <form action="{{URL::to('/')}}/admin/update-gateway-request" id="update-gateway-request" method="GET">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h3>Approve Gateway Request</h3>
</div>
+ <!--
<div class="modal-body onTenantLoad">
Adding tenant for GatewayId: <span class="gatewayid-for-approval"></span>. Please do not refresh or close this page!
</div>
- <div class="modal-body onTenantComplete hide">
+ -->
+ <div class="modal-body">
+ <!--
<h3>Gateway Tenant has been added. Please fill in rest of the required details.</h3>
+ -->
<div class="form-group">
<h4>GatewayId: <span class="gatewayid-for-approval"></span></h4>
</div>
<div class="form-group">
+ <label>Gateway Name</label>
+ <input type="text" name="gatewayName" class="form-control gatewayName"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Acronym</label>
+ <input type="text" name="gatewayAcronym" class="form-control gatewayAcronym"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Domain</label>
+ <input type="text" name="domain" class="form-control domain" value="Domain will become - 'airavata' . [gateway acroym]" disabled="disabled" />
+ </div>
+ <div class="form-group">
+ <label>Gateway Url</label>
+ <input type="text" name="gatewayURL" class="form-control gatewayURL"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Public Abstract</label>
+ <textarea readonly="readonly" name="gatewayPublicAbstract" class="form-control gatewayPublicAbstract"></textarea>
+ </div>
+ <div class="form-group">
+ <label>Gateway Proposal Description</label>
+ <textarea readonly="readonly" name="reviewProposalDescription" class="form-control reviewProposalDescription"></textarea>
+ </div>
+ <div class="form-group">
+ <label>Gateway Admin First Name</label>
+ <input type="text" readonly="readonly" name="gatewayAdminFirstName" class="form-control gatewayAdminFirstName"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Admin Last Name</label>
+ <input type="text" readonly="readonly" name="gatewayAdminLastName" class="form-control gatewayAdminLastName"/>
+ </div>
+ <div class="form-group">
+ <label>Contact Email Address</label>
+ <input type="text" readonly="readonly" name="emailAddress" class="form-control emailAddress"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Admin Username</label>
+ <input type="text" readonly="readonly" name="identityServerUserName" class="form-control identityServerUserName"/>
+ </div>
+ <div class="form-group">
+ <label>Gateway Admin First Name</label>
+ <input type="text" readonly="readonly" name="gatewayAdminFirstName" class="form-control gatewayAdminFirstName"/>
+ </div>
+ <div class="form-group">
<label>Oauth Client Id</label>
- <input type="text" name="oauth-client-id" class="form-control" required="required"/>
+ <input type="text" name="oauthClientId" class="form-control oauthClientId"/>
</div>
<div class="form-group">
<label>Oauth Client Secret</label>
- <input type="text" name="oauth-client-secret" class="form-control" required="required" >
+ <input type="text" name="oauthClientSecret" class="form-control oauthClientSecret"/>
</div>
<div class="form-group">
<label>Comments</label>
- <textarea style="width:100%; height:80px" width="100%" name="comments"></textarea>
+ <textarea style="width:100%; height:80px" width="100%" name="declinedReason" class="declinedReason"></textarea>
+ </div>
+
+ <div class="form-group">
+ <label>Status</label>
+ <input type="text" name="gatewayApprovalStatus" class="form-control gatewayApprovalStatus" disabled="disabled" />
+ <!--
+ <select name="gatewayApprovalStatus" class="form-control gatewayApprovalStatus">
+ @foreach( $gatewayApprovalStatuses as $val => $status)
+ <option value="{{$val}}">{{$status}}</option>
+ @endforeach
+ </select>
+ -->
</div>
<input type="hidden" class="gatewayid-for-approval" name="gateway_id">
</div>
- <div class="modal-footer onTenantComplete hide">
- <input type="submit" name="status" class="btn btn-primary" value="Approve"/>
- <input type="cancel" data-dismiss="modal" class="btn btn-default" value="Cancel"/>
+ <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>
</form>
@@ -481,22 +544,55 @@
}
$(".start-approval").click( function(){
- var gatewayId = $(this).data("gatewayid");
+ var gatewayObject = $(this).data("gatewayobject");
+ var gatewayId = gatewayObject.gatewayId;
+ var gatewayApprovalStatuses = $.parseJSON( $(".gatewayApprovalStatuses").val() );
+
$(".onTenantLoad").removeClass("hide");
- $(".gatewayid-for-approval").val( gatewayId).html( $(this).data("gatewayid"));
+ $(".gatewayid-for-approval").val( gatewayId).html( gatewayId);
+ $(".gatewayName").val( gatewayObject.gatewayName);
+ $(".gatewayAcronym").val( gatewayObject.gatewayAcronym);
+ //$(".domain").val( gatewayObject.domain);
+ $(".gatewayURL").val( gatewayObject.gatewayURL);
+ $(".gatewayPublicAbstract").val( gatewayObject.gatewayPublicAbstract);
+ $(".reviewProposalDescription").val( gatewayObject.reviewProposalDescription);
+ $(".gatewayAdminFirstName").val( gatewayObject.gatewayAdminFirstName);
+ $(".gatewayAdminLastName").val( gatewayObject.gatewayAdminLastName);
+ $(".emailAddress").val( gatewayObject.emailAddress);
+ $(".identityServerUserName").val( gatewayObject.identityServerUserName);
+ $(".oauthClientId").val( gatewayObject.oauthClientId);
+ $(".oauthClientSecret").val( gatewayObject.oauthClientSecret);
+ $(".declinedReason").val( gatewayObject.declinedReason);
+ $(".gatewayApprovalStatus").val(gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus]);
$(".onTenantComplete").addClass("hide");
+
+ if( gatewayApprovalStatuses[ gatewayObject.gatewayApprovalStatus] == "REQUESTED"){
+ $(".createdGateway").addClass("hide");
+ $(".notCreatedGateway").removeClass("hide");
+ }
+ else
+ {
+ $(".createdGateway").removeClass("hide");
+ $(".notCreatedGateway").addClass("hide");
+ }
$("#approve-gateway").modal("show");
+ });
- $.ajax({
- url: "{{URL::to('/')}}/admin/update-gateway-request",
- method: "GET",
- data: { gateway_id : gatewayId, status: 1}
- }).done( function( data){
- $(".onTenantComplete").removeClass("hide");
- $(".onTenantLoad").addClass("hide");
- $(".onTenantComplete").removeClass("hide");
+ $(".create-tenant").click( function( ev){
+ ev.preventDefault();
+ var updateGatewayData = $("#update-gateway-request").serializeArray();
+ updateGatewayData.push({name:'createTenant', value: true});
+ $.ajax({
+ url: "{{URL::to('/')}}/admin/update-gateway-request",
+ method: "GET",
+ data: updateGatewayData
+ }).done( function( data){
+ console.log( data);
+ //$(".onTenantComplete").removeClass("hide");
+ //$(".onTenantLoad").addClass("hide");
+ //$(".onTenantComplete").removeClass("hide");
+ });
});
- });
$(".deny-approval").click( function(){
$(".gatewayid-for-approval").val( $(this).data("gatewayid")).html( $(this).data("gatewayid"));
@@ -529,5 +625,10 @@
$('.datetimepicker1').data("DateTimePicker").setMaxDate(e.date);
});
+
+ $(".qualityOfService").popover({
+ 'trigger':'focus'
+ });
+
</script>
@stop
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5fa7aced/app/views/partials/compute-resource-preferences.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/compute-resource-preferences.blade.php b/app/views/partials/compute-resource-preferences.blade.php
index 13a8240..172f27d 100644
--- a/app/views/partials/compute-resource-preferences.blade.php
+++ b/app/views/partials/compute-resource-preferences.blade.php
@@ -117,25 +117,28 @@
<label class="control-label col-md-3">Quality of Service</label>
<div class="col-md-9">
- <input type="text" name="qualityOfService" class="form-control"
- value="@if( isset( $preferences) ){{$preferences->qualityOfService}}@endif"/>
+ <input type="text" name="qualityOfService" class="qualityOfService form-control"
+ value="@if( isset( $preferences) ){{$preferences->qualityOfService}}@endif" data-toggle="popover" data-placement="bottom" data-content="Format: <queue name1>=<qos1>,<queue name2>=<qos2>"/>
</div>
</div>
<div class="form-group">
- <label class="control-label col-md-3">Reservation</label>
+ <label class="control-label col-md-3">Reservation Name</label>
<div class="col-md-9">
<input type="text" name="reservation" class="form-control"
value="@if( isset( $preferences) ){{$preferences->reservation}}@endif"/>
</div>
</div>
+@if( isset( $preferences))
+{{var_dump( $preferences)}}
+@endif
<div class="form-group col-md-6">
<label class="control-label col-md-3">Reservation Start Time</label>
<div class="input-group date datetimepicker1">
<input type="text" name="reservationStartTime" class="form-control"
- value="@if( isset( $preferences) ){{date('m/d/Y A',$preferences->reservationStartTime/1000) }}@endif"/>
+ value="@if( isset( $preferences) ) @if( $preferences->reservationStartTime != '') {{date('m/d/Y',$preferences->reservationStartTime/1000) }} @endif @endif"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
@@ -147,7 +150,7 @@
<div class="input-group date datetimepicker2">
<input type="text" name="reservationEndTime" class="form-control"
- value="@if( isset( $preferences) ){{date('m/d/Y A',$preferences->reservationEndTime/1000) }}@endif"/>
+ value="@if( isset( $preferences) ){{date('m/d/Y',$preferences->reservationEndTime/1000) }}@endif"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>