add current rpc alias placeholder in title

This commit is contained in:
MaysWind 2019-02-21 21:36:50 +08:00
parent 767cdd9f08
commit 03609c9f26
7 changed files with 57 additions and 8 deletions

View file

@ -181,6 +181,7 @@ Invalid settings data format!=无效的设置数据格式!
Data has been copied to clipboard.=数据已经复制到剪贴板中.
Supported Placeholder=支持的占位符
AriaNg Title=AriaNg 标题
Current RPC Alias=当前 RPC 别名
Downloading Count=正在下载数量
Waiting Count=正在等待数量
Stopped Count=已停止数量

View file

@ -182,6 +182,7 @@ Data has been copied to clipboard.=資料已經複製到剪貼簿中.
Supported Placeholder=支援的預留位置
AriaNg Title=AriaNg 標題
Downloading Count=正在下載數量
Current RPC Alias=目前 RPC 別名
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

@ -185,6 +185,7 @@
'Data has been copied to clipboard.': 'Data has been copied to clipboard.',
'Supported Placeholder': 'Supported Placeholder',
'AriaNg Title': 'AriaNg Title',
'Current RPC Alias': 'Current RPC Alias',
'Downloading Count': 'Downloading Count',
'Waiting Count': 'Waiting Count',
'Stopped Count': 'Stopped Count',

View file

@ -6,7 +6,10 @@
var globalStatRefreshPromise = null;
var refreshPageTitle = function () {
$document[0].title = ariaNgTitleService.getFinalTitleByGlobalStat($scope.globalStat);
$document[0].title = ariaNgTitleService.getFinalTitleByGlobalStat({
globalStat: $scope.globalStat,
currentRpcProfile: getCurrentRPCProfile()
});
};
var refreshGlobalStat = function (silent, callback) {
@ -27,6 +30,21 @@
}, silent);
};
var getCurrentRPCProfile = function () {
if (!$scope.rpcSettings || $scope.rpcSettings.length < 1) {
return null;
}
for (var i = 0; i < $scope.rpcSettings.length; i++) {
var rpcSetting = $scope.rpcSettings[i];
if (rpcSetting.isDefault) {
return rpcSetting;
}
}
return null;
};
if (ariaNgSettingService.getBrowserNotification()) {
ariaNgNotificationService.requestBrowserPermission();
}

View file

@ -6,7 +6,25 @@
var lastRefreshPageNotification = null;
var getFinalTitle = function () {
return ariaNgTitleService.getFinalTitleByGlobalStat(ariaNgMonitorService.getCurrentGlobalStat());
return ariaNgTitleService.getFinalTitleByGlobalStat({
globalStat: ariaNgMonitorService.getCurrentGlobalStat(),
currentRpcProfile: getCurrentRPCProfile()
});
};
var getCurrentRPCProfile = function () {
if (!$scope.context || !$scope.context.rpcSettings || $scope.context.rpcSettings.length < 1) {
return null;
}
for (var i = 0; i < $scope.context.rpcSettings.length; i++) {
var rpcSetting = $scope.context.rpcSettings[i];
if (rpcSetting.isDefault) {
return rpcSetting;
}
}
return null;
};
var setNeedRefreshPage = function () {
@ -50,6 +68,7 @@
exportSettingsCopied: false
};
$scope.context.titlePreview = getFinalTitle();
$scope.context.showDebugMode = $scope.context.sessionSettings.debugMode || extendType === 'debug';
$scope.changeGlobalTab = function () {

View file

@ -61,6 +61,12 @@
return title;
};
var replaceCurrentRPCAlias = function (title, value) {
return replacePlaceholders(title, 'rpcprofile', {
value: value
});
};
var replaceDownloadingCount = function (title, value) {
return replacePlaceholders(title, 'downloading', {
prefix: ariaNgLocalizationService.getLocalizedText('Downloading') + ': ',
@ -118,6 +124,7 @@
uploadSpeed: 0
}, context);
title = replaceCurrentRPCAlias(title, context.currentRPCAlias);
title = replaceDownloadingCount(title, context.downloadingCount);
title = replaceWaitingCount(title, context.waitingCount);
title = replaceStoppedCount(title, context.stoppedCount);
@ -127,13 +134,14 @@
return title;
},
getFinalTitleByGlobalStat: function (globalStat) {
getFinalTitleByGlobalStat: function (params) {
var context = {
downloadingCount: (globalStat ? globalStat.numActive : 0),
waitingCount: (globalStat ? globalStat.numWaiting : 0),
stoppedCount: (globalStat ? globalStat.numStopped : 0),
downloadSpeed: (globalStat ? globalStat.downloadSpeed : 0),
uploadSpeed: (globalStat ? globalStat.uploadSpeed : 0)
currentRPCAlias: (params && params.currentRpcProfile ? (params.currentRpcProfile.rpcAlias || (params.currentRpcProfile.rpcHost + ':' + params.currentRpcProfile.rpcPort)) : ''),
downloadingCount: (params && params.globalStat ? params.globalStat.numActive : 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),
uploadSpeed: (params && params.globalStat ? params.globalStat.uploadSpeed : 0)
};
return this.getFinalTitle(context);

View file

@ -56,6 +56,7 @@
data-trigger="hover" data-placement="auto right" data-container="body" data-html="true"
data-content="{{('Supported Placeholder' | translate) + ':<br/>' +
('AriaNg Title' | translate) + ': ${title}<br/>' +
('Current RPC Alias' | translate) + ': ${rpcprofile}<br/>' +
('Downloading Count' | translate) + ': ${downloading}<br/>' +
('Waiting Count' | translate) + ': ${waiting}<br/>' +
('Stopped Count' | translate) + ': ${stopped}<br/>' +