Merge pull request #81 from nmaier/perf
Improve ngWatch time significantly
This commit is contained in:
commit
97271eabbc
|
@ -182,14 +182,33 @@ function(
|
||||||
|
|
||||||
_.each([
|
_.each([
|
||||||
'totalLength', 'completedLength', 'uploadLength', 'dir',
|
'totalLength', 'completedLength', 'uploadLength', 'dir',
|
||||||
'pieceLength', 'downloadSpeed', 'uploadSpeed', 'files',
|
'pieceLength', 'downloadSpeed', 'uploadSpeed', 'status',
|
||||||
'status', 'gid', 'bitfield', 'numPieces', 'connections',
|
'gid', 'numPieces', 'connections', 'bitfield'
|
||||||
'bittorrent'
|
|
||||||
], function(e) {
|
], function(e) {
|
||||||
if (ctx[e] != d[e])
|
ctx[e] = d[e];
|
||||||
ctx[e] = d[e];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var files = d["files"];
|
||||||
|
if (files) {
|
||||||
|
var cfiles = ctx["files"] || (ctx["files"] = []);
|
||||||
|
for (var i = 0; i < files.length; ++i) {
|
||||||
|
var file = cfiles[i] || (cfiles[i] = {});
|
||||||
|
file.path = files[i].path;
|
||||||
|
file.length = files[i].length;
|
||||||
|
}
|
||||||
|
cfiles.length = files.length;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete ctx["files"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d.bittorrent) {
|
||||||
|
ctx.bittorrentName = d.bittorrent.info && d.bittorrent.info.name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete ctx.bittorrentName;
|
||||||
|
}
|
||||||
|
|
||||||
// collapse the download details initially
|
// collapse the download details initially
|
||||||
if (ctx.collapsed === undefined)
|
if (ctx.collapsed === undefined)
|
||||||
ctx.collapsed = true;
|
ctx.collapsed = true;
|
||||||
|
@ -224,7 +243,7 @@ function(
|
||||||
|
|
||||||
// gets the progress in percentages
|
// gets the progress in percentages
|
||||||
scope.getProgress = function(d) {
|
scope.getProgress = function(d) {
|
||||||
var percentage = (d.completedLength / d.totalLength)*100;
|
var percentage = (d.completedLength / d.totalLength)*100 || 0;
|
||||||
percentage = percentage.toFixed(2);
|
percentage = percentage.toFixed(2);
|
||||||
if(!percentage) percentage = 0;
|
if(!percentage) percentage = 0;
|
||||||
|
|
||||||
|
@ -233,8 +252,8 @@ function(
|
||||||
|
|
||||||
// gets a pretty name for the download
|
// gets a pretty name for the download
|
||||||
scope.getName = function(d) {
|
scope.getName = function(d) {
|
||||||
if (d.bittorrent && d.bittorrent.info) {
|
if (d.bittorrentName) {
|
||||||
return d.bittorrent.info.name;
|
return d.bittorrentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.getFileName(
|
return utils.getFileName(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user