Admin can update a Credential Store Token for a gateway.

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

Branch: refs/heads/master
Commit: cf050d52b80840e827675ce5aca3a80478e28f52
Parents: 1543e22
Author: Nipurn Doshi <[email protected]>
Authored: Fri Oct 9 11:55:48 2015 -0400
Committer: Nipurn Doshi <[email protected]>
Committed: Fri Oct 9 11:55:48 2015 -0400

----------------------------------------------------------------------
 app/controllers/GatewayprofileController.php | 11 +++++++
 app/libraries/CRUtilities.php                |  6 ++++
 app/routes.php                               | 22 ++++++++------
 app/views/admin/manage-gateway.blade.php     | 35 ++++++++++++++++++++++-
 app/views/layout/basic.blade.php             |  7 +++++
 public/css/admin.css                         |  6 +++-
 6 files changed, 77 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/app/controllers/GatewayprofileController.php
----------------------------------------------------------------------
diff --git a/app/controllers/GatewayprofileController.php 
b/app/controllers/GatewayprofileController.php
index 24b8589..f6bff16 100644
--- a/app/controllers/GatewayprofileController.php
+++ b/app/controllers/GatewayprofileController.php
@@ -74,6 +74,17 @@ class GatewayprofileController extends BaseController {
                }
        }
 
+       public function cstChange(){
+               $inputs = Input::all();
+               
+               if( CRUtilities::updateGatewayProfile( $inputs) )
+               {
+            return "Credential Store Token has been updated";     
+        }
+        else
+            return "An error has occurred. Please try again later or report a 
bug using the link in the Help menu";
+       }
+
 }
 
 ?>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/app/libraries/CRUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/CRUtilities.php b/app/libraries/CRUtilities.php
index 5dcb864..f4e44ba 100755
--- a/app/libraries/CRUtilities.php
+++ b/app/libraries/CRUtilities.php
@@ -466,6 +466,12 @@ class CRUtilities
         return $gateways;
     }
 
+    public static function updateGatewayProfile( $data){
+        $gatewayResourceProfile = Airavata::getGatewayResourceProfile( 
Session::get('authz-token'), $data["gateway_id"]);
+        $gatewayResourceProfile->credentialStoreToken = $data["cst"];
+        return Airavata::updateGatewayResourceProfile( 
Session::get('authz-token'), $data["gateway_id"], $gatewayResourceProfile); 
+    }
+
     public static function add_or_update_CRP($inputs)
     {
         $computeResourcePreferences = new computeResourcePreference($inputs);

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 7e1a83c..76d7b1a 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -10,14 +10,6 @@
 | and give it the Closure to execute when that URI is requested.
 |
 */
-
-/*
-* Theme Pages Routes
-*/
-Route::get( "pages/{theme_view}", function( $theme_view){
-    return View::make("pages", array("page" => $theme_view) );
-});
-
 /*
  * User Routes
 */
@@ -162,6 +154,8 @@ Route::post("gp/add-crp", 
"GatewayprofileController@modifyCRP");
 
 Route::post("gp/update-crp", "GatewayprofileController@modifyCRP");
 
+Route::post("gp/credential-store-token-change", 
"GatewayprofileController@cstChange");
+
 //Management Dashboard
 
 Route::get("admin/console", "AdminController@console");
@@ -215,6 +209,18 @@ Route::post("admin/remove-role-from-user", 
"AdminController@removeRoleFromUser")
 Route::post("admin/add-gateway", "AdminController@addGateway");
 Route::get("admin/add-gateway", "AdminController@addGateway");
 
+Route::get("admin/pages/{page}", function( $page){
+    return Redirect::to("pages/" . $page);
+});
+
+/*
+* Theme Pages Routes
+*/
+Route::get( "pages/{theme_view}", function( $theme_view){
+    return View::make("pages", array("page" => $theme_view) );
+});
+
+
 //Airavata Server Check
 Route::get("airavata/down", function () {
     return View::make("server-down");

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/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 2c4265b..dac0c58 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -58,13 +58,28 @@
                         <div class="panel-body">
                             <div class="app-interface-block">
                                 <div class="row">
-                                    @if(Session::has("admin"))
+                                     @if(Session::has("admin"))
+                                    <div class="col-md-10 
credential-store-token-change">
+                                        <form>
+                                            <div class="form-group">
+                                                <label class="control-label 
col-md-12">Credential Store Token</label>
+                                                <div class="col-md-9">
+                                                    <input type="text" 
name="resourceSpecificCredentialStoreToken"  data-gpid="{{$gp->gatewayId}}" 
class="form-control credential-store-token"
+                                                           value="@if( isset( 
$gp->profile->credentialStoreToken) 
){{$gp->profile->credentialStoreToken}}@endif"/>
+                                                </div>
+                                                <div class="col-md-3">
+                                                        <input type="submit" 
class="form-control btn btn-primary" value="Set"/>
+                                                </div>
+                                            </div>
+                                        </form>
+                                    </div>
                                     <div class="col-md-10">
                                         <button class="btn btn-default add-cr" 
data-gpid="{{$gp->gatewayId}}"><span
                                                 class="glyphicon 
glyphicon-plus"></span> Add a Compute Resource
                                         </button>
                                     </div>
                                     @endif
+                                </div>
                                     <div class="col-md-10">
                                         @if( isset( 
$gp->profile->computeResourcePreferences) )
                                         <div>
@@ -218,5 +233,23 @@
     //make first tab of accordion open by default.
     //temporary fix
     $("#accordion2").children(".panel").children(".collapse").addClass("in");
+
+    $(".credential-store-token-change > form").submit( function(e){
+        $(this).prepend( "<img id='loading-gif' 
src='{{URL::to('/')}}/assets/ajax-loader.gif'/>");
+        e.preventDefault();
+        cstField = $(".credential-store-token");
+        if( $.trim( cstField.val()) != ""){
+            $.ajax({
+                url: "{{URL::to('/')}}/gp/credential-store-token-change",
+                method: "POST",
+                data: { cst : cstField.val(), gateway_id: 
cstField.data("gpid") }
+            }).done( function( data){
+                $("#loading-gif").remove();
+                alert( data);
+            });
+        }
+        else
+            alert("Please enter a valid Credential Store Token.");
+    });
 </script>
 @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/app/views/layout/basic.blade.php
----------------------------------------------------------------------
diff --git a/app/views/layout/basic.blade.php b/app/views/layout/basic.blade.php
index b1d941c..882c938 100755
--- a/app/views/layout/basic.blade.php
+++ b/app/views/layout/basic.blade.php
@@ -56,8 +56,15 @@ var fullName = {{ Session::get("user-profile")["firstname"] 
. " " . Session::get
 @include('layout/fixed-scripts')
 @show
 
+<style>
+.theme-footer{
+       margin-top: 5%;
+}
+</style>
 @if( isset( $theme))
+<footer class="theme-footer">
 {{ $theme->partial("footer") }}
+</footer>
 @endif
 
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/cf050d52/public/css/admin.css
----------------------------------------------------------------------
diff --git a/public/css/admin.css b/public/css/admin.css
index 3c93a7d..8550e8f 100644
--- a/public/css/admin.css
+++ b/public/css/admin.css
@@ -304,4 +304,8 @@ ul.alert-dropdown {
     color:#000
 } 
 
-/* ------------------- experiment Stages CSS over ---------------- */
\ No newline at end of file
+/* ------------------- experiment Stages CSS over ---------------- */
+
+.credential-store-token-change{
+    margin-bottom: 15px;
+}
\ No newline at end of file

Reply via email to