diff --git a/scm-webapp/src/main/webapp/index.html b/scm-webapp/src/main/webapp/index.html
index fcca2eaf60..0de37f789d 100644
--- a/scm-webapp/src/main/webapp/index.html
+++ b/scm-webapp/src/main/webapp/index.html
@@ -101,6 +101,7 @@
+
diff --git a/scm-webapp/src/main/webapp/resources/images/document.gif b/scm-webapp/src/main/webapp/resources/images/document.gif
new file mode 100644
index 0000000000..0c9e17f2b6
Binary files /dev/null and b/scm-webapp/src/main/webapp/resources/images/document.gif differ
diff --git a/scm-webapp/src/main/webapp/resources/images/folder.gif b/scm-webapp/src/main/webapp/resources/images/folder.gif
new file mode 100644
index 0000000000..a9aca86379
Binary files /dev/null and b/scm-webapp/src/main/webapp/resources/images/folder.gif differ
diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.extendedinfopanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.extendedinfopanel.js
index 0d9b704e72..bc094d7713 100644
--- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.extendedinfopanel.js
+++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.extendedinfopanel.js
@@ -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);
}
});
diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.repositorybrowser.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.repositorybrowser.js
new file mode 100644
index 0000000000..029cc88099
--- /dev/null
+++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.repositorybrowser.js
@@ -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: '
',
+
+ 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);