improved aria2 connection settings handling in angular
This commit is contained in:
parent
cc9e33f5bc
commit
9e63fa2ff6
|
@ -16,7 +16,7 @@ angular.module('webui.ctrls.alert', [
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var ind = scope.pendingAlerts.indexOf(obj);
|
var ind = scope.pendingAlerts.indexOf(obj);
|
||||||
if (ind != -1) scope.removeAlert(ind);
|
if (ind != -1) scope.removeAlert(ind);
|
||||||
}, 5000);
|
}, 10000);
|
||||||
|
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
});
|
});
|
||||||
|
|
|
@ -87,7 +87,7 @@ angular
|
||||||
conf: {
|
conf: {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 6800,
|
port: 6800,
|
||||||
encrypt: true,
|
encrypt: false,
|
||||||
auth: {
|
auth: {
|
||||||
user: '',
|
user: '',
|
||||||
pass: ''
|
pass: ''
|
||||||
|
|
|
@ -64,6 +64,7 @@ angular
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
rpc.ariaRequest(
|
rpc.ariaRequest(
|
||||||
authUrl,
|
authUrl,
|
||||||
|
opts.name,
|
||||||
opts.params,
|
opts.params,
|
||||||
opts.success,
|
opts.success,
|
||||||
function() {
|
function() {
|
||||||
|
|
|
@ -24,13 +24,22 @@ function(_, JSON, name, utils, alerts) {
|
||||||
scheme: 'ws',
|
scheme: 'ws',
|
||||||
|
|
||||||
// called when a connection error occurs
|
// called when a connection error occurs
|
||||||
onerror: function(err) {
|
onerror: function(ev) {
|
||||||
_.each(sockRPC.handles, function(h) { h.error() });
|
_.each(sockRPC.handles, function(h) { h.error() });
|
||||||
sockRPC.handles = [];
|
sockRPC.handles = [];
|
||||||
|
sockRPC.initialized = false;
|
||||||
|
alerts.log('Error while talking to aria2 over websocket');
|
||||||
|
|
||||||
|
},
|
||||||
|
onclose: function(ev) {
|
||||||
|
if (sockRPC.handles && sockRPC.handles.length)
|
||||||
|
sockRPC.onerror('Connection reset while pending calls to aria2');
|
||||||
|
sockRPC.initialized = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// when connection opens
|
// when connection opens
|
||||||
onopen: function() {
|
onopen: function() {
|
||||||
|
alerts.addAlert('Connected to aria2 successfully over websocket!', 'success');
|
||||||
sockRPC.initialized = true;
|
sockRPC.initialized = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -82,14 +91,15 @@ function(_, JSON, name, utils, alerts) {
|
||||||
sockRPC.scheme = sockRPC.conf.encrypt ? 'wss' : 'ws';
|
sockRPC.scheme = sockRPC.conf.encrypt ? 'wss' : 'ws';
|
||||||
|
|
||||||
if (sockRPC.sock) {
|
if (sockRPC.sock) {
|
||||||
sockRPC.onopen = sockRPC.sock.onmessage = sockRPC.sock.onerror = sockRPC.sock.onclose = null;
|
sockRPC.sock.onopen = sockRPC.sock.onmessage = sockRPC.sock.onerror = sockRPC.sock.onclose = null;
|
||||||
sockRPC.onerror();
|
sockRPC.onerror({message: 'Changing the websocket aria2 server details'});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sockRPC.sock = new WebSocket(sockRPC.scheme + '://' + conf.host + ':' + conf.port + '/jsonrpc');
|
sockRPC.sock = new WebSocket(sockRPC.scheme + '://' + conf.host + ':' + conf.port + '/jsonrpc');
|
||||||
sockRPC.sock.onopen = sockRPC.onopen;
|
sockRPC.sock.onopen = sockRPC.onopen;
|
||||||
sockRPC.sock.onclose = sockRPC.sock.onerror = sockRPC.onerror;
|
sockRPC.sock.onclose = sockRPC.onclose;
|
||||||
|
sockRPC.sock.onerror = sockRPC.onerror;
|
||||||
sockRPC.sock.onmessage = sockRPC.onmessage;
|
sockRPC.sock.onmessage = sockRPC.onmessage;
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ function(log, jsonRPC, sockRPC, alerts) {
|
||||||
return sockRPC.invoke(opts);
|
return sockRPC.invoke(opts);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
console.log('calling json rpc');
|
||||||
return jsonRPC.invoke(opts);
|
return jsonRPC.invoke(opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user