You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/06/11 20:25:37 UTC

[08/12] airavata-php-gateway git commit: AIRAVATA-2316 user profile editor: success/error messages

AIRAVATA-2316 user profile editor: success/error messages


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

Branch: refs/heads/keycloak-integration
Commit: 5d527c1d580a4498306e77b2780f6e3d0ec08d3f
Parents: ab980d4
Author: Marcus Christie <ma...@iu.edu>
Authored: Fri Feb 24 10:46:48 2017 -0500
Committer: Marcus Christie <ma...@iu.edu>
Committed: Fri Feb 24 10:46:48 2017 -0500

----------------------------------------------------------------------
 app/controllers/UserSettingsController.php | 14 ++++++++++----
 app/views/account/user-profile.blade.php   | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5d527c1d/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php
index 099d1e7..abacb02 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -197,7 +197,6 @@ class UserSettingsController extends BaseController
 
     public function updateUserProfile() {
 
-        // TODO: handle errors by redispaying input page
         $username = Session::get('username');
         $userProfile = UserProfileUtilities::get_user_profile($username);
 
@@ -210,8 +209,15 @@ class UserSettingsController extends BaseController
         $userProfile->phones = array_filter($phones, function($phone) {
             return trim($phone) !== "";
         });
-        Log::debug("userProfile", array($userProfile));
-        UserProfileUtilities::update_user_profile($userProfile);
-        return Redirect::to("account/user-profile");
+        try {
+            UserProfileUtilities::update_user_profile($userProfile);
+            return Redirect::to("account/user-profile")->with("message", "Your profile has been updated.");
+        } catch (Exception $e) {
+            return View::make("account/user-profile", array(
+                "userProfile" => $userProfile,
+                "errorMessage" => "An error occurred while trying to update your profile: " . $e->getMessage()
+            ));
+        }
+
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/5d527c1d/app/views/account/user-profile.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/user-profile.blade.php b/app/views/account/user-profile.blade.php
index 86690c4..202284a 100644
--- a/app/views/account/user-profile.blade.php
+++ b/app/views/account/user-profile.blade.php
@@ -13,6 +13,20 @@
         <li class="active">Your Profile</li>
     </ol>
 
+    @if( Session::has("message") )
+        <div class="alert alert-success alert-dismissible" role="alert">
+            <button type="button" class="close" data-dismiss="alert"><span
+                    aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+            {{{ Session::get("message") }}}
+        </div>
+    @endif
+
+    @if( isset($errorMessage) )
+        <div class="alert alert-danger" role="alert">
+            {{{ $errorMessage }}}
+        </div>
+    @endif
+
     <div class="row">
         <div class="col-md-6 col-md-offset-3">
             <h1>Profile for {{ Session::get("username") }}</h1>