upgrade to ext js 3.1

This commit is contained in:
Damien Churchill 2010-01-21 21:01:02 +00:00
parent 1ac0403f05
commit cd24acd74f
10 changed files with 37664 additions and 31593 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,461 +1,461 @@
/* /*
Script: deluge-connections.js Script: deluge-connections.js
Contains all objects and functions related to the connection manager. Contains all objects and functions related to the connection manager.
Copyright: Copyright:
(C) Damien Churchill 2009 <damoxc@gmail.com> (C) Damien Churchill 2009 <damoxc@gmail.com>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option) the Free Software Foundation; either version 3, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, write to: along with this program. If not, write to:
The Free Software Foundation, Inc., The Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
In addition, as a special exception, the copyright holders give In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the OpenSSL permission to link the code of portions of this program with the OpenSSL
library. library.
You must obey the GNU General Public License in all respects for all of You must obey the GNU General Public License in all respects for all of
the code used other than OpenSSL. If you modify file(s) with this the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the file(s), exception, you may extend this exception to your version of the file(s),
but you are not obligated to do so. If you do not wish to do so, delete but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version. If you delete this exception this exception statement from your version. If you delete this exception
statement from all source files in the program, then also delete it here. statement from all source files in the program, then also delete it here.
*/ */
(function() { (function() {
var hostRenderer = function(value, p, r) { var hostRenderer = function(value, p, r) {
return value + ':' + r.data['port'] return value + ':' + r.data['port']
} }
Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, { Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply({
layout: 'fit', layout: 'fit',
width: 300, width: 300,
height: 195, height: 195,
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
buttonAlign: 'right', buttonAlign: 'right',
closeAction: 'hide', closeAction: 'hide',
closable: true, closable: true,
plain: true, plain: true,
title: _('Add Connection'), title: _('Add Connection'),
iconCls: 'x-deluge-add-window-icon' iconCls: 'x-deluge-add-window-icon'
}, config); }, config);
Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config); Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config);
}, },
initComponent: function() { initComponent: function() {
Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this); Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);
this.addEvents('hostadded'); this.addEvents('hostadded');
this.addButton(_('Close'), this.hide, this); this.addButton(_('Close'), this.hide, this);
this.addButton(_('Add'), this.onAdd, this); this.addButton(_('Add'), this.onAddClick, this);
this.on('hide', this.onHide, this); this.on('hide', this.onHide, this);
this.form = this.add({ this.form = this.add({
xtype: 'form', xtype: 'form',
defaultType: 'textfield', defaultType: 'textfield',
id: 'connectionAddForm', id: 'connectionAddForm',
baseCls: 'x-plain', baseCls: 'x-plain',
labelWidth: 55 labelWidth: 55
}); });
this.hostField = this.form.add({ this.hostField = this.form.add({
fieldLabel: _('Host'), fieldLabel: _('Host'),
id: 'host', id: 'host',
name: 'host', name: 'host',
anchor: '100%', anchor: '100%',
value: '' value: ''
}); });
this.portField = this.form.add({ this.portField = this.form.add({
fieldLabel: _('Port'), fieldLabel: _('Port'),
id: 'port', id: 'port',
xtype: 'uxspinner', xtype: 'uxspinner',
ctCls: 'x-form-uxspinner', ctCls: 'x-form-uxspinner',
name: 'port', name: 'port',
strategy: { strategy: {
xtype: 'number', xtype: 'number',
decimalPrecision: 0, decimalPrecision: 0,
minValue: -1, minValue: -1,
maxValue: 65535 maxValue: 65535
}, },
value: '58846', value: '58846',
anchor: '50%' anchor: '50%'
}); });
this.usernameField = this.form.add({ this.usernameField = this.form.add({
fieldLabel: _('Username'), fieldLabel: _('Username'),
id: 'username', id: 'username',
name: 'username', name: 'username',
anchor: '100%', anchor: '100%',
value: '' value: ''
}); });
this.passwordField = this.form.add({ this.passwordField = this.form.add({
fieldLabel: _('Password'), fieldLabel: _('Password'),
anchor: '100%', anchor: '100%',
id: '_password', id: '_password',
name: '_password', name: '_password',
inputType: 'password', inputType: 'password',
value: '' value: ''
}); });
}, },
onAdd: function() { onAddClick: function() {
var host = this.hostField.getValue(); var host = this.hostField.getValue();
var port = this.portField.getValue(); var port = this.portField.getValue();
var username = this.usernameField.getValue(); var username = this.usernameField.getValue();
var password = this.passwordField.getValue(); var password = this.passwordField.getValue();
Deluge.Client.web.add_host(host, port, username, password, { Deluge.Client.web.add_host(host, port, username, password, {
success: function(result) { success: function(result) {
if (!result[0]) { if (!result[0]) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
msg: "Unable to add host: " + result[1], msg: "Unable to add host: " + result[1],
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error'
}); });
} else { } else {
this.fireEvent('hostadded'); this.fireEvent('hostadded');
} }
this.hide(); this.hide();
}, },
scope: this scope: this
}); });
}, },
onHide: function() { onHide: function() {
this.form.getForm().reset(); this.form.getForm().reset();
} }
}); });
Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, { Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, {
layout: 'fit', layout: 'fit',
width: 300, width: 300,
height: 220, height: 220,
bodyStyle: 'padding: 10px 5px;', bodyStyle: 'padding: 10px 5px;',
buttonAlign: 'right', buttonAlign: 'right',
closeAction: 'hide', closeAction: 'hide',
closable: true, closable: true,
plain: true, plain: true,
title: _('Connection Manager'), title: _('Connection Manager'),
iconCls: 'x-deluge-connect-window-icon', iconCls: 'x-deluge-connect-window-icon',
initComponent: function() { initComponent: function() {
Ext.deluge.ConnectionManager.superclass.initComponent.call(this); Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
this.on({ this.on({
'hide': this.onHide, 'hide': this.onHide,
'show': this.onShow 'show': this.onShow
}); });
Deluge.Events.on('login', this.onLogin, this); Deluge.Events.on('login', this.onLogin, this);
Deluge.Events.on('logout', this.onLogout, this); Deluge.Events.on('logout', this.onLogout, this);
this.addButton(_('Close'), this.onClose, this); this.addButton(_('Close'), this.onClose, this);
this.addButton(_('Connect'), this.onConnect, this); this.addButton(_('Connect'), this.onConnect, this);
this.grid = this.add({ this.grid = this.add({
xtype: 'grid', xtype: 'grid',
store: new Ext.data.SimpleStore({ store: new Ext.data.SimpleStore({
fields: [ fields: [
{name: 'status', mapping: 3}, {name: 'status', mapping: 3},
{name: 'host', mapping: 1}, {name: 'host', mapping: 1},
{name: 'port', mapping: 2}, {name: 'port', mapping: 2},
{name: 'version', mapping: 4} {name: 'version', mapping: 4}
], ],
id: 0 id: 0
}), }),
columns: [{ columns: [{
header: _('Status'), header: _('Status'),
width: 65, width: 65,
sortable: true, sortable: true,
renderer: fplain, renderer: fplain,
dataIndex: 'status' dataIndex: 'status'
}, { }, {
id:'host', id:'host',
header: _('Host'), header: _('Host'),
width: 150, width: 150,
sortable: true, sortable: true,
renderer: hostRenderer, renderer: hostRenderer,
dataIndex: 'host' dataIndex: 'host'
}, { }, {
header: _('Version'), header: _('Version'),
width: 75, width: 75,
sortable: true, sortable: true,
renderer: fplain, renderer: fplain,
dataIndex: 'version' dataIndex: 'version'
}], }],
stripeRows: true, stripeRows: true,
selModel: new Ext.grid.RowSelectionModel({ selModel: new Ext.grid.RowSelectionModel({
singleSelect: true, singleSelect: true,
listeners: { listeners: {
'rowselect': {fn: this.onSelect, scope: this}, 'rowselect': {fn: this.onSelect, scope: this},
'selectionchange': {fn: this.onSelectionChanged, scope: this} 'selectionchange': {fn: this.onSelectionChanged, scope: this}
} }
}), }),
autoExpandColumn: 'host', autoExpandColumn: 'host',
deferredRender:false, deferredRender:false,
autoScroll:true, autoScroll:true,
margins: '0 0 0 0', margins: '0 0 0 0',
bbar: new Ext.Toolbar({ bbar: new Ext.Toolbar({
buttons: [ buttons: [
{ {
id: 'cm-add', id: 'cm-add',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Add'), text: _('Add'),
icon: '/icons/add.png', icon: '/icons/add.png',
handler: this.onAdd, handler: this.onAddClick,
scope: this scope: this
}, { }, {
id: 'cm-remove', id: 'cm-remove',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Remove'), text: _('Remove'),
icon: '/icons/remove.png', icon: '/icons/remove.png',
handler: this.onRemove, handler: this.onRemove,
disabled: true, disabled: true,
scope: this scope: this
}, '->', { }, '->', {
id: 'cm-stop', id: 'cm-stop',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Stop Daemon'), text: _('Stop Daemon'),
icon: '/icons/error.png', icon: '/icons/error.png',
handler: this.onStop, handler: this.onStop,
disabled: true, disabled: true,
scope: this scope: this
} }
] ]
}) })
}); });
}, },
disconnect: function() { disconnect: function() {
Deluge.Events.fire('disconnect'); Deluge.Events.fire('disconnect');
}, },
loadHosts: function() { loadHosts: function() {
Deluge.Client.web.get_hosts({ Deluge.Client.web.get_hosts({
success: this.onGetHosts, success: this.onGetHosts,
scope: this scope: this
}); });
}, },
update: function(self) { update: function(self) {
self.grid.getStore().each(function(r) { self.grid.getStore().each(function(r) {
Deluge.Client.web.get_host_status(r.id, { Deluge.Client.web.get_host_status(r.id, {
success: self.onGetHostStatus, success: self.onGetHostStatus,
scope: self scope: self
}); });
}, this); }, this);
}, },
/** /**
* Updates the buttons in the Connection Manager UI according to the * Updates the buttons in the Connection Manager UI according to the
* passed in records host state. * passed in records host state.
* @param {Ext.data.Record} record The hosts record to update the UI for * @param {Ext.data.Record} record The hosts record to update the UI for
*/ */
updateButtons: function(record) { updateButtons: function(record) {
var button = this.buttons[1], status = record.get('status'); var button = this.buttons[1], status = record.get('status');
// Update the Connect/Disconnect button // Update the Connect/Disconnect button
if (status == _('Connected')) { if (status == _('Connected')) {
button.enable(); button.enable();
button.setText(_('Disconnect')); button.setText(_('Disconnect'));
} else if (status == _('Offline')) { } else if (status == _('Offline')) {
button.disable(); button.disable();
} else { } else {
button.enable(); button.enable();
button.setText(_('Connect')); button.setText(_('Connect'));
} }
// Update the Stop/Start Daemon button // Update the Stop/Start Daemon button
if (status == _('Offline')) { if (status == _('Offline')) {
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') { if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
this.stopHostButton.enable(); this.stopHostButton.enable();
this.stopHostButton.setText(_('Start Daemon')); this.stopHostButton.setText(_('Start Daemon'));
} else { } else {
this.stopHostButton.disable(); this.stopHostButton.disable();
} }
} else { } else {
this.stopHostButton.enable(); this.stopHostButton.enable();
this.stopHostButton.setText(_('Stop Daemon')); this.stopHostButton.setText(_('Stop Daemon'));
} }
}, },
onAdd: function(button, e) { onAddClick: function(button, e) {
if (!this.addWindow) { if (!this.addWindow) {
this.addWindow = new Ext.deluge.AddConnectionWindow(); this.addWindow = new Ext.deluge.AddConnectionWindow();
this.addWindow.on('hostadded', this.onHostAdded, this); this.addWindow.on('hostadded', this.onHostAdded, this);
} }
this.addWindow.show(); this.addWindow.show();
}, },
onHostAdded: function() { onHostAdded: function() {
this.loadHosts(); this.loadHosts();
}, },
onClose: function(e) { onClose: function(e) {
if (this.running) window.clearInterval(this.running); if (this.running) window.clearInterval(this.running);
this.hide(); this.hide();
}, },
onConnect: function(e) { onConnect: function(e) {
var selected = this.grid.getSelectionModel().getSelected(); var selected = this.grid.getSelectionModel().getSelected();
if (!selected) return; if (!selected) return;
if (selected.get('status') == _('Connected')) { if (selected.get('status') == _('Connected')) {
Deluge.Client.web.disconnect({ Deluge.Client.web.disconnect({
success: function(result) { success: function(result) {
this.update(this); this.update(this);
Deluge.Events.fire('disconnect'); Deluge.Events.fire('disconnect');
}, },
scope: this scope: this
}); });
} else { } else {
var id = selected.id; var id = selected.id;
Deluge.Client.web.connect(id, { Deluge.Client.web.connect(id, {
success: function(methods) { success: function(methods) {
Deluge.Client.reloadMethods(); Deluge.Client.reloadMethods();
Deluge.Client.on('connected', function(e) { Deluge.Client.on('connected', function(e) {
Deluge.Events.fire('connect'); Deluge.Events.fire('connect');
}, this, {single: true}); }, this, {single: true});
} }
}); });
if (this.running) window.clearInterval(this.running); if (this.running) window.clearInterval(this.running);
this.hide(); this.hide();
} }
}, },
onGetHosts: function(hosts) { onGetHosts: function(hosts) {
this.grid.getStore().loadData(hosts); this.grid.getStore().loadData(hosts);
Ext.each(hosts, function(host) { Ext.each(hosts, function(host) {
Deluge.Client.web.get_host_status(host[0], { Deluge.Client.web.get_host_status(host[0], {
success: this.onGetHostStatus, success: this.onGetHostStatus,
scope: this scope: this
}); });
}, this); }, this);
}, },
onGetHostStatus: function(host) { onGetHostStatus: function(host) {
var record = this.grid.getStore().getById(host[0]); var record = this.grid.getStore().getById(host[0]);
record.set('status', host[3]) record.set('status', host[3])
record.set('version', host[4]) record.set('version', host[4])
record.commit(); record.commit();
if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record); if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record);
}, },
onLogin: function() { onLogin: function() {
Deluge.Client.web.connected({ Deluge.Client.web.connected({
success: function(connected) { success: function(connected) {
if (connected) { if (connected) {
Deluge.Events.fire('connect'); Deluge.Events.fire('connect');
} else { } else {
this.show(); this.show();
} }
}, },
scope: this scope: this
}); });
}, },
onLogout: function() { onLogout: function() {
this.disconnect(); this.disconnect();
if (!this.hidden && this.rendered) { if (!this.hidden && this.rendered) {
this.hide(); this.hide();
} }
}, },
onRemove: function(button) { onRemove: function(button) {
var connection = this.grid.getSelectionModel().getSelected(); var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return; if (!connection) return;
Deluge.Client.web.remove_host(connection.id, { Deluge.Client.web.remove_host(connection.id, {
success: function(result) { success: function(result) {
if (!result) { if (!result) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
msg: result[1], msg: result[1],
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error'
}); });
} else { } else {
this.grid.getStore().remove(connection); this.grid.getStore().remove(connection);
} }
}, },
scope: this scope: this
}); });
}, },
onSelect: function(selModel, rowIndex, record) { onSelect: function(selModel, rowIndex, record) {
this.selectedRow = rowIndex; this.selectedRow = rowIndex;
}, },
onSelectionChanged: function(selModel) { onSelectionChanged: function(selModel) {
var record = selModel.getSelected(); var record = selModel.getSelected();
if (selModel.hasSelection()) { if (selModel.hasSelection()) {
this.removeHostButton.enable(); this.removeHostButton.enable();
this.stopHostButton.enable(); this.stopHostButton.enable();
this.stopHostButton.setText(_('Stop Daemon')); this.stopHostButton.setText(_('Stop Daemon'));
} else { } else {
this.removeHostButton.disable(); this.removeHostButton.disable();
this.stopHostButton.disable(); this.stopHostButton.disable();
} }
this.updateButtons(record); this.updateButtons(record);
}, },
onShow: function() { onShow: function() {
if (!this.addHostButton) { if (!this.addHostButton) {
var bbar = this.grid.getBottomToolbar(); var bbar = this.grid.getBottomToolbar();
this.addHostButton = bbar.items.get('cm-add'); this.addHostButton = bbar.items.get('cm-add');
this.removeHostButton = bbar.items.get('cm-remove'); this.removeHostButton = bbar.items.get('cm-remove');
this.stopHostButton = bbar.items.get('cm-stop'); this.stopHostButton = bbar.items.get('cm-stop');
} }
this.loadHosts(); this.loadHosts();
this.running = window.setInterval(this.update, 2000, this); this.running = window.setInterval(this.update, 2000, this);
}, },
onStop: function(button, e) { onStop: function(button, e) {
var connection = this.grid.getSelectionModel().getSelected(); var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return; if (!connection) return;
if (connection.get('status') == 'Offline') { if (connection.get('status') == 'Offline') {
// This means we need to start the daemon // This means we need to start the daemon
Deluge.Client.web.start_daemon(connection.get('port')); Deluge.Client.web.start_daemon(connection.get('port'));
} else { } else {
// This means we need to stop the daemon // This means we need to stop the daemon
Deluge.Client.web.stop_daemon(connection.id, { Deluge.Client.web.stop_daemon(connection.id, {
success: function(result) { success: function(result) {
if (!result[0]) { if (!result[0]) {
Ext.MessageBox.show({ Ext.MessageBox.show({
title: _('Error'), title: _('Error'),
msg: result[1], msg: result[1],
buttons: Ext.MessageBox.OK, buttons: Ext.MessageBox.OK,
modal: false, modal: false,
icon: Ext.MessageBox.ERROR, icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error' iconCls: 'x-deluge-icon-error'
}); });
} }
} }
}); });
} }
} }
}); });
Deluge.ConnectionManager = new Ext.deluge.ConnectionManager(); Deluge.ConnectionManager = new Ext.deluge.ConnectionManager();
})(); })();

View File

@ -1,6 +1,6 @@
/* /*
Script: Deluge.EditTrackers.js Script: Deluge.EditTrackers.js
Contains the edit trackers window. Contains the edit trackers window.
Copyright: Copyright:
(C) Damien Churchill 2009 <damoxc@gmail.com> (C) Damien Churchill 2009 <damoxc@gmail.com>
@ -20,15 +20,15 @@ Copyright:
51 Franklin Street, Fifth Floor 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
In addition, as a special exception, the copyright holders give In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the OpenSSL permission to link the code of portions of this program with the OpenSSL
library. library.
You must obey the GNU General Public License in all respects for all of You must obey the GNU General Public License in all respects for all of
the code used other than OpenSSL. If you modify file(s) with this the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the file(s), exception, you may extend this exception to your version of the file(s),
but you are not obligated to do so. If you do not wish to do so, delete but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version. If you delete this exception this exception statement from your version. If you delete this exception
statement from all source files in the program, then also delete it here. statement from all source files in the program, then also delete it here.
*/ */
@ -54,8 +54,8 @@ Copyright:
initComponent: function() { initComponent: function() {
Ext.deluge.AddTracker.superclass.initComponent.call(this); Ext.deluge.AddTracker.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancel, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Add'), this.onAdd, this); this.addButton(_('Add'), this.onAddClick, this);
this.addEvents('add'); this.addEvents('add');
this.form = this.add({ this.form = this.add({
@ -71,12 +71,7 @@ Copyright:
}) })
}, },
onCancel: function() { onAddClick: function() {
this.form.getForm().findField('trackers').setValue('');
this.hide();
},
onAdd: function() {
var trackers = this.form.getForm().findField('trackers').getValue(); var trackers = this.form.getForm().findField('trackers').getValue();
trackers = trackers.split('\n'); trackers = trackers.split('\n');
@ -89,6 +84,11 @@ Copyright:
this.fireEvent('add', cleaned); this.fireEvent('add', cleaned);
this.hide(); this.hide();
this.form.getForm().findField('trackers').setValue(''); this.form.getForm().findField('trackers').setValue('');
},
onCancelClick: function() {
this.form.getForm().findField('trackers').setValue('');
this.hide();
} }
}); });
@ -224,31 +224,31 @@ Copyright:
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Up'), text: _('Up'),
icon: '/icons/up.png', icon: '/icons/up.png',
handler: this.onUp, handler: this.onUpClick,
scope: this scope: this
}, { }, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Down'), text: _('Down'),
icon: '/icons/down.png', icon: '/icons/down.png',
handler: this.onDown, handler: this.onDownClick,
scope: this scope: this
}, '->', { }, '->', {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Add'), text: _('Add'),
icon: '/icons/add.png', icon: '/icons/add.png',
handler: this.onAdd, handler: this.onAddClick,
scope: this scope: this
}, { }, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Edit'), text: _('Edit'),
icon: '/icons/edit_trackers.png', icon: '/icons/edit_trackers.png',
handler: this.onEdit, handler: this.onEditClick,
scope: this scope: this
}, { }, {
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
text: _('Remove'), text: _('Remove'),
icon: '/icons/remove.png', icon: '/icons/remove.png',
handler: this.onRemove, handler: this.onRemoveClick,
scope: this scope: this
} }
] ]
@ -256,7 +256,7 @@ Copyright:
}); });
}, },
onAdd: function() { onAddClick: function() {
this.addWindow.show(); this.addWindow.show();
}, },
@ -279,11 +279,11 @@ Copyright:
}, this); }, this);
}, },
onCancel: function() { onCancelClick: function() {
this.hide(); this.hide();
}, },
onEdit: function() { onEditClick: function() {
var r = this.grid.getSelectionModel().getSelected(); var r = this.grid.getSelectionModel().getSelected();
this.editWindow.show(r); this.editWindow.show(r);
}, },

View File

@ -1,153 +1,151 @@
(function() { Ext.deluge.Statusbar = Ext.extend(Ext.Toolbar, {
Ext.deluge.Statusbar = Ext.extend(Ext.StatusBar, { constructor: function(config) {
constructor: function(config) { config = Ext.apply({
config = Ext.apply({ id: 'deluge-statusbar',
id: 'deluge-statusbar', defaultIconCls: 'x-not-connected',
defaultIconCls: 'x-not-connected', defaultText: _('Not Connected')
defaultText: _('Not Connected') }, config);
}, config); Ext.deluge.Statusbar.superclass.constructor.call(this, config);
Ext.deluge.Statusbar.superclass.constructor.call(this, config); },
},
initComponent: function() { initComponent: function() {
Ext.deluge.Statusbar.superclass.initComponent.call(this); Ext.deluge.Statusbar.superclass.initComponent.call(this);
Deluge.Events.on('connect', this.onConnect, this); Deluge.Events.on('connect', this.onConnect, this);
Deluge.Events.on('disconnect', this.onDisconnect, this); Deluge.Events.on('disconnect', this.onDisconnect, this);
}, },
createButtons: function() { createButtons: function() {
this.add({ this.add({
id: 'statusbar-connections', id: 'statusbar-connections',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-connections', iconCls: 'x-deluge-connections',
tooltip: _('Connections'), tooltip: _('Connections'),
menu: Deluge.Menus.Connections menu: Deluge.Menus.Connections
}, '-', { }, '-', {
id: 'statusbar-downspeed', id: 'statusbar-downspeed',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-downloading', iconCls: 'x-deluge-downloading',
tooltip: _('Download Speed'), tooltip: _('Download Speed'),
menu: Deluge.Menus.Download menu: Deluge.Menus.Download
}, '-', { }, '-', {
id: 'statusbar-upspeed', id: 'statusbar-upspeed',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-seeding', iconCls: 'x-deluge-seeding',
tooltip: _('Upload Speed'), tooltip: _('Upload Speed'),
menu: Deluge.Menus.Upload menu: Deluge.Menus.Upload
}, '-', { }, '-', {
id: 'statusbar-traffic', id: 'statusbar-traffic',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-traffic', iconCls: 'x-deluge-traffic',
tooltip: _('Protocol Traffic Download/Upload') tooltip: _('Protocol Traffic Download/Upload')
}, '-', { }, '-', {
id: 'statusbar-dht', id: 'statusbar-dht',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-dht', iconCls: 'x-deluge-dht',
tooltip: _('DHT Nodes') tooltip: _('DHT Nodes')
}, '-', { }, '-', {
id: 'statusbar-freespace', id: 'statusbar-freespace',
text: ' ', text: ' ',
cls: 'x-btn-text-icon', cls: 'x-btn-text-icon',
iconCls: 'x-deluge-freespace', iconCls: 'x-deluge-freespace',
tooltip: _('Freespace in download location') tooltip: _('Freespace in download location')
}); });
this.created = true; this.created = true;
}, },
onConnect: function() { onConnect: function() {
this.setStatus({ //this.setStatus({
iconCls: 'x-connected', // iconCls: 'x-connected',
text: '' // text: ''
}); //});
if (!this.created) this.createButtons(); if (!this.created) this.createButtons();
else { else {
this.items.each(function(item) {
item.show();
item.enable();
});
}
},
onDisconnect: function() {
this.clearStatus({useDefaults:true});
this.items.each(function(item) { this.items.each(function(item) {
item.hide(); item.show();
item.disable(); item.enable();
}); });
},
update: function(stats) {
if (!stats) return;
function addSpeed(val) {return val + ' KiB/s'}
var updateStat = function(name, config) {
var item = this.items.get('statusbar-' + name);
if (config.limit.value > 0) {
var value = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value) : config.limit.value;
var str = String.format(config.format, value, limit);
} else {
var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
}
item.setText(str);
}.bind(this);
updateStat('connections', {
value: {value: stats.num_connections},
limit: {value: stats.max_num_connections},
format: '{0} ({1})'
});
updateStat('downspeed', {
value: {
value: stats.download_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.max_download,
formatter: addSpeed
},
format: '{0} ({1})'
});
updateStat('upspeed', {
value: {
value: stats.upload_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.max_upload,
formatter: addSpeed
},
format: '{0} ({1})'
});
updateStat('traffic', {
value: {
value: stats.download_protocol_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.upload_protocol_rate,
formatter: Deluge.Formatters.speed
},
format: '{0}/{1}'
});
this.items.get('statusbar-dht').setText(stats.dht_nodes);
this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
Deluge.Menus.Connections.setValue(stats.max_num_connections);
Deluge.Menus.Download.setValue(stats.max_download);
Deluge.Menus.Upload.setValue(stats.max_upload);
} }
}); },
Deluge.Statusbar = new Ext.deluge.Statusbar();
})(); onDisconnect: function() {
//this.clearStatus({useDefaults:true});
this.items.each(function(item) {
item.hide();
item.disable();
});
},
update: function(stats) {
if (!stats) return;
function addSpeed(val) {return val + ' KiB/s'}
var updateStat = function(name, config) {
var item = this.items.get('statusbar-' + name);
if (config.limit.value > 0) {
var value = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value) : config.limit.value;
var str = String.format(config.format, value, limit);
} else {
var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
}
item.setText(str);
}.bind(this);
updateStat('connections', {
value: {value: stats.num_connections},
limit: {value: stats.max_num_connections},
format: '{0} ({1})'
});
updateStat('downspeed', {
value: {
value: stats.download_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.max_download,
formatter: addSpeed
},
format: '{0} ({1})'
});
updateStat('upspeed', {
value: {
value: stats.upload_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.max_upload,
formatter: addSpeed
},
format: '{0} ({1})'
});
updateStat('traffic', {
value: {
value: stats.download_protocol_rate,
formatter: Deluge.Formatters.speed
},
limit: {
value: stats.upload_protocol_rate,
formatter: Deluge.Formatters.speed
},
format: '{0}/{1}'
});
this.items.get('statusbar-dht').setText(stats.dht_nodes);
this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
Deluge.Menus.Connections.setValue(stats.max_num_connections);
Deluge.Menus.Download.setValue(stats.max_download);
Deluge.Menus.Upload.setValue(stats.max_upload);
}
});
Deluge.Statusbar = new Ext.deluge.Statusbar();

View File

@ -48,8 +48,8 @@ Copyright:
value = new Number(value); value = new Number(value);
var progress = value; var progress = value;
var text = r.data['state'] + ' ' + value.toFixed(2) + '%' var text = r.data['state'] + ' ' + value.toFixed(2) + '%'
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8; //var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8;
return Deluge.progressBar(value, width, text); return Deluge.progressBar(value, this.width - 8, text);
} }
function seedsRenderer(value, p, r) { function seedsRenderer(value, p, r) {
if (r.data['total_seeds'] > -1) { if (r.data['total_seeds'] > -1) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -309,7 +309,7 @@ class TopLevel(resource.Resource):
] ]
__debug_scripts = [ __debug_scripts = [
"/js/ext-base.js", "/js/ext-base-debug.js",
"/js/ext-all-debug.js", "/js/ext-all-debug.js",
"/js/ext-extensions-debug.js", "/js/ext-extensions-debug.js",
"/config.js", "/config.js",