diff --git a/deluge/ui/web/js/deluge-bars.js b/deluge/ui/web/js/deluge-bars.js index f4a6042a4..a79ff14b7 100644 --- a/deluge/ui/web/js/deluge-bars.js +++ b/deluge/ui/web/js/deluge-bars.js @@ -26,6 +26,10 @@ Deluge.ToolBar = { Deluge.Login.Window.show(); }, + onConnectionManagerClick: function(item) { + Deluge.Connections.Window.show(); + }, + onTorrentAction: function(item) { var selection = Deluge.Torrents.getSelectionModel().getSelections(); var ids = new Array(); @@ -42,36 +46,21 @@ Deluge.ToolBar = { }); break; case 'pause': - Deluge.Client.core.pause_torrent(ids, { - onSuccess: function() { - Deluge.Ui.update(); - } - }); - break; case 'resume': - Deluge.Client.core.resume_torrent(ids, { + Deluge.Client.core[item.id + '_torrent'](ids, { onSuccess: function() { Deluge.Ui.update(); } }); break; case 'up': - Deluge.Client.core.queue_up(ids, { - onSuccess: function() { - Deluge.Ui.update(); - } - }); - break; case 'down': - Deluge.Client.core.queue_down(ids, { + Deluge.Client.core['queue_' + item.id](ids, { onSuccess: function() { Deluge.Ui.update(); } }); break; - case 'connectionman': - Deluge.Connections.Window.show(); - break; } }, @@ -143,13 +132,16 @@ Deluge.ToolBar.Bar = new Ext.Toolbar({ cls: 'x-btn-text-icon', text: _('Connection Manager'), icon: '/icons/16/connection_manager.png', - handler: Deluge.ToolBar.onTorrentAction + handler: Deluge.ToolBar.onConnectionManagerClick, + scope: Deluge.ToolBar },'->',{ id: 'help', cls: 'x-btn-text-icon', disabled: true, icon: '/icons/16/help.png', - text: _('Help') + text: _('Help'), + handler: Deluge.ToolBar.onHelpClick, + scope: Deluge.ToolBar },{ id: 'logout', cls: 'x-btn-text-icon', diff --git a/deluge/ui/web/js/deluge-ui.js b/deluge/ui/web/js/deluge-ui.js index 2f09beb75..6e76ff9f0 100644 --- a/deluge/ui/web/js/deluge-ui.js +++ b/deluge/ui/web/js/deluge-ui.js @@ -29,6 +29,15 @@ Deluge.Ui = { onSuccess: this.onUpdate.bindWithEvent(this), onFailure: this.onUpdateError.bindWithEvent(this) }); + Deluge.Client.web.connected({ + onSuccess: this.onConnectedCheck.bindWithEvent(this) + }); + }, + + onConnectedCheck: function(connected) { + if (!connected) { + Deluge.Events.fire('disconnect'); + } }, onUpdateError: function(error) { diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 32504b5ec..f37a79d8d 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -142,7 +142,8 @@ class JSON(resource.Resource): "web.add_torrents": self.add_torrents, "web.login": self.login, "web.get_hosts": self.get_hosts, - "web.connect": self.connect + "web.connect": self.connect, + "web.connected": self.connected } for entry in open(common.get_default_config_dir("auth")): parts = entry.split(":") @@ -307,13 +308,17 @@ class JSON(resource.Resource): self._connect(*host[1:]).addCallback(on_connected) return d - def update_ui(self, keys, filter_dict, cache_id=None): + def connected(self): + d = Deferred() + d.callback(client.connected()) + return d + + def update_ui(self, keys, filter_dict): ui_info = { "torrents": None, "filters": None, - "stats": None, - "cache_id": -1 + "stats": None } d = Deferred()