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

167 lines
4.4 KiB
JavaScript
Raw Normal View History

2010-10-31 19:22:53 +01:00
/*
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
2010-09-04 16:36:25 +02:00
*/
Ext.onReady(function(){
2010-09-20 15:32:55 +02:00
2010-09-04 16:36:25 +02:00
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
2010-09-05 13:54:49 +02:00
var tabPanel = new Ext.TabPanel({
2010-09-20 15:32:55 +02:00
region: 'center',
2010-09-05 13:54:49 +02:00
deferredRender: false,
2010-09-20 15:32:55 +02:00
activeTab: 0,
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: [
new Ext.BoxComponent({
region: 'north',
id: 'north-panel',
contentEl: 'north',
height: 75
}), {
region: 'west',
2010-09-20 15:32:55 +02:00
id: 'west',
title: 'Navigation',
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'
}),
2010-09-05 13:54:49 +02:00
tabPanel
]});
2010-09-17 15:13:53 +02:00
function addTabPanel(id, xtype, title){
2010-09-05 13:54:49 +02:00
tabPanel.add({
2010-09-17 15:13:53 +02:00
id: id,
xtype: xtype,
title: title,
2010-09-05 13:54:49 +02:00
closable: true,
autoScroll: true
});
2010-09-17 15:13:53 +02:00
tabPanel.setActiveTab(id);
}
2010-09-06 12:28:13 +02:00
function addRepositoryPanel(){
2010-10-13 15:07:06 +02:00
tabPanel.add({
id: 't_repository',
title: 'Repositories',
xtype: 'restPanel',
2010-10-23 13:29:44 +02:00
closable: true,
2010-10-13 15:07:06 +02:00
grid: {xtype: 'repositoryGrid'}
});
tabPanel.setActiveTab('t_repository');
2010-09-17 15:13:53 +02:00
}
function addConfigPanel(){
addTabPanel('t_config', 'configPanel', 'Repository Config');
2010-09-06 12:28:13 +02:00
}
2010-10-15 23:03:00 +02:00
function logout(){
Ext.Ajax.request({
url: restUrl + 'authentication/logout.json',
method: 'GET',
success: function(response){
tabPanel.removeAll();
Ext.getCmp('west').removeAll();
var loginWin = new Sonia.login.Window();
loginWin.show();
},
failure: function(){
alert("logout failed");
}
});
}
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: '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',
2010-09-17 15:13:53 +02:00
fn: addConfigPanel
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-10-15 23:03:00 +02:00
},{
title: 'Abmelden',
items: [{
label: 'Abmelden',
fn: logout
}]
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();
loginWin.show();
}
2010-09-04 16:36:25 +02:00
});
});