reduce response size in task list page
This commit is contained in:
parent
baf4561edb
commit
6746de57f6
|
@ -4,6 +4,7 @@
|
||||||
angular.module('ariaNg').controller('DownloadListController', ['$scope', '$window', '$location', '$interval', 'translateFilter', 'aria2RpcService', 'ariaNgSettingService', 'utils', function ($scope, $window, $location, $interval, translateFilter, aria2RpcService, ariaNgSettingService, utils) {
|
angular.module('ariaNg').controller('DownloadListController', ['$scope', '$window', '$location', '$interval', 'translateFilter', 'aria2RpcService', 'ariaNgSettingService', 'utils', function ($scope, $window, $location, $interval, translateFilter, aria2RpcService, ariaNgSettingService, utils) {
|
||||||
var location = $location.path().substring(1);
|
var location = $location.path().substring(1);
|
||||||
var downloadTaskRefreshPromise = null;
|
var downloadTaskRefreshPromise = null;
|
||||||
|
var needRequestWholeInfo = true;
|
||||||
|
|
||||||
var getTitleWidth = function () {
|
var getTitleWidth = function () {
|
||||||
var titleColumn = angular.element('#task-table > .row > .col-md-8:first-child');
|
var titleColumn = angular.element('#task-table > .row > .col-md-8:first-child');
|
||||||
|
@ -31,12 +32,15 @@
|
||||||
'uploadSpeed',
|
'uploadSpeed',
|
||||||
'downloadSpeed',
|
'downloadSpeed',
|
||||||
'connections',
|
'connections',
|
||||||
'files',
|
|
||||||
'bittorrent',
|
|
||||||
'numSeeders',
|
'numSeeders',
|
||||||
'seeder'
|
'seeder'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (needRequestWholeInfo) {
|
||||||
|
requestParams.push('files');
|
||||||
|
requestParams.push('bittorrent');
|
||||||
|
}
|
||||||
|
|
||||||
if (location == 'downloading') {
|
if (location == 'downloading') {
|
||||||
invokeMethod = aria2RpcService.tellActive;
|
invokeMethod = aria2RpcService.tellActive;
|
||||||
params = [requestParams];
|
params = [requestParams];
|
||||||
|
@ -52,14 +56,21 @@
|
||||||
return invokeMethod({
|
return invokeMethod({
|
||||||
params: params,
|
params: params,
|
||||||
callback: function (result) {
|
callback: function (result) {
|
||||||
if (result && result.length > 0) {
|
if (!utils.extendArray(result, $scope.downloadTasks, 'gid')) {
|
||||||
for (var i = 0; i < result.length; i++) {
|
if (needRequestWholeInfo) {
|
||||||
utils.processDownloadTask(result[i]);
|
$scope.downloadTasks = result;
|
||||||
|
needRequestWholeInfo = false;
|
||||||
|
} else {
|
||||||
|
needRequestWholeInfo = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
needRequestWholeInfo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utils.replaceArray(result, $scope.downloadTasks, 'gid')) {
|
if ($scope.downloadTasks && $scope.downloadTasks.length > 0) {
|
||||||
$scope.downloadTasks = result;
|
for (var i = 0; i < $scope.downloadTasks.length; i++) {
|
||||||
|
utils.processDownloadTask($scope.downloadTasks[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
replaceArray: function (sourceArray, targetArray, keyProperty) {
|
extendArray: function (sourceArray, targetArray, keyProperty) {
|
||||||
if (!targetArray || !sourceArray || sourceArray.length != targetArray.length) {
|
if (!targetArray || !sourceArray || sourceArray.length != targetArray.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue