-
Notifications
You must be signed in to change notification settings - Fork 37
/
main.controllers.js
50 lines (49 loc) · 1.53 KB
/
main.controllers.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
angular.module('admin.main.controllers', ['resource.users']).controller('GlobalController', [
"$scope", "$location", "account", "version", "$localStorage", function($scope, $location, account, version, $localStorage) {
account.get().then(function(data) {
return $scope.User = data;
});
version.get().then(function(data) {
if (!data.length) {
return;
}
$scope.newVersion = data[0];
if ($scope.newVersion.ver !== $localStorage.ver) {
return $scope.newVersion.showDialog = true;
}
});
return $scope.versionClick = function() {
$localStorage.ver = $scope.newVersion.ver;
return $scope.newVersion.showDialog = false;
};
}
]).controller('LoginController', [
"$scope", "$window", "User", function($scope, $window, User) {
$scope.signin = function() {
$scope.submitting = true;
return User.signin({
id: '(1)'
}, $scope.user, function(data) {
$scope.submitting = false;
return $window.location.href = '/admin/';
}, function(error) {
$scope.error = error.data['odata.error'].innererror.message;
$scope.user.Password = '';
return $scope.submitting = false;
});
};
$scope.signout = function() {
$scope.submitting = true;
return User.signout({
id: '(1)'
}, function(data) {
$scope.submitting = false;
return $window.location.href = '/';
});
};
return $scope.backHome = function() {
return $window.location.href = '/';
};
}
]);