Changeset 1ff29a


Ignore:
Timestamp:
02/16/2009 11:27:12 PM (16 years ago)
Author:
Damien Churchill <damoc@gmail.com>
Branches:
2.0.x, develop, extjs4-port, master
Children:
cc272d
Parents:
b6dee7
Message:

more improvements to the connection manager, ui actually starts running after a connect now.

Location:
deluge/ui/web
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • deluge/ui/web/js/deluge-connections.js

    rb6dee7 r1ff29a  
    22    onClose: function(e) {
    33                $clear(Deluge.Connections.running);
     4                Deluge.Connections.Window.hide();
    45    },
    56   
    67    onConnect: function(e) {
     8                $clear(Deluge.Connections.running);
     9                Deluge.Connections.Window.hide();
     10                var selected = Deluge.Connections.Grid.getSelectionModel().getSelected();
     11                var id = selected.id;
     12                Deluge.Client.web.connect(id, {
     13                        onSuccess: function(methods) {
     14                                Deluge.Client = new JSON.RPC('/json', {
     15                                        methods: methods
     16                                });
     17                                Deluge.Ui.run();
     18                        }
     19                });
    720    },
     21       
     22        onSelect: function(selModel, rowIndex, record) {
     23                Deluge.Connections.selectedRow = rowIndex;
     24        },
    825       
    926        onShow: function(window) {
     
    2037        onGetHosts: function(hosts) {
    2138                Deluge.Connections.Store.loadData(hosts);
     39                var selection = Deluge.Connections.Grid.getSelectionModel();
     40                selection.selectRow(Deluge.Connections.selectedRow);
    2241        }
    2342}
     
    2948                {name: 'port', mapping: 2},
    3049                {name: 'version', mapping: 6}
    31         ]
     50        ],
     51        id: 0
    3252});
    3353
     
    4565        ],     
    4666        stripeRows: true,
     67        selModel: new Ext.grid.RowSelectionModel({
     68                singleSelect: true,
     69                listeners: {'rowselect': Deluge.Connections.onSelect}
     70        }),
    4771        autoExpandColumn: 'host',
    4872        deferredRender:false,
     
    7094    }],
    7195        listeners: {
     96                'hide': Deluge.Connections.onClose,
    7297                'show': Deluge.Connections.onShow
    7398        }
  • deluge/ui/web/js/deluge-ui.js

    rb6dee7 r1ff29a  
    6868                });
    6969                Deluge.Torrents.store.loadData(torrents);
    70                 this.updateStatusBar(data['stats']);
     70                //this.updateStatusBar(data['stats']);
    7171                this.errorCount = 0;
    7272        },
  • deluge/ui/web/server.py

    rb6dee7 r1ff29a  
    147147            "web.add_torrents": self.add_torrents,
    148148            "web.login": self.login,
    149             "web.get_hosts": self.get_hosts
     149            "web.get_hosts": self.get_hosts,
     150            "web.connect": self.connect
    150151        }
    151152        for entry in open(common.get_default_config_dir("auth")):
     
    161162            self.local_password = password
    162163   
    163     def connect(self, host="localhost", port=58846, username=None, password=None):
     164    def _connect(self, host="localhost", port=58846, username=None, password=None):
    164165        """
    165166        Connects the client to a daemon
     
    167168        username = username or self.local_username
    168169        password = password or self.local_password
    169         d = client.connect(host=host, username=username, password=password)
     170        d = Deferred()
     171        _d = client.connect(host=host, username=username, password=password)
    170172       
    171173        def on_get_methods(methods):
     
    174176            """
    175177            self._remote_methods = methods
     178            methods = list(self._remote_methods)
     179            methods.extend(self._local_methods)
     180            d.callback(methods)
    176181       
    177182        def on_client_connected(connection_id):
     
    182187            d = client.daemon.get_method_list()
    183188            d.addCallback(on_get_methods)
    184         d.addCallback(on_client_connected)
     189        _d.addCallback(on_client_connected)
     190        return d
    185191
    186192    def _exec_local(self, method, params):
     
    294300        except Exception, e:
    295301            return self._on_json_request_failed(e, request)
     302   
     303    def connect(self, host_id):
     304        d = Deferred()
     305        def on_connected(methods):
     306            d.callback(methods)
     307        for host in hostlist["hosts"]:
     308            if host_id != host[0]:
     309                continue
     310            self._connect(*host[1:]).addCallback(on_connected)
     311        return d
    296312   
    297313    def update_ui(self, keys, filter_dict, cache_id=None):
     
    407423           
    408424        def on_connect_failed(reason, host_id):
    409             print reason
     425            log.exception(reason)
    410426            hosts[host_id][5] = _("Offline")
    411427            run_check()
Note: See TracChangeset for help on using the changeset viewer.