-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsettings.js
59 lines (51 loc) · 1.87 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
/**
* @ngdoc function
* @name App.controller:SettingsCtrl
* @description
* # SettingsCtrl
* Controller of the App
*/
angular.module('App')
.controller('SettingsCtrl', function ($scope, $rootScope, $location, $mdDialog, $mdToast, SettingsService) {
$rootScope.$emit('page-title', 'BHB ⚡️ Settings');
$scope.loading = true;
SettingsService.getAllSettings()
.then(function (settings) {
$scope.currentSettings = settings;
})
.finally(function () {
$scope.loading = false;
});
$scope.validUnits = ['XBT', 'SAT', 'mSAT'];
$scope.disconnectFromServer = function (ev) {
var confirm = $mdDialog.confirm()
.title('Do you really want to disconnect?')
.textContent('You will be asked for a new lightning-ui server address the next time you\'ll come back')
.ariaLabel('Confirm disconnection')
.targetEvent(ev)
.ok('Disconnect')
.cancel('Cancel');
$mdDialog.show(confirm)
.then(function () {
window.localStorage.removeItem('serverHost');
window.location.reload();
});
};
$scope.save = function () {
$scope.loading = true;
SettingsService.updateSettings($scope.currentSettings)
.then(function () {
$mdToast.show(
$mdToast.simple()
.textContent('Settings saved!')
.position('bottom right')
.hideDelay(3000)
);
$scope.loading = false;
});
};
$scope.goTo = function (path) {
$location.path(path);
};
});