Completed
Push — master ( 3d31b2...c9ad65 )
by Sander
8s
created

angular.controller(ꞌMainCtrlꞌ)   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 8.8571
cc 5
nc 4
nop 0
1
/**
2
 * Nextcloud - passman
3
 *
4
 * @copyright Copyright (c) 2016, Sander Brand ([email protected])
5
 * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected])
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
(function () {
24
	'use strict';
25
26
	/**
27
	 * @ngdoc function
28
	 * @name passmanApp.controller:MainCtrl
29
	 * @description
30
	 * # MainCtrl
31
	 * Controller of the passmanApp
32
	 */
33
	angular.module('passmanApp')
34
		.controller('MainCtrl', ['$scope', '$rootScope', '$location', 'SettingsService', function ($scope, $rootScope, $location, SettingsService) {
35
			$scope.selectedVault = false;
36
37
			$scope.http_warning_hidden = true;
38
			if ($location.$$protocol === 'http' && $location.$$host !== 'localhost' && $location.$host !== '127.0.0.1') {
39
				$scope.using_http = true;
40
				$scope.http_warning_hidden = false;
41
42
			}
43
44
			$rootScope.$on('settings_loaded', function(){
45
				if (SettingsService.getSetting('disable_contextmenu') === '1' || SettingsService.getSetting('disable_contextmenu') === 1) {
46
					document.addEventListener('contextmenu', function (event) {
47
						event.preventDefault();
48
					});
49
				}
50
				if (SettingsService.getSetting('https_check') === '0' || SettingsService.getSetting('https_check') === 0) {
51
					$scope.http_warning_hidden = true;
52
				}
53
			});
54
55
			$rootScope.setHttpWarning = function (state) {
56
				$scope.http_warning_hidden = state;
57
			};
58
59
			$rootScope.$on('app_menu', function (evt, shown) {
60
				$scope.app_sidebar = shown;
61
			});
62
63
			$rootScope.$on('logout', function () {
64
				$scope.selectedVault = false;
65
			});
66
		}]);
67
68
}());