fix adding hosts and clearing the form after changing password to _password
This commit is contained in:
parent
0e94c31ca2
commit
3f8ef6c66e
|
@ -52,14 +52,14 @@ Deluge.Connections = {
|
||||||
var host = form.items.get('host').getValue();
|
var host = form.items.get('host').getValue();
|
||||||
var port = form.items.get('port').getValue();
|
var port = form.items.get('port').getValue();
|
||||||
var username = form.items.get('username').getValue();
|
var username = form.items.get('username').getValue();
|
||||||
var password = form.items.get('password').getValue();
|
var password = form.items.get('_password').getValue();
|
||||||
|
|
||||||
Deluge.Client.web.add_host(host, port, username, password, {
|
Deluge.Client.web.add_host(host, port, username, password, {
|
||||||
onSuccess: function(result) {
|
onSuccess: function(result) {
|
||||||
if (!result) {
|
if (!result[0]) {
|
||||||
Ext.MessageBox.show({
|
Ext.MessageBox.show({
|
||||||
title: _('Error'),
|
title: _('Error'),
|
||||||
msg: "Unable to add host",
|
msg: "Unable to add host: " + result[1],
|
||||||
buttons: Ext.MessageBox.OK,
|
buttons: Ext.MessageBox.OK,
|
||||||
modal: false,
|
modal: false,
|
||||||
icon: Ext.MessageBox.ERROR,
|
icon: Ext.MessageBox.ERROR,
|
||||||
|
@ -79,7 +79,7 @@ Deluge.Connections = {
|
||||||
form.items.get('host').reset();
|
form.items.get('host').reset();
|
||||||
form.items.get('port').reset();
|
form.items.get('port').reset();
|
||||||
form.items.get('username').reset();
|
form.items.get('username').reset();
|
||||||
form.items.get('password').reset();
|
form.items.get('_password').reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
onClose: function(e) {
|
onClose: function(e) {
|
||||||
|
|
|
@ -480,14 +480,20 @@ class WebApi(JSONComponent):
|
||||||
# if thats the case
|
# if thats the case
|
||||||
for entry in self.host_list["hosts"]:
|
for entry in self.host_list["hosts"]:
|
||||||
if (entry[0], entry[1], entry[2]) == (host, port, username):
|
if (entry[0], entry[1], entry[2]) == (host, port, username):
|
||||||
d.callback(False)
|
d.callback((False, "Host already in the list"))
|
||||||
|
|
||||||
|
try:
|
||||||
|
port = int(port)
|
||||||
|
except:
|
||||||
|
d.callback((False, "Port is invalid"))
|
||||||
|
return d
|
||||||
|
|
||||||
# Host isn't in the list, so lets add it
|
# Host isn't in the list, so lets add it
|
||||||
connection_id = hashlib.sha1(str(time.time())).hexdigest()
|
connection_id = hashlib.sha1(str(time.time())).hexdigest()
|
||||||
self.host_list["hosts"].append([connection_id, host, port, username,
|
self.host_list["hosts"].append([connection_id, host, port, username,
|
||||||
password])
|
password])
|
||||||
self.host_list.save()
|
self.host_list.save()
|
||||||
d.callback(True)
|
d.callback((True,))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@export
|
@export
|
||||||
|
|
Loading…
Reference in New Issue