Files
SCM-Manager/scm-webapp/src/main/webapp/resources/js/layout.js

129 lines
3.1 KiB
JavaScript
Raw Normal View History

2010-09-04 16:36:25 +02:00
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
Ext.onReady(function(){
// NOTE: This is an example showing simple state management. During development,
// it is generally best to disable state management as dynamically-generated ids
// can change across page loads, leading to unpredictable results. The developer
// should ensure that stable state ids are set for stateful components in real apps.
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
2010-09-05 13:54:49 +02:00
var tabPanel = new Ext.TabPanel({
region: 'center', // a center region is ALWAYS required for border layout
deferredRender: false,
2010-09-06 11:47:37 +02:00
activeTab: 0, // first tab initially active
2010-09-05 13:54:49 +02:00
items: [{
id: 'welcome',
xtype: 'panel',
title: 'Welcome',
// closable: true,
autoScroll: true
}]
});
new Ext.Viewport({
2010-09-04 16:36:25 +02:00
layout: 'border',
items: [
// create instance immediately
new Ext.BoxComponent({
region: 'north',
id: 'north-panel',
contentEl: 'north',
height: 75
}), {
region: 'west',
2010-09-15 14:51:20 +02:00
id: 'west', // see Ext.getCmp() below
2010-09-04 16:36:25 +02:00
title: 'West',
2010-09-15 14:51:20 +02:00
xtype: 'navPanel',
2010-09-04 16:36:25 +02:00
split: true,
width: 200,
minSize: 175,
maxSize: 400,
collapsible: true,
2010-09-15 14:18:55 +02:00
margins: '0 0 0 5'
2010-09-04 16:36:25 +02:00
},
2010-09-05 13:54:49 +02:00
new Ext.BoxComponent({
2010-09-04 16:36:25 +02:00
region: 'south',
id: 'south-panel',
contentEl: 'south',
height: 16,
margins: '2 2 2 5'
}),
// in this instance the TabPanel is not wrapped by another panel
// since no title is needed, this Panel is added directly
// as a Container
2010-09-05 13:54:49 +02:00
tabPanel
]});
function addGroupPanel(){
tabPanel.add({
id: 't_group',
xtype: 'groupGrid',
title: 'Groups',
closable: true,
autoScroll: true
});
2010-09-05 13:57:15 +02:00
tabPanel.setActiveTab('t_group');
2010-09-05 13:54:49 +02:00
}
2010-09-06 12:28:13 +02:00
function addRepositoryPanel(){
tabPanel.add({
id: 't_repository',
xtype: 'repositoryGrid',
title: 'Repositories',
closable: true,
autoScroll: true
});
tabPanel.setActiveTab('t_repository');
}
2010-09-05 16:14:46 +02:00
function createMainMenu(){
2010-09-15 14:51:20 +02:00
var panel = Ext.getCmp('west');
panel.addSections([{
2010-09-15 14:18:55 +02:00
title: 'Main',
2010-09-15 14:51:20 +02:00
items: [{
2010-09-15 14:18:55 +02:00
label: 'Groups',
fn: addGroupPanel
},{
label: 'Repositories',
fn: addRepositoryPanel
}]
2010-09-15 14:51:20 +02:00
},{
title: 'Config',
items: [{
2010-09-15 15:12:57 +02:00
label: 'General',
fn: function(){ console.debug( 'General Config' ); }
},{
label: 'Repository Types',
fn: function(){ console.debug( 'Repository Type Config' ); }
2010-09-15 14:51:20 +02:00
},{
label: 'Server',
2010-09-15 15:12:57 +02:00
fn: function(){ console.debug( 'Server Config' ); }
2010-09-15 14:51:20 +02:00
}]
}]);
2010-09-05 16:14:46 +02:00
}
2010-09-09 18:35:54 +02:00
// create menu after login
authCallbacks.push( createMainMenu );
2010-09-05 13:54:49 +02:00
Ext.Ajax.request({
url: restUrl + 'authentication.json',
method: 'GET',
2010-09-06 14:34:04 +02:00
success: function(response){
2010-09-09 18:35:54 +02:00
var s = Ext.decode(response.responseText);
loadState(s);
2010-09-05 13:54:49 +02:00
},
failure: function(){
var loginWin = new Sonia.login.Window();
2010-09-09 18:35:54 +02:00
/*loginWin.on('success', function(){
2010-09-05 16:14:46 +02:00
createMainMenu();
2010-09-09 18:35:54 +02:00
});*/
2010-09-05 13:54:49 +02:00
loginWin.show();
}
2010-09-04 16:36:25 +02:00
});
});