can change aria2 connection settings in angular implementation, cookie caching and error handling still missing
This commit is contained in:
parent
96fb34cb73
commit
0060d884d3
23
angular.html
23
angular.html
|
@ -632,7 +632,9 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
<label class="control-label">Enter the host:</label>
|
<label class="control-label">Enter the host:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="input-prepend">
|
<div class="input-prepend">
|
||||||
<span class="add-on">http(s)://</span><input type="text" class="input-xlarge"/>
|
<span class="add-on">http(s)://</span>
|
||||||
|
<input type="text" class="input-xlarge"
|
||||||
|
ng-model="connection.conf.host"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Enter the ip or dns name of the server on which the
|
Enter the ip or dns name of the server on which the
|
||||||
|
@ -643,8 +645,7 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
<label class="control-label">Enter the port:</label>
|
<label class="control-label">Enter the port:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xlarge"
|
<input type="text" class="input-xlarge"
|
||||||
ng-model="connection.port"
|
ng-model="connection.conf.port"/>
|
||||||
placeholder="{{connection.port}}"/>
|
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Enter the port of the server on which the rpc for
|
Enter the port of the server on which the rpc for
|
||||||
aria2 is running (default = 6800)
|
aria2 is running (default = 6800)
|
||||||
|
@ -653,14 +654,17 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
|
|
||||||
<label class="control-label">SSL/TLS encryption:</label>
|
<label class="control-label">SSL/TLS encryption:</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<button type="button" class="btn" data-toggle="button">ON</button>
|
<input type="checkbox"
|
||||||
|
ng-model="connection.conf.encrypt">
|
||||||
|
Enable encryption connection to aria2
|
||||||
|
</input>
|
||||||
<p class="help-block">Enable SSL/TLS encryption.</p>
|
<p class="help-block">Enable SSL/TLS encryption.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="control-label">Enter the username (optional):</label>
|
<label class="control-label">Enter the username (optional):</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xlarge"
|
<input type="text" class="input-xlarge"
|
||||||
ng-model="connection.auth.user"/>
|
ng-model="connection.conf.auth.user"/>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Enter the aria2 RPC username
|
Enter the aria2 RPC username
|
||||||
(empty if authentication not enabled)
|
(empty if authentication not enabled)
|
||||||
|
@ -670,7 +674,7 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
<label class="control-label">Enter the password (optional):</label>
|
<label class="control-label">Enter the password (optional):</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="password" class="input-xlarge"
|
<input type="password" class="input-xlarge"
|
||||||
ng-model="connection.auth.pass"/>
|
ng-model="connection.conf.auth.pass"/>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Enter the aria2 RPC password
|
Enter the aria2 RPC password
|
||||||
(empty if authentication not enabled)
|
(empty if authentication not enabled)
|
||||||
|
@ -681,8 +685,11 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button href="#" class="btn" ng-click="connection.close()">Retry with default configuration</button>
|
<button href="#" class="btn" ng-click="connection.close()">Cancel</button>
|
||||||
<button href="#" class="btn btn-primary" ng-click="connection.close()">Use custom IP and port settings</button>
|
<button href="#"
|
||||||
|
class="btn btn-primary" ng-click="connection.success()">
|
||||||
|
Save Connection configuration
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- }}} -->
|
<!-- }}} -->
|
||||||
|
|
|
@ -13,12 +13,10 @@ angular.module('webui.ctrls.alert', [
|
||||||
var obj = { msg: msg, type: type };
|
var obj = { msg: msg, type: type };
|
||||||
scope.pendingAlerts.push(obj);
|
scope.pendingAlerts.push(obj);
|
||||||
|
|
||||||
/*
|
|
||||||
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);
|
}, 5000);
|
||||||
*/
|
|
||||||
|
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,11 +84,14 @@ angular
|
||||||
scope.connection = {
|
scope.connection = {
|
||||||
shown: false,
|
shown: false,
|
||||||
|
|
||||||
host: 'localhost',
|
conf: {
|
||||||
port: 6800,
|
host: 'localhost',
|
||||||
auth: {
|
port: 6800,
|
||||||
user: '',
|
encrypt: true,
|
||||||
pass: ''
|
auth: {
|
||||||
|
user: '',
|
||||||
|
pass: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
init: function(defaults, cb) {
|
init: function(defaults, cb) {
|
||||||
|
@ -96,10 +99,15 @@ angular
|
||||||
this.open = this.shown = true;
|
this.open = this.shown = true;
|
||||||
},
|
},
|
||||||
success: function() {
|
success: function() {
|
||||||
|
console.log(this);
|
||||||
|
|
||||||
|
if (this.cb) {
|
||||||
|
this.cb(this.conf);
|
||||||
|
}
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
close: function() {
|
close: function() {
|
||||||
if (this.cb) this.cb();
|
|
||||||
this.cb = null;
|
this.cb = null;
|
||||||
this.open = this.shown = false;
|
this.open = this.shown = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ angular
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.changeCSettings = function() {
|
scope.changeCSettings = function() {
|
||||||
modals.invoke('connection', {}, function(data) {
|
modals.invoke(
|
||||||
console.log('connection modal closed, got back the follwing data', data);
|
'connection', rpc.getConfiguration(), _.bind(rpc.configure, rpc)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.changeGSettings = function() {
|
scope.changeGSettings = function() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ angular
|
||||||
},
|
},
|
||||||
invoke: function(opts) {
|
invoke: function(opts) {
|
||||||
var rpc = this;
|
var rpc = this;
|
||||||
var scheme = rpc.serverConf.encryption ? 'https' : 'http';
|
var scheme = rpc.serverConf.encrypt ? 'https' : 'http';
|
||||||
rpc.ariaRequest(
|
rpc.ariaRequest(
|
||||||
scheme + '://' + rpc.serverConf.host + ':' + rpc.serverConf.port + '/jsonrpc',
|
scheme + '://' + rpc.serverConf.host + ':' + rpc.serverConf.port + '/jsonrpc',
|
||||||
opts.name,
|
opts.name,
|
||||||
|
@ -66,7 +66,10 @@ angular
|
||||||
authUrl,
|
authUrl,
|
||||||
opts.params,
|
opts.params,
|
||||||
opts.success,
|
opts.success,
|
||||||
opts.error
|
function() {
|
||||||
|
console.log("jsonrpc disconnect!!!");
|
||||||
|
return opts.error();
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}, rpc.avgTimeout);
|
}, rpc.avgTimeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ angular
|
||||||
function(syscall, time, alerts) {
|
function(syscall, time, alerts) {
|
||||||
|
|
||||||
var subscriptions = []
|
var subscriptions = []
|
||||||
, configurations = [{ host: 'localhost', port: 6800 }]
|
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
|
||||||
, currentConf = {}
|
, currentConf = {}
|
||||||
, timeout = null
|
, timeout = null
|
||||||
, forceNextUpdate = false;
|
, forceNextUpdate = false;
|
||||||
|
@ -40,7 +40,6 @@ function(syscall, time, alerts) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
syscall.invoke({
|
syscall.invoke({
|
||||||
name: 'system.multicall',
|
name: 'system.multicall',
|
||||||
params: [params],
|
params: [params],
|
||||||
|
@ -96,11 +95,18 @@ function(syscall, time, alerts) {
|
||||||
// each one will be tried one after the other till success,
|
// each one will be tried one after the other till success,
|
||||||
// for all options for one conf read rpc/syscall.js
|
// for all options for one conf read rpc/syscall.js
|
||||||
configure: function(conf) {
|
configure: function(conf) {
|
||||||
|
alerts.addAlert('Successfully changed aria2 connection configuration', 'success');
|
||||||
|
|
||||||
if (conf instanceof Array)
|
if (conf instanceof Array)
|
||||||
configurations = conf;
|
configurations = conf;
|
||||||
else
|
else
|
||||||
configurations = [conf];
|
configurations = [conf];
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// get current configuration being used
|
||||||
|
getConfiguration: function() { return currentConf },
|
||||||
|
|
||||||
// syscall is done only once, delay is optional
|
// syscall is done only once, delay is optional
|
||||||
// and pass true to only dispatch it in the global timeout
|
// and pass true to only dispatch it in the global timeout
|
||||||
// which can be used to batch up once calls
|
// which can be used to batch up once calls
|
||||||
|
|
|
@ -79,7 +79,7 @@ function(_, JSON, name, utils, alerts) {
|
||||||
}
|
}
|
||||||
sockRPC.conf = conf || sockRPC.conf;
|
sockRPC.conf = conf || sockRPC.conf;
|
||||||
|
|
||||||
sockRPC.scheme = sockRPC.conf.encryption ? '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.onopen = sockRPC.sock.onmessage = sockRPC.sock.onerror = sockRPC.sock.onclose = null;
|
||||||
|
|
|
@ -11,7 +11,7 @@ function(log, jsonRPC, sockRPC, alerts) {
|
||||||
// {
|
// {
|
||||||
// host (string): host for the aria2 server
|
// host (string): host for the aria2 server
|
||||||
// port (number): port number for the aria2 server
|
// port (number): port number for the aria2 server
|
||||||
// encryption (boolean, optional): true if encryption is enabled in the aria2 server
|
// encrypt (boolean, optional): true if encryption is enabled in the aria2 server
|
||||||
// auth (optional): {
|
// auth (optional): {
|
||||||
// user (string): username for http authentication if enabled
|
// user (string): username for http authentication if enabled
|
||||||
// pass (string): password for the http authentication if enabled
|
// pass (string): password for the http authentication if enabled
|
||||||
|
@ -22,7 +22,7 @@ function(log, jsonRPC, sockRPC, alerts) {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 6800
|
port: 6800
|
||||||
};
|
};
|
||||||
conf.encryption = conf.encryption || false;
|
conf.encrypt = conf.encrypt || false;
|
||||||
|
|
||||||
jsonRPC.init(conf);
|
jsonRPC.init(conf);
|
||||||
sockRPC.init(conf);
|
sockRPC.init(conf);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user