(js) Make use of 'controllerAs' in MainUI module
parent
6e82a7ba7b
commit
fb7d5b628f
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
"Connect" = "Connect";
|
"Connect" = "Connect";
|
||||||
|
|
||||||
|
"Authentication Failed" = "Authentication Failed";
|
||||||
"Wrong username or password." = "Wrong username or password.";
|
"Wrong username or password." = "Wrong username or password.";
|
||||||
"cookiesNotEnabled" = "You cannot login because your browser's cookies are disabled. Please enable cookies in your browser's settings and try again.";
|
"cookiesNotEnabled" = "You cannot login because your browser's cookies are disabled. Please enable cookies in your browser's settings and try again.";
|
||||||
|
|
||||||
|
|
|
@ -17,30 +17,11 @@
|
||||||
-->
|
-->
|
||||||
<main class="view md-layout-fill md-layout-padding" ui-view="login" layout="row" layout-align="center start">
|
<main class="view md-layout-fill md-layout-padding" ui-view="login" layout="row" layout-align="center start">
|
||||||
<md-content class="md-padding" md-scroll-y="true">
|
<md-content class="md-padding" md-scroll-y="true">
|
||||||
<div ng-controller="loginController">
|
<div ng-controller="LoginController as app">
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var cookieUsername = '<var:string var:value="cookieUsername" const:escapeHTML="NO"/>';
|
var cookieUsername = '<var:string var:value="cookieUsername" const:escapeHTML="NO"/>';
|
||||||
</script>
|
</script>
|
||||||
<!-- <div id="aboutBox" style="display:none;">
|
|
||||||
<div>
|
|
||||||
<p class="logo"><img const:alt="SOGo" rsrc:src="img/sogo-logo.png"/></p>
|
|
||||||
<p>Version <var:string value="version"/> <span class="buildDate">(<var:string value="buildDate" />)</span></p>
|
|
||||||
<p class="scroll"><var:string label:value="AboutBox" const:escapeHTML="NO"/></p>
|
|
||||||
<img const:alt="Inverse" rsrc:src="img/inverse.png"/>
|
|
||||||
<p class="links"><a href="http://sogo.nu/" target="_new">sogo.nu</a> /
|
|
||||||
<a href="http://inverse.ca/" target="_new">inverse.ca</a></p>
|
|
||||||
<p><a id="aboutClose" href="#" class="button">
|
|
||||||
<span><var:string label:value="OK" /></span></a></p>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
<!-- <nav class="top-bar">
|
|
||||||
<section class="top-bar-section">
|
|
||||||
<ul class="right">
|
|
||||||
<li><a href="#"><var:string label:value="About" /></a></li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</nav> -->
|
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<div id="logo">
|
<div id="logo">
|
||||||
<img const:alt="*" id="splash" rsrc:src="img/sogo-full.svg"/>
|
<img const:alt="*" id="splash" rsrc:src="img/sogo-full.svg"/>
|
||||||
|
@ -48,28 +29,26 @@
|
||||||
|
|
||||||
<form name="loginForm" layout="column"
|
<form name="loginForm" layout="column"
|
||||||
ng-cloak="ng-cloak"
|
ng-cloak="ng-cloak"
|
||||||
ng-controller="loginController"
|
ng-submit="app.login()">
|
||||||
ng-submit="login(creds)">
|
|
||||||
<var:if condition="hasLoginSuffix">
|
<var:if condition="hasLoginSuffix">
|
||||||
<input type="hidden" ng-model="creds.loginSuffix" var:value="loginSuffix"/>
|
<input type="hidden" ng-model="app.creds.loginSuffix" var:value="loginSuffix"/>
|
||||||
</var:if>
|
</var:if>
|
||||||
<div ng-show="warning" ng-cloak="ng-cloak" alert="alert" class="alert-box radius warning">{{warning}}</div>
|
|
||||||
<md-input-container>
|
<md-input-container>
|
||||||
<label>
|
<label>
|
||||||
<var:string label:value="Username"/>
|
<var:string label:value="Username"/>
|
||||||
</label>
|
</label>
|
||||||
<input autocapitalize="off" type="text" ng-model="creds.username" required="required" />
|
<input autocapitalize="off" type="text" ng-model="app.creds.username" required="required" />
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
<md-input-container>
|
<md-input-container>
|
||||||
<label>
|
<label>
|
||||||
<var:string label:value="Password"/>
|
<var:string label:value="Password"/>
|
||||||
</label>
|
</label>
|
||||||
<input type="password" ng-model="creds.password" required="required" />
|
<input type="password" ng-model="app.creds.password" required="required" />
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
|
|
||||||
<!-- CONNECT BUTTON -->
|
<!-- CONNECT BUTTON -->
|
||||||
<div layout="row" layout-align="end center">
|
<div layout="row" layout-align="end center">
|
||||||
<md-button class="md-raised" type="submit" ng-disabled='!loginForm.$valid'>
|
<md-button class="md-raised" type="submit" ng-disabled='app.loginForm.$invalid'>
|
||||||
<span>
|
<span>
|
||||||
<var:string label:value="Connect"/>
|
<var:string label:value="Connect"/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -82,7 +61,7 @@
|
||||||
<label class="login-lang">
|
<label class="login-lang">
|
||||||
<var:string label:value="Language"/>
|
<var:string label:value="Language"/>
|
||||||
</label>
|
</label>
|
||||||
<md-select flex="true" ng-model="creds.language">
|
<md-select flex="true" ng-model="app.creds.language">
|
||||||
<var:foreach list="languages" item="item">
|
<var:foreach list="languages" item="item">
|
||||||
<md-option var:value="item">
|
<md-option var:value="item">
|
||||||
<var:string value="languageText"/>
|
<var:string value="languageText"/>
|
||||||
|
@ -98,7 +77,7 @@
|
||||||
<label>
|
<label>
|
||||||
<var:string label:value="Domain"/>
|
<var:string label:value="Domain"/>
|
||||||
</label>
|
</label>
|
||||||
<md-select flex="true" ng-model="creds.domain" label:placeholder="choose">
|
<md-select class="md-flex" ng-model="app.creds.domain" label:placeholder="choose">
|
||||||
<var:foreach list="loginDomains" item="item">
|
<var:foreach list="loginDomains" item="item">
|
||||||
<md-option var:value="item">
|
<md-option var:value="item">
|
||||||
<var:string value="item"/>
|
<var:string value="item"/>
|
||||||
|
@ -109,7 +88,7 @@
|
||||||
</var:if>
|
</var:if>
|
||||||
|
|
||||||
<div layout="row" layout-align="center center">
|
<div layout="row" layout-align="center center">
|
||||||
<md-switch ng-model="creds.rememberLogin" label:arial-label="Remember username">
|
<md-switch ng-model="app.creds.rememberLogin" label:arial-label="Remember username">
|
||||||
<var:string label:value="Remember username"/>
|
<var:string label:value="Remember username"/>
|
||||||
</md-switch>
|
</md-switch>
|
||||||
</div>
|
</div>
|
||||||
|
@ -117,7 +96,7 @@
|
||||||
<div layout="row" layout-align="end end" ng-cloak="ng-cloak">
|
<div layout="row" layout-align="end end" ng-cloak="ng-cloak">
|
||||||
<md-button class="sg-icon-button fg-sogoPaper-500"
|
<md-button class="sg-icon-button fg-sogoPaper-500"
|
||||||
label:aria-label="About"
|
label:aria-label="About"
|
||||||
ng-click="showAbout()">
|
ng-click="app.showAbout()">
|
||||||
<md-icon class="material-icons fg-sogoPaper-500">info</md-icon>
|
<md-icon class="material-icons fg-sogoPaper-500">info</md-icon>
|
||||||
</md-button>
|
</md-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -136,7 +115,7 @@
|
||||||
<!--<img class="full-image" const:alt="Inverse" rsrc:src="img/inverse.png"/>-->
|
<!--<img class="full-image" const:alt="Inverse" rsrc:src="img/inverse.png"/>-->
|
||||||
</md-dialog-content>
|
</md-dialog-content>
|
||||||
<div class="md-actions">
|
<div class="md-actions">
|
||||||
<md-button ng-click="closeDialog()"><var:string label:value="Close"/></md-button>
|
<md-button ng-click="about.closeDialog()"><var:string label:value="Close"/></md-button>
|
||||||
</div>
|
</div>
|
||||||
</md-dialog>
|
</md-dialog>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -26,9 +26,6 @@
|
||||||
// TODO: convert to a Factory recipe?
|
// TODO: convert to a Factory recipe?
|
||||||
.provider('Authentication', Authentication);
|
.provider('Authentication', Authentication);
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngInject
|
|
||||||
*/
|
|
||||||
function Authentication() {
|
function Authentication() {
|
||||||
function readCookie(name) {
|
function readCookie(name) {
|
||||||
var foundCookie, prefix, pairs, i, currentPair, start;
|
var foundCookie, prefix, pairs, i, currentPair, start;
|
||||||
|
@ -91,9 +88,11 @@
|
||||||
|
|
||||||
this.$get = getService;
|
this.$get = getService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ngInject
|
||||||
|
*/
|
||||||
getService.$inject = ['$q', '$http', 'passwordPolicyConfig'];
|
getService.$inject = ['$q', '$http', 'passwordPolicyConfig'];
|
||||||
function getService($q, $http, passwordPolicyConfig) {
|
function getService($q, $http, passwordPolicyConfig) {
|
||||||
|
|
||||||
var _this = this, service;
|
var _this = this, service;
|
||||||
|
|
||||||
service = {
|
service = {
|
||||||
|
|
|
@ -4,35 +4,46 @@
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('SOGo.MainUI', ['SOGo.Common', 'SOGo.Authentication'])
|
angular.module('SOGo.MainUI', ['SOGo.Common', 'SOGo.Authentication']);
|
||||||
.controller('loginController', loginController);
|
|
||||||
|
|
||||||
loginController.$inject = ['$scope', '$mdDialog', 'Authentication'];
|
/**
|
||||||
function loginController($scope, $mdDialog, Authentication) {
|
* @ngInject
|
||||||
$scope.warning = false;
|
*/
|
||||||
$scope.creds = { username: cookieUsername, password: null };
|
LoginController.$inject = ['$scope', 'Dialog', '$mdDialog', 'Authentication'];
|
||||||
$scope.login = function(creds) {
|
function LoginController($scope, Dialog, $mdDialog, Authentication) {
|
||||||
$scope.warning = false;
|
var vm = this;
|
||||||
Authentication.login(creds)
|
|
||||||
|
vm.creds = { username: cookieUsername, password: null };
|
||||||
|
vm.login = login;
|
||||||
|
vm.showAbout = showAbout;
|
||||||
|
|
||||||
|
function login() {
|
||||||
|
Authentication.login(vm.creds)
|
||||||
.then(function(url) {
|
.then(function(url) {
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}, function(msg) {
|
}, function(msg) {
|
||||||
$scope.warning = msg.error;
|
Dialog.alert(l('Authentication Failed'), msg.error);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
$scope.showAbout = function($event) {
|
|
||||||
|
function showAbout($event) {
|
||||||
$mdDialog.show({
|
$mdDialog.show({
|
||||||
targetEvent: $event,
|
targetEvent: $event,
|
||||||
templateUrl: 'aboutBox.html',
|
templateUrl: 'aboutBox.html',
|
||||||
controller: AboutDialogController
|
controller: AboutDialogController,
|
||||||
|
controllerAs: 'about'
|
||||||
});
|
});
|
||||||
AboutDialogController.$inject = ['scope', '$mdDialog'];
|
AboutDialogController.$inject = ['$mdDialog'];
|
||||||
function AboutDialogController(scope, $mdDialog) {
|
function AboutDialogController($mdDialog) {
|
||||||
scope.closeDialog = function() {
|
this.closeDialog = function() {
|
||||||
$mdDialog.hide();
|
$mdDialog.hide();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
angular
|
||||||
|
.module('SOGo.MainUI')
|
||||||
|
.controller('LoginController', LoginController);
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue