--- /dev/null
+'use strict';
+
+var alloWebadminControllers = angular.module('AlloWebadminControllers', []);
+
+alloWebadminControllers
+ .controller('MainCtrl',
+ ['$scope', '$rootScope', 'allo_server_url', 'sugar_fqdn',
+ function($scope, $rootScope, allo_server_url, sugar_fqdn) {
+ $scope.allo_server_url = allo_server_url;
+ $rootScope.allo_server_url = allo_server_url;
+ $scope.sugar_fqdn = sugar_fqdn;
+ $scope.currentPath = [];
+ }
+ ]
+ )
+ .controller('MenuCtrl',
+ ['$scope',
+ function($scope) {
+ $scope.menuItems = [
+ {'value': 'Products', 'name': 'Produits'},
+ {'value': 'Customers', 'name': 'Clients'},
+ {'value': 'Warnings', 'name': 'Alertes'}
+ ];
+
+ $scope.setActive = function(menuItem) {
+ $scope.activeMenu = menuItem;
+ };
+
+ $scope.setActive($scope.menuItems[0]);
+
+ //$scope.currentPath[0] = "products";
+ }
+ ]
+ )
+ .controller('LoginCtrl',
+ ['$scope', '$rootScope', '$location', 'AuthenticationService', 'allo_server_url',
+ function ($scope, $rootScope, $location, AuthenticationService, allo_server_url) {
+ AuthenticationService.ClearCredentials();
+
+ $scope.loginAction = function () {
+ $scope.dataLoading = true;
+ AuthenticationService.Login(allo_server_url, $scope.login, $scope.password, function(response) {
+ if(response.retour === "OK") {
+ AuthenticationService.SetCredentials($scope.login, $scope.password);
+ $location.path('/');
+ $scope.result = response.result;
+ } else {
+ $scope.error = response.message;
+ $scope.dataLoading = false;
+ }
+ });
+ };
+ }
+ ]
+ )
+ .controller('LogoutCtrl',
+ ['$scope', '$rootScope', '$location', 'AuthenticationService', 'allo_server_url',
+ function ($scope, $rootScope, $location, AuthenticationService, allo_server_url) {
+ AuthenticationService.ClearCredentials();
+
+ AuthenticationService.Logout(allo_server_url, function(response) {
+ if(response.retour === "OK") {
+ $location.path('/');
+ $scope.result = response.result;
+ } else {
+ $scope.error = response.message;
+ }
+ });
+ }
+ ]
+ );
\ No newline at end of file