display user informations on the bottom of the page

This commit is contained in:
Sebastian Sdorra
2012-05-12 12:25:04 +02:00
parent 945dbba396
commit 1757eec23d
3 changed files with 53 additions and 3 deletions

View File

@@ -197,7 +197,7 @@
&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>

View File

@@ -570,7 +570,11 @@ if (Sonia.scm.Main){
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'
});
}

View File

@@ -71,6 +71,10 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
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,
infoPanels: [],
@@ -526,6 +530,44 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
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');
}
});
@@ -598,6 +640,10 @@ Ext.onReady(function(){
Ext.History.init();
});
// user informations
main.addListeners('login', main.renderUserInformations);
main.addListeners('logout', main.removeUserInformations);
main.init();
main.checkLogin();
});