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

162 lines
4.4 KiB
JavaScript
Raw Normal View History

2010-11-03 18:40:43 +01:00
/**
2010-10-31 19:22:53 +01:00
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
2010-11-03 18:40:43 +01:00
*
2010-10-31 19:22:53 +01:00
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
2010-11-03 18:40:43 +01:00
*
2010-10-31 19:22:53 +01:00
* 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.
2010-11-03 18:40:43 +01:00
*
2010-10-31 19:22:53 +01:00
* 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.
2010-11-03 18:40:43 +01:00
*
2010-10-31 19:22:53 +01:00
* http://bitbucket.org/sdorra/scm-manager
2010-11-03 18:40:43 +01:00
*
2010-09-04 16:36:25 +02:00
*/
Ext.onReady(function(){
2010-11-03 18:40:43 +01:00
2010-09-04 16:36:25 +02:00
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
2010-11-03 18:40:43 +01:00
var mainTabPanel = new Ext.TabPanel({
id: 'mainTabPanel',
region: 'center',
deferredRender: false
});
2010-09-05 13:54:49 +02:00
new Ext.Viewport({
2010-09-04 16:36:25 +02:00
layout: 'border',
items: [
2010-11-03 18:40:43 +01:00
new Ext.BoxComponent({
region: 'north',
id: 'north-panel',
contentEl: 'north',
height: 75
}), {
region: 'west',
id: 'navigationPanel',
title: 'Navigation',
xtype: 'navPanel',
split: true,
width: 200,
minSize: 175,
maxSize: 400,
collapsible: true,
margins: '0 0 0 5'
2010-10-15 23:03:00 +02:00
},
2010-11-03 18:40:43 +01:00
new Ext.BoxComponent({
region: 'south',
id: 'south-panel',
contentEl: 'south',
height: 16,
margins: '2 2 2 5'
}),
mainTabPanel
]
});
// check login
Ext.Ajax.request({
url: restUrl + 'authentication.json',
method: 'GET',
success: function(response){
if ( debug ){
console.debug('login success');
2010-10-15 23:03:00 +02:00
}
2010-11-03 18:40:43 +01:00
var s = Ext.decode(response.responseText);
loadState(s);
},
failure: function(){
if ( debug ){
console.debug('login failed');
}
var loginWin = new Sonia.login.Window();
loginWin.show();
}
});
// adds a tab to main TabPanel
function addTabPanel(id, xtype, title){
mainTabPanel.add({
id: id,
xtype: xtype,
title: title,
closable: true,
autoScroll: true
});
mainTabPanel.setActiveTab(id);
}
// methods called after login
2010-10-15 23:03:00 +02:00
2010-09-05 16:14:46 +02:00
function createMainMenu(){
2010-11-03 18:40:43 +01:00
if ( debug ){
console.debug('create main menu');
}
var panel = Ext.getCmp('navigationPanel');
2010-09-15 14:51:20 +02:00
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',
2010-11-03 18:40:43 +01:00
fn: function(){console.debug( 'Repositories' );}
2010-09-15 14:18:55 +02:00
}]
2010-09-15 14:51:20 +02:00
},{
title: 'Config',
items: [{
2010-09-15 15:12:57 +02:00
label: 'General',
2010-11-03 18:40:43 +01:00
fn: function(){console.debug( 'General Config' );}
2010-09-15 15:12:57 +02:00
},{
label: 'Repository Types',
2010-11-03 18:40:43 +01:00
fn: function(){console.debug( 'RepositoryType Config' );}
2010-09-15 14:51:20 +02:00
},{
label: 'Server',
2010-11-03 18:40:43 +01: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-11-03 18:40:43 +01:00
function createWelcomePanel(){
if ( debug ){
console.debug('create welcome tab');
2010-09-05 13:54:49 +02:00
}
2010-11-03 18:40:43 +01:00
mainTabPanel.add({
id: 'welcomeTab',
xtype: 'panel',
title: 'Welcome',
hideMode: 'offsets',
bodyCssClass: 'x-panel-mc',
enableTabScroll: true,
autoScroll: true
});
mainTabPanel.setActiveTab('welcomeTab');
}
// register login callbacks
// create menu
loginCallbacks.push( createMainMenu );
// add welcome tab
loginCallbacks.push( createWelcomePanel );
2010-09-04 16:36:25 +02:00
});