added sonia.repository.repositorybrowser.js

This commit is contained in:
Sebastian Sdorra
2011-06-13 12:38:54 +02:00
parent a8f9692295
commit a9061d8592
5 changed files with 160 additions and 1 deletions

View File

@@ -101,6 +101,7 @@
<script type="text/javascript" src="resources/js/repository/sonia.repository.panel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.changesetviewergrid.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.changesetviewerpanel.js"></script>
<script type="text/javascript" src="resources/js/repository/sonia.repository.repositorybrowser.js"></script>
<!-- sonia.user -->
<script type="text/javascript" src="resources/js/user/sonia.user.js"></script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

View File

@@ -39,6 +39,9 @@ Sonia.repository.ExtendedInfoPanel = Ext.extend(Sonia.repository.InfoPanel,{
// text
checkoutText: 'Checkout: ',
// TODO i18n
repositoryBrowserText: 'RepositoryBrowser',
modifyDefaultConfig: function(config){
var items = config.items;
if ( items == null ){
@@ -55,8 +58,39 @@ Sonia.repository.ExtendedInfoPanel = Ext.extend(Sonia.repository.InfoPanel,{
)
},
this.createSpacer(),
this.createChangesetViewerLink()
this.createChangesetViewerLink(),
this.createSpacer(),
this.createRepositoryBrowserLink()
);
},
createRepositoryBrowserLink: function(){
return {
xtype: 'link',
colspan: 2,
text: this.repositoryBrowserText,
listeners: {
click: {
fn: this.openRepositoryBrowser,
scope: this
}
}
};
},
createRepositoryBrowser: function(){
return {
id: 'repositorybrowser-' + this.item.id,
xtype: 'repositoryBrowser',
repository: this.item
}
},
openRepositoryBrowser: function(browser){
if ( browser == null ){
browser = this.createRepositoryBrowser();
}
main.addTab(browser);
}
});

View File

@@ -0,0 +1,124 @@
/* *
* 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
*
*/
Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
repository: null,
// TODO i18n
repositoryBrowserTitleText: 'RepositoryBrowser: {0}',
iconFolder: 'resources/images/folder.gif',
iconDocument: 'resources/images/document.gif',
templateIcon: '<img src="{0}" alt="{1}" title="{2}" />',
initComponent: function(){
var browserStore = new Sonia.rest.JsonStore({
proxy: new Ext.data.HttpProxy({
url: restUrl + 'repositories/' + this.repository.id + '/browse.json',
method: 'GET'
}),
fields: ['path', 'name', 'length', 'lastModified', 'directory'],
root: 'file.children',
idProperty: 'path',
autoLoad: true,
autoDestroy: true
});
var browserColModel = new Ext.grid.ColumnModel({
defaults: {
sortable: false
},
columns: [{
id: 'icon',
dataIndex: 'directory',
header: '',
width: 28,
renderer: this.renderIcon,
scope: this
},{
id: 'name',
dataIndex: 'name',
header: 'Name',
renderer: this.renderName,
scope: this
},{
id: 'length',
dataIndex: 'length',
header: 'Length',
renderer: this.renderLength
},{
id: 'lastModified',
dataIndex: 'lastModified',
header: 'LastModified',
renderer: Ext.util.Format.formatTimestamp
}]
});
var config = {
title: String.format(this.repositoryBrowserTitleText, this.repository.name),
store: browserStore,
colModel: browserColModel,
loadMask: true
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.RepositoryBrowser.superclass.initComponent.apply(this, arguments);
},
renderName: function(name, p, record){
return name;
},
renderIcon: function(directory, p, record){
var icon = null;
var name = record.data.name;
if ( directory ){
icon = this.iconFolder;
} else {
icon = this.iconDocument;
}
return String.format(this.templateIcon, icon, name, name);
},
renderLength: function(length, p, record){
var result = '';
var directory = record.data.directory;
if ( ! directory ){
result = Ext.util.Format.fileSize(length);
}
return result;
}
});
// register xtype
Ext.reg('repositoryBrowser', Sonia.repository.RepositoryBrowser);