airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [05/12] airavata-php-gateway git commit: AIRAVATA-2316 Adding initial impl of user profile editor
Date Sun, 11 Jun 2017 20:25:34 GMT
AIRAVATA-2316 Adding initial impl of user profile editor


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

Branch: refs/heads/keycloak-integration
Commit: 3bfc4e33644215f7c2c07d1ceaf9440820b17290
Parents: 1f8d0b8
Author: Marcus Christie <machrist@iu.edu>
Authored: Mon Feb 20 21:12:47 2017 -0500
Committer: Marcus Christie <machrist@iu.edu>
Committed: Mon Feb 20 21:13:29 2017 -0500

----------------------------------------------------------------------
 app/controllers/AccountController.php      |  3 +-
 app/controllers/UserSettingsController.php | 11 ++++-
 app/libraries/UserProfileUtilities.php     | 22 ++++++++-
 app/routes.php                             |  2 +
 app/views/account/user-profile.blade.php   | 64 +++++++------------------
 5 files changed, 49 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3bfc4e33/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index cc2dd07..aefaffb 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -253,7 +253,8 @@ class AccountController extends BaseController
         }
 
         // Create basic user profile if it doesn't exist
-        if (!UserProfileUtilities::does_user_profile_exist()) {
+        // TODO: Move this to UserProfileUtilities
+        if (!UserProfileUtilities::does_user_profile_exist($username)) {
             $gatewayId = Session::get("gateway_id");
             $userProfileData = array();
             $userProfileData["airavataInternalUserId"] = $username . '@' . $gatewayId;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3bfc4e33/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php
index 49c4257..054ea05 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -189,9 +189,16 @@ class UserSettingsController extends BaseController
 
     public function getUserProfile() {
 
-        $emailAddress = "foo@example.com";
+        $userProfile = UserProfileUtilities::get_user_profile(Session::get("username"));
         return View::make("account/user-profile", array(
-            "emailAddress" => $emailAddress
+            "userProfile" => $userProfile
         ));
     }
+
+    public function updateUserProfile() {
+
+        // TODO: handle errors by redispaying input page
+        UserProfileUtilities::update_user_profile(Input::all());
+        return Redirect::to("account/user-profile");
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3bfc4e33/app/libraries/UserProfileUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/UserProfileUtilities.php b/app/libraries/UserProfileUtilities.php
index 5908e59..09f4e34 100644
--- a/app/libraries/UserProfileUtilities.php
+++ b/app/libraries/UserProfileUtilities.php
@@ -6,8 +6,7 @@ use Airavata\Model\User\UserProfile;
 class UserProfileUtilities
 {
 
-    public static function does_user_profile_exist() {
-        $userId = Session::get('username');
+    public static function does_user_profile_exist($userId) {
         $gatewayId = Session::get('gateway_id');
         return Airavata::doesUserProfileExist(Session::get('authz-token'), $userId, $gatewayId);
     }
@@ -21,6 +20,25 @@ class UserProfileUtilities
         $userProfile->State = Status::ACTIVE;
         return Airavata::addUserProfile(Session::get('authz-token'), $userProfile);
     }
+
+    public static function get_user_profile($userId) {
+
+        $gatewayId = Session::get('gateway_id');
+        return Airavata::getUserProfileById(Session::get('authz-token'), $userId, $gatewayId);
+    }
+
+    public static function update_user_profile($userProfileData) {
+
+        Log::debug("userProfileData", array($userProfileData));
+        $username = Session::get('username');
+        $userProfile = UserProfileUtilities::get_user_profile($username);
+
+        // Copy data from form to $userProfile object and update
+        $userProfile->userName = $userProfileData["userName"];
+        $userProfile->homeOrganization = $userProfileData["homeOrganization"];
+        $userProfile->country = $userProfileData["country"];
+        return Airavata::updateUserProfile(Session::get('authz-token'), $userProfile);
+    }
 }
 
 ?>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3bfc4e33/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index e750ef1..1486751 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -65,6 +65,8 @@ Route::post("account/update-user-srp", "UserSettingsController@updateUserStorage
 Route::post("account/delete-user-srp", "UserSettingsController@deleteUserStorageResourcePreference");
 
 Route::get("account/user-profile", "UserSettingsController@getUserProfile");
+Route::post("account/user-profile", "UserSettingsController@updateUserProfile");
+
 /*
  * The following routes will not work without logging in.
  *

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/3bfc4e33/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 53dbef2..e96b50c 100644
--- a/app/views/account/user-profile.blade.php
+++ b/app/views/account/user-profile.blade.php
@@ -12,79 +12,47 @@
         <li><a href="{{ URL::to('/') }}/account/settings">User Settings</a></li>
         <li class="active">Your Profile</li>
     </ol>
-    
+
     <div class="row">
         <div class="col-md-6 col-md-offset-3">
             <h1>Profile for {{ Session::get("username") }}</h1>
         </div>
     </div>
-    
+
     <div class="row">
         <div class="col-md-6 col-md-offset-3">
     <form action="{{ URL::to("account/user-profile") }}" method="post" role="form">
 
         <div class="form-group">
             <label class="control-label">E-mail</label>
-            <p class="form-control-static">{{{ $emailAddress }}}</p>
-        </div>
-        <div class="form-group required">
-            <label class="control-label">First Name</label>
-            <div><input class="form-control" id="first_name" maxlength="30" name="first_name"
-                        placeholder="First Name" required="required" title="" type="text"
-                        value="{{Input::old('first_name') }}"/></div>
+            <p class="form-control-static">{{{ $userProfile->emails[0] }}}</p>
         </div>
         <div class="form-group required">
-            <label class="control-label">Last Name</label>
-            <div><input class="form-control" id="last_name" maxlength="30" name="last_name"
-                        placeholder="Last Name" required="required" title="" type="text"
-                        value="{{Input::old('last_name') }}"/></div>
+            <label class="control-label">Name</label>
+            <div><input class="form-control" id="userName" maxlength="50" name="userName"
+                        placeholder="Name" type="text"
+                        value="{{{ $userProfile->userName }}}"/></div>
         </div>
         <div class="form-group">
             <label class="control-label">Organization</label>
-            <div><input class="form-control" id="organization" name="organization"
-                        placeholder="Organization" title="" type="text" value="{{Input::old('organization')
}}"/>
-            </div>
-        </div>
-        <div class="form-group">
-            <label class="control-label">Address</label>
-            <div><input class="form-control" id="address" name="address"
-                        placeholder="Address" title="" type="text" value="{{Input::old('address')
}}"/>
+            <div><input class="form-control" id="homeOrganization" name="homeOrganization"
+                        placeholder="Organization" type="text"
+                        value="{{{ $userProfile->homeOrganization }}}"/>
             </div>
         </div>
         <div class="form-group">
             <label class="control-label">Country</label>
             <div><input class="form-control" id="country" name="country"
-                        placeholder="Country" title="" type="text" value="{{Input::old('country')
}}"/>
-            </div>
-        </div>
-        <div class="form-group">
-            <label class="control-label">Telephone</label>
-            <div><input class="form-control" id="telephone" name="telephone"
-                        placeholder="Telephone" title="" type="tel" value="{{Input::old('telephone')
}}"/>
-            </div>
-        </div>
-        <div class="form-group">
-            <label class="control-label">Mobile</label>
-            <div><input class="form-control" id="mobile" name="mobile"
-                        placeholder="Mobile" title="" type="tel" value="{{Input::old('mobile')
}}"/>
-            </div>
-        </div>
-        <div class="form-group">
-            <label class="control-label">IM</label>
-            <div><input class="form-control" id="im" name="im"
-                        placeholder="IM" title="" type="text" value="{{Input::old('im') }}"/>
+                        placeholder="Country" type="text"
+                        value="{{{ $userProfile->country }}}"/>
             </div>
         </div>
-        <div class="form-group">
-            <label class="control-label">URL</label>
-            <div><input class="form-control" id="url" name="url"
-                        placeholder="URL" title="" type="text" value="{{Input::old('url')
}}"/>
-            </div>
-        </div>
-        <br/>
+
+        {{-- TODO: add phone numbers --}}
+
         <input name="update" type="submit" class="btn btn-primary btn-block" value="Update">
     </form>
-    
+
 </div>
 
 @stop


Mime
View raw message