mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 18:51:10 +01:00
prepare sonia.scm.js for localization
This commit is contained in:
@@ -46,6 +46,18 @@ var logoutCallbacks = [];
|
|||||||
|
|
||||||
var restUrl = "api/rest/";
|
var restUrl = "api/rest/";
|
||||||
|
|
||||||
|
function execCallbacks(callbacks, param){
|
||||||
|
Ext.each(callbacks, function(callback){
|
||||||
|
if ( Ext.isFunction(callback) ){
|
||||||
|
callback(state);
|
||||||
|
} else if (Ext.isObject(callback)) {
|
||||||
|
callback.fn.call( callback.scope, param );
|
||||||
|
} else if (debug){
|
||||||
|
console.debug( "callback is not a function or object. " + callback );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function loadState(s){
|
function loadState(s){
|
||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug( s );
|
console.debug( s );
|
||||||
@@ -53,11 +65,7 @@ function loadState(s){
|
|||||||
state = s;
|
state = s;
|
||||||
admin = s.user.admin;
|
admin = s.user.admin;
|
||||||
// call login callback functions
|
// call login callback functions
|
||||||
Ext.each(loginCallbacks, function(callback){
|
execCallbacks(loginCallbacks, state);
|
||||||
if ( Ext.isFunction(callback) ){
|
|
||||||
callback(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearState(){
|
function clearState(){
|
||||||
@@ -108,11 +116,7 @@ function logout(){
|
|||||||
}
|
}
|
||||||
clearState();
|
clearState();
|
||||||
// call logout callback functions
|
// call logout callback functions
|
||||||
Ext.each(logoutCallbacks, function(callback){
|
execCallbacks(logoutCallbacks, state);
|
||||||
if ( Ext.isFunction(callback) ){
|
|
||||||
callback(state);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var s = null;
|
var s = null;
|
||||||
var text = response.responseText;
|
var text = response.responseText;
|
||||||
|
|||||||
@@ -29,6 +29,154 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Ext.ns("Sonia.scm");
|
||||||
|
|
||||||
|
Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||||
|
|
||||||
|
tabRepositoriesText: 'Repositories',
|
||||||
|
navChangePasswordText: 'Change Password',
|
||||||
|
sectionMainText: 'Main',
|
||||||
|
sectionSecurityText: 'Security',
|
||||||
|
navRepositoriesText: 'Repositories',
|
||||||
|
sectionConfigText: 'Config',
|
||||||
|
navGeneralConfigText: 'General',
|
||||||
|
tabGeneralConfigText: 'SCM Config',
|
||||||
|
|
||||||
|
navRepositoryTypesText: 'Repository Types',
|
||||||
|
tabRepositoryTypesText: 'Repository Config',
|
||||||
|
navPluginsText: 'Plugins',
|
||||||
|
tabPluginsText: 'Plugins',
|
||||||
|
navUsersText: 'Users',
|
||||||
|
tabUsersText: 'Users',
|
||||||
|
navGroupsText: 'Groups',
|
||||||
|
tabGroupsText: 'Groups',
|
||||||
|
|
||||||
|
sectionLoginText: 'Login',
|
||||||
|
navLoginText: 'Login',
|
||||||
|
|
||||||
|
sectionLogoutText: 'Log out',
|
||||||
|
navLogoutText: 'Log out',
|
||||||
|
|
||||||
|
|
||||||
|
createRepositoryPanel: function(){
|
||||||
|
if ( debug ){
|
||||||
|
console.debug('create repository panel');
|
||||||
|
}
|
||||||
|
var mainTabPanel = Ext.getCmp('mainTabPanel');
|
||||||
|
mainTabPanel.add({
|
||||||
|
id: 'repositories',
|
||||||
|
xtype: 'repositoryPanel',
|
||||||
|
title: this.tabRepositoriesText,
|
||||||
|
closeable: false,
|
||||||
|
autoScroll: true
|
||||||
|
});
|
||||||
|
mainTabPanel.setActiveTab('repositories');
|
||||||
|
},
|
||||||
|
|
||||||
|
createMainMenu: function(){
|
||||||
|
if ( debug ){
|
||||||
|
console.debug('create main menu');
|
||||||
|
}
|
||||||
|
var panel = Ext.getCmp('navigationPanel');
|
||||||
|
panel.addSection({
|
||||||
|
id: 'navMain',
|
||||||
|
title: this.sectionMainText,
|
||||||
|
items: [{
|
||||||
|
label: this.navRepositoriesText,
|
||||||
|
fn: function(){
|
||||||
|
mainTabPanel.setActiveTab('repositories');
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
var securitySection = null;
|
||||||
|
|
||||||
|
if ( state.user.type == 'xml' && state.user.name != 'anonymous' ){
|
||||||
|
securitySection = {
|
||||||
|
title: this.sectionSecurityText,
|
||||||
|
items: [{
|
||||||
|
label: this.navChangePasswordText,
|
||||||
|
fn: function(){
|
||||||
|
new Sonia.action.ChangePasswordWindow().show();
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( admin ){
|
||||||
|
|
||||||
|
panel.addSections([{
|
||||||
|
id: 'navConfig',
|
||||||
|
title: this.sectionConfigText,
|
||||||
|
items: [{
|
||||||
|
label: this.navGeneralConfigText,
|
||||||
|
fn: function(){
|
||||||
|
addTabPanel("scmConfig", "scmConfig", this.navGeneralConfigText);
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
label: this.navRepositoryTypesText,
|
||||||
|
fn: function(){
|
||||||
|
addTabPanel('repositoryConfig', 'repositoryConfig', this.tabRepositoryTypesText);
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
label: this.navPluginsText,
|
||||||
|
fn: function(){
|
||||||
|
addTabPanel('plugins', 'pluginGrid', this.navPluginsText);
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}]);
|
||||||
|
|
||||||
|
if ( securitySection == null ){
|
||||||
|
securitySection = {
|
||||||
|
title: this.sectionSecurityText,
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
securitySection.items.push({
|
||||||
|
label: this.navUsersText,
|
||||||
|
fn: function(){
|
||||||
|
addTabPanel('users', 'userPanel', this.navUsersText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
securitySection.items.push({
|
||||||
|
label: this.navGroupsText,
|
||||||
|
fn: function(){
|
||||||
|
addTabPanel('groups', 'groupPanel', this.tabGroupsText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( securitySection != null ){
|
||||||
|
panel.addSection( securitySection );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( state.user.name == 'anonymous' ){
|
||||||
|
panel.addSection({
|
||||||
|
id: 'navLogin',
|
||||||
|
title: this.sectionLoginText,
|
||||||
|
items: [{
|
||||||
|
label: this.sectionLoginText,
|
||||||
|
fn: login
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
panel.addSection({
|
||||||
|
id: 'navLogout',
|
||||||
|
title: this.sectionLogoutText,
|
||||||
|
items: [{
|
||||||
|
label: this.navLogoutText,
|
||||||
|
fn: logout
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//fix hidden logout button
|
||||||
|
panel.doLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
Ext.onReady(function(){
|
Ext.onReady(function(){
|
||||||
|
|
||||||
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
||||||
@@ -87,129 +235,13 @@ Ext.onReady(function(){
|
|||||||
mainTabPanel.setActiveTab(id);
|
mainTabPanel.setActiveTab(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods called after login
|
|
||||||
|
|
||||||
function createMainMenu(){
|
|
||||||
if ( debug ){
|
|
||||||
console.debug('create main menu');
|
|
||||||
}
|
|
||||||
var panel = Ext.getCmp('navigationPanel');
|
|
||||||
panel.addSection({
|
|
||||||
id: 'navMain',
|
|
||||||
title: 'Main',
|
|
||||||
items: [{
|
|
||||||
label: 'Repositories',
|
|
||||||
fn: function(){
|
|
||||||
mainTabPanel.setActiveTab('repositories');
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
|
|
||||||
var securitySection = null;
|
|
||||||
|
|
||||||
if ( state.user.type == 'xml' && state.user.name != 'anonymous' ){
|
|
||||||
securitySection = {
|
|
||||||
title: 'Security',
|
|
||||||
items: [{
|
|
||||||
label: 'Change Password',
|
|
||||||
fn: function(){
|
|
||||||
new Sonia.action.ChangePasswordWindow().show();
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( admin ){
|
|
||||||
|
|
||||||
panel.addSections([{
|
|
||||||
id: 'navConfig',
|
|
||||||
title: 'Config',
|
|
||||||
items: [{
|
|
||||||
label: 'General',
|
|
||||||
fn: function(){
|
|
||||||
addTabPanel("scmConfig", "scmConfig", "SCM Config");
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
label: 'Repository Types',
|
|
||||||
fn: function(){
|
|
||||||
addTabPanel('repositoryConfig', 'repositoryConfig', 'Repository Config');
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
label: 'Plugins',
|
|
||||||
fn: function(){
|
|
||||||
addTabPanel('plugins', 'pluginGrid', 'Plugins');
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}]);
|
|
||||||
|
|
||||||
if ( securitySection == null ){
|
|
||||||
securitySection = {
|
|
||||||
title: 'Security',
|
|
||||||
items: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
securitySection.items.push({
|
|
||||||
label: 'Users',
|
|
||||||
fn: function(){
|
|
||||||
addTabPanel('users', 'userPanel', 'Users');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
securitySection.items.push({
|
|
||||||
label: 'Groups',
|
|
||||||
fn: function(){
|
|
||||||
addTabPanel('groups', 'groupPanel', 'Groups');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( securitySection != null ){
|
|
||||||
panel.addSection( securitySection );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( state.user.name == 'anonymous' ){
|
|
||||||
panel.addSection({
|
|
||||||
id: 'navLogin',
|
|
||||||
title: 'Login',
|
|
||||||
items: [{
|
|
||||||
label: 'Login',
|
|
||||||
fn: login
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
panel.addSection({
|
|
||||||
id: 'navLogout',
|
|
||||||
title: 'Log out',
|
|
||||||
items: [{
|
|
||||||
label: 'Log out',
|
|
||||||
fn: logout
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//fix hidden logout button
|
|
||||||
panel.doLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRepositoryPanel(){
|
|
||||||
if ( debug ){
|
|
||||||
console.debug('create repository panel');
|
|
||||||
}
|
|
||||||
mainTabPanel.add({
|
|
||||||
id: 'repositories',
|
|
||||||
xtype: 'repositoryPanel',
|
|
||||||
title: 'Repositories',
|
|
||||||
closeable: false,
|
|
||||||
autoScroll: true
|
|
||||||
});
|
|
||||||
mainTabPanel.setActiveTab('repositories');
|
|
||||||
}
|
|
||||||
|
|
||||||
// register login callbacks
|
// register login callbacks
|
||||||
|
|
||||||
|
var main = new Sonia.scm.Main();
|
||||||
|
|
||||||
// create menu
|
// create menu
|
||||||
loginCallbacks.splice(0, 0, createMainMenu );
|
loginCallbacks.splice(0, 0, {fn: main.createMainMenu, scope: main});
|
||||||
// add welcome tab
|
// add repository tab
|
||||||
loginCallbacks.push( createRepositoryPanel );
|
loginCallbacks.push({fn: main.createRepositoryPanel, scope: main});
|
||||||
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user