2016-05-16 17:41:39 +02:00
( function ( ) {
'use strict' ;
2016-11-06 15:41:28 +01:00
angular . module ( 'ariaNg' ) . controller ( 'AriaNgSettingsController' , [ '$rootScope' , '$scope' , '$routeParams' , '$timeout' , 'ariaNgLanguages' , 'ariaNgCommonService' , 'ariaNgSettingService' , 'ariaNgNotificationService' , function ( $rootScope , $scope , $routeParams , $timeout , ariaNgLanguages , ariaNgCommonService , ariaNgSettingService , ariaNgNotificationService ) {
2016-08-13 16:51:42 +02:00
var tabOrders = [ 'global' , 'rpc' ] ;
2016-11-06 15:41:28 +01:00
var extendType = $routeParams . extendType ;
2016-08-13 16:51:42 +02:00
2016-06-20 18:20:30 +02:00
$scope . context = {
2016-08-13 16:51:42 +02:00
currentTab : 'global' ,
2016-06-20 18:20:30 +02:00
languages : ariaNgLanguages ,
availableTime : ariaNgCommonService . getTimeOptions ( [ 1000 , 2000 , 3000 , 5000 , 10000 , 30000 , 60000 ] , true ) ,
2016-06-26 16:52:06 +02:00
trueFalseOptions : [ { name : 'True' , value : true } , { name : 'False' , value : false } ] ,
2016-12-04 14:09:09 +01:00
showRpcSecret : false ,
2016-11-06 15:41:28 +01:00
settings : ariaNgSettingService . getAllOptions ( ) ,
sessionSettings : ariaNgSettingService . getAllSessionOptions ( )
2016-06-20 18:20:30 +02:00
} ;
2016-06-26 16:52:06 +02:00
2016-11-06 15:41:28 +01:00
$scope . context . showDebugMode = $scope . context . sessionSettings . debugMode || extendType === 'debug' ;
2016-08-13 16:51:42 +02:00
$scope . changeTab = function ( tabName ) {
$scope . context . currentTab = tabName ;
} ;
$rootScope . swipeActions . extentLeftSwipe = function ( ) {
var tabIndex = tabOrders . indexOf ( $scope . context . currentTab ) ;
if ( tabIndex < tabOrders . length - 1 ) {
$scope . changeTab ( tabOrders [ tabIndex + 1 ] ) ;
return true ;
} else {
return false ;
}
} ;
$rootScope . swipeActions . extentRightSwipe = function ( ) {
var tabIndex = tabOrders . indexOf ( $scope . context . currentTab ) ;
if ( tabIndex > 0 ) {
$scope . changeTab ( tabOrders [ tabIndex - 1 ] ) ;
return true ;
} else {
return false ;
}
} ;
2016-05-16 17:41:39 +02:00
$scope . settingService = ariaNgSettingService ;
2016-06-22 16:23:18 +02:00
2016-06-29 17:30:01 +02:00
$scope . isSupportNotification = function ( ) {
return ariaNgNotificationService . isSupportBrowserNotification ( ) &&
ariaNgSettingService . isUseWebSocket ( $scope . context . settings . protocol ) ;
} ;
2016-06-26 16:52:06 +02:00
$scope . setEnableBrowserNotification = function ( value ) {
ariaNgSettingService . setBrowserNotification ( value ) ;
if ( value && ! ariaNgNotificationService . hasBrowserPermission ( ) ) {
ariaNgNotificationService . requestBrowserPermission ( function ( permission ) {
if ( ! ariaNgNotificationService . isPermissionGranted ( permission ) ) {
$scope . context . settings . browserNotification = false ;
ariaNgCommonService . showError ( 'You have disabled notification in your browser. You should change your browser\'s settings before you enable this function.' ) ;
}
} ) ;
}
} ;
2016-11-06 08:58:04 +01:00
$ ( '[data-toggle="popover"]' ) . popover ( ) ;
2016-08-01 16:49:16 +02:00
$rootScope . loadPromise = $timeout ( function ( ) { } , 100 ) ;
2016-05-16 17:41:39 +02:00
} ] ) ;
2016-08-01 16:49:16 +02:00
} ( ) ) ;