global settings partially working in angular
This commit is contained in:
parent
1a3ddf5089
commit
30ae20260f
34
angular.html
34
angular.html
|
@ -304,7 +304,7 @@
|
|||
<!--{{{ add new Download template -->
|
||||
<div class="modal hide modal-adduris" modal="getUris.shown">
|
||||
<div class="modal-header">
|
||||
<button class="close" ng-click="getUris.shown = false">x</button>
|
||||
<button class="close" ng-click="getUris.close()">x</button>
|
||||
<h3>Add Downloads By URIs</h3>
|
||||
</div>
|
||||
<form class="modal-body">
|
||||
|
@ -337,8 +337,8 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
</fieldset>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" ng-click="getUris.shown = false">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getUris.finish()">Start</button>
|
||||
<button class="btn" ng-click="getUris.close()">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getUris.success()">Start</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- }}} -->
|
||||
|
@ -346,7 +346,7 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
<!-- {{{ add new torrent -->
|
||||
<div class="modal hide" modal="getTorrents.shown">
|
||||
<div class="modal-header">
|
||||
<button class="close" ng-click="getTorrents.shown = false">x</button>
|
||||
<button class="close" ng-click="getTorrents.close()">x</button>
|
||||
<h3>Add Downloads By Torrents</h3>
|
||||
</div>
|
||||
<form class="modal-body">
|
||||
|
@ -363,8 +363,8 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
</fieldset>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" ng-click="getTorrents.shown = false">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getTorrents.finish()">Start</button>
|
||||
<button class="btn" ng-click="getTorrents.close()">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getTorrents.success()">Start</button>
|
||||
</div>
|
||||
</div
|
||||
<!-- }}} -->
|
||||
|
@ -372,7 +372,7 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
<!-- {{{ add new metalink -->
|
||||
<div class="modal hide" modal="getMetalinks.shown">
|
||||
<div class="modal-header">
|
||||
<button class="close" ng-click="getMetalinks.shown = false">x</button>
|
||||
<button class="close" ng-click="getMetalinks.close()">x</button>
|
||||
<h3>Add Downloads By Metalinks</h3>
|
||||
</div>
|
||||
<form class="modal-body">
|
||||
|
@ -387,8 +387,8 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
</fieldset>
|
||||
</form>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" ng-click="getMetalinks.shown = false">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getMetalinks.finish()">Start</button>
|
||||
<button class="btn" ng-click="getMetalinks.close()">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="getMetalinks.success()">Start</button>
|
||||
</div>
|
||||
</div
|
||||
<!-- }}} -->
|
||||
|
@ -396,7 +396,7 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
<!-- {{{ global settings -->
|
||||
<div class="modal hide" modal="globalSettings.shown">
|
||||
<div class="modal-header">
|
||||
<button class="close" ng-click="globalSettings.shown = false">x</button>
|
||||
<button class="close" ng-click="globalSettings.close()">x</button>
|
||||
<h3>Global Settings</h3>
|
||||
</div>
|
||||
|
||||
|
@ -404,16 +404,14 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
<fieldset>
|
||||
<legend>Global Settings</legend>
|
||||
<div class="control-group">
|
||||
<div ng-repeat="(name, val) in globalSettings.settings">
|
||||
<div ng-repeat="(name, set) in globalSettings.settings">
|
||||
<label class="control-label">{{name}}</label>
|
||||
|
||||
<div class="controls">
|
||||
<select ng-show="val.options.length">
|
||||
<option ng-repeat="opt in val.options" value="{{opt}}">{{opt}}</option>
|
||||
<select ng-show="set.options.length" ng-options="opt for opt in set.options" ng-model="set.val">
|
||||
</select>
|
||||
<input ng-show="!val.options.length" typ="text" class="input-xlarge" placeholder="{{val.val}}"/>
|
||||
|
||||
<p class="help-block">{{val.desc}}</p>
|
||||
<input ng-show="!set.options.length" typ="text" class="input-xlarge" ng-model="set.val"/>
|
||||
<p class="help-block">{{set.desc}}</p>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
|
@ -422,8 +420,8 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
</form>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn" ng-click="globalSettings.shown = false">Cancel</button>
|
||||
<button class="btn btn-primary">Save</button>
|
||||
<button class="btn" ng-click="globalSettings.close()">Cancel</button>
|
||||
<button class="btn btn-success" ng-click="globalSettings.success()">Save</button>
|
||||
</div>
|
||||
</div
|
||||
<!-- }}} -->
|
||||
|
|
|
@ -30,8 +30,8 @@ angular
|
|||
'webui.services.settings'
|
||||
])
|
||||
.controller('ModalCtrl', [
|
||||
'$_', '$scope', '$rpc', '$modals', '$settings',
|
||||
function(_, scope, rpc, modals, settings) {
|
||||
'$_', '$scope', '$rpc', '$modals',
|
||||
function(_, scope, rpc, modals) {
|
||||
|
||||
scope.getUris = {
|
||||
shown: false,
|
||||
|
@ -45,14 +45,18 @@ angular
|
|||
.filter(function(d) { return d.length })
|
||||
.value();
|
||||
},
|
||||
finish: function() {
|
||||
success: function() {
|
||||
var uris = this.parse();
|
||||
this.uris = '';
|
||||
|
||||
if (this.cb) this.cb(uris);
|
||||
|
||||
this.close();
|
||||
|
||||
},
|
||||
close: function() {
|
||||
this.shown = this.open = false;
|
||||
this.cb = null;
|
||||
this.shown = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -62,16 +66,19 @@ angular
|
|||
init: function(cb) { this.shown = true; this.cb = cb },
|
||||
|
||||
files: [],
|
||||
finish: function() {
|
||||
success: function() {
|
||||
var self = this;
|
||||
console.log('parsing files');
|
||||
parseFiles(self.files, function(txts) {
|
||||
console.log('calling cb', this.cb);
|
||||
if (self.cb) self.cb(txts);
|
||||
|
||||
self.cb = null;
|
||||
self.shown = false;
|
||||
self.close();
|
||||
});
|
||||
},
|
||||
close: function() {
|
||||
this.cb = null;
|
||||
this.shown = false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -79,26 +86,18 @@ angular
|
|||
scope.globalSettings = {
|
||||
shown: false,
|
||||
settings: [],
|
||||
init: function(cb) {
|
||||
var self = this;
|
||||
self.cb = cb;
|
||||
|
||||
rpc.once('getGlobalOption', [], function(data) {
|
||||
var vals = data[0];
|
||||
for (var i in vals) {
|
||||
if (!(i in data)) {
|
||||
data.push({ name: i, val: vals[i], desc: '' });
|
||||
}
|
||||
else data[i].val = vals[i];
|
||||
}
|
||||
console.log(vals);
|
||||
self.shown = true;
|
||||
});
|
||||
|
||||
self.settings = settings;
|
||||
init: function(settings, cb) {
|
||||
this.cb = cb;
|
||||
this.settings = settings;
|
||||
this.shown = true;
|
||||
},
|
||||
finish: function() {
|
||||
|
||||
success: function() {
|
||||
if (this.cb) this.cb(this.settings);
|
||||
this.close();
|
||||
},
|
||||
close: function() {
|
||||
this.cb = null;
|
||||
this.shown = this.open = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -107,14 +106,13 @@ angular
|
|||
'globalSettings'
|
||||
], function(name) {
|
||||
modals.register(name, function(cb) {
|
||||
if (scope[name].open) {
|
||||
if (scope[name].open && scope[name].cb) {
|
||||
// modal already shown, user is busy
|
||||
// TODO: get a better method of passing this info
|
||||
cb([]);
|
||||
}
|
||||
else {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
console.log('setting cb for ', name, cb);
|
||||
scope[name].open = true;
|
||||
scope[name].init.apply(scope[name], args);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
angular
|
||||
.module('webui.ctrls.nav', [
|
||||
'webui.services.constants', 'webui.services.modals',
|
||||
'webui.services.rpc.helpers'
|
||||
'webui.services.rpc', 'webui.services.rpc.helpers',
|
||||
'webui.services.settings'
|
||||
])
|
||||
.controller('NavCtrl', [
|
||||
'$scope', '$name', '$modals', '$rpchelpers',
|
||||
function(scope, name, modals, rhelpers) {
|
||||
'$scope', '$name', '$modals', '$rpc', '$rpchelpers', '$settings',
|
||||
function(scope, name, modals, rpc, rhelpers, settings) {
|
||||
|
||||
scope.name = name;
|
||||
|
||||
|
@ -37,8 +38,23 @@ angular
|
|||
};
|
||||
|
||||
scope.changeGSettings = function() {
|
||||
modals.invoke('globalSettings', function() {
|
||||
alert('closing dialog');
|
||||
rpc.once('getGlobalOption', [], function(data) {
|
||||
var vals = data[0];
|
||||
for (var i in vals) {
|
||||
if (!(i in settings)) {
|
||||
settings[i] = { name: i, val: vals[i], desc: '' };
|
||||
}
|
||||
else {
|
||||
settings[i].val = vals[i];
|
||||
}
|
||||
}
|
||||
|
||||
modals.invoke('globalSettings', settings, function(settings) {
|
||||
var sets = {};
|
||||
for (var i in settings) { sets[i] = settings[i].val };
|
||||
|
||||
rpc.once('changeGlobalOption', [sets]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ angular.module('webui.services.settings', [])
|
|||
},
|
||||
|
||||
"bt-prioritize-piece": {
|
||||
val: '1M',
|
||||
val: '',
|
||||
desc: "Try to download first and last pieces of each file first. This is useful for previewing files. The argument can contain 2 keywords: head and tail. To include both keywords, they must be separated by comma. These keywords can take one parameter, SIZE. For example, if head=<SIZE> is specified, pieces in the range of first SIZE bytes of each file get higher priority. tail=<SIZE> means the range of last SIZE bytes of each file. SIZE can include K or M (1K = 1024, 1M = 1024K). If SIZE is omitted, SIZE=1M is used."
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user