self-service
    Selects the site map based on the presence or absense of rolegroups for
the current user. If the user has no rolegroups, UI defaults to the Details page for that user.

>From 90d86afc318d317962ce2ac7b3138a49d662f9d9 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Tue, 21 Sep 2010 16:22:45 -0400
Subject: [PATCH] self-service
 Selects the site map based on the presence or absense of rolegroups for
 the current user.  If the user has no rolegroups, UI defaults to the Details page for that user.

---
 install/static/webui.js |   47 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/install/static/webui.js b/install/static/webui.js
index 5e93e18..bb12079 100644
--- a/install/static/webui.js
+++ b/install/static/webui.js
@@ -21,7 +21,7 @@
 /* REQUIRES: everything, this file puts it all togheter */
 
 /* tabs definition for IPA webUI */
-var nav_tabs_lists = [
+var admin_tabs_lists = [
     ['identity', 'IDENTITY', [
         ['user', 'Users', ipa_entity_setup],
         ['group', 'Groups', ipa_entity_setup],
@@ -35,29 +35,42 @@ var nav_tabs_lists = [
     ['config', 'CONFIG', unimplemented_tab]
 ];
 
+
+var self_serv_tabs_lists = 
+    [['user', 'Users', ipa_entity_setup]];
+
+
+var nav_tabs_list;
+
 /* main (document onready event handler) */
 $(function() {
-    function set_logged_in_as(principal) {
-        $.cookie('whoami', principal);
-        $('#loggedinas').find('strong').text(principal);
-    };
 
     function whoami_on_win(data, text_status, xhr) {
-        if (!data.error)
-            set_logged_in_as(data.result.summary);
+        $(window).bind('hashchange', window_hashchange);
+        if (!data.error){
+            var whoami = data.result.result[0];
+            $('#loggedinas').find('strong').text(whoami.krbprincipalname[0]);
+            if (whoami.hasOwnProperty('memberof_rolegroup') &&
+                whoami.memberof_rolegroup.length > 0){
+                nav_tabs_lists = admin_tabs_lists;
+                window_hashchange(null);
+            }else{
+                nav_tabs_lists = self_serv_tabs_lists;
+
+                var state = {'user-pkey': whoami.uid[0],
+                             'user-facet': jQuery.bbq.getState('user-facet') ||
+                             'details'};
+                $.bbq.pushState(state);
+            }
+            nav_create(nav_tabs_lists, $('#navigation'), 'tabs');
+
+        }else{
+            alert("Unable to find prinicpal for logged in user");
+        }
     };
 
     function init_on_win(data, text_status, xhr) {
-        nav_create(nav_tabs_lists, $('#navigation'), 'tabs');
-
-        $(window).bind('hashchange', window_hashchange);
-        window_hashchange(null);
-
-        var whoami = $.cookie('whoami');
-        if (whoami)
-            set_logged_in_as(whoami);
-        else
-            ipa_cmd('whoami', [], {}, whoami_on_win, null, null, 'sampledata/whoami.json');
+        ipa_cmd('user_find', [], {"whoami":"true","all":"true"}, whoami_on_win, null, null);
     };
 
     ipa_init(null, init_on_win);
-- 
1.7.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to