added select files feature
This commit is contained in:
parent
091fbb0d41
commit
b12247580e
40
index.html
40
index.html
|
@ -382,6 +382,13 @@
|
|||
<i class="fa fa-fw fa-stop"></i>
|
||||
</button>
|
||||
|
||||
<button
|
||||
ng-show="hasStatus(download, 'paused')"
|
||||
class="btn"
|
||||
ng-click="selectFiles(download)">
|
||||
<i class="fa fa-fw fa-list"></i>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn hidden-phone"
|
||||
ng-show="['waiting', 'active'].indexOf( getType(download) )!= -1"
|
||||
|
@ -582,7 +589,7 @@
|
|||
<li class="label" title="Download Path"><i class="fa fa-fw fa-folder-open"> </i> <span class="download-dir">{{download.dir}}</span></li>
|
||||
</ul>
|
||||
<ul class="download-files hidden-phone download-item">
|
||||
<li class="label" ng-repeat="file in download.files">{{file.relpath}} ({{file.fmtLength}})</li>
|
||||
<li class="label" ng-repeat="file in download.files" ng-class="{'label-success': file.selected}">{{file.relpath}} ({{file.fmtLength}})</li>
|
||||
</ul>
|
||||
<div ng-show="hasStatus(download, 'active')" class="download-item hidden-phone">
|
||||
<div class="download-graph" dspeed="download.downloadSpeed" uspeed="download.uploadSpeed" xticks="7" yticks="7" dgraph draw="!download.collapsed"></div>
|
||||
|
@ -842,6 +849,37 @@ http://ex1.com/f2.mp4 http://ex2.com/f2.mp4
|
|||
</script>
|
||||
<!-- }}} -->
|
||||
|
||||
<!-- {{{ select file modal -->
|
||||
<script type="text/ng-template" id="selectFiles.html">
|
||||
<div class="modal-header">
|
||||
<button class="close" ng-click="$dismiss()">x</button>
|
||||
<h3>Choose files to start download for</h3>
|
||||
</div>
|
||||
|
||||
<form class="form-horizontal modal-body">
|
||||
<fieldset>
|
||||
<div class="control-group">
|
||||
<div ng-repeat="file in selectFiles.files">
|
||||
<label class="control-label">Select to download </label>
|
||||
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" ng-model="file.selected"/>{{file.relpath}}
|
||||
</label>
|
||||
</div>
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn" ng-click="$dismiss()">Cancel</button>
|
||||
<button class="btn btn-primary" ng-click="$close()">Choose</button>
|
||||
</div>
|
||||
</script>
|
||||
<!-- }}} -->
|
||||
|
||||
<!-- {{{ settings modal -->
|
||||
<script type="text/ng-template" id="settings.html">
|
||||
<div class="modal-header">
|
||||
|
|
|
@ -415,6 +415,7 @@ function(
|
|||
var cfile = cfiles[i] || (cfiles[i] = {});
|
||||
var file = files[i];
|
||||
if (file.path !== cfile.path) {
|
||||
cfile.index = +file.index;
|
||||
cfile.path = file.path;
|
||||
cfile.length = file.length;
|
||||
cfile.fmtLength = utils.fmtsize(file.length);
|
||||
|
@ -426,6 +427,7 @@ function(
|
|||
cfile.relpath = cfile.relpath.substr(ctx.dir.length + 1);
|
||||
}
|
||||
}
|
||||
cfile.selected = (file.selected === "true");
|
||||
}
|
||||
cfiles.length = files.length;
|
||||
if (cfiles.length) {
|
||||
|
@ -506,6 +508,23 @@ function(
|
|||
return type;
|
||||
};
|
||||
|
||||
scope.selectFiles = function(d) {
|
||||
console.log('got back files for the torrent ...');
|
||||
modals.invoke('selectFiles', d.files, function(files) {
|
||||
var indexes = "";
|
||||
_.forEach(files, function(f) {
|
||||
if (f.selected) {
|
||||
indexes += "," + f.index;
|
||||
}
|
||||
});
|
||||
|
||||
indexes = indexes.slice(1);
|
||||
rpc.once('changeOption', [d.gid, {'select-file': indexes}], function(res) {
|
||||
console.log('changed indexes to:', indexes, res);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
scope.showSettings = function(d) {
|
||||
var type = scope.getType(d)
|
||||
, settings = {};
|
||||
|
|
|
@ -107,6 +107,30 @@ angular
|
|||
}
|
||||
};
|
||||
|
||||
scope.selectFiles = {
|
||||
open: function(files, cb) {
|
||||
var self = this;
|
||||
|
||||
this.files = _.cloneDeep(files);
|
||||
this.inst = $modal.open({
|
||||
templateUrl: "selectFiles.html",
|
||||
scope: scope,
|
||||
windowClass: "modal-large"
|
||||
});
|
||||
|
||||
this.inst.result.then(function() {
|
||||
delete self.inst;
|
||||
|
||||
if (cb) {
|
||||
cb(self.files);
|
||||
}
|
||||
},
|
||||
function() {
|
||||
delete self.inst;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
scope.connection = {
|
||||
open: function(defaults, cb) {
|
||||
var self = this;
|
||||
|
@ -118,6 +142,7 @@ angular
|
|||
scope: scope,
|
||||
windowClass: "modal-large",
|
||||
});
|
||||
|
||||
this.inst.result.then(function() {
|
||||
delete self.inst;
|
||||
if (cb) {
|
||||
|
@ -150,6 +175,7 @@ angular
|
|||
scope: scope,
|
||||
windowClass: "modal-large",
|
||||
});
|
||||
|
||||
this.inst.result.then(function() {
|
||||
delete self.inst;
|
||||
if (cb) {
|
||||
|
@ -201,7 +227,7 @@ angular
|
|||
});
|
||||
|
||||
_.each([
|
||||
'getUris', 'getTorrents', 'getMetalinks',
|
||||
'getUris', 'getTorrents', 'getMetalinks', 'selectFiles',
|
||||
'settings', 'connection', 'server_info', 'about'
|
||||
], function(name) {
|
||||
modals.register(name, function() {
|
||||
|
|
|
@ -46,21 +46,15 @@ angular
|
|||
);
|
||||
};
|
||||
|
||||
scope.addTorrents = function() {
|
||||
modals.invoke(
|
||||
'getTorrents', _.bind(rhelpers.addTorrents, rhelpers)
|
||||
);
|
||||
};
|
||||
|
||||
scope.addMetalinks = function() {
|
||||
modals.invoke(
|
||||
'getMetalinks', _.bind(rhelpers.addMetalinks, rhelpers)
|
||||
);
|
||||
};
|
||||
|
||||
scope.addTorrent = function() {
|
||||
scope.addTorrents = function() {
|
||||
modals.invoke(
|
||||
'getTorrent', _.bind(rhelpers.addTorrents, rhelpers)
|
||||
'getTorrents', _.bind(rhelpers.addTorrents, rhelpers)
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -11,28 +11,28 @@ angular.module('webui.services.rpc.helpers', [
|
|||
getAria2Version: function() {
|
||||
return miscellaneous.version;
|
||||
},
|
||||
addUris: function(uris, settings) {
|
||||
addUris: function(uris, settings, cb) {
|
||||
_.each(uris, function(uri) {
|
||||
// passing true to batch all the addUri calls
|
||||
rpc.once('addUri', [uri, settings], angular.noop, true);
|
||||
rpc.once('addUri', [uri, settings], cb, true);
|
||||
});
|
||||
|
||||
// now dispatch all addUri syscalls
|
||||
rpc.forceUpdate();
|
||||
},
|
||||
addTorrents: function(txts, settings) {
|
||||
addTorrents: function(txts, settings, cb) {
|
||||
_.each(txts, function(txt) {
|
||||
// passing true to batch all the addUri calls
|
||||
rpc.once('addTorrent', [txt, [], settings], angular.noop, true);
|
||||
rpc.once('addTorrent', [txt, [], settings], cb, true);
|
||||
});
|
||||
|
||||
// now dispatch all addUri syscalls
|
||||
rpc.forceUpdate();
|
||||
},
|
||||
addMetalinks: function(txts, settings) {
|
||||
addMetalinks: function(txts, settings, cb) {
|
||||
_.each(txts, function(txt) {
|
||||
// passing true to batch all the addUri calls
|
||||
rpc.once('addMetalink', [txt, settings], angular.noop, true);
|
||||
rpc.once('addMetalink', [txt, settings], cb, true);
|
||||
});
|
||||
|
||||
// now dispatch all addUri syscalls
|
||||
|
|
Loading…
Reference in New Issue
Block a user