settings-ariang.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. (function () {
  2. 'use strict';
  3. angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$window', '$interval', '$timeout', '$filter', 'clipboard', 'ariaNgLanguages', 'ariaNgSupportedAudioFileTypes', 'ariaNgCommonService', 'ariaNgVersionService', 'ariaNgKeyboardService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgFileService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2SettingService', 'ariaNgNativeElectronService', function ($rootScope, $scope, $routeParams, $window, $interval, $timeout, $filter, clipboard, ariaNgLanguages, ariaNgSupportedAudioFileTypes, ariaNgCommonService, ariaNgVersionService, ariaNgKeyboardService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgLogService, ariaNgFileService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2SettingService, ariaNgNativeElectronService) {
  4. var extendType = $routeParams.extendType;
  5. var lastRefreshPageNotification = null;
  6. var getFinalTitle = function () {
  7. return ariaNgTitleService.getFinalTitleByGlobalStat({
  8. globalStat: ariaNgMonitorService.getCurrentGlobalStat(),
  9. currentRpcProfile: getCurrentRPCProfile()
  10. });
  11. };
  12. var getCurrentRPCProfile = function () {
  13. if (!$scope.context || !$scope.context.rpcSettings || $scope.context.rpcSettings.length < 1) {
  14. return null;
  15. }
  16. for (var i = 0; i < $scope.context.rpcSettings.length; i++) {
  17. var rpcSetting = $scope.context.rpcSettings[i];
  18. if (rpcSetting.isDefault) {
  19. return rpcSetting;
  20. }
  21. }
  22. return null;
  23. };
  24. var getNativeSettings = function () {
  25. var originalConfig = ariaNgNativeElectronService.getNativeConfig();
  26. var config = {};
  27. config.defaultPosition = originalConfig.defaultPosition || 'last-position';
  28. if (!originalConfig.minimizedToTray) {
  29. config.afterMainWindowClosed = 'exit-application';
  30. } else {
  31. config.afterMainWindowClosed = 'minimize-to-tray';
  32. }
  33. config.execCommandOnStartup = originalConfig.execCommandOnStartup;
  34. config.execCommandArgumentsOnStartup = originalConfig.execCommandArgumentsOnStartup;
  35. if (!originalConfig.execDetachedCommandOnStartup) {
  36. config.execCommandOptionsOnStartup = 'as-child-process';
  37. } else {
  38. config.execCommandOptionsOnStartup = 'as-detached-process';
  39. }
  40. return config;
  41. };
  42. var importNativeSetting = function (settings, key, nativeUpdateFn) {
  43. if (!settings.hasOwnProperty(key)) {
  44. return;
  45. }
  46. $scope.context.nativeSettings[key] = settings[key];
  47. delete settings[key];
  48. if (angular.isFunction(nativeUpdateFn)) {
  49. nativeUpdateFn($scope.context.nativeSettings[key]);
  50. }
  51. };
  52. var importAllSettings = function (settings) {
  53. importNativeSetting(settings, 'defaultPosition', $scope.setDefaultPosition);
  54. importNativeSetting(settings, 'afterMainWindowClosed', $scope.setAfterMainWindowClosed);
  55. importNativeSetting(settings, 'execCommandOnStartup', $scope.setExecCommandOnStartup);
  56. importNativeSetting(settings, 'execCommandArgumentsOnStartup', $scope.setExecCommandArgumentsOnStartup);
  57. importNativeSetting(settings, 'execCommandOptionsOnStartup', $scope.setExecCommandOptionsOnStartup);
  58. ariaNgSettingService.importAllOptions(settings);
  59. };
  60. var exportAllSettings = function () {
  61. var allSettings = angular.extend({}, ariaNgSettingService.exportAllOptions());
  62. if ($scope.context.nativeSettings) {
  63. for (const key in $scope.context.nativeSettings) {
  64. if (!$scope.context.nativeSettings.hasOwnProperty(key)) {
  65. continue;
  66. }
  67. allSettings[key] = $scope.context.nativeSettings[key];
  68. }
  69. }
  70. return allSettings;
  71. };
  72. var setNeedRefreshPage = function () {
  73. if (lastRefreshPageNotification) {
  74. return;
  75. }
  76. lastRefreshPageNotification = ariaNgNotificationService.notifyInPage('', 'Configuration has been modified, please reload the page for the changes to take effect.', {
  77. delay: false,
  78. type: 'info',
  79. templateUrl: 'views/notification-reloadable.html',
  80. onClose: function () {
  81. lastRefreshPageNotification = null;
  82. }
  83. });
  84. };
  85. $scope.context = {
  86. currentTab: 'global',
  87. ariaNgVerboseVersionCollapsed: true,
  88. ariaNgNativeVersion: ariaNgVersionService.getBuildVersion(),
  89. ariaNgVersion: ariaNgVersionService.getAriaNgVersion(),
  90. buildCommit: ariaNgVersionService.getBuildCommit(),
  91. isCurrentLatestVersion: false,
  92. runtimeEnvironment: ariaNgNativeElectronService.getRuntimeEnvironment(),
  93. runtimeEnvironmentCollapsed: true,
  94. languages: (function () {
  95. var languages = [];
  96. for (var langName in ariaNgLanguages) {
  97. if (!ariaNgLanguages.hasOwnProperty(langName)) {
  98. continue;
  99. }
  100. var language = ariaNgLanguages[langName];
  101. languages.push({
  102. type: langName,
  103. name: language.name,
  104. displayName: language.displayName
  105. });
  106. }
  107. languages.sort(function (lang1, lang2) {
  108. return String.naturalCompare(lang1.type, lang2.type);
  109. });
  110. return languages;
  111. })(),
  112. titlePreview: getFinalTitle(),
  113. availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
  114. trueFalseOptions: [{name: 'Enabled', value: true}, {name: 'Disabled', value: false}],
  115. showRpcSecret: false,
  116. isInsecureProtocolDisabled: ariaNgSettingService.isInsecureProtocolDisabled(),
  117. settings: ariaNgSettingService.getAllOptions(),
  118. nativeSettings: getNativeSettings(),
  119. sessionSettings: ariaNgSettingService.getAllSessionOptions(),
  120. rpcSettings: ariaNgSettingService.getAllRpcSettings(),
  121. isMacKeyboardLike: ariaNgKeyboardService.isMacKeyboardLike(),
  122. isSupportReconnect: aria2SettingService.canReconnect(),
  123. isSupportBlob: ariaNgFileService.isSupportBlob(),
  124. isSupportDarkMode: ariaNgSettingService.isBrowserSupportDarkMode(),
  125. importSettings: null,
  126. exportSettings: null,
  127. exportSettingsCopied: false,
  128. exportCommandApiOptions: null
  129. };
  130. $scope.context.titlePreview = getFinalTitle();
  131. $scope.context.showDebugMode = false; // AriaNg Native does not allow to disable debug mode when current is in debug mode
  132. $scope.isEnableDebugMode = function () {
  133. return ariaNgSettingService.isEnableDebugMode();
  134. };
  135. $scope.changeGlobalTab = function () {
  136. $scope.context.currentTab = 'global';
  137. };
  138. $scope.isCurrentGlobalTab = function () {
  139. return $scope.context.currentTab === 'global';
  140. };
  141. $scope.changeRpcTab = function (rpcIndex) {
  142. $scope.context.currentTab = 'rpc' + rpcIndex;
  143. };
  144. $scope.isCurrentRpcTab = function (rpcIndex) {
  145. return $scope.context.currentTab === 'rpc' + rpcIndex;
  146. };
  147. $scope.getCurrentRpcTabIndex = function () {
  148. if ($scope.isCurrentGlobalTab()) {
  149. return -1;
  150. }
  151. return parseInt($scope.context.currentTab.substring(3));
  152. };
  153. $scope.checkUpdate = function () {
  154. return ariaNgVersionService.getTheLatestVersion()
  155. .then(function onSuccess(response) {
  156. ariaNgLogService.debug('[AriaNgSettingsController.checkUpdate] latest version info', response);
  157. if (!response || !response.data || !response.data.tag_name) {
  158. ariaNgLogService.warn('[AriaNgSettingsController.checkUpdate] data format of latest version is invalid', response);
  159. ariaNgCommonService.showError('Failed to get latest version!');
  160. return;
  161. }
  162. var latestVersion = response.data.tag_name;
  163. if (ariaNgVersionService.compareVersion(ariaNgVersionService.getBuildVersionNumber(), latestVersion) >= 0) {
  164. ariaNgCommonService.showInfo('Check Update', 'You have installed the latest version!');
  165. $scope.context.isCurrentLatestVersion = true;
  166. } else {
  167. ariaNgNativeElectronService.openProjectReleaseLink();
  168. }
  169. }).catch(function onError(response) {
  170. ariaNgLogService.error('[AriaNgSettingsController.checkUpdate] failed to get latest version', response);
  171. ariaNgCommonService.showError('Failed to get latest version!');
  172. });
  173. };
  174. $scope.updateTitlePreview = function () {
  175. $scope.context.titlePreview = getFinalTitle();
  176. };
  177. $rootScope.swipeActions.extendLeftSwipe = function () {
  178. var tabIndex = -1;
  179. if (!$scope.isCurrentGlobalTab()) {
  180. tabIndex = parseInt($scope.getCurrentRpcTabIndex());
  181. }
  182. if (tabIndex < $scope.context.rpcSettings.length - 1) {
  183. $scope.changeRpcTab(tabIndex + 1);
  184. return true;
  185. } else {
  186. return false;
  187. }
  188. };
  189. $rootScope.swipeActions.extendRightSwipe = function () {
  190. var tabIndex = -1;
  191. if (!$scope.isCurrentGlobalTab()) {
  192. tabIndex = parseInt($scope.getCurrentRpcTabIndex());
  193. }
  194. if (tabIndex > 0) {
  195. $scope.changeRpcTab(tabIndex - 1);
  196. return true;
  197. } else if (tabIndex === 0) {
  198. $scope.changeGlobalTab();
  199. return true;
  200. } else {
  201. return false;
  202. }
  203. };
  204. $scope.isSupportMessagePush = function () {
  205. return ariaNgSettingService.isCurrentRpcUseWebSocket($scope.context.settings.protocol);
  206. };
  207. $scope.isSupportNotification = function () {
  208. return ariaNgNotificationService.isSupportBrowserNotification() &&
  209. ariaNgSettingService.isCurrentRpcUseWebSocket($scope.context.settings.protocol);
  210. };
  211. $scope.setLanguage = function (value) {
  212. if (ariaNgSettingService.setLanguage(value)) {
  213. ariaNgLocalizationService.applyLanguage(value);
  214. }
  215. $scope.updateTitlePreview();
  216. };
  217. $scope.setAutoCheckUpdates = function (value) {
  218. ariaNgSettingService.setAutoCheckUpdates(value);
  219. };
  220. $scope.setTheme = function (value) {
  221. ariaNgSettingService.setTheme(value);
  222. $rootScope.setTheme(value);
  223. };
  224. $scope.setDebugMode = function (value) {
  225. ariaNgSettingService.setDebugMode(value);
  226. };
  227. $scope.setTitle = function (value) {
  228. ariaNgSettingService.setTitle(value);
  229. };
  230. $scope.setEnableBrowserNotification = function (value) {
  231. ariaNgSettingService.setBrowserNotification(value);
  232. if (value && !ariaNgNotificationService.hasBrowserPermission()) {
  233. ariaNgNotificationService.requestBrowserPermission(function (result) {
  234. if (!result.granted) {
  235. $scope.context.settings.browserNotification = false;
  236. ariaNgCommonService.showError('You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.');
  237. }
  238. });
  239. }
  240. };
  241. $scope.setBrowserNotificationSound = function (value) {
  242. ariaNgSettingService.setBrowserNotificationSound(value);
  243. };
  244. $scope.setBrowserNotificationFrequency = function (value) {
  245. ariaNgSettingService.setBrowserNotificationFrequency(value);
  246. };
  247. $scope.browseAndSetPlaySoundAfterDownloadFinished = function () {
  248. var supportedExtensions = [];
  249. for (const extension in ariaNgSupportedAudioFileTypes) {
  250. if (!ariaNgSupportedAudioFileTypes.hasOwnProperty(extension)) {
  251. continue;
  252. }
  253. supportedExtensions.push(extension.substring(1));
  254. }
  255. ariaNgNativeElectronService.showOpenFileDialogAsync([{
  256. name: ariaNgLocalizationService.getLocalizedText('Audios'),
  257. extensions: supportedExtensions
  258. }], function (result) {
  259. if (result && !result.canceled && angular.isArray(result.filePaths) && result.filePaths.length) {
  260. var filePath = result.filePaths[0];
  261. var fileExtension = ariaNgCommonService.getFileExtension(filePath);
  262. if (!ariaNgSupportedAudioFileTypes[fileExtension]) {
  263. ariaNgCommonService.showError('This sound file type is not supported.');
  264. return;
  265. }
  266. $scope.$apply(function () {
  267. $scope.context.settings.playSoundAfterDownloadFinished = filePath;
  268. $rootScope.soundContext.loadSoundFile(filePath);
  269. ariaNgSettingService.setPlaySoundAfterDownloadFinished(filePath);
  270. });
  271. }
  272. });
  273. }
  274. $scope.playSound = function () {
  275. if (!$scope.context.settings.playSoundAfterDownloadFinished) {
  276. return;
  277. }
  278. $rootScope.soundContext.playSound($scope.context.settings.playSoundAfterDownloadFinished);
  279. };
  280. $scope.stopPlayingSound = function () {
  281. $rootScope.soundContext.stopPlayingSound();
  282. };
  283. $scope.clearPlaySoundAfterDownloadFinished = function () {
  284. $scope.context.settings.playSoundAfterDownloadFinished = '';
  285. $rootScope.soundContext.loadSoundFile('');
  286. ariaNgSettingService.setPlaySoundAfterDownloadFinished('');
  287. };
  288. $scope.setWebSocketReconnectInterval = function (value) {
  289. setNeedRefreshPage();
  290. ariaNgSettingService.setWebSocketReconnectInterval(value);
  291. };
  292. $scope.setTitleRefreshInterval = function (value) {
  293. setNeedRefreshPage();
  294. ariaNgSettingService.setTitleRefreshInterval(value);
  295. };
  296. $scope.setGlobalStatRefreshInterval = function (value) {
  297. setNeedRefreshPage();
  298. ariaNgSettingService.setGlobalStatRefreshInterval(value);
  299. };
  300. $scope.setDownloadTaskRefreshInterval = function (value) {
  301. setNeedRefreshPage();
  302. ariaNgSettingService.setDownloadTaskRefreshInterval(value);
  303. };
  304. $scope.setRPCListDisplayOrder = function (value) {
  305. setNeedRefreshPage();
  306. ariaNgSettingService.setRPCListDisplayOrder(value);
  307. };
  308. $scope.setTaskListIndependentDisplayOrder = function (value) {
  309. ariaNgSettingService.setTaskListIndependentDisplayOrder(value);
  310. };
  311. $scope.setKeyboardShortcuts = function (value) {
  312. ariaNgSettingService.setKeyboardShortcuts(value);
  313. };
  314. $scope.setSwipeGesture = function (value) {
  315. ariaNgSettingService.setSwipeGesture(value);
  316. };
  317. $scope.setDragAndDropTasks = function (value) {
  318. ariaNgSettingService.setDragAndDropTasks(value);
  319. };
  320. $scope.setAfterCreatingNewTask = function (value) {
  321. ariaNgSettingService.setAfterCreatingNewTask(value);
  322. };
  323. $scope.setRemoveOldTaskAfterRetrying = function (value) {
  324. ariaNgSettingService.setRemoveOldTaskAfterRetrying(value);
  325. };
  326. $scope.setConfirmTaskRemoval = function (value) {
  327. ariaNgSettingService.setConfirmTaskRemoval(value);
  328. };
  329. $scope.setIncludePrefixWhenCopyingFromTaskDetails = function (value) {
  330. ariaNgSettingService.setIncludePrefixWhenCopyingFromTaskDetails(value);
  331. };
  332. $scope.setShowPiecesInfoInTaskDetailPage = function (value) {
  333. ariaNgSettingService.setShowPiecesInfoInTaskDetailPage(value);
  334. };
  335. $scope.setAfterRetryingTask = function (value) {
  336. ariaNgSettingService.setAfterRetryingTask(value);
  337. };
  338. $scope.setDefaultPosition = function (value) {
  339. ariaNgNativeElectronService.setDefaultPosition(value);
  340. }
  341. $scope.setExecCommandOnStartup = function (value) {
  342. ariaNgNativeElectronService.setExecCommandOnStartup(value);
  343. };
  344. $scope.setExecCommandArgumentsOnStartup = function (value) {
  345. ariaNgNativeElectronService.setExecCommandArgumentsOnStartup(value);
  346. };
  347. $scope.setExecCommandOptionsOnStartup = function (value) {
  348. if (value === 'as-child-process') {
  349. ariaNgNativeElectronService.setExecDetachedCommandOnStartup(false);
  350. } else if (value === 'as-detached-process') {
  351. ariaNgNativeElectronService.setExecDetachedCommandOnStartup(true);
  352. }
  353. };
  354. $scope.browseAndSetExecCommandOnStartup = function () {
  355. ariaNgNativeElectronService.showOpenFileDialogAsync([{
  356. name: ariaNgLocalizationService.getLocalizedText('All Files'),
  357. extensions: ['*']
  358. }], function (result) {
  359. if (result && !result.canceled && angular.isArray(result.filePaths) && result.filePaths.length) {
  360. var filePath = result.filePaths[0];
  361. $scope.$apply(function () {
  362. $scope.context.nativeSettings.execCommandOnStartup = filePath;
  363. $scope.setExecCommandOnStartup(filePath);
  364. });
  365. }
  366. });
  367. }
  368. $scope.setAfterMainWindowClosed = function (value) {
  369. if (value === 'minimize-to-tray') {
  370. ariaNgNativeElectronService.setMinimizedToTray(true);
  371. } else if (value === 'exit-application') {
  372. ariaNgNativeElectronService.setMinimizedToTray(false);
  373. }
  374. };
  375. $scope.showImportSettingsModal = function () {
  376. $scope.context.importSettings = null;
  377. angular.element('#import-settings-modal').modal();
  378. };
  379. $('#import-settings-modal').on('show.bs.modal', function (e) {
  380. ariaNgNativeElectronService.updateTitleBarBackgroundColorWithModalOverlay();
  381. });
  382. $('#import-settings-modal').on('hide.bs.modal', function (e) {
  383. $scope.context.importSettings = null;
  384. ariaNgNativeElectronService.updateTitleBarBackgroundColor();
  385. });
  386. $scope.openAriaNgConfigFile = function () {
  387. ariaNgFileService.openFileContent({
  388. scope: $scope,
  389. fileFilter: '.json',
  390. fileType: 'text'
  391. }, function (result) {
  392. $scope.context.importSettings = result.content;
  393. }, function (error) {
  394. ariaNgCommonService.showError(error);
  395. }, angular.element('#import-file-holder'));
  396. };
  397. $scope.importSettings = function (settings) {
  398. var settingsObj = null;
  399. try {
  400. settingsObj = JSON.parse(settings);
  401. } catch (e) {
  402. ariaNgLogService.error('[AriaNgSettingsController.importSettings] parse settings json error', e);
  403. ariaNgCommonService.showError('Invalid settings data format!');
  404. return;
  405. }
  406. if (!angular.isObject(settingsObj) || angular.isArray(settingsObj)) {
  407. ariaNgLogService.error('[AriaNgSettingsController.importSettings] settings json is not object');
  408. ariaNgCommonService.showError('Invalid settings data format!');
  409. return;
  410. }
  411. if (settingsObj) {
  412. ariaNgCommonService.confirm('Confirm Import', 'Are you sure you want to import all settings?', 'warning', function () {
  413. importAllSettings(settingsObj);
  414. $window.location.reload();
  415. });
  416. }
  417. };
  418. $scope.showExportSettingsModal = function () {
  419. $scope.context.exportSettings = $filter('json')(exportAllSettings());
  420. $scope.context.exportSettingsCopied = false;
  421. angular.element('#export-settings-modal').modal();
  422. };
  423. $('#export-settings-modal').on('show.bs.modal', function (e) {
  424. ariaNgNativeElectronService.updateTitleBarBackgroundColorWithModalOverlay();
  425. });
  426. $('#export-settings-modal').on('hide.bs.modal', function (e) {
  427. $scope.context.exportSettings = null;
  428. $scope.context.exportSettingsCopied = false;
  429. ariaNgNativeElectronService.updateTitleBarBackgroundColor();
  430. });
  431. $scope.copyExportSettings = function () {
  432. clipboard.copyText($scope.context.exportSettings, {
  433. container: angular.element('#export-settings-modal')[0]
  434. });
  435. $scope.context.exportSettingsCopied = true;
  436. };
  437. $scope.addNewRpcSetting = function () {
  438. setNeedRefreshPage();
  439. var newRpcSetting = ariaNgSettingService.addNewRpcSetting();
  440. $scope.context.rpcSettings.push(newRpcSetting);
  441. $scope.changeRpcTab($scope.context.rpcSettings.length - 1);
  442. };
  443. $scope.updateRpcSetting = function (setting, field) {
  444. setNeedRefreshPage();
  445. ariaNgSettingService.updateRpcSetting(setting, field);
  446. };
  447. $scope.removeRpcSetting = function (setting) {
  448. var rpcName = (setting.rpcAlias ? setting.rpcAlias : setting.rpcHost + ':' + setting.rpcPort);
  449. ariaNgCommonService.confirm('Confirm Remove', 'Are you sure you want to remove rpc setting "{rpcName}"?', 'warning', function () {
  450. setNeedRefreshPage();
  451. var currentIndex = $scope.getCurrentRpcTabIndex();
  452. var index = $scope.context.rpcSettings.indexOf(setting);
  453. ariaNgSettingService.removeRpcSetting(setting);
  454. $scope.context.rpcSettings.splice(index, 1);
  455. if (currentIndex >= $scope.context.rpcSettings.length) {
  456. $scope.changeRpcTab($scope.context.rpcSettings.length - 1);
  457. } else if (currentIndex <= 0 || currentIndex <= index) {
  458. ; // Do Nothing
  459. } else { // currentIndex > index
  460. $scope.changeRpcTab(currentIndex - 1);
  461. }
  462. }, false, {
  463. textParams: {
  464. rpcName: rpcName
  465. }
  466. });
  467. };
  468. $scope.showExportCommandAPIModal = function (setting) {
  469. $scope.context.exportCommandApiOptions = {
  470. type: 'setting',
  471. data: setting
  472. };
  473. };
  474. $scope.setDefaultRpcSetting = function (setting) {
  475. if (setting.isDefault) {
  476. return;
  477. }
  478. ariaNgSettingService.setDefaultRpcSetting(setting);
  479. $window.location.reload();
  480. };
  481. $scope.resetSettings = function () {
  482. ariaNgCommonService.confirm('Confirm Reset', 'Are you sure you want to reset all settings?', 'warning', function () {
  483. ariaNgSettingService.resetSettings();
  484. $window.location.reload();
  485. });
  486. };
  487. $scope.clearHistory = function () {
  488. ariaNgCommonService.confirm('Confirm Clear', 'Are you sure you want to clear all settings history?', 'warning', function () {
  489. aria2SettingService.clearSettingsHistorys();
  490. $window.location.reload();
  491. });
  492. };
  493. $scope.reloadApp = function () {
  494. ariaNgNativeElectronService.reload();
  495. };
  496. angular.element('[data-toggle="popover"]').popover();
  497. $rootScope.loadPromise = $timeout(function () {}, 100);
  498. }]);
  499. }());