Updates for optimizing interaction with sign-in action.

This commit is contained in:
kunw 2016-11-16 17:54:47 +08:00
parent 05759cf0ad
commit 2ccb521e42
4 changed files with 14 additions and 16 deletions

View File

@ -36,20 +36,24 @@
vm.doLogOut = doLogOut;
vm.signInTIP = false;
function reset() {
vm.hasError = false;
vm.errorMessage = '';
}
function doSignIn(user) {
if(user && angular.isDefined(user.principal) && angular.isDefined(user.password)) {
function doSignIn(user) {
if($scope.user.principal.length === 0 || $scope.user.password.length === 0) {
vm.hasError = true;
vm.errorMessage = 'username_and_password_are_required';
}
if(user.principal && user.password) {
vm.lastUrl = getParameterByName('last_url', $location.absUrl());
vm.signInTIP = true;
SignInService(user.principal, user.password)
.success(signedInSuccess)
.error(signedInFailed);
}
}
}
function signedInSuccess(data, status) {

View File

@ -125,6 +125,7 @@ var locale_messages = {
'username_already_exist': 'Username already exist.',
'username_does_not_exist': 'Username does not exist.',
'username_or_password_is_incorrect': 'Username or password is incorrect',
'username_and_password_are_required': 'Both username and password are required.',
'username_email': 'Username/Email',
'project_name_is_required': 'Project name is required',
'project_already_exist': 'Project already exist',

View File

@ -125,6 +125,7 @@ var locale_messages = {
'username_already_exist': '用户名已存在。',
'username_does_not_exist': '用户名不存在。',
'username_or_password_is_incorrect': '用户名或密码不正确。',
'username_and_password_are_required': '用户名和密码为必填项。',
'username_email': '用户名/邮箱',
'project_name_is_required': '项目名称为必填项。',
'project_already_exist': '项目已存在。',
@ -183,7 +184,7 @@ var locale_messages = {
'name_is_required': '名称为必填项',
'name_is_too_long': '名称长度超出限制。最长为20个字符',
'description_is_too_long': '描述内容长度超出限制。',
'general_setting': '一般设置',
'general_setting': '一般设置',
'destination_setting': '目标设置',
'endpoint': '目标URL',
'endpoint_is_required': '目标URL为必填项。',

View File

@ -23,21 +23,13 @@
<form name="form" class="form-horizontal css-form" novalidate autocomplete="off">
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input id="username" type="text" class="form-control" placeholder="// 'username_email' | tr //" name="uPrincipal" ng-change="vm.reset()" ng-model="user.principal" required>
<div class="error-message">
<div ng-messages="form.$submitted && form.uPrincipal.$error">
<span ng-message="required">// 'username_is_required' | tr //</span>
</div>
</div>
<input id="username" type="text" class="form-control" placeholder="// 'username_email' | tr //" name="uPrincipal" ng-change="vm.reset()" ng-model="user.principal">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<input type="password" class="form-control" placeholder="// 'password' | tr //" name="uPassword" ng-change="vm.reset()" ng-model="user.password" required>
<input type="password" class="form-control" placeholder="// 'password' | tr //" name="uPassword" ng-change="vm.reset()" ng-model="user.password">
<div class="error-message">
<div ng-messages="form.$submitted && form.uPassword.$error">
<span ng-message="required">// 'password_is_required' | tr //</span>
</div>
<span ng-show="vm.hasError">// vm.errorMessage | tr //</span>
</div>
</div>