Commits

Sebastian Sdorra committed 87614a3 Merge

merge with branch issue-146

Comments (0)

Files changed (3)

scm-webapp/src/main/webapp/index.html

           &copy; <a target="_blank" href="http://bitbucket.org/sdorra/scm-manager">SCM Manager</a>
         </div>
         <div class="right-side">
-          ${version}
+          <span id="scm-userinfo"></span> ${version}
         </div>
       </div>
 

scm-webapp/src/main/webapp/resources/js/i18n/de.js

     errorNoPermissionsMessage: 'Sie haben nicht genügend Rechte um diese Aktion auszuführen.',
   
     errorNotFoundTitle: 'Nicht gefunden',
-    errorNotFoundMessage: 'Die Ressource konnte nicht gefunden werden.'
+    errorNotFoundMessage: 'Die Ressource konnte nicht gefunden werden.',
+    
+    loggedInTextTemplate: 'angemeldet als <a id="scm-userinfo-tip">{state.user.name}</a> - ',
+    userInfoMailText: 'E-Mail',
+    userInfoGroupsText: 'Gruppen'
   });
 
 }

scm-webapp/src/main/webapp/resources/js/sonia.scm.js

   
   errorNotFoundTitle: 'Not found',
   errorNotFoundMessage: 'The resource could not be found.',
+  
+  loggedInTextTemplate: 'logged in as <a id="scm-userinfo-tip">{state.user.name}</a> - ',
+  userInfoMailText: 'Mail',
+  userInfoGroupsText: 'Groups',
 
   mainTabPanel: null,
   
   
   getMainTabPanel: function(){
     return this.mainTabPanel;
+  },
+  
+  renderUserInformations: function(state){
+    if ( state.user.name != 'anonymous' ){
+      var tpl = new Ext.XTemplate(this.loggedInTextTemplate);
+      tpl.overwrite(Ext.get('scm-userinfo'), state);
+      var text = '';
+      if (state.user.mail){
+        text += this.userInfoMailText + ': ' + state.user.mail + '<br />';
+      }
+      if (state.groups && state.groups.length > 0){
+        text += this.userInfoGroupsText + ': ' + this.getGroups(state.groups) + '<br />';
+      }
+
+      Ext.QuickTips.register({
+        target : 'scm-userinfo-tip',
+        title : state.user.displayName,
+        text : text,
+        enabled : true
+      });
+    }
+  },
+  
+  getGroups: function(groups){
+    var out = '';
+    var s = groups.length;
+    for ( var i=0; i<s; i++ ){
+      out += groups[i];
+      if ( (i+1)<s ){
+        out += ', ';
+      }
+    }
+    return out;
+  },
+  
+  removeUserInformations: function(){
+    Ext.get('scm-userinfo').dom.innerHTML = '';
+    Ext.QuickTips.unregister('scm-userinfo-tip');
   }
 
 });
   main.addListeners('login', function(){
     Ext.History.init();
   });
-
+  
+  // user informations
+  main.addListeners('login', main.renderUserInformations);
+  main.addListeners('logout', main.removeUserInformations);
+  
   main.init();
   main.checkLogin();
 });