improve the layout of the deluge-torrents module

delegate updating stats to the individual tabs in the details panel
This commit is contained in:
Damien Churchill 2009-02-20 20:09:29 +00:00
parent 7c3c1fb767
commit 8d1a49f11c
3 changed files with 49 additions and 60 deletions

View File

@ -15,19 +15,19 @@ Deluge.Details.Status = {
border: false, border: false,
listeners: {'render': Deluge.Details.Status.onStatusRender} listeners: {'render': Deluge.Details.Status.onStatusRender}
}); });
this.panel.update = this.update.bind(this);
}, },
onStatusRender: function(panel) { onStatusRender: function(panel) {
this.status = panel; this.status = panel;
this.status.load({ this.status.load({
url: "/render/tab_statistics.html", url: "/render/tab_statistics.html",
text: _("Loading") + "...", text: _("Loading") + "..."
callback: this.onStatusLoaded
}); });
}, },
onStatusLoaded: function() { update: function(torrentId) {
alert("loaded"); alert(torrentId);
} }
} }
@ -41,8 +41,14 @@ Deluge.Details.Details = {
$extend(Deluge.Details, { $extend(Deluge.Details, {
update: function(torrentId) { update: function() {
var torrent = Deluge.Torrents.getSelected();
if (!torrent) return;
var tab = this.Panel.getActiveTab();
if (tab.update) {
tab.update(torrent.id);
}
}, },
Panel: new Ext.TabPanel({ Panel: new Ext.TabPanel({
@ -56,11 +62,11 @@ $extend(Deluge.Details, {
items: [{ items: [{
id: 'status', id: 'status',
title: _('Status'), title: _('Status'),
listeners: {'render': Deluge.Details.Status.onRender} listeners: {'render': {fn: Deluge.Details.Status.onRender, scope: Deluge.Details.Status}}
},{ },{
id: 'details', id: 'details',
title: _('Details'), title: _('Details'),
listeners: {'render': Deluge.Details.Details.onRender} listeners: {'render': {fn: Deluge.Details.Details.onRender, scope: Deluge.Details.Status}}
},{ },{
id: 'files', id: 'files',
title: _('Files') title: _('Files')
@ -72,32 +78,4 @@ $extend(Deluge.Details, {
title: _('Options') title: _('Options')
}] }]
}) })
}); });
/*Deluge.Details.Status = {
onShow: function(panel) {
this.panel = panel;
},
initialize: function() {
this.Panel = Deluge.Details.Panel.items.get('status');
this.ProgressBar = new Ext.ProgressBar({
text: "0% Stopped",
id: "pbar-status",
cls: 'deluge-status-progressbar'
});
this.Panel.add(this.ProgressBar);
this.Panel.add({
id: 'status-details',
cls: 'deluge-status',
border: false
});
//this.Details = Deluge.Details.Status.Panel.items.get("status-details").load({
// url: "/render/tab_statistics.html"
//});
}
}*/

View File

@ -22,30 +22,40 @@ function avail(value) {
return value.toFixed(3); return value.toFixed(3);
} }
var torrentStore = new Ext.data.SimpleStore({ Deluge.Torrents = {
fields: [ Store: new Ext.data.SimpleStore({
{name: 'queue'}, fields: [
{name: 'name'}, {name: 'queue'},
{name: 'size', type: 'int'}, {name: 'name'},
{name: 'state'}, {name: 'size', type: 'int'},
{name: 'progress', type: 'float'}, {name: 'state'},
{name: 'seeds', type: 'int'}, {name: 'progress', type: 'float'},
{name: 'total_seeds', type: 'int'}, {name: 'seeds', type: 'int'},
{name: 'peers', type: 'int'}, {name: 'total_seeds', type: 'int'},
{name: 'total_peers', type: 'int'}, {name: 'peers', type: 'int'},
{name: 'downspeed', type: 'int'}, {name: 'total_peers', type: 'int'},
{name: 'upspeed', type: 'int'}, {name: 'downspeed', type: 'int'},
{name: 'eta', type: 'int'}, {name: 'upspeed', type: 'int'},
{name: 'ratio', type: 'float'}, {name: 'eta', type: 'int'},
{name: 'avail', type: 'float'} {name: 'ratio', type: 'float'},
], {name: 'avail', type: 'float'}
id: 14 ],
}); id: 14
torrentStore.setDefaultSort("queue"); }),
getSelected: function() {
return this.Grid.getSelectionModel().getSelected();
},
getSelection: function() {
return this.Grid.getSelectionModel().getSelection();
}
}
Deluge.Torrents.Store.setDefaultSort("queue");
Deluge.Torrents = new Ext.grid.GridPanel({ Deluge.Torrents.Grid = new Ext.grid.GridPanel({
region: 'center', region: 'center',
store: torrentStore, store: Deluge.Torrents.Store,
cls: 'deluge-torrents', cls: 'deluge-torrents',
columns: [ columns: [
{id:'queue',header: "#", width: 30, sortable: true, renderer: queue, dataIndex: 'queue'}, {id:'queue',header: "#", width: 30, sortable: true, renderer: queue, dataIndex: 'queue'},

View File

@ -7,7 +7,7 @@ Deluge.Ui = {
title: 'Deluge', title: 'Deluge',
layout: 'border', layout: 'border',
tbar: Deluge.ToolBar.Bar, tbar: Deluge.ToolBar.Bar,
items: [Deluge.SideBar, Deluge.Details.Panel, Deluge.Torrents], items: [Deluge.SideBar, Deluge.Details.Panel, Deluge.Torrents.Grid],
bbar: Deluge.StatusBar.Bar bbar: Deluge.StatusBar.Bar
}); });
@ -29,6 +29,7 @@ Deluge.Ui = {
onSuccess: this.onUpdate.bindWithEvent(this), onSuccess: this.onUpdate.bindWithEvent(this),
onFailure: this.onUpdateError.bindWithEvent(this) onFailure: this.onUpdateError.bindWithEvent(this)
}); });
Deluge.Details.update();
Deluge.Client.web.connected({ Deluge.Client.web.connected({
onSuccess: this.onConnectedCheck.bindWithEvent(this) onSuccess: this.onConnectedCheck.bindWithEvent(this)
}); });
@ -73,7 +74,7 @@ Deluge.Ui = {
id id
]); ]);
}); });
Deluge.Torrents.store.loadData(torrents); Deluge.Torrents.Store.loadData(torrents);
Deluge.StatusBar.update(data['stats']); Deluge.StatusBar.update(data['stats']);
this.errorCount = 0; this.errorCount = 0;
}, },