add debug mode
This commit is contained in:
parent
530f391392
commit
59518832f3
|
@ -334,6 +334,7 @@
|
||||||
<script src="scripts/services/ariaNgMonitorService.js"></script>
|
<script src="scripts/services/ariaNgMonitorService.js"></script>
|
||||||
<script src="scripts/services/ariaNgNotificationService.js"></script>
|
<script src="scripts/services/ariaNgNotificationService.js"></script>
|
||||||
<script src="scripts/services/ariaNgSettingService.js"></script>
|
<script src="scripts/services/ariaNgSettingService.js"></script>
|
||||||
|
<script src="scripts/services/ariaNgLogService.js"></script>
|
||||||
<script src="scripts/services/aria2HttpRpcService.js"></script>
|
<script src="scripts/services/aria2HttpRpcService.js"></script>
|
||||||
<script src="scripts/services/aria2WebSocketRpcService.js"></script>
|
<script src="scripts/services/aria2WebSocketRpcService.js"></script>
|
||||||
<script src="scripts/services/aria2RpcService.js"></script>
|
<script src="scripts/services/aria2RpcService.js"></script>
|
||||||
|
|
|
@ -113,6 +113,7 @@ Download Completed=下载完成
|
||||||
BT Download Completed=BT 下载完成
|
BT Download Completed=BT 下载完成
|
||||||
Download Error=下载出错
|
Download Error=下载出错
|
||||||
Language=语言
|
Language=语言
|
||||||
|
Debug Mode=调试模式
|
||||||
Page Title=页面标题
|
Page Title=页面标题
|
||||||
Page Title Refresh Interval=页面标题刷新间隔
|
Page Title Refresh Interval=页面标题刷新间隔
|
||||||
Enable Browser Notification=启用浏览器通知
|
Enable Browser Notification=启用浏览器通知
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
'BT Download Completed': 'BT Download Completed',
|
'BT Download Completed': 'BT Download Completed',
|
||||||
'Download Error': 'Download Error',
|
'Download Error': 'Download Error',
|
||||||
'Language': 'Language',
|
'Language': 'Language',
|
||||||
|
'Debug Mode': 'Debug Mode',
|
||||||
'Page Title': 'Page Title',
|
'Page Title': 'Page Title',
|
||||||
'Page Title Refresh Interval': 'Page Title Refresh Interval',
|
'Page Title Refresh Interval': 'Page Title Refresh Interval',
|
||||||
'Enable Browser Notification': 'Enable Browser Notification',
|
'Enable Browser Notification': 'Enable Browser Notification',
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgNotificationService', function ($rootScope, $scope, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgNotificationService) {
|
angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$timeout', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgSettingService', 'ariaNgNotificationService', function ($rootScope, $scope, $routeParams, $timeout, ariaNgLanguages, ariaNgCommonService, ariaNgSettingService, ariaNgNotificationService) {
|
||||||
var tabOrders = ['global', 'rpc'];
|
var tabOrders = ['global', 'rpc'];
|
||||||
|
var extendType = $routeParams.extendType;
|
||||||
|
|
||||||
$scope.context = {
|
$scope.context = {
|
||||||
currentTab: 'global',
|
currentTab: 'global',
|
||||||
languages: ariaNgLanguages,
|
languages: ariaNgLanguages,
|
||||||
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
|
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
|
||||||
trueFalseOptions: [{name: 'True', value: true}, {name: 'False', value: false}],
|
trueFalseOptions: [{name: 'True', value: true}, {name: 'False', value: false}],
|
||||||
settings: ariaNgSettingService.getAllOptions()
|
settings: ariaNgSettingService.getAllOptions(),
|
||||||
|
sessionSettings: ariaNgSettingService.getAllSessionOptions()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.context.showDebugMode = $scope.context.sessionSettings.debugMode || extendType === 'debug';
|
||||||
|
|
||||||
$scope.changeTab = function (tabName) {
|
$scope.changeTab = function (tabName) {
|
||||||
$scope.context.currentTab = tabName;
|
$scope.context.currentTab = tabName;
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
templateUrl: 'views/settings-ariang.html',
|
templateUrl: 'views/settings-ariang.html',
|
||||||
controller: 'AriaNgSettingsController'
|
controller: 'AriaNgSettingsController'
|
||||||
})
|
})
|
||||||
|
.when('/settings/ariang/:extendType', {
|
||||||
|
templateUrl: 'views/settings-ariang.html',
|
||||||
|
controller: 'AriaNgSettingsController'
|
||||||
|
})
|
||||||
.when('/settings/aria2/basic', {
|
.when('/settings/aria2/basic', {
|
||||||
templateUrl: 'views/settings-aria2.html',
|
templateUrl: 'views/settings-aria2.html',
|
||||||
controller: 'Aria2SettingsController'
|
controller: 'Aria2SettingsController'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('aria2HttpRpcService', ['$http', 'ariaNgSettingService', function ($http, ariaNgSettingService) {
|
angular.module('ariaNg').factory('aria2HttpRpcService', ['$http', 'ariaNgSettingService', 'ariaNgLogService', function ($http, ariaNgSettingService, ariaNgLogService) {
|
||||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -16,7 +16,11 @@
|
||||||
data: context.requestBody
|
data: context.requestBody
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ariaNgLogService.debug('Http Request Start', requestContext);
|
||||||
|
|
||||||
return $http(requestContext).success(function (data) {
|
return $http(requestContext).success(function (data) {
|
||||||
|
ariaNgLogService.debug('Http Response Success', data);
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +29,8 @@
|
||||||
context.successCallback(data.id, data.result);
|
context.successCallback(data.id, data.result);
|
||||||
}
|
}
|
||||||
}).error(function (data) {
|
}).error(function (data) {
|
||||||
|
ariaNgLogService.debug('Http Response Error', data);
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = {
|
data = {
|
||||||
id: '-1',
|
id: '-1',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgSettingService', function ($q, $websocket, ariaNgSettingService) {
|
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $websocket, ariaNgSettingService, ariaNgLogService) {
|
||||||
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
var rpcUrl = ariaNgSettingService.getJsonRpcUrl();
|
||||||
var socketClient = null;
|
var socketClient = null;
|
||||||
|
|
||||||
|
@ -29,10 +29,14 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
if (content.result && context.successCallback) {
|
if (content.result && context.successCallback) {
|
||||||
|
ariaNgLogService.debug('WebSocket Response Success', content);
|
||||||
|
|
||||||
context.successCallback(context.id, content.result);
|
context.successCallback(context.id, content.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.error && context.errorCallback) {
|
if (content.error && context.errorCallback) {
|
||||||
|
ariaNgLogService.debug('WebSocket Response Error', content);
|
||||||
|
|
||||||
context.errorCallback(context.id, content.error);
|
context.errorCallback(context.id, content.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +99,8 @@
|
||||||
var uniqueId = context.uniqueId;
|
var uniqueId = context.uniqueId;
|
||||||
var requestBody = angular.toJson(context.requestBody);
|
var requestBody = angular.toJson(context.requestBody);
|
||||||
|
|
||||||
|
ariaNgLogService.debug('WebSocket Request Start', context);
|
||||||
|
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
sendIdStates[uniqueId] = {
|
sendIdStates[uniqueId] = {
|
||||||
|
|
22
src/scripts/services/ariaNgLogService.js
Normal file
22
src/scripts/services/ariaNgLogService.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('ariaNg').factory('ariaNgLogService', ['$log', 'ariaNgSettingService', function ($log, ariaNgSettingService) {
|
||||||
|
return {
|
||||||
|
debug: function (msg, obj) {
|
||||||
|
if (ariaNgSettingService.isEnableDebugMode()) {
|
||||||
|
$log.debug('[AriaNg Debug]' + msg, obj);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
info: function (msg, obj) {
|
||||||
|
$log.info('[AriaNg Info]' + msg, obj);
|
||||||
|
},
|
||||||
|
warn: function (msg, obj) {
|
||||||
|
$log.warn('[AriaNg Warn]' + msg, obj);
|
||||||
|
},
|
||||||
|
error: function (msg, obj) {
|
||||||
|
$log.error('[AriaNg Error]' + msg, obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
}());
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
angular.module('ariaNg').factory('ariaNgSettingService', ['$window', '$location', '$filter', '$translate', 'base64', 'amMoment', 'localStorageService', 'ariaNgConstants', 'ariaNgDefaultOptions', 'ariaNgLanguages', function ($window, $location, $filter, $translate, base64, amMoment, localStorageService, ariaNgConstants, ariaNgDefaultOptions, ariaNgLanguages) {
|
angular.module('ariaNg').factory('ariaNgSettingService', ['$window', '$location', '$filter', '$translate', 'base64', 'amMoment', 'localStorageService', 'ariaNgConstants', 'ariaNgDefaultOptions', 'ariaNgLanguages', function ($window, $location, $filter, $translate, base64, amMoment, localStorageService, ariaNgConstants, ariaNgDefaultOptions, ariaNgLanguages) {
|
||||||
var onFirstVisitCallbacks = [];
|
var onFirstVisitCallbacks = [];
|
||||||
|
var sessionSettings = {
|
||||||
|
debugMode: false
|
||||||
|
};
|
||||||
|
|
||||||
var fireFirstVisitEvent = function () {
|
var fireFirstVisitEvent = function () {
|
||||||
if (!angular.isArray(onFirstVisitCallbacks) || onFirstVisitCallbacks.length < 1) {
|
if (!angular.isArray(onFirstVisitCallbacks) || onFirstVisitCallbacks.length < 1) {
|
||||||
|
@ -91,6 +94,9 @@
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
|
getAllSessionOptions: function () {
|
||||||
|
return angular.copy(sessionSettings);
|
||||||
|
},
|
||||||
applyLanguage: function (lang) {
|
applyLanguage: function (lang) {
|
||||||
if (!ariaNgLanguages[lang]) {
|
if (!ariaNgLanguages[lang]) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -109,6 +115,12 @@
|
||||||
setOption('language', value);
|
setOption('language', value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
isEnableDebugMode: function () {
|
||||||
|
return sessionSettings.debugMode;
|
||||||
|
},
|
||||||
|
setDebugMode: function (value) {
|
||||||
|
sessionSettings.debugMode = value;
|
||||||
|
},
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
return getOption('title');
|
return getOption('title');
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,6 +22,17 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row" ng-if="context.showDebugMode">
|
||||||
|
<div class="setting-key setting-key-without-desc col-sm-4">
|
||||||
|
<span translate>Debug Mode</span>
|
||||||
|
</div>
|
||||||
|
<div class="setting-value col-sm-8">
|
||||||
|
<select class="form-control" style="width: 100%;" ng-model="context.sessionSettings.debugMode"
|
||||||
|
ng-options="option.value as (option.name | translate) for option in context.trueFalseOptions"
|
||||||
|
ng-change="settingService.setDebugMode(context.sessionSettings.debugMode)">
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="setting-key setting-key-without-desc col-sm-4">
|
<div class="setting-key setting-key-without-desc col-sm-4">
|
||||||
<span translate>Page Title</span>
|
<span translate>Page Title</span>
|
||||||
|
|
Reference in a new issue