can change aria2 connection settings in angular implementation, cookie caching and error handling still missing

This commit is contained in:
hamza zia 2013-03-09 05:35:53 +00:00
parent 96fb34cb73
commit 0060d884d3
8 changed files with 48 additions and 26 deletions

View File

@ -632,7 +632,9 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
<label class="control-label">Enter the host:</label>
<div class="controls">
<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>
<p class="help-block">
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>
<div class="controls">
<input type="text" class="input-xlarge"
ng-model="connection.port"
placeholder="{{connection.port}}"/>
ng-model="connection.conf.port"/>
<p class="help-block">
Enter the port of the server on which the rpc for
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>
<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>
</div>
<label class="control-label">Enter the username (optional):</label>
<div class="controls">
<input type="text" class="input-xlarge"
ng-model="connection.auth.user"/>
ng-model="connection.conf.auth.user"/>
<p class="help-block">
Enter the aria2 RPC username
(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>
<div class="controls">
<input type="password" class="input-xlarge"
ng-model="connection.auth.pass"/>
ng-model="connection.conf.auth.pass"/>
<p class="help-block">
Enter the aria2 RPC password
(empty if authentication not enabled)
@ -681,8 +685,11 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
</form>
</div>
<div class="modal-footer">
<button href="#" class="btn" ng-click="connection.close()">Retry with default configuration</button>
<button href="#" class="btn btn-primary" ng-click="connection.close()">Use custom IP and port settings</button>
<button href="#" class="btn" ng-click="connection.close()">Cancel</button>
<button href="#"
class="btn btn-primary" ng-click="connection.success()">
Save Connection configuration
</button>
</div>
</div>
<!-- }}} -->

View File

@ -13,12 +13,10 @@ angular.module('webui.ctrls.alert', [
var obj = { msg: msg, type: type };
scope.pendingAlerts.push(obj);
/*
setTimeout(function() {
var ind = scope.pendingAlerts.indexOf(obj);
if (ind != -1) scope.removeAlert(ind);
}, 5000);
*/
scope.$digest();
});

View File

@ -84,11 +84,14 @@ angular
scope.connection = {
shown: false,
conf: {
host: 'localhost',
port: 6800,
encrypt: true,
auth: {
user: '',
pass: ''
}
},
init: function(defaults, cb) {
@ -96,10 +99,15 @@ angular
this.open = this.shown = true;
},
success: function() {
console.log(this);
if (this.cb) {
this.cb(this.conf);
}
this.close();
},
close: function() {
if (this.cb) this.cb();
this.cb = null;
this.open = this.shown = false;
}

View File

@ -58,9 +58,9 @@ angular
};
scope.changeCSettings = function() {
modals.invoke('connection', {}, function(data) {
console.log('connection modal closed, got back the follwing data', data);
});
modals.invoke(
'connection', rpc.getConfiguration(), _.bind(rpc.configure, rpc)
);
}
scope.changeGSettings = function() {

View File

@ -33,7 +33,7 @@ angular
},
invoke: function(opts) {
var rpc = this;
var scheme = rpc.serverConf.encryption ? 'https' : 'http';
var scheme = rpc.serverConf.encrypt ? 'https' : 'http';
rpc.ariaRequest(
scheme + '://' + rpc.serverConf.host + ':' + rpc.serverConf.port + '/jsonrpc',
opts.name,
@ -66,7 +66,10 @@ angular
authUrl,
opts.params,
opts.success,
opts.error
function() {
console.log("jsonrpc disconnect!!!");
return opts.error();
}
);
}, rpc.avgTimeout);
}

View File

@ -6,7 +6,7 @@ angular
function(syscall, time, alerts) {
var subscriptions = []
, configurations = [{ host: 'localhost', port: 6800 }]
, configurations = [{ host: 'localhost', port: 6800, encrypt: false }]
, currentConf = {}
, timeout = null
, forceNextUpdate = false;
@ -40,7 +40,6 @@ function(syscall, time, alerts) {
});
syscall.invoke({
name: 'system.multicall',
params: [params],
@ -96,11 +95,18 @@ function(syscall, time, alerts) {
// each one will be tried one after the other till success,
// for all options for one conf read rpc/syscall.js
configure: function(conf) {
alerts.addAlert('Successfully changed aria2 connection configuration', 'success');
if (conf instanceof Array)
configurations = conf;
else
configurations = [conf];
},
// get current configuration being used
getConfiguration: function() { return currentConf },
// syscall is done only once, delay is optional
// and pass true to only dispatch it in the global timeout
// which can be used to batch up once calls

View File

@ -79,7 +79,7 @@ function(_, JSON, name, utils, alerts) {
}
sockRPC.conf = conf || sockRPC.conf;
sockRPC.scheme = sockRPC.conf.encryption ? 'wss' : 'ws';
sockRPC.scheme = sockRPC.conf.encrypt ? 'wss' : 'ws';
if (sockRPC.sock) {
sockRPC.onopen = sockRPC.sock.onmessage = sockRPC.sock.onerror = sockRPC.sock.onclose = null;

View File

@ -11,7 +11,7 @@ function(log, jsonRPC, sockRPC, alerts) {
// {
// host (string): host 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): {
// user (string): username for http authentication if enabled
// pass (string): password for the http authentication if enabled
@ -22,7 +22,7 @@ function(log, jsonRPC, sockRPC, alerts) {
host: 'localhost',
port: 6800
};
conf.encryption = conf.encryption || false;
conf.encrypt = conf.encrypt || false;
jsonRPC.init(conf);
sockRPC.init(conf);