airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndo...@apache.org
Subject [1/2] airavata-php-gateway git commit: Addition of multiple gateway requests
Date Thu, 28 Jul 2016 07:17:16 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 93005a505 -> 1709b7895


Addition of multiple gateway requests


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

Branch: refs/heads/develop
Commit: ddc2b26d9a827e36f19a63667e10f6be821ccbf0
Parents: 4ef0b33
Author: Nipurn Doshi <nipunhere@gmail.com>
Authored: Thu Jul 28 00:13:04 2016 -0700
Committer: Nipurn Doshi <nipunhere@gmail.com>
Committed: Thu Jul 28 00:13:04 2016 -0700

----------------------------------------------------------------------
 app/controllers/AccountController.php    |   2 +-
 app/controllers/AdminController.php      |  38 ++++--
 app/libraries/AdminUtilities.php         |  14 +-
 app/libraries/CommonUtilities.php        |   9 ++
 app/libraries/Wsis/Wsis.php              |   8 ++
 app/views/account/dashboard.blade.php    | 181 ++++++++++++++++----------
 app/views/admin/manage-gateway.blade.php |  14 +-
 7 files changed, 179 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 601ad8e..8c2ebe2 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -134,6 +134,7 @@ class AccountController extends BaseController
             Session::put('oauth-refresh-code',$refreshToken);
             Session::put('oauth-expiration-time',$expirationTime);
             Session::put("user-profile", $userProfile);
+
             Session::put("roles", $userRoles);
             if (in_array(Config::get('pga_config.wsis')['admin-role-name'], $userRoles))
{
                 Session::put("admin", true);
@@ -149,7 +150,6 @@ class AccountController extends BaseController
             if (in_array("gateway-provider", $userRoles)) {
                 Session::put("gateway-provider", true);
             }
-
             //only for super admin
             if(  Config::get('pga_config.portal')['super-admin-portal'] == true &&
Session::has("admin")){
                 Session::put("super-admin", true);

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index e27c30b..fecfb0e 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -10,37 +10,55 @@ class AdminController extends BaseController {
 
 	public function dashboard(){
         $userInfo = array();
-        
+        $data = array();
         $userProfile = Session::get("user-profile");
         Session::forget("new-gateway-provider");
         if( in_array( "gateway-provider", $userProfile["roles"]) ) {
             $gatewayOfUser = "";
+            Session::put("super-admin", true);
             $gatewaysInfo = CRUtilities::getAllGateways();
-            //var_dump( $gatewaysInfo); exit;
+            $requestedGateways = array();
             foreach ($gatewaysInfo as $index => $gateway) {
                 if ($gateway->identityServerUserName == $userProfile["username"]) {
-                    Session::set("gateway_id", $gateway->gatewayId);
                     $gatewayOfUser = $gateway->gatewayId;
                     Session::forget("super-admin");
+                    Session::put("new-gateway-provider", true);
                     Session::put("existing-gateway-provider", true);
+                    $requestedGateways[ $gateway->gatewayId]["gatewayInfo"] = $gateway;
+                    $requestedGateways[ $gateway->gatewayId]["approvalStatus"] = "Approved";
                     if( $gateway->gatewayApprovalStatus == 0){
-                    	Session::put("approvalStatus", "Requested");
+                    	$requestedGateways[ $gateway->gatewayId]["approvalStatus"] = "Requested";
+                    }
+                    if( $gateway->gatewayApprovalStatus == 1){
+                    	$requestedGateways[ $gateway->gatewayId]["approvalStatus"] = "Approved";
+		            	Session::put("gateway_id", $gateway->gatewayId);
                     }
                     elseif( $gateway->gatewayApprovalStatus == 3){
-                    	Session::put("approvalStatus", "Denied");
+                    	$requestedGateways[ $gateway->gatewayId]["approvalStatus"] = "Denied";
                     }
-                    break;
+                    //seeing if admin wants to start managing one of the gateways
+		            if( Input::has("gatewayId")){
+		            	if( Input::get("gatewayId") == $gateway->gatewayId)
+		            	{
+		            		Session::put("gateway_id", $gateway->gatewayId);
+		            	}
+		            }
                 }
             }
+            $data["requestedGateways"] = $requestedGateways;
+            //to make it accessible to navbar
+            Session::put("requestedGateways", $requestedGateways);
 
             if ($gatewayOfUser == "") {
                 $userInfo["username"] = $userProfile["username"];
                 $userInfo["email"] = $userProfile["email"];
+    			$data["userInfo"] = $userInfo;
+    			$data["gatewaysInfo"] = $gatewaysInfo;
                 Session::put("new-gateway-provider", true);
             }
         }
         //var_dump( $userInfo); exit;
-		return View::make("account/dashboard", array("userInfo"=> $userInfo));
+		return View::make("account/dashboard", $data);
 	}
 
 	public function addAdminSubmit(){
@@ -411,8 +429,10 @@ class AdminController extends BaseController {
 
         $validator = Validator::make( $checkValidation, $rules, $messages);
         if ($validator->fails()) {
-            Session::put("message", $validator->messages() );
-            return Redirect::to("admin/dashboard");
+            Session::put("validationMessages", $validator->messages() );
+            return Redirect::to("admin/dashboard")
+            	->withInput(Input::except('password', 'password_confirm'))
+            	->withErrors($validator);
         }
         else{
 	        $gateway = AdminUtilities::request_gateway(Input::all());

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/libraries/AdminUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/AdminUtilities.php b/app/libraries/AdminUtilities.php
index 2057a29..7338b7c 100644
--- a/app/libraries/AdminUtilities.php
+++ b/app/libraries/AdminUtilities.php
@@ -47,11 +47,19 @@ class AdminUtilities
     public static function update_gateway_status( $gatewayId, $status){
         $gateway = Airavata::getGateway( Session::get('authz-token'), $gatewayId);
         $gateway->gatewayApprovalStatus = intval( $status);
-        
         if( Airavata::updateGateway( Session::get('authz-token'), $gateway->gatewayId,
$gateway) ){
             if( $gateway->gatewayApprovalStatus == GatewayApprovalStatus::APPROVED){
-                if( AdminUtilities::add_tenant( $gateway) ){
-                    Adminutilities::update_gateway_status( Input::get("gateway_id"), GatewayApprovalStatus::ACTIVE);
+                $tenants = WSIS::getTenants();
+                $tenantExists = false;
+                foreach( $tenants as $tenant){
+                    if( $tenant->tenantDomain == $gateway->gatewayURL){
+                        $tenantExists = true;
+                    }
+                }
+                if( !$tenantExists){
+                    if( AdminUtilities::add_tenant( $gateway) ){
+                            Adminutilities::update_gateway_status( Input::get("gateway_id"),
GatewayApprovalStatus::ACTIVE);
+                    }
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/libraries/CommonUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CommonUtilities.php b/app/libraries/CommonUtilities.php
index b56f09b..55db6a5 100644
--- a/app/libraries/CommonUtilities.php
+++ b/app/libraries/CommonUtilities.php
@@ -221,6 +221,15 @@ class CommonUtilities
                 <a href="#" class="dropdown-toggle" data-toggle="dropdown">' . Session::get("username")
. ' <span class="caret"></span></a>';
             echo '<ul class="dropdown-menu" role="menu">';
 
+            if ( Session::has("existing-gateway-provider")) {
+                $requestedGateways = Session::get("requestedGateways");
+                foreach( $requestedGateways as $gatewayId => $gateway){
+                    if( $gateway["approvalStatus"] == "Approved"){
+                        echo '<li><a href="' . URL::to('/') . '/admin/dashboard?gatewayId='
. $gateway["gatewayInfo"]->gatewayId . '">Manage ' . $gateway["gatewayInfo"]->gatewayName
. '</a></li>';
+                    }
+                }
+            }
+
             echo '<li><a href="' . URL::to('/') . '/logout"><span class="glyphicon
glyphicon-log-out"></span> Log out</a></li>';
             echo '</ul></li></ul>';
         } else {

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/libraries/Wsis/Wsis.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php
index 1f5b406..c7d929a 100755
--- a/app/libraries/Wsis/Wsis.php
+++ b/app/libraries/Wsis/Wsis.php
@@ -412,6 +412,14 @@ class Wsis {
         }
     }
 
+    public function getTenants(){
+        try {
+            return $this->tenantManager->retrieveTenants();
+        } catch (Exception $ex) {
+            throw new Exception("Unable to get Tenants.", 0, $ex);
+        }
+    }
+
     /**
      * Function to update the user profile
      * @param $username

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/app/views/account/dashboard.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/dashboard.blade.php b/app/views/account/dashboard.blade.php
index 917319b..bdc9742 100644
--- a/app/views/account/dashboard.blade.php
+++ b/app/views/account/dashboard.blade.php
@@ -20,79 +20,116 @@
         @endif
 
         @if( Session::has('new-gateway-provider') )
-        <div class="row">
-            <div class="col-md-offset-2 col-md-8">
-                <form id="add-tenant-form" action="{{ URL::to('/') }}/provider/request-gateway">
-                    <div class="col-md-12 text-center" style="margin-top:50px;">
-                        <h3>Request your gateway now!</h3>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Gateway Name</label>
-                        <input type="text" name="gateway-name" class="form-control" required="required"/>
-                    </div>
-                    <div class="form-group">
-                        <label class="control-label">Gateway Acronym <i>(optional)</i></label>
-                        <input type="text" name="gateway-acronym" class="form-control"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Domain</label>
-                        <input type="text" name="domain" class="form-control"/>
-                    </div>
+            <div style="margin-top:50px;" class="col-md-12">
+            @if( Session::has("existing-gateway-provider") )
+                <h3>List of Requested Gateways</h3>
+                <table class="table table-bordered">
+                    <thead>
+                        <tr class="text-center">
+                            <th>Gateway Name</th>
+                            <th>Request Status</th>
+                            <th>Actions</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                    @foreach( $requestedGateways as $gatewayId => $gateway)
+                        <tr>
+                            <td>{{ $gateway["gatewayInfo"]->gatewayName }}</td>
+                            <td>{{ $gateway["approvalStatus"] }}</td>
+                            <td>
+                                @if( $gateway["approvalStatus"] == "Approved")
+                                    <div class="btn-group" role="group" aria-label="...">
+                                        <button type="button" class="btn btn-default">Download
Credentials</button>
+                                        <button type="button" class="btn btn-default"><a
href="{{URL::to('/')}}/admin/dashboard?gatewayId={{$gatewayId}}">Manage Gateway</a></button>
+                                        <button type="button" class="btn btn-default">Remove
Gateway</button>
+                                    </div>
+                                @elseif( $gateway["approvalStatus"] == "Requested")
+                                    <button type="button" class="btn btn-danger">Cancel
Request</button>
+                                @endif
+                            </td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            @endif
+            </div>
+            <div class="col-md-12">
+            <button class="gateway-request-button btn btn-default">Request a New Gateway</button>
+                
+            @if ($errors->has())
+                @foreach ($errors->all() as $error)
+                {{ CommonUtilities::print_error_message($error) }}
+                @endforeach
+            @endif
+            <div class="row @if(! $errors->has())hide @endif gateway-request-form">
+                <div class="col-md-offset-2 col-md-8">
+                    <form id="add-tenant-form" action="{{ URL::to('/') }}/provider/request-gateway">
+                        <div class="col-md-12 text-center" style="margin-top:20px;">
+                            <h3>Request your gateway now!</h3>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Gateway Name</label>
+                            <input type="text" name="gateway-name" class="form-control"
required="required" value="{{Input::old('gateway-name') }}" />
+                        </div>
+                        <div class="form-group">
+                            <label class="control-label">Gateway Acronym <i>(optional)</i></label>
+                            <input type="text" name="gateway-acronym" class="form-control"
value="{{Input::old('gateway-acronym') }}"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Domain</label>
+                            <input type="text" name="domain" class="form-control" value="{{Input::old('domain')
}}"/>
+                        </div>
 
-                    <div class="form-group required">
-                        <label class="control-label">Gateway URL</label>
-                        <input type="text" name="gateway-url" class="form-control"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Gateway Admin Username</label>
-                        <input type="text" name="admin-username" value="{{ Session::get('username')
}}" readonly="true" class="form-control" required="required"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Gateway Admin Password</label>
-                        <input type="password" name="admin-password" class="form-control"
required="required"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Admin Password Confirmation</label>
-                        <input type="password" name="admin-password-confirm" class="form-control"
required="required"/>
-                    </div>
+                        <div class="form-group required">
+                            <label class="control-label">Gateway URL</label>
+                            <input type="text" name="gateway-url" class="form-control"
value="{{Input::old('gateway-url') }}"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Gateway Admin Username</label>
+                            <input type="text" name="admin-username" value="{{ Session::get('username')
}}" readonly="true" class="form-control" required="required" />
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Gateway Admin Password</label>
+                            <input type="password" id="password" name="admin-password"
class="form-control" required="required" title="" type="password" data-container="body" data-toggle="popover"
data-placement="left" data-content="Password needs to contain at least (a) One lower case
letter (b) One Upper case letter and (c) One number (d) One of the following special characters
- !@#$*"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Admin Password Confirmation</label>
+                            <input type="password" name="admin-password-confirm" class="form-control"
required="required"/>
+                        </div>
 
-                    <div class="form-group required">
-                        <label class="control-label">Admin First Name</label>
-                        <input type="text" name="admin-firstname" class="form-control"
required="required"/>
-                    </div>
+                        <div class="form-group required">
+                            <label class="control-label">Admin First Name</label>
+                            <input type="text" name="admin-firstname" class="form-control"
required="required" value="{{Input::old('admin-firstname') }}"/>
+                        </div>
 
-                    <div class="form-group required">
-                        <label class="control-label">Admin Last Name</label>
-                        <input type="text" name="admin-lastname" class="form-control"
required="required"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Gateway Email</label>
-                        <input type="text" name="email-address" class="form-control" required="required"/>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Project Details</label>
-                        <textarea type="text" name="project-details" class="form-control"
required="required"></textarea>
-                    </div>
-                    <div class="form-group required">
-                        <label class="control-label">Public Project Description</label>
-                        <textarea type="text" name="public-project-description" class="form-control"
required="required"></textarea>
-                    </div>
-                    <input type="submit" value="Send Request" class="btn btn-primary"/>
-                    <input type="reset" value="Reset" class="btn">
-                </form>
+                        <div class="form-group required">
+                            <label class="control-label">Admin Last Name</label>
+                            <input type="text" name="admin-lastname" class="form-control"
required="required" value="{{Input::old('admin-lastname') }}"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Gateway Email</label>
+                            <input type="text" name="email-address" class="form-control"
required="required" value="{{Input::old('email-address') }}"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Project Details</label>
+                            <textarea type="text" name="project-details" class="form-control"
required="required">{{Input::old('project-details') }}</textarea>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Public Project Description</label>
+                            <textarea type="text" name="public-project-description" class="form-control"
required="required">{{Input::old('public-project-description') }}</textarea>
+                        </div>
+                        <input type="submit" value="Send Request" class="btn btn-primary"/>
+                        <input type="reset" value="Reset" class="btn">
+                    </form>
+                </div>
             </div>
-        </div>
-        @elseif( Session::has("existing-gateway-provider") )
-            @if( Session::get("approvalStatus") == "Requested")
-                <blockquote>Gateway you have request is yet to be approved. Please
log back in after sometime.</blockquote>
-            @elseif( Session::get("approvalStatus") == "Denied")
-                <div class="well alert alert-danger">Unfortunately, Your Request has
been denied at this moment.</div>
-            @else
-                <blockquote>Download Credentials | Get Started with your PGA View</blockquote>
-            @endif
-        @elseif( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only')
)
+            <hr/>
+            </div>
+        @endif
+        @if( Session::has('authorized-user') || Session::has('admin') || Session::has('admin-read-only')
)
         <div class="row text-center breathing-space">
-            <h1>Let's get started!</h1>
+            <h1>Gateway: {{Session::get("gateway_id")}}</h1>
+            <h3>Let's get started!</h3>
         </div>
         <div class="row text-center admin-options">
 
@@ -314,6 +351,14 @@
         $(".add-tenant").slideDown();
     });
 
+    $(".gateway-request-button").click( function(){
+        $(".gateway-request-form").removeClass("hide");
+    });
+
+
+    $("#password").popover({
+        'trigger':'focus'
+    });
 
 </script>
 @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/ddc2b26d/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 4198db3..348c9e6 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -78,19 +78,21 @@
                         </thead>
                         <tbody>
                         @foreach( $gateways as $indexGP => $gp )
-                            @if( $gp->gatewayApprovalStatus == 0)
                             <tr>
                                 <td>{{$gp->gatewayName }}</td>
                                 <td>{{ $gp->gatewayAdminFirstName }} {{ $gp->gatewayAdminLastName
}} </td>
                                 <td>{{ $gp->gatewayURL }}</td>
                                 <td>{{ $gp->reviewProposalDescription}}</td>
                                 <td>{{ $gp->gatewayPublicAbstract}}</td>
-                                <td>
-                                    <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=1"><input
type="button" class="btn btn-primary" value="Approve"/></a>
-                                    <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=3"><input
type="button" class="btn btn-danger" value="Deny"/></a>
-                                </td>
+                                @if( $gp->gatewayApprovalStatus == 0)
+                                    <td>
+                                        <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=1"><input
type="button" class="btn btn-primary" value="Approve"/></a>
+                                        <a href="{{URL::to('/')}}/admin/update-gateway-request?gateway_id={{$gp->gatewayId}}&status=3"><input
type="button" class="btn btn-danger" value="Deny"/></a>
+                                    </td>
+                                @elseif( $gp->gatewayApprovalStatus == 1)
+                                    <td>Approved</td>
+                                @endif
                             </tr>
-                            @endif
                         @endforeach
                         <!-- foreach code ends -->
                         </tbody>


Mime
View raw message