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 2015/12/10 17:50:35 UTC

[22/23] airavata-php-gateway git commit: Super Admin features to add a gateway + Compute Resource made Uneditable

Super Admin features to add a gateway + Compute Resource made Uneditable


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

Branch: refs/heads/develop
Commit: 3aeb34402d600489b14fb49dba34bc2cf604de37
Parents: 93eb29d
Author: Nipurn Doshi <ni...@gmail.com>
Authored: Thu Dec 10 11:47:50 2015 -0500
Committer: Nipurn Doshi <ni...@gmail.com>
Committed: Thu Dec 10 11:47:50 2015 -0500

----------------------------------------------------------------------
 app/controllers/AdminController.php             | 40 +++----------
 app/libraries/Wsis/Stubs/TenantManager.php      |  6 +-
 app/libraries/Wsis/Wsis.php                     |  6 +-
 app/views/admin/manage-gateway.blade.php        | 59 ++++++++++++++++++++
 app/views/resource/browse.blade.php             | 14 +++--
 app/views/resource/edit.blade.php               | 26 ++++++++-
 app/views/scigap-admin/manage-gateway.blade.php | 14 +++--
 7 files changed, 115 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/controllers/AdminController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AdminController.php b/app/controllers/AdminController.php
index 8d3cad3..e40a249 100644
--- a/app/controllers/AdminController.php
+++ b/app/controllers/AdminController.php
@@ -5,33 +5,12 @@ class AdminController extends BaseController {
 	public function __construct()
 	{
         $this->beforeFilter('verifyadmin');
+		Session::put("scigap_admin", true);
 		Session::put("nav-active", "user-console");
 	}
 
 	public function dashboard(){
-		//only for super admin
-		//Session::put("scigap_admin", true);
-
-		if( Session::has("scigap_admin"))
-		{
-			$crData = CRUtilities::getEditCRData();
-			$gateways = CRUtilities::getAllGatewayProfilesData();
-
-			$gatewayData = array( 
-									"gateways" => $gateways, 
-									"computeResources" => CRUtilities::getAllCRObjects(),
-									"crData" => $crData
-								);
-			
-			$view = "scigap-admin/manage-gateway";
-
-            Session::put("admin-nav", "gateway-prefs");
-			return View::make( $view, $gatewayData);
-		}
-		else{
-        	return View::make("account/dashboard");
-
-        }
+    	return View::make("account/dashboard");
 	}
 
 	public function addAdminSubmit(){
@@ -73,8 +52,7 @@ class AdminController extends BaseController {
     }
 
     public function gatewayView(){
-    	//only for super admin
-		//Session::put("scigap_admin", true);
+
 		$crData = CRUtilities::getEditCRData();
 		$gateways = CRUtilities::getAllGatewayProfilesData();
 		$tokens = AdminUtilities::get_ssh_tokens();
@@ -87,11 +65,11 @@ class AdminController extends BaseController {
 								"tokens" => $tokens
 							);
 		//var_dump( $gateways); exit;
-		if( Session::has("scigap_admin"))
+		/*if( Session::has("scigap_admin"))
 			$view = "scigap-admin/manage-gateway";
 		else{
+		*/
 			$view = "admin/manage-gateway";
-        }
 
         Session::put("admin-nav", "gateway-prefs");
 		return View::make( $view, $gatewayData);
@@ -192,12 +170,12 @@ class AdminController extends BaseController {
 
 		$inputs = Input::all();
 
-        $gateway = AdminUtilities::add_gateway(Input::all());
-
-		$tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"],
+		$tm = WSIS::createTenant(true, $inputs["admin-username"], $inputs["admin-password"],
 			$inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);
 
-		return $gateway;
+        $gateway = AdminUtilities::add_gateway(Input::all());
+
+		return Redirect::to("admin/dashboard/gateway")->with("message", "Gateway has been registered successfully.");
 	}
 
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/libraries/Wsis/Stubs/TenantManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/TenantManager.php b/app/libraries/Wsis/Stubs/TenantManager.php
index c621b7a..634bc56 100755
--- a/app/libraries/Wsis/Stubs/TenantManager.php
+++ b/app/libraries/Wsis/Stubs/TenantManager.php
@@ -69,13 +69,13 @@ class TenantManager {
         $tenantInfoBean->admin = $adminUsername;
         $tenantInfoBean->adminPassword = $adminPassword;
         $tenantInfoBean->email = $email;
-        $tenantInfoBean->firstName = $firstName;
-        $tenantInfoBean->lastName = $lastName;
+        $tenantInfoBean->firstname = $firstName;
+        $tenantInfoBean->lastname = $lastName;
         $tenantInfoBean->tenantDomain = $tenantDomain;
 
         $addTenant  = new addTenant();
         $addTenant->tenantInfoBean = $tenantInfoBean;
-        $this->serviceStub->addTenant($addTenant);
+        return $this->serviceStub->addTenant($addTenant);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/libraries/Wsis/Wsis.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php
index 48739e2..f3e1e55 100755
--- a/app/libraries/Wsis/Wsis.php
+++ b/app/libraries/Wsis/Wsis.php
@@ -401,11 +401,7 @@ class Wsis {
             return $this->tenantManager->addTenant($active, $adminUsername, $adminPassword, $email,
                 $firstName, $lastName, $tenantDomain);
         } catch (Exception $ex) {
-            /**
-             * Fixme -  There is an issue in the Remote IS which throws an exception when called this method
-             * But the tenant creation works. Therefore ignores the exception for the moment.
-             */
-            //throw new Exception("Unable to create Tenant.", 0, $ex);
+            throw new Exception("Unable to create Tenant.", 0, $ex);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/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 4db7980..621ac4e 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -235,6 +235,54 @@
                     </div>
                 </div>
                 @endforeach
+                @if( Session::has("scigap_admin"))
+                <form id="add-tenant-form" action="{{ URL::to("/") }}/admin/add-gateway">
+                    <div class="col-md-12">
+                        <button type="button" class="btn btn-default toggle-add-tenant"><span
+                                class="glyphicon glyphicon-plus"></span>Add a new gateway
+                        </button>
+                    </div>
+                    <div class="add-tenant col-md-6">
+                        <div class="form-group required">
+                            <label class="control-label">Enter Domain Name</label>
+                            <input type="text" name="domain" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Enter Desired Gateway Name</label>
+                            <input type="text" name="gatewayName" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Enter Admin Email Address</label>
+                            <input type="text" name="admin-email" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Enter 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">Enter 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">Enter Admin Username</label>
+                            <input type="text" name="admin-username" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Enter Admin Password</label>
+                            <input type="password" name="admin-password" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <label class="control-label">Re-enter Admin Password</label>
+                            <input type="password" name="admin-password-confirm" class="form-control" required="required"/>
+                        </div>
+                        <div class="form-group required">
+                            <input type="submit" class="col-md-2 form-control btn btn-primary" value="Register"/>
+                        </div>
+                    </div>
+                    <div class="col-md-6 alert alert-danger gateway-error hide">
+                    </div>
+                </form>
+                @endif
             </div>
         </div>
         <!-- /.container-fluid -->
@@ -328,5 +376,16 @@
         else
             alert("Please enter a valid Credential Store Token.");
     });
+
+
+    $(".add-tenant").slideUp();
+
+    $(".toggle-add-tenant").click(function () {
+        $('html, body').animate({
+            scrollTop: $(".toggle-add-tenant").offset().top
+        }, 500);
+        $(".add-tenant").slideDown();
+    });
+
 </script>
 @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/views/resource/browse.blade.php
----------------------------------------------------------------------
diff --git a/app/views/resource/browse.blade.php b/app/views/resource/browse.blade.php
index c9b5382..1ee5491 100644
--- a/app/views/resource/browse.blade.php
+++ b/app/views/resource/browse.blade.php
@@ -51,11 +51,11 @@
                         <th>Id</th>
                         @if(Session::has("admin"))
                         <th>Enabled</th>
-                        <th>Edit</th>
+                        <!--<th>Edit</th>-->
                         @endif
                         <th>View</th>
                         @if(Session::has("admin"))
-                        <th>Delete</th>
+                        <!--<th>Delete</th>-->
                         @endif
                     </tr>
 
@@ -66,7 +66,7 @@
                         $enabled = $resource->enabled;
                     ?>
                     <tr id="crDetails">
-                        <td>{{ $crName }}</td>
+                        <td><a href="{{URL::to('/')}}/cr/edit?crId={{ $crId }}" title="Edit">{{ $crName }}</a></td>
                         <td>{{ $crId }}</td>
                         @if(Session::has("admin"))
                         <td>
@@ -80,17 +80,20 @@
                             </div>
                             @endif
                         </td>
+                        <!--
                         <td><a href="{{URL::to('/')}}/cr/edit?crId={{ $crId }}" title="Edit">
                                 <span class="glyphicon glyphicon-pencil"></span>
                             </a>
                         </td>
+                        -->
                         @endif
                         <td>
-                            <a href="{{URL::to('/')}}/cr/view?crId={{ $crId }}" title="Edit">
+                            <a href="{{URL::to('/')}}/cr/edit?crId={{ $crId }}" title="Edit">
                             <span class="glyphicon glyphicon-list"></span>
                             </a>
                         </td>
                         @if(Session::has("admin"))
+                        <!--
                         <td>
                             <a href="#" title="Delete">
                                 <span class="glyphicon glyphicon-trash del-cr" data-toggle="modal"
@@ -99,6 +102,7 @@
                                       data-crid="{{$crId}}"></span>
                             </a>
                         </td>
+                        -->
                         @endif
                     </tr>
                     @endforeach
@@ -209,5 +213,5 @@
                 });
             }
         });
-    </script>
+        </script>
     @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/views/resource/edit.blade.php
----------------------------------------------------------------------
diff --git a/app/views/resource/edit.blade.php b/app/views/resource/edit.blade.php
index b52af67..459bbf3 100644
--- a/app/views/resource/edit.blade.php
+++ b/app/views/resource/edit.blade.php
@@ -14,7 +14,7 @@
 <div id="page-wrapper">
 
 <div class="container-fluid">
-<div class="col-md-offset-2 col-md-8">
+<div class="col-md-offset-2 col-md-8 compute-resource-properties">
 
 <input type="hidden" class="base-url" value="{{URL::to('/')}}"/>
 
@@ -840,4 +840,28 @@
         $(".delete-queueName").html($(this).data("queue-name"));
     })
 </script>
+
+@if(! Session::has('scigap_admin'))
+    <script>
+    function disableInputs( elem){
+        elem.find("input").each( function( i,e){
+            if( $(e).attr("type")=='submit' || $(e).attr("type")=='button'  )
+                $(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");
+        //remove previously created input/output blocks
+        elem.find(".app-inputs").html("");
+        elem.find(".app-outputs").html("");
+        $(".glyphicon").hide();
+    }
+
+    disableInputs( $(".compute-resource-properties"));
+    </script>
+@endif
+
 @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3aeb3440/app/views/scigap-admin/manage-gateway.blade.php
----------------------------------------------------------------------
diff --git a/app/views/scigap-admin/manage-gateway.blade.php b/app/views/scigap-admin/manage-gateway.blade.php
index a07c329..4a663e1 100644
--- a/app/views/scigap-admin/manage-gateway.blade.php
+++ b/app/views/scigap-admin/manage-gateway.blade.php
@@ -59,7 +59,7 @@
                 </tr>
                 @endforeach
             </table>
-            <form id="add-tenant-form">
+            <form id="add-tenant-form" action="{{ URL::to("/") }}/admin/add-gateway">
                 <div class="col-md-12">
                     <button type="button" class="btn btn-default toggle-add-tenant"><span
                             class="glyphicon glyphicon-plus"></span>Add a new gateway
@@ -171,7 +171,7 @@
         $(".add-tenant").slideDown();
     });
 
-    $("#add-tenant-form").submit(function (event) {
+    /*$("#add-tenant-form").submit(function (event) {
         event.preventDefault();
         event.stopPropagation();
         var formData = $("#add-tenant-form").serialize();
@@ -179,13 +179,17 @@
         $.ajax({
             type: "POST",
             data: formData,
-            url: '{{ URL::to(' / ') }}/admin/add-gateway',
+            url: '{{ URL::to("/") }}/admin/add-gateway',
             success: function (data) {
-                $(".gateway-error").html(data).removeClass("hide");
+                
+            },
+            error: function( data){
+                var error = $.parseJSON( data.responseText);
+                $(".gateway-error").html(error.message).removeClass("hide");
             }
         }).complete(function () {
             $("#add-gateway-loading").modal("hide");
         });
-    });
+    });*/
 </script>
 @stop
\ No newline at end of file