mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
remove the function wrap from the connection manager
This commit is contained in:
parent
c0fd70a856
commit
759ae6356d
1 changed files with 316 additions and 320 deletions
|
@ -30,288 +30,340 @@
|
||||||
* 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() {
|
Deluge.ConnectionManager = Ext.extend(Ext.Window, {
|
||||||
var hostRenderer = function(value, p, r) {
|
|
||||||
return value + ':' + r.data['port']
|
|
||||||
}
|
|
||||||
|
|
||||||
Deluge.ConnectionManager = Ext.extend(Ext.Window, {
|
layout: 'fit',
|
||||||
|
width: 300,
|
||||||
|
height: 220,
|
||||||
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
|
buttonAlign: 'right',
|
||||||
|
closeAction: 'hide',
|
||||||
|
closable: true,
|
||||||
|
plain: true,
|
||||||
|
title: _('Connection Manager'),
|
||||||
|
iconCls: 'x-deluge-connect-window-icon',
|
||||||
|
|
||||||
layout: 'fit',
|
initComponent: function() {
|
||||||
width: 300,
|
Deluge.ConnectionManager.superclass.initComponent.call(this);
|
||||||
height: 220,
|
this.on('hide', this.onHide, this);
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
this.on('show', this.onShow, this);
|
||||||
buttonAlign: 'right',
|
|
||||||
closeAction: 'hide',
|
|
||||||
closable: true,
|
|
||||||
plain: true,
|
|
||||||
title: _('Connection Manager'),
|
|
||||||
iconCls: 'x-deluge-connect-window-icon',
|
|
||||||
|
|
||||||
initComponent: function() {
|
|
||||||
Deluge.ConnectionManager.superclass.initComponent.call(this);
|
|
||||||
this.on('hide', this.onHide, this);
|
|
||||||
this.on('show', this.onShow, this);
|
|
||||||
|
|
||||||
deluge.events.on('disconnect', this.onDisconnect, this);
|
deluge.events.on('disconnect', this.onDisconnect, this);
|
||||||
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(_('Connect'), this.onConnect, this);
|
|
||||||
|
|
||||||
this.list = new Ext.list.ListView({
|
this.addButton(_('Close'), this.onClose, this);
|
||||||
store: new Ext.data.ArrayStore({
|
this.addButton(_('Connect'), this.onConnect, this);
|
||||||
fields: [
|
|
||||||
{name: 'status', mapping: 3},
|
|
||||||
{name: 'host', mapping: 1},
|
|
||||||
{name: 'port', mapping: 2},
|
|
||||||
{name: 'version', mapping: 4}
|
|
||||||
],
|
|
||||||
id: 0
|
|
||||||
}),
|
|
||||||
columns: [{
|
|
||||||
header: _('Status'),
|
|
||||||
width: .24,
|
|
||||||
sortable: true,
|
|
||||||
dataIndex: 'status'
|
|
||||||
}, {
|
|
||||||
id:'host',
|
|
||||||
header: _('Host'),
|
|
||||||
width: .51,
|
|
||||||
sortable: true,
|
|
||||||
tpl: '{host}:{port}',
|
|
||||||
dataIndex: 'host'
|
|
||||||
}, {
|
|
||||||
header: _('Version'),
|
|
||||||
width: .25,
|
|
||||||
sortable: true,
|
|
||||||
dataIndex: 'version'
|
|
||||||
}],
|
|
||||||
singleSelect: true,
|
|
||||||
listeners: {
|
|
||||||
'selectionchange': {fn: this.onSelectionChanged, scope: this}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.panel = this.add({
|
|
||||||
autoScroll: true,
|
|
||||||
items: [this.list],
|
|
||||||
bbar: new Ext.Toolbar({
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
id: 'cm-add',
|
|
||||||
cls: 'x-btn-text-icon',
|
|
||||||
text: _('Add'),
|
|
||||||
iconCls: 'icon-add',
|
|
||||||
handler: this.onAddClick,
|
|
||||||
scope: this
|
|
||||||
}, {
|
|
||||||
id: 'cm-remove',
|
|
||||||
cls: 'x-btn-text-icon',
|
|
||||||
text: _('Remove'),
|
|
||||||
iconCls: 'icon-remove',
|
|
||||||
handler: this.onRemoveClick,
|
|
||||||
disabled: true,
|
|
||||||
scope: this
|
|
||||||
}, '->', {
|
|
||||||
id: 'cm-stop',
|
|
||||||
cls: 'x-btn-text-icon',
|
|
||||||
text: _('Stop Daemon'),
|
|
||||||
iconCls: 'icon-error',
|
|
||||||
handler: this.onStopClick,
|
|
||||||
disabled: true,
|
|
||||||
scope: this
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
this.update = this.update.createDelegate(this);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
this.list = new Ext.list.ListView({
|
||||||
* Check to see if the the web interface is currently connected
|
store: new Ext.data.ArrayStore({
|
||||||
* to a Deluge Daemon and show the Connection Manager if not.
|
fields: [
|
||||||
*/
|
{name: 'status', mapping: 3},
|
||||||
checkConnected: function() {
|
{name: 'host', mapping: 1},
|
||||||
deluge.client.web.connected({
|
{name: 'port', mapping: 2},
|
||||||
success: function(connected) {
|
{name: 'version', mapping: 4}
|
||||||
if (connected) {
|
],
|
||||||
deluge.events.fire('connect');
|
id: 0
|
||||||
} else {
|
}),
|
||||||
this.show();
|
columns: [{
|
||||||
|
header: _('Status'),
|
||||||
|
width: .24,
|
||||||
|
sortable: true,
|
||||||
|
dataIndex: 'status'
|
||||||
|
}, {
|
||||||
|
id:'host',
|
||||||
|
header: _('Host'),
|
||||||
|
width: .51,
|
||||||
|
sortable: true,
|
||||||
|
tpl: '{host}:{port}',
|
||||||
|
dataIndex: 'host'
|
||||||
|
}, {
|
||||||
|
header: _('Version'),
|
||||||
|
width: .25,
|
||||||
|
sortable: true,
|
||||||
|
dataIndex: 'version'
|
||||||
|
}],
|
||||||
|
singleSelect: true,
|
||||||
|
listeners: {
|
||||||
|
'selectionchange': {fn: this.onSelectionChanged, scope: this}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.panel = this.add({
|
||||||
|
autoScroll: true,
|
||||||
|
items: [this.list],
|
||||||
|
bbar: new Ext.Toolbar({
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
id: 'cm-add',
|
||||||
|
cls: 'x-btn-text-icon',
|
||||||
|
text: _('Add'),
|
||||||
|
iconCls: 'icon-add',
|
||||||
|
handler: this.onAddClick,
|
||||||
|
scope: this
|
||||||
|
}, {
|
||||||
|
id: 'cm-remove',
|
||||||
|
cls: 'x-btn-text-icon',
|
||||||
|
text: _('Remove'),
|
||||||
|
iconCls: 'icon-remove',
|
||||||
|
handler: this.onRemoveClick,
|
||||||
|
disabled: true,
|
||||||
|
scope: this
|
||||||
|
}, '->', {
|
||||||
|
id: 'cm-stop',
|
||||||
|
cls: 'x-btn-text-icon',
|
||||||
|
text: _('Stop Daemon'),
|
||||||
|
iconCls: 'icon-error',
|
||||||
|
handler: this.onStopClick,
|
||||||
|
disabled: true,
|
||||||
|
scope: this
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.update = this.update.createDelegate(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the the web interface is currently connected
|
||||||
|
* to a Deluge Daemon and show the Connection Manager if not.
|
||||||
|
*/
|
||||||
|
checkConnected: function() {
|
||||||
|
deluge.client.web.connected({
|
||||||
|
success: function(connected) {
|
||||||
|
if (connected) {
|
||||||
|
deluge.events.fire('connect');
|
||||||
|
} else {
|
||||||
|
this.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
disconnect: function() {
|
||||||
|
deluge.events.fire('disconnect');
|
||||||
|
},
|
||||||
|
|
||||||
|
loadHosts: function() {
|
||||||
|
deluge.client.web.get_hosts({
|
||||||
|
success: this.onGetHosts,
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function() {
|
||||||
|
this.list.getStore().each(function(r) {
|
||||||
|
deluge.client.web.get_host_status(r.id, {
|
||||||
|
success: this.onGetHostStatus,
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the buttons in the Connection Manager UI according to the
|
||||||
|
* passed in records host state.
|
||||||
|
* @param {Ext.data.Record} record The hosts record to update the UI for
|
||||||
|
*/
|
||||||
|
updateButtons: function(record) {
|
||||||
|
var button = this.buttons[1], status = record.get('status');
|
||||||
|
|
||||||
|
// Update the Connect/Disconnect button
|
||||||
|
if (status == _('Connected')) {
|
||||||
|
button.enable();
|
||||||
|
button.setText(_('Disconnect'));
|
||||||
|
} else if (status == _('Offline')) {
|
||||||
|
button.disable();
|
||||||
|
} else {
|
||||||
|
button.enable();
|
||||||
|
button.setText(_('Connect'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the Stop/Start Daemon button
|
||||||
|
if (status == _('Offline')) {
|
||||||
|
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
||||||
|
this.stopHostButton.enable();
|
||||||
|
this.stopHostButton.setText(_('Start Daemon'));
|
||||||
|
} else {
|
||||||
|
this.stopHostButton.disable();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.stopHostButton.enable();
|
||||||
|
this.stopHostButton.setText(_('Stop Daemon'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onAddClick: function(button, e) {
|
||||||
|
if (!this.addWindow) {
|
||||||
|
this.addWindow = new Deluge.AddConnectionWindow();
|
||||||
|
this.addWindow.on('hostadded', this.onHostAdded, this);
|
||||||
|
}
|
||||||
|
this.addWindow.show();
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onHostAdded: function() {
|
||||||
|
this.loadHosts();
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onClose: function(e) {
|
||||||
|
this.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onConnect: function(e) {
|
||||||
|
var selected = this.list.getSelectedRecords()[0];
|
||||||
|
if (!selected) return;
|
||||||
|
|
||||||
|
if (selected.get('status') == _('Connected')) {
|
||||||
|
deluge.client.web.disconnect({
|
||||||
|
success: function(result) {
|
||||||
|
this.update(this);
|
||||||
|
deluge.events.fire('disconnect');
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
} else {
|
||||||
|
var id = selected.id;
|
||||||
|
deluge.client.web.connect(id, {
|
||||||
|
success: function(methods) {
|
||||||
|
deluge.client.reloadMethods();
|
||||||
|
deluge.client.on('connected', function(e) {
|
||||||
|
deluge.events.fire('connect');
|
||||||
|
}, this, {single: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
disconnect: function() {
|
// private
|
||||||
deluge.events.fire('disconnect');
|
onDisconnect: function() {
|
||||||
},
|
if (this.isVisible()) return;
|
||||||
|
this.show();
|
||||||
loadHosts: function() {
|
},
|
||||||
deluge.client.web.get_hosts({
|
|
||||||
success: this.onGetHosts,
|
// private
|
||||||
|
onGetHosts: function(hosts) {
|
||||||
|
this.list.getStore().loadData(hosts);
|
||||||
|
Ext.each(hosts, function(host) {
|
||||||
|
deluge.client.web.get_host_status(host[0], {
|
||||||
|
success: this.onGetHostStatus,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
}, this);
|
||||||
|
},
|
||||||
update: function() {
|
|
||||||
this.list.getStore().each(function(r) {
|
|
||||||
deluge.client.web.get_host_status(r.id, {
|
|
||||||
success: this.onGetHostStatus,
|
|
||||||
scope: this
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the buttons in the Connection Manager UI according to the
|
|
||||||
* passed in records host state.
|
|
||||||
* @param {Ext.data.Record} record The hosts record to update the UI for
|
|
||||||
*/
|
|
||||||
updateButtons: function(record) {
|
|
||||||
var button = this.buttons[1], status = record.get('status');
|
|
||||||
|
|
||||||
// Update the Connect/Disconnect button
|
|
||||||
if (status == _('Connected')) {
|
|
||||||
button.enable();
|
|
||||||
button.setText(_('Disconnect'));
|
|
||||||
} else if (status == _('Offline')) {
|
|
||||||
button.disable();
|
|
||||||
} else {
|
|
||||||
button.enable();
|
|
||||||
button.setText(_('Connect'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the Stop/Start Daemon button
|
|
||||||
if (status == _('Offline')) {
|
|
||||||
if (record.get('host') == '127.0.0.1' || record.get('host') == 'localhost') {
|
|
||||||
this.stopHostButton.enable();
|
|
||||||
this.stopHostButton.setText(_('Start Daemon'));
|
|
||||||
} else {
|
|
||||||
this.stopHostButton.disable();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.stopHostButton.enable();
|
|
||||||
this.stopHostButton.setText(_('Stop Daemon'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onAddClick: function(button, e) {
|
onGetHostStatus: function(host) {
|
||||||
if (!this.addWindow) {
|
var record = this.list.getStore().getById(host[0]);
|
||||||
this.addWindow = new Deluge.AddConnectionWindow();
|
record.set('status', host[3])
|
||||||
this.addWindow.on('hostadded', this.onHostAdded, this);
|
record.set('version', host[4])
|
||||||
}
|
record.commit();
|
||||||
this.addWindow.show();
|
if (this.list.getSelectedRecords()[0] == record) this.updateButtons(record);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onHostAdded: function() {
|
onHide: function() {
|
||||||
this.loadHosts();
|
if (this.running) window.clearInterval(this.running);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
|
||||||
onClose: function(e) {
|
|
||||||
if (this.running) window.clearInterval(this.running);
|
|
||||||
this.hide();
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onConnect: function(e) {
|
|
||||||
var selected = this.list.getSelectedRecords()[0];
|
|
||||||
if (!selected) return;
|
|
||||||
|
|
||||||
if (selected.get('status') == _('Connected')) {
|
// private
|
||||||
deluge.client.web.disconnect({
|
onLogin: function() {
|
||||||
success: function(result) {
|
if (deluge.config.first_login) {
|
||||||
this.update(this);
|
Ext.MessageBox.confirm('Change password',
|
||||||
deluge.events.fire('disconnect');
|
'As this is your first login, we recommend that you ' +
|
||||||
},
|
'change your password. Would you like to ' +
|
||||||
scope: this
|
'do this now?', function(res) {
|
||||||
});
|
this.checkConnected();
|
||||||
} else {
|
if (res == 'yes') {
|
||||||
var id = selected.id;
|
deluge.preferences.show();
|
||||||
deluge.client.web.connect(id, {
|
deluge.preferences.selectPage('Interface');
|
||||||
success: function(methods) {
|
|
||||||
deluge.client.reloadMethods();
|
|
||||||
deluge.client.on('connected', function(e) {
|
|
||||||
deluge.events.fire('connect');
|
|
||||||
}, this, {single: true});
|
|
||||||
}
|
}
|
||||||
});
|
deluge.client.web.set_config({first_login: false});
|
||||||
this.hide();
|
}, this);
|
||||||
}
|
} else {
|
||||||
},
|
this.checkConnected();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onDisconnect: function() {
|
onLogout: function() {
|
||||||
if (this.isVisible()) return;
|
this.disconnect();
|
||||||
this.show();
|
if (!this.hidden && this.rendered) {
|
||||||
},
|
this.hide();
|
||||||
|
}
|
||||||
|
if (this.running) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGetHosts: function(hosts) {
|
onRemoveClick: function(button) {
|
||||||
this.list.getStore().loadData(hosts);
|
var connection = this.list.getSelectedRecords()[0];
|
||||||
Ext.each(hosts, function(host) {
|
if (!connection) return;
|
||||||
deluge.client.web.get_host_status(host[0], {
|
|
||||||
success: this.onGetHostStatus,
|
deluge.client.web.remove_host(connection.id, {
|
||||||
scope: this
|
success: function(result) {
|
||||||
});
|
if (!result) {
|
||||||
}, this);
|
Ext.MessageBox.show({
|
||||||
},
|
title: _('Error'),
|
||||||
|
msg: result[1],
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
modal: false,
|
||||||
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
iconCls: 'x-deluge-icon-error'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.list.getStore().remove(connection);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onSelectionChanged: function(list, selections) {
|
||||||
|
if (selections[0]) {
|
||||||
|
this.removeHostButton.enable();
|
||||||
|
this.stopHostButton.enable();
|
||||||
|
this.stopHostButton.setText(_('Stop Daemon'));
|
||||||
|
this.updateButtons(this.list.getRecord(selections[0]));
|
||||||
|
} else {
|
||||||
|
this.removeHostButton.disable();
|
||||||
|
this.stopHostButton.disable();
|
||||||
|
this.updateButtons(null);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onShow: function() {
|
||||||
|
if (!this.addHostButton) {
|
||||||
|
var bbar = this.panel.getBottomToolbar();
|
||||||
|
this.addHostButton = bbar.items.get('cm-add');
|
||||||
|
this.removeHostButton = bbar.items.get('cm-remove');
|
||||||
|
this.stopHostButton = bbar.items.get('cm-stop');
|
||||||
|
}
|
||||||
|
this.loadHosts();
|
||||||
|
this.running = window.setInterval(this.update, 2000, this);
|
||||||
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onGetHostStatus: function(host) {
|
onStopClick: function(button, e) {
|
||||||
var record = this.list.getStore().getById(host[0]);
|
var connection = this.list.getSelectedRecords()[0];
|
||||||
record.set('status', host[3])
|
if (!connection) return;
|
||||||
record.set('version', host[4])
|
|
||||||
record.commit();
|
|
||||||
if (this.list.getSelectedRecords()[0] == record) this.updateButtons(record);
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
if (connection.get('status') == 'Offline') {
|
||||||
onHide: function() {
|
// This means we need to start the daemon
|
||||||
if (this.running) window.clearInterval(this.running);
|
deluge.client.web.start_daemon(connection.get('port'));
|
||||||
},
|
} else {
|
||||||
|
// This means we need to stop the daemon
|
||||||
// private
|
deluge.client.web.stop_daemon(connection.id, {
|
||||||
onLogin: function() {
|
|
||||||
if (deluge.config.first_login) {
|
|
||||||
Ext.MessageBox.confirm('Change password',
|
|
||||||
'As this is your first login, we recommend that you ' +
|
|
||||||
'change your password. Would you like to ' +
|
|
||||||
'do this now?', function(res) {
|
|
||||||
this.checkConnected();
|
|
||||||
if (res == 'yes') {
|
|
||||||
deluge.preferences.show();
|
|
||||||
deluge.preferences.selectPage('Interface');
|
|
||||||
}
|
|
||||||
deluge.client.web.set_config({first_login: false});
|
|
||||||
}, this);
|
|
||||||
} else {
|
|
||||||
this.checkConnected();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onLogout: function() {
|
|
||||||
this.disconnect();
|
|
||||||
if (!this.hidden && this.rendered) {
|
|
||||||
this.hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onRemoveClick: function(button) {
|
|
||||||
var connection = this.list.getSelectedRecords()[0];
|
|
||||||
if (!connection) return;
|
|
||||||
|
|
||||||
deluge.client.web.remove_host(connection.id, {
|
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
if (!result) {
|
if (!result[0]) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: result[1],
|
msg: result[1],
|
||||||
|
@ -320,65 +372,9 @@
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
iconCls: 'x-deluge-icon-error'
|
iconCls: 'x-deluge-icon-error'
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.list.getStore().remove(connection);
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
scope: this
|
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onSelectionChanged: function(list, selections) {
|
|
||||||
if (selections[0]) {
|
|
||||||
this.removeHostButton.enable();
|
|
||||||
this.stopHostButton.enable();
|
|
||||||
this.stopHostButton.setText(_('Stop Daemon'));
|
|
||||||
this.updateButtons(this.list.getRecord(selections[0]));
|
|
||||||
} else {
|
|
||||||
this.removeHostButton.disable();
|
|
||||||
this.stopHostButton.disable();
|
|
||||||
this.updateButtons(null);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onShow: function() {
|
|
||||||
if (!this.addHostButton) {
|
|
||||||
var bbar = this.panel.getBottomToolbar();
|
|
||||||
this.addHostButton = bbar.items.get('cm-add');
|
|
||||||
this.removeHostButton = bbar.items.get('cm-remove');
|
|
||||||
this.stopHostButton = bbar.items.get('cm-stop');
|
|
||||||
}
|
|
||||||
this.loadHosts();
|
|
||||||
this.running = window.setInterval(this.update, 2000, this);
|
|
||||||
},
|
|
||||||
|
|
||||||
// private
|
|
||||||
onStopClick: function(button, e) {
|
|
||||||
var connection = this.list.getSelectedRecords()[0];
|
|
||||||
if (!connection) return;
|
|
||||||
|
|
||||||
if (connection.get('status') == 'Offline') {
|
|
||||||
// This means we need to start the daemon
|
|
||||||
deluge.client.web.start_daemon(connection.get('port'));
|
|
||||||
} else {
|
|
||||||
// This means we need to stop the daemon
|
|
||||||
deluge.client.web.stop_daemon(connection.id, {
|
|
||||||
success: function(result) {
|
|
||||||
if (!result[0]) {
|
|
||||||
Ext.MessageBox.show({
|
|
||||||
title: _('Error'),
|
|
||||||
msg: result[1],
|
|
||||||
buttons: Ext.MessageBox.OK,
|
|
||||||
modal: false,
|
|
||||||
icon: Ext.MessageBox.ERROR,
|
|
||||||
iconCls: 'x-deluge-icon-error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
})();
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue