diff --git a/src/index.html b/src/index.html index 6f7757f..441bced 100644 --- a/src/index.html +++ b/src/index.html @@ -334,6 +334,7 @@ + diff --git a/src/langs/zh_CN.txt b/src/langs/zh_CN.txt index 14e59ef..6362068 100644 --- a/src/langs/zh_CN.txt +++ b/src/langs/zh_CN.txt @@ -113,6 +113,7 @@ Download Completed=下载完成 BT Download Completed=BT 下载完成 Download Error=下载出错 Language=语言 +Debug Mode=调试模式 Page Title=页面标题 Page Title Refresh Interval=页面标题刷新间隔 Enable Browser Notification=启用浏览器通知 diff --git a/src/scripts/config/defaultLanguage.js b/src/scripts/config/defaultLanguage.js index 9f6d5d5..4b93dae 100644 --- a/src/scripts/config/defaultLanguage.js +++ b/src/scripts/config/defaultLanguage.js @@ -117,6 +117,7 @@ 'BT Download Completed': 'BT Download Completed', 'Download Error': 'Download Error', 'Language': 'Language', + 'Debug Mode': 'Debug Mode', 'Page Title': 'Page Title', 'Page Title Refresh Interval': 'Page Title Refresh Interval', 'Enable Browser Notification': 'Enable Browser Notification', diff --git a/src/scripts/controllers/settings-ariang.js b/src/scripts/controllers/settings-ariang.js index 1984111..b945add 100644 --- a/src/scripts/controllers/settings-ariang.js +++ b/src/scripts/controllers/settings-ariang.js @@ -1,17 +1,20 @@ (function () { '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 extendType = $routeParams.extendType; $scope.context = { currentTab: 'global', languages: ariaNgLanguages, availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true), 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.context.currentTab = tabName; diff --git a/src/scripts/core/router.js b/src/scripts/core/router.js index c9e515e..f7cdfb9 100644 --- a/src/scripts/core/router.js +++ b/src/scripts/core/router.js @@ -31,6 +31,10 @@ templateUrl: 'views/settings-ariang.html', controller: 'AriaNgSettingsController' }) + .when('/settings/ariang/:extendType', { + templateUrl: 'views/settings-ariang.html', + controller: 'AriaNgSettingsController' + }) .when('/settings/aria2/basic', { templateUrl: 'views/settings-aria2.html', controller: 'Aria2SettingsController' diff --git a/src/scripts/services/aria2HttpRpcService.js b/src/scripts/services/aria2HttpRpcService.js index a5763b7..70d3ce3 100644 --- a/src/scripts/services/aria2HttpRpcService.js +++ b/src/scripts/services/aria2HttpRpcService.js @@ -1,7 +1,7 @@ (function () { '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(); return { @@ -16,7 +16,11 @@ data: context.requestBody }; + ariaNgLogService.debug('Http Request Start', requestContext); + return $http(requestContext).success(function (data) { + ariaNgLogService.debug('Http Response Success', data); + if (!data) { return; } @@ -25,6 +29,8 @@ context.successCallback(data.id, data.result); } }).error(function (data) { + ariaNgLogService.debug('Http Response Error', data); + if (!data) { data = { id: '-1', diff --git a/src/scripts/services/aria2WebSocketRpcService.js b/src/scripts/services/aria2WebSocketRpcService.js index d99063c..bda56f7 100644 --- a/src/scripts/services/aria2WebSocketRpcService.js +++ b/src/scripts/services/aria2WebSocketRpcService.js @@ -1,7 +1,7 @@ (function () { '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 socketClient = null; @@ -29,10 +29,14 @@ }); if (content.result && context.successCallback) { + ariaNgLogService.debug('WebSocket Response Success', content); + context.successCallback(context.id, content.result); } if (content.error && context.errorCallback) { + ariaNgLogService.debug('WebSocket Response Error', content); + context.errorCallback(context.id, content.error); } @@ -95,6 +99,8 @@ var uniqueId = context.uniqueId; var requestBody = angular.toJson(context.requestBody); + ariaNgLogService.debug('WebSocket Request Start', context); + var deferred = $q.defer(); sendIdStates[uniqueId] = { diff --git a/src/scripts/services/ariaNgLogService.js b/src/scripts/services/ariaNgLogService.js new file mode 100644 index 0000000..0186c3b --- /dev/null +++ b/src/scripts/services/ariaNgLogService.js @@ -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); + } + }; + }]); +}()); diff --git a/src/scripts/services/ariaNgSettingService.js b/src/scripts/services/ariaNgSettingService.js index 2a27fef..43265ea 100644 --- a/src/scripts/services/ariaNgSettingService.js +++ b/src/scripts/services/ariaNgSettingService.js @@ -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) { var onFirstVisitCallbacks = []; + var sessionSettings = { + debugMode: false + }; var fireFirstVisitEvent = function () { if (!angular.isArray(onFirstVisitCallbacks) || onFirstVisitCallbacks.length < 1) { @@ -91,6 +94,9 @@ return options; }, + getAllSessionOptions: function () { + return angular.copy(sessionSettings); + }, applyLanguage: function (lang) { if (!ariaNgLanguages[lang]) { return false; @@ -109,6 +115,12 @@ setOption('language', value); } }, + isEnableDebugMode: function () { + return sessionSettings.debugMode; + }, + setDebugMode: function (value) { + sessionSettings.debugMode = value; + }, getTitle: function () { return getOption('title'); }, diff --git a/src/views/settings-ariang.html b/src/views/settings-ariang.html index 3840d7f..e0678a3 100644 --- a/src/views/settings-ariang.html +++ b/src/views/settings-ariang.html @@ -22,6 +22,17 @@ +
+
+ Debug Mode +
+
+ +
+
Page Title