airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/4] airavata-php-gateway git commit: Making setting preferences an ajax call instead of a complete page load and losing system status.
Date Wed, 30 Mar 2016 20:26:48 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/master f7900df42 -> e410f776e


Making setting preferences an ajax call instead of a complete page load and losing system
status.


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

Branch: refs/heads/master
Commit: 6fc5ded93b611d9682be060573e5f93655d24a22
Parents: 6b40911
Author: Nipurn Doshi <nipunhere@gmail.com>
Authored: Wed Mar 30 13:52:16 2016 -0400
Committer: Nipurn Doshi <nipunhere@gmail.com>
Committed: Wed Mar 30 13:52:16 2016 -0400

----------------------------------------------------------------------
 app/controllers/GatewayprofileController.php    | 12 ++++-
 app/views/admin/manage-gateway.blade.php        | 52 ++++++++++++++++++++
 .../compute-resource-preferences.blade.php      | 10 +++-
 .../gateway-preferences-block.blade.php         |  4 +-
 .../storage-resource-preferences.blade.php      | 21 ++++----
 5 files changed, 83 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6fc5ded9/app/controllers/GatewayprofileController.php
----------------------------------------------------------------------
diff --git a/app/controllers/GatewayprofileController.php b/app/controllers/GatewayprofileController.php
index 9930344..e981f0b 100644
--- a/app/controllers/GatewayprofileController.php
+++ b/app/controllers/GatewayprofileController.php
@@ -40,7 +40,11 @@ class GatewayprofileController extends BaseController {
 	{
 		if( CRUtilities::add_or_update_CRP( Input::all()) )
 		{
-			return Redirect::to("admin/dashboard/gateway")->with("message","Compute Resource Preference
has been set.");
+			if( Request::ajax()){
+				return 1;
+			}
+			else
+				return Redirect::to("admin/dashboard/gateway")->with("message","Compute Resource Preference
has been set.");
 		}
 	}
 
@@ -48,7 +52,11 @@ class GatewayprofileController extends BaseController {
 	{
 		if( SRUtilities::add_or_update_SRP( Input::all()) )
 		{
-			return Redirect::to("admin/dashboard/gateway")->with("message","Storage Preference
has been set.");
+			if( Request::ajax()){
+				return 1;
+			}
+			else
+				return Redirect::to("admin/dashboard/gateway")->with("message","Storage Resource Preference
has been set.");
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6fc5ded9/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 362989a..a455321 100644
--- a/app/views/admin/manage-gateway.blade.php
+++ b/app/views/admin/manage-gateway.blade.php
@@ -258,6 +258,58 @@
        
     });
 
+    $(".set-cr-preference").submit( function( ev){
+        var crForm = $(this);
+        crForm.find(".loading-gif").removeClass("hide");
+
+        ev.preventDefault();
+        var datastring = crForm.serialize();
+        $.ajax({
+            type: "POST",
+            url: "{{URL::to('/')}}/gp/update-crp",
+            data: datastring,
+            success: function(data) {
+                if( data == 1)
+                    crForm.find(".alert-success").removeClass("hide");
+                else
+                    crForm.find(".alert-danger").removeClass("hide");
+            }
+        }).complete( function(){
+            crForm.find(".loading-gif").addClass("hide");
+            setTimeout( function(){
+                crForm.find(".alert-success").addClass("hide");
+                crForm.find(".alert-danger").addClass("hide");
+            }, 5000);
+        });
+
+    });
+
+    $(".set-sr-preference").submit( function( ev){
+        var srForm = $(this);
+        srForm.find(".loading-gif").removeClass("hide");
+
+        ev.preventDefault();
+        var datastring = srForm.serialize();
+        $.ajax({
+            type: "POST",
+            url: "{{URL::to('/')}}/gp/update-srp",
+            data: datastring,
+            success: function(data) {
+                if( data == 1)
+                    srForm.find(".alert-success").removeClass("hide");
+                else
+                    srForm.find(".alert-danger").removeClass("hide");
+            }
+        }).complete( function(){
+            srForm.find(".loading-gif").addClass("hide");
+            setTimeout( function(){
+                srForm.find(".alert-success").addClass("hide");
+                srForm.find(".alert-danger").addClass("hide");
+            }, 5000);
+        });
+
+    });
+
 
     $(".add-tenant").slideUp();
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6fc5ded9/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 109a8e2..a487465 100644
--- a/app/views/partials/compute-resource-preferences.blade.php
+++ b/app/views/partials/compute-resource-preferences.blade.php
@@ -114,7 +114,13 @@
 
 @if(Session::has("admin"))
 <div class="form-group text-center">
-    <input type="submit" class="btn btn-primary" value="Set preferences"/>
+    <input type="submit" class="btn btn-primary submit-crp-form" value="Set preferences"/>
 </div>
 @endif
-</div>
\ No newline at end of file
+</div>
+
+<div class="loading-gif text-center hide">
+    <img  src='{{URL::to('/')}}/assets/ajax-loader.gif'/>
+</div>
+<div class="col-md-offset-2 col-md-8 alert alert-success hide">Compute Resource Preferences
have been updated.</div>
+<div class="col-md-offset-2 col-md-8 alert alert-danger hide">An error has occurred.</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6fc5ded9/app/views/partials/gateway-preferences-block.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/gateway-preferences-block.blade.php b/app/views/partials/gateway-preferences-block.blade.php
index d384fbf..990a420 100644
--- a/app/views/partials/gateway-preferences-block.blade.php
+++ b/app/views/partials/gateway-preferences-block.blade.php
@@ -95,7 +95,7 @@
                                      class="panel-collapse collapse">
                                     <div class="panel-body">
                                         <div class="app-compute-resource-preferences-block">
-                                            <form action="{{URL::to('/')}}/gp/update-crp"
+                                            <form class="set-cr-preference" action="{{URL::to('/')}}/gp/update-crp"
                                                   method="POST">
                                                 <input type="hidden" name="gatewayId"
id="gatewayId"
                                                        value="{{$gp->gatewayId}}">
@@ -160,7 +160,7 @@
                                      class="panel-collapse collapse">
                                     <div class="panel-body">
                                         <div class="app-compute-resource-preferences-block">
-                                            <form action="{{URL::to('/')}}/gp/update-srp"
+                                            <form class="set-sr-preference" action="{{URL::to('/')}}/gp/update-srp"
                                                   method="POST">
                                                 <input type="hidden" name="gatewayId"
id="gatewayId"
                                                        value="{{$gp->gatewayId}}">

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/6fc5ded9/app/views/partials/storage-resource-preferences.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/storage-resource-preferences.blade.php b/app/views/partials/storage-resource-preferences.blade.php
index 632d6a4..ca43291 100644
--- a/app/views/partials/storage-resource-preferences.blade.php
+++ b/app/views/partials/storage-resource-preferences.blade.php
@@ -39,16 +39,10 @@ dmi preference might be needed in the future
 
     <div class="col-md-9">
         <select class="form-control gateway-credential-store-token" name="resourceSpecificCredentialStoreToken"
>
-            @if( isset( $preferences) )
+            <option value="">Select a Credential Token from Store</option>
             @foreach( $tokens as $token => $publicKey)
-                <option value="{{$token}}" @if( $token == $preferences->resourceSpecificCredentialStoreToken)
selected @endif >{{$token}}</option>
+                <option value="{{$token}}" @if( isset( $preferences) ) @if( $token ==
$preferences->resourceSpecificCredentialStoreToken) selected @endif @endif>{{$token}}</option>
             @endforeach
-            @else
-                <option value="">Select a Credential Token from Store</option>
-                @foreach( $tokens as $token => $publicKey)
-                <option value="{{$token}}">{{$token}}</option>
-                @endforeach
-            @endif
             <option value="">DO-NO-SET</option>
         </select>
         <!--
@@ -60,7 +54,14 @@ dmi preference might be needed in the future
 
 @if(Session::has("admin"))
 <div class="form-group text-center">
-    <input type="submit" class="btn btn-primary" value="Set preferences"/>
+    <input type="submit" class="btn btn-primary submit-srp-form" value="Set preferences"/>
 </div>
 @endif
-</div>
\ No newline at end of file
+</div>
+
+
+<div class="loading-gif text-center hide">
+    <img  src='{{URL::to('/')}}/assets/ajax-loader.gif'/>
+</div>
+<div class="col-md-offset-2 col-md-8 alert alert-success hide">Storage Resource Preferences
have been updated.</div>
+<div class="col-md-offset-2 col-md-8 alert alert-danger hide">An error has occurred.</div>
\ No newline at end of file


Mime
View raw message