1
|
|
|
/* global API */ |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Nextcloud - passman |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
7
|
|
|
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
8
|
|
|
* @license GNU AGPL version 3 or any later version |
9
|
|
|
* |
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
13
|
|
|
* License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
(function () { |
26
|
|
|
'use strict'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @ngdoc function |
30
|
|
|
* @name passmanApp.controller:MainCtrl |
31
|
|
|
* @description |
32
|
|
|
* # MainCtrl |
33
|
|
|
* Controller of the passmanApp |
34
|
|
|
*/ |
35
|
|
|
angular.module('passmanExtension') |
36
|
|
|
.controller('SettingsCtrl', ['$scope', 'notify', '$routeParams', function ($scope, notify, $routeParams) { |
37
|
|
|
$scope.settings = { |
38
|
|
|
accounts: [], |
39
|
|
|
ignoreProtocol: true, |
40
|
|
|
ignoreSubdomain: true, |
41
|
|
|
ignorePort: true, |
42
|
|
|
ignorePath: true, |
43
|
|
|
generatedPasswordLength: 12, |
44
|
|
|
remember_password: true, |
45
|
|
|
refreshTime: 60, |
46
|
|
|
debug: false |
47
|
|
|
}; |
48
|
|
|
$scope.errors = []; |
49
|
|
|
|
50
|
|
|
$scope.tabActive = ($routeParams.tab) ? parseInt($routeParams.tab) : 1; |
51
|
|
|
$scope.extension = API.runtime.getManifest().name + ' extension ' + API.runtime.getManifest().version; |
52
|
|
|
|
53
|
|
|
API.runtime.sendMessage(API.runtime.id, {'method': 'getRuntimeSettings'}).then(function (settings) { |
54
|
|
|
$scope.errors = []; |
55
|
|
|
if (settings) { |
56
|
|
|
$scope.settings = angular.copy(settings); |
57
|
|
|
} |
58
|
|
|
$scope.$apply(); |
59
|
|
|
}); |
60
|
|
|
|
61
|
|
|
$scope.saving = false; |
62
|
|
|
$scope.saveSettings = function (redirect) { |
63
|
|
|
$scope.errors = []; |
64
|
|
|
var settings = angular.copy($scope.settings); |
65
|
|
|
$scope.saving = true; |
66
|
|
|
API.runtime.sendMessage(API.runtime.id, {method: "saveSettings", args: settings}).then(function () { |
67
|
|
|
setTimeout(function () { |
68
|
|
|
if(redirect) { |
69
|
|
|
window.location = '#!/'; |
70
|
|
|
} |
71
|
|
|
$scope.saving = false; |
72
|
|
|
}, 750); |
73
|
|
|
}); |
74
|
|
|
}; |
75
|
|
|
|
76
|
|
|
$scope.removeSite = function (site) { |
77
|
|
|
var idx = $scope.settings.ignored_sites.indexOf(site); |
78
|
|
|
$scope.settings.ignored_sites.splice(idx, 1); |
79
|
|
|
}; |
80
|
|
|
|
81
|
|
|
$scope.ignoreSite = ''; |
82
|
|
|
$scope.addSite = function (site) { |
83
|
|
|
$scope.settings.ignored_sites.push(site); |
84
|
|
|
$scope.ignoreSite = ''; |
85
|
|
|
}; |
86
|
|
|
|
87
|
|
|
$scope.removeAccount = function (account) { |
88
|
|
|
var idx = $scope.settings.accounts.indexOf(account); |
89
|
|
|
$scope.settings.accounts.splice(idx, 1); |
90
|
|
|
$scope.saveSettings(false); |
91
|
|
|
}; |
92
|
|
|
|
93
|
|
|
$scope.cancel = function () { |
94
|
|
|
window.location = '#!/'; |
95
|
|
|
}; |
96
|
|
|
$scope.addAccount = function () { |
97
|
|
|
window.location = '#!/accounts/add'; |
98
|
|
|
}; |
99
|
|
|
}]); |
100
|
|
|
}()); |
101
|
|
|
|
102
|
|
|
|