Author: damoxc
Revision: 4919
Log:
implement disconnecting from a connected daemon
Diff:
Modified: trunk/deluge/ui/web/js/deluge-connections.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-connections.js 2009-03-22 23:37:21 UTC
(rev 4918)
+++ trunk/deluge/ui/web/js/deluge-connections.js 2009-03-22 23:52:34 UTC
(rev 4919)
@@ -88,19 +88,30 @@
},
onConnect: function(e) {
- $clear(Deluge.Connections.running);
- Deluge.Connections.Window.hide();
+
var selected =
Deluge.Connections.Grid.getSelectionModel().getSelected();
if (!selected) return;
- var id = selected.id;
- Deluge.Client.web.connect(id, {
- onSuccess: function(methods) {
- Deluge.Client = new JSON.RPC('/json', {
- methods: methods
- });
- Deluge.Events.fire('connect');
- }
- });
+
+ if (selected.get('status') == _('Connected')) {
+ Deluge.Client.web.disconnect({
+ onSuccess: function(result) {
+ Deluge.Connections.runCheck();
+ Deluge.Events.fire('disconnect');
+ }
+ });
+ } else {
+ var id = selected.id;
+ Deluge.Client.web.connect(id, {
+ onSuccess: function(methods) {
+ Deluge.Client = new JSON.RPC('/json', {
+ methods: methods
+ });
+ Deluge.Events.fire('connect');
+ }
+ });
+ $clear(Deluge.Connections.running);
+ Deluge.Connections.Window.hide();
+ }
},
onGetHosts: function(hosts) {
@@ -131,6 +142,12 @@
onSelect: function(selModel, rowIndex, record) {
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) {
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-03-22 23:37:21 UTC (rev 4918)
+++ trunk/deluge/ui/web/json_api.py 2009-03-22 23:52:34 UTC (rev 4919)
@@ -282,6 +282,13 @@
return d
@export
+ def disconnect(self):
+ d = Deferred()
+ client.disconnect()
+ d.callback(True)
+ return d
+
+ @export
def update_ui(self, keys, filter_dict):
ui_info = {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---