From d182202fc6001983541504ed323d68479086317e Mon Sep 17 00:00:00 2001 From: WuKong Date: Sat, 22 Apr 2017 13:25:07 +0200 Subject: add moonv4 Change-Id: I247af788d0b0fb961fbc85416486b241eb1d807c Signed-off-by: WuKong --- .../authentication/authentication.controller.js | 54 ++++++++++++++++++++++ .../app/authentication/authentication.tpl.html | 28 +++++++++++ 2 files changed, 82 insertions(+) create mode 100644 moonv4/moon_gui/static/app/authentication/authentication.controller.js create mode 100644 moonv4/moon_gui/static/app/authentication/authentication.tpl.html (limited to 'moonv4/moon_gui/static/app/authentication') diff --git a/moonv4/moon_gui/static/app/authentication/authentication.controller.js b/moonv4/moon_gui/static/app/authentication/authentication.controller.js new file mode 100644 index 00000000..d3510fed --- /dev/null +++ b/moonv4/moon_gui/static/app/authentication/authentication.controller.js @@ -0,0 +1,54 @@ +/** + * @author Samy Abdallah + */ +(function() { + + 'use strict'; + + angular + .module('moon') + .controller('AuthenticationController', AuthenticationController); + + AuthenticationController.$inject = ['authenticationService', '$translate', 'alertService', '$state', '$rootScope']; + + function AuthenticationController(authenticationService, $translate, alertService, $state, $rootScope) { + + var vm = this; + + vm.login = login; + vm.loading = false; + + vm.credentials = { + username : '', + password : '' + }; + + activate(); + + function activate(){ + if($rootScope.connected){ + $state.go('moon.dashboard'); + } + } + + function login(){ + vm.loading = true; + authenticationService.Login(vm.credentials, loginSuccess, loginError); + } + + function loginSuccess() { + $translate('moon.login.success').then( function(translatedValue) { + alertService.alertSuccess(translatedValue); + $state.go('moon.dashboard'); + vm.loading = false; + }); + } + + function loginError(reason) { + $translate('moon.login.error', { errorCode: reason.status }).then( function(translatedValue) { + alertService.alertError(translatedValue); + vm.loading = false; + }); + } + } +})(); \ No newline at end of file diff --git a/moonv4/moon_gui/static/app/authentication/authentication.tpl.html b/moonv4/moon_gui/static/app/authentication/authentication.tpl.html new file mode 100644 index 00000000..77d1646b --- /dev/null +++ b/moonv4/moon_gui/static/app/authentication/authentication.tpl.html @@ -0,0 +1,28 @@ +
+ +

Login

+ +
+ +
+ + +
+
Username is required
+
+
+ +
+ + +
+
Password is required
+
+
+ +
+ + +
+
+
\ No newline at end of file -- cgit 1.2.3-korg