added select files feature

This commit is contained in:
hamza zia 2014-09-02 00:15:33 +05:00
parent 091fbb0d41
commit b12247580e
5 changed files with 666 additions and 589 deletions

View File

@ -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">&nbsp;</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">

File diff suppressed because it is too large Load Diff

View File

@ -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) {
@ -198,10 +224,10 @@ angular
rpc.once('getVersion', [], function(data) {
scope.miscellaneous = data[0];
});
});
_.each([
'getUris', 'getTorrents', 'getMetalinks',
'getUris', 'getTorrents', 'getMetalinks', 'selectFiles',
'settings', 'connection', 'server_info', 'about'
], function(name) {
modals.register(name, function() {

View File

@ -1,142 +1,136 @@
angular
.module('webui.ctrls.nav', [
'webui.services.configuration', 'webui.services.modals',
'webui.services.rpc', 'webui.services.rpc.helpers',
'webui.services.settings', 'webui.services.utils'
'webui.services.configuration', 'webui.services.modals',
'webui.services.rpc', 'webui.services.rpc.helpers',
'webui.services.settings', 'webui.services.utils'
])
.controller('NavCtrl', [
'$scope', '$modals',
'$rpc', '$rpchelpers', '$fileSettings',
'$globalSettings', '$globalExclude',
'$utils',
function(
scope, modals,
rpc, rhelpers, fsettings,
gsettings, gexclude,
utils
) {
'$scope', '$modals',
'$rpc', '$rpchelpers', '$fileSettings',
'$globalSettings', '$globalExclude',
'$utils',
function(
scope, modals,
rpc, rhelpers, fsettings,
gsettings, gexclude,
utils
) {
scope.isFeatureEnabled = function(f) { return rhelpers.isFeatureEnabled(f) };
scope.isFeatureEnabled = function(f) { return rhelpers.isFeatureEnabled(f) };
// initially collapsed in mobile resolution
scope.collapsed = true;
// initially collapsed in mobile resolution
scope.collapsed = true;
scope.onDownloadFilter = function() {
// Forward to MainCtrl.
scope.$parent.downloadFilter = scope.downloadFilter;
scope.$parent.onDownloadFilter();
};
scope.onDownloadFilter = function() {
// Forward to MainCtrl.
scope.$parent.downloadFilter = scope.downloadFilter;
scope.$parent.onDownloadFilter();
};
// manage download functions
scope.forcePauseAll = function() {
rpc.once('forcePauseAll', []);
}
// manage download functions
scope.forcePauseAll = function() {
rpc.once('forcePauseAll', []);
}
scope.purgeDownloadResult = function() {
rpc.once('purgeDownloadResult', []);
}
scope.purgeDownloadResult = function() {
rpc.once('purgeDownloadResult', []);
}
scope.unpauseAll = function() {
rpc.once('unpauseAll', []);
}
scope.unpauseAll = function() {
rpc.once('unpauseAll', []);
}
scope.addUris = function() {
modals.invoke(
'getUris', _.bind(rhelpers.addUris, rhelpers)
);
};
scope.addUris = function() {
modals.invoke(
'getUris', _.bind(rhelpers.addUris, rhelpers)
);
};
scope.addTorrents = function() {
modals.invoke(
'getTorrents', _.bind(rhelpers.addTorrents, rhelpers)
);
};
scope.addMetalinks = function() {
modals.invoke(
'getMetalinks', _.bind(rhelpers.addMetalinks, rhelpers)
);
};
scope.addMetalinks = function() {
modals.invoke(
'getMetalinks', _.bind(rhelpers.addMetalinks, rhelpers)
);
};
scope.addTorrents = function() {
modals.invoke(
'getTorrents', _.bind(rhelpers.addTorrents, rhelpers)
);
};
scope.addTorrent = function() {
modals.invoke(
'getTorrent', _.bind(rhelpers.addTorrents, rhelpers)
);
};
scope.changeCSettings = function() {
modals.invoke(
'connection', rpc.getConfiguration(), _.bind(rpc.configure, rpc)
);
}
scope.changeCSettings = function() {
modals.invoke(
'connection', rpc.getConfiguration(), _.bind(rpc.configure, rpc)
);
}
scope.changeGSettings = function() {
rpc.once('getGlobalOption', [], function(data) {
var starred = utils.getCookie('aria2props');
if (!starred || !starred.indexOf) starred = [];
var vals = data[0];
var settings = {};
scope.changeGSettings = function() {
rpc.once('getGlobalOption', [], function(data) {
var starred = utils.getCookie('aria2props');
if (!starred || !starred.indexOf) starred = [];
var vals = data[0];
var settings = {};
// global settings divided into
// file settings + some global specific
// settings
// global settings divided into
// file settings + some global specific
// settings
_.forEach([fsettings, gsettings], function(sets) {
for (var i in sets) {
if (gexclude.indexOf(i) != -1) continue;
_.forEach([fsettings, gsettings], function(sets) {
for (var i in sets) {
if (gexclude.indexOf(i) != -1) continue;
settings[i] = _.cloneDeep(sets[i]);
settings[i].starred = starred.indexOf(i) != -1;
}
});
settings[i] = _.cloneDeep(sets[i]);
settings[i].starred = starred.indexOf(i) != -1;
}
});
for (var i in vals) {
if (i in gexclude) continue;
for (var i in vals) {
if (i in gexclude) continue;
if (!(i in settings)) {
settings[i] = { name: i, val: vals[i], desc: '', starred: starred.indexOf(i) != -1 };
}
if (!(i in settings)) {
settings[i] = { name: i, val: vals[i], desc: '', starred: starred.indexOf(i) != -1 };
}
else {
settings[i].val = vals[i];
}
}
else {
settings[i].val = vals[i];
}
}
modals.invoke(
'settings', _.cloneDeep(settings),
'Global Settings', 'Save', function(chsettings) {
modals.invoke(
'settings', _.cloneDeep(settings),
'Global Settings', 'Save', function(chsettings) {
var sets = {};
var starred = [];
for (var i in chsettings) {
// no need to change default values
if (settings[i].val != chsettings[i].val)
sets[i] = chsettings[i].val
var sets = {};
var starred = [];
for (var i in chsettings) {
// no need to change default values
if (settings[i].val != chsettings[i].val)
sets[i] = chsettings[i].val
if (chsettings[i].starred) {
starred.push(i);
}
};
if (chsettings[i].starred) {
starred.push(i);
}
};
console.log('saving aria2 settings:', sets);
console.log('saving aria2 starred:', starred);
console.log('saving aria2 settings:', sets);
console.log('saving aria2 starred:', starred);
rpc.once('changeGlobalOption', [sets]);
utils.setCookie('aria2props', starred);
});
});
};
rpc.once('changeGlobalOption', [sets]);
utils.setCookie('aria2props', starred);
});
});
};
scope.showServerInfo = function() {
modals.invoke(
'server_info'
);
};
scope.showServerInfo = function() {
modals.invoke(
'server_info'
);
};
scope.showAbout = function() {
modals.invoke(
'about'
);
}
scope.showAbout = function() {
modals.invoke(
'about'
);
}
}]);

View File

@ -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