From 8f97df85eefe4d648f2002b8d68818ef6020c2df Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Thu, 16 Jan 2014 11:57:55 +0000
Subject: [PATCH] #396 feature - Added i18n support to JS and HTML tags with AngularJS
---
securis/src/main/resources/static/js/login.js | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/securis/src/main/resources/static/js/login.js b/securis/src/main/resources/static/js/login.js
index 1d0f307..29a7eae 100644
--- a/securis/src/main/resources/static/js/login.js
+++ b/securis/src/main/resources/static/js/login.js
@@ -1,21 +1,15 @@
(function() {
'use strict';
- var app = angular.module('app', ['ngRoute']);
+ var app = angular.module('securis');
- app.controller('LoginCtrl', ['$scope', '$http', '$window',
- function($scope, $http, $window) {
+ app.controller('LoginCtrl', ['$scope', '$http', '$window', '$location', 'toaster', '$L',
+ function($scope, $http, $window, $location, toaster, $L) {
+
+ $('#username').focus();
- $scope.$loginerror = false;
- $('#loginError').removeClass('hide');
-
- $scope.hideAlert = function() {
- $scope.$loginerror = false;
- $('#user').focus();
- }
$scope.submit = function() {
console.log('Sending user: ' + $scope.username + ' pass: ' + $scope.password);
- $scope.hideAlert();
$http({ method: 'POST',
url: '/user/login',
headers: {
@@ -27,17 +21,17 @@
})
}).
success(function(data, status, headers, config) {
- $window.location.href = "/main.html";
+ toaster.pop('success', $L.get('Login successful'), $L.get('User {0} has logged in SeCuris', $scope.username), 1500);
+ $location.path('/licenses');
}).
error(function(data, status, headers, config) {
console.error(data + " status: "+ status);
- $scope.$loginerror = true;
if (status === 403 /* forbidden */) {
- $scope.$errormsg = 'Invalid credentials'
+ toaster.pop('error', $L.get('Login error'), $L.get('Invalid credentials'), 3000);
} else {
- $scope.$errormsg = 'Unexpected error HTTP ' + status + ' accessing to server. Contact with the administrator.'
+ toaster.pop('error', $L.get('Unexpected Login error'), $L.get('Unexpected error HTTP ({0}) accessing to server. Contact with the administrator.', status), 5000);
}
- $('#user').focus();
+ $('#username').focus();
});
return false;
}
--
Gitblit v1.3.2