add overall completed percent in title

This commit is contained in:
MaysWind
2019-04-09 00:08:58 +08:00
parent 5c4acf8616
commit f7633923a4
7 changed files with 45 additions and 0 deletions

View File

@@ -190,6 +190,8 @@ Supported Placeholder=支持的占位符
AriaNg Title=AriaNg 标题
Current RPC Alias=当前 RPC 别名
Downloading Count=正在下载数量
Overall Completed Percent=整体完成进度
Completed Percent=完成进度
Waiting Count=正在等待数量
Stopped Count=已停止数量
You have disabled notification in your browser. You should change your browser's settings before you enable this function.=您已经在浏览器中禁用通知功能. 如需使用此功能, 请修改您浏览器的设置.

View File

@@ -189,6 +189,8 @@ Data has been copied to clipboard.=資料已經複製到剪貼簿中.
Supported Placeholder=支援的預留位置
AriaNg Title=AriaNg 標題
Downloading Count=正在下載數量
Overall Completed Percent=整體完成進度
Completed Percent=完成進度
Current RPC Alias=目前 RPC 別名
Waiting Count=正在等待數量
Stopped Count=已停止數量

View File

@@ -194,6 +194,8 @@
'AriaNg Title': 'AriaNg Title',
'Current RPC Alias': 'Current RPC Alias',
'Downloading Count': 'Downloading Count',
'Overall Completed Percent': 'Overall Completed Percent',
'Completed Percent': 'Completed Percent',
'Waiting Count': 'Waiting Count',
'Stopped Count': 'Stopped Count',
'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.': 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.',

View File

@@ -8,6 +8,7 @@
var refreshPageTitle = function () {
$document[0].title = ariaNgTitleService.getFinalTitleByGlobalStat({
globalStat: $scope.globalStat,
completedPercent: $rootScope.taskContext.getOverallPercent(),
currentRpcProfile: getCurrentRPCProfile()
});
};

View File

@@ -99,6 +99,27 @@
list: [],
selected: {},
enableSelectAll: false,
getOverallPercent: function () {
var allCompletedLength = 0;
var allTotalLength = 0;
if (!this.list || this.list.length < 1) {
return 0;
}
for (var i = 0; i < this.list.length; i++) {
var task = this.list[i];
allCompletedLength += task.completedLength;
allTotalLength += task.totalLength;
}
if (allCompletedLength <= 0 || allTotalLength <= 0) {
return 0;
}
return allCompletedLength / allTotalLength * 100;
},
getSelectedTaskIds: function () {
var result = [];

View File

@@ -34,6 +34,10 @@
value = $filter('readableVolume')(value, context.scale);
}
if (context.type === 'percent') {
value = $filter('percent')(value, context.scale || 2);
}
if (context.prefix && !context.noprefix) {
value = context.prefix + value;
}
@@ -74,6 +78,15 @@
});
};
var replaceOverallCompletedPercentCount = function (title, value) {
return replacePlaceholders(title, 'completedPercent', {
prefix: ariaNgLocalizationService.getLocalizedText('Completed Percent') + ': ',
value: value,
type: 'percent',
suffix: '%'
});
};
var replaceWaitingCount = function (title, value) {
return replacePlaceholders(title, 'waiting', {
prefix: ariaNgLocalizationService.getLocalizedText('Waiting') + ': ',
@@ -118,6 +131,7 @@
context = angular.extend({
downloadingCount: 0,
completedPercent: 0,
waitingCount: 0,
stoppedCount: 0,
downloadSpeed: 0,
@@ -126,6 +140,7 @@
title = replaceCurrentRPCAlias(title, context.currentRPCAlias);
title = replaceDownloadingCount(title, context.downloadingCount);
title = replaceOverallCompletedPercentCount(title, context.completedPercent);
title = replaceWaitingCount(title, context.waitingCount);
title = replaceStoppedCount(title, context.stoppedCount);
title = replaceDownloadSpeed(title, context.downloadSpeed);
@@ -138,6 +153,7 @@
var context = {
currentRPCAlias: (params && params.currentRpcProfile ? (params.currentRpcProfile.rpcAlias || (params.currentRpcProfile.rpcHost + ':' + params.currentRpcProfile.rpcPort)) : ''),
downloadingCount: (params && params.globalStat ? params.globalStat.numActive : 0),
completedPercent: (params && params.completedPercent ? params.completedPercent : 0),
waitingCount: (params && params.globalStat ? params.globalStat.numWaiting : 0),
stoppedCount: (params && params.globalStat ? params.globalStat.numStopped : 0),
downloadSpeed: (params && params.globalStat ? params.globalStat.downloadSpeed : 0),

View File

@@ -58,6 +58,7 @@
('AriaNg Title' | translate) + ': ${title}<br/>' +
('Current RPC Alias' | translate) + ': ${rpcprofile}<br/>' +
('Downloading Count' | translate) + ': ${downloading}<br/>' +
('Overall Completed Percent' | translate) + ': ${completedPercent}<br/>' +
('Waiting Count' | translate) + ': ${waiting}<br/>' +
('Stopped Count' | translate) + ': ${stopped}<br/>' +
('Download Speed' | translate) + ': ${downspeed}<br/>' +