implement disconnecting from a connected daemon
This commit is contained in:
parent
a0e9fafb8f
commit
2193905fa6
|
@ -88,10 +88,18 @@ Deluge.Connections = {
|
||||||
},
|
},
|
||||||
|
|
||||||
onConnect: function(e) {
|
onConnect: function(e) {
|
||||||
$clear(Deluge.Connections.running);
|
|
||||||
Deluge.Connections.Window.hide();
|
|
||||||
var selected = Deluge.Connections.Grid.getSelectionModel().getSelected();
|
var selected = Deluge.Connections.Grid.getSelectionModel().getSelected();
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
|
|
||||||
|
if (selected.get('status') == _('Connected')) {
|
||||||
|
Deluge.Client.web.disconnect({
|
||||||
|
onSuccess: function(result) {
|
||||||
|
Deluge.Connections.runCheck();
|
||||||
|
Deluge.Events.fire('disconnect');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
var id = selected.id;
|
var id = selected.id;
|
||||||
Deluge.Client.web.connect(id, {
|
Deluge.Client.web.connect(id, {
|
||||||
onSuccess: function(methods) {
|
onSuccess: function(methods) {
|
||||||
|
@ -101,6 +109,9 @@ Deluge.Connections = {
|
||||||
Deluge.Events.fire('connect');
|
Deluge.Events.fire('connect');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$clear(Deluge.Connections.running);
|
||||||
|
Deluge.Connections.Window.hide();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onGetHosts: function(hosts) {
|
onGetHosts: function(hosts) {
|
||||||
|
@ -131,6 +142,12 @@ Deluge.Connections = {
|
||||||
|
|
||||||
onSelect: function(selModel, rowIndex, record) {
|
onSelect: function(selModel, rowIndex, record) {
|
||||||
Deluge.Connections.selectedRow = rowIndex;
|
Deluge.Connections.selectedRow = rowIndex;
|
||||||
|
var button = Deluge.Connections.Window.buttons[1];
|
||||||
|
if (record.get('status') == _('Connected')) {
|
||||||
|
button.setText(_('Disconnect'));
|
||||||
|
} else {
|
||||||
|
button.setText(_('Connect'));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShow: function(window) {
|
onShow: function(window) {
|
||||||
|
|
|
@ -281,6 +281,13 @@ class WebApi(JSONComponent):
|
||||||
d.callback(client.connected())
|
d.callback(client.connected())
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@export
|
||||||
|
def disconnect(self):
|
||||||
|
d = Deferred()
|
||||||
|
client.disconnect()
|
||||||
|
d.callback(True)
|
||||||
|
return d
|
||||||
|
|
||||||
@export
|
@export
|
||||||
def update_ui(self, keys, filter_dict):
|
def update_ui(self, keys, filter_dict):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue