Merge pull request #12 from steven-zou/fix/issue_1860

fix issue 1860 and other minor remending
This commit is contained in:
Steven Zou 2017-03-30 13:25:29 +08:00 committed by GitHub
commit ad79cb9e29
11 changed files with 55 additions and 13 deletions

View File

@ -13,7 +13,8 @@
<label for="account_settings_email" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-top-left" [class.invalid]='!getValidationState("account_settings_email")'> <label for="account_settings_email" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-top-left" [class.invalid]='!getValidationState("account_settings_email")'>
<input name="account_settings_email" type="text" #eamilInput="ngModel" [(ngModel)]="account.email" <input name="account_settings_email" type="text" #eamilInput="ngModel" [(ngModel)]="account.email"
required required
pattern='^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$' id="account_settings_email" size="30" email
id="account_settings_email" size="30"
(input)='handleValidation("account_settings_email", false)' (input)='handleValidation("account_settings_email", false)'
(focusout)='handleValidation("account_settings_email", true)'> (focusout)='handleValidation("account_settings_email", true)'>
<span class="tooltip-content"> <span class="tooltip-content">

View File

@ -28,7 +28,7 @@
required required
pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{8,20}$" pattern="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{8,20}$"
name="reNewPassword" name="reNewPassword"
[(ngModel)]="ngModel" [(ngModel)]="confirmPwd"
#reNewPassInput #reNewPassInput
size="25" size="25"
(input)='handleValidation("reNewPassword", true)' (input)='handleValidation("reNewPassword", true)'

View File

@ -21,6 +21,7 @@ export class ResetPasswordComponent implements OnInit {
}; };
private resetUuid: string = ""; private resetUuid: string = "";
private resetOk: boolean = false; private resetOk: boolean = false;
confirmPwd: string = "";
@ViewChild("resetPwdForm") resetPwdForm: NgForm; @ViewChild("resetPwdForm") resetPwdForm: NgForm;
@ViewChild(InlineAlertComponent) @ViewChild(InlineAlertComponent)

View File

@ -162,7 +162,8 @@ export class SignInComponent implements AfterViewChecked, OnInit {
private handleUserCreation(user: User): void { private handleUserCreation(user: User): void {
if (user) { if (user) {
this.currentForm.setValue({ this.currentForm.setValue({
"login_username": user.username "login_username": user.username,
"login_password": ""
}); });
} }

View File

@ -0,0 +1,33 @@
import { Directive } from '@angular/core';
import { ValidatorFn, AbstractControl, Validator, NG_VALIDATORS, Validators } from '@angular/forms';
const emailPattern = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
export function emailValidator(): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => {
const value: string = control.value
if (!value) {
return { 'email': false };
}
const regExp = new RegExp(emailPattern);
if(!regExp.test(value)){
return { 'email': false };
}
return null;
}
}
@Directive({
selector: '[email]',
providers: [{ provide: NG_VALIDATORS, useExisting: EmailValidatorDirective, multi: true }]
})
export class EmailValidatorDirective implements Validator {
valFn = emailValidator();
validate(control: AbstractControl): { [key: string]: any } {
return this.valFn(control);
}
}

View File

@ -17,7 +17,8 @@
<label for="email" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-bottom-left" [class.invalid]='getValidationState("email")'> <label for="email" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-bottom-left" [class.invalid]='getValidationState("email")'>
<input name="email" type="text" #eamilInput="ngModel" [(ngModel)]="newUser.email" <input name="email" type="text" #eamilInput="ngModel" [(ngModel)]="newUser.email"
required required
pattern='^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$' id="email" size="36" email
id="email" size="36"
(input)='handleValidation("email", false)' (input)='handleValidation("email", false)'
(focusout)='handleValidation("email", true)'> (focusout)='handleValidation("email", true)'>
<span class="tooltip-content"> <span class="tooltip-content">

View File

@ -38,6 +38,7 @@ import { ListProjectROComponent } from './list-project-ro/list-project-ro.compon
import { ListRepositoryROComponent } from './list-repository-ro/list-repository-ro.component'; import { ListRepositoryROComponent } from './list-repository-ro/list-repository-ro.component';
import { MessageHandlerService } from './message-handler/message-handler.service'; import { MessageHandlerService } from './message-handler/message-handler.service';
import { EmailValidatorDirective } from './email.directive';
@NgModule({ @NgModule({
imports: [ imports: [
@ -60,7 +61,8 @@ import { MessageHandlerService } from './message-handler/message-handler.service
StatisticsComponent, StatisticsComponent,
StatisticsPanelComponent, StatisticsPanelComponent,
ListProjectROComponent, ListProjectROComponent,
ListRepositoryROComponent ListRepositoryROComponent,
EmailValidatorDirective
], ],
exports: [ exports: [
CoreModule, CoreModule,
@ -79,7 +81,8 @@ import { MessageHandlerService } from './message-handler/message-handler.service
StatisticsComponent, StatisticsComponent,
StatisticsPanelComponent, StatisticsPanelComponent,
ListProjectROComponent, ListProjectROComponent,
ListRepositoryROComponent ListRepositoryROComponent,
EmailValidatorDirective
], ],
providers: [ providers: [
SessionService, SessionService,

View File

@ -130,9 +130,7 @@ export class UserComponent implements OnInit, OnDestroy {
} }
//Value copy //Value copy
let updatedUser: User = { let updatedUser: User = new User(user.user_id);;
user_id: user.user_id
};
if (user.has_admin_role === 0) { if (user.has_admin_role === 0) {
updatedUser.has_admin_role = 1;//Set as admin updatedUser.has_admin_role = 1;//Set as admin

View File

@ -5,6 +5,10 @@
* @class User * @class User
*/ */
export class User { export class User {
constructor(userId: number){
this.user_id = userId;
}
user_id: number; user_id: number;
username?: string; username?: string;
realname?: string; realname?: string;

View File

@ -112,7 +112,7 @@
"IS_ADMIN": "Yes", "IS_ADMIN": "Yes",
"IS_NOT_ADMIN": "No", "IS_NOT_ADMIN": "No",
"ADD_USER_TITLE": "New User", "ADD_USER_TITLE": "New User",
"SAVE_SUCCESS": "New user added successfully", "SAVE_SUCCESS": "New user created successfully",
"DELETION_TITLE": "Confirm user deletion", "DELETION_TITLE": "Confirm user deletion",
"DELETION_SUMMARY": "Do you want to delete user {{param}}?", "DELETION_SUMMARY": "Do you want to delete user {{param}}?",
"DELETE_SUCCESS": "User deleted successfully", "DELETE_SUCCESS": "User deleted successfully",
@ -320,7 +320,7 @@
"COPY": "Copy" "COPY": "Copy"
}, },
"ALERT": { "ALERT": {
"FORM_CHANGE_CONFIRMATION": "Some changes are not saved yet, do you really want to cancel?" "FORM_CHANGE_CONFIRMATION": "Some changes are not saved yet, do you want to cancel?"
}, },
"RESET_PWD": { "RESET_PWD": {
"TITLE": "Reset Password", "TITLE": "Reset Password",
@ -387,7 +387,7 @@
"TEST_MAIL_FAILED": "Failed to verify mail server with error: {{param}}", "TEST_MAIL_FAILED": "Failed to verify mail server with error: {{param}}",
"TEST_LDAP_FAILED": "Failed to verify LDAP server with error: {{param}}", "TEST_LDAP_FAILED": "Failed to verify LDAP server with error: {{param}}",
"LEAVING_CONFIRMATION_TITLE": "Confirm to leave", "LEAVING_CONFIRMATION_TITLE": "Confirm to leave",
"LEAVING_CONFIRMATION_SUMMARY": "Changes have not been saved yet,do you really want to leave currnet page?" "LEAVING_CONFIRMATION_SUMMARY": "Changes have not been saved yet, do you want to leave currnet page?"
}, },
"PAGE_NOT_FOUND": { "PAGE_NOT_FOUND": {
"MAIN_TITLE": "Page not found", "MAIN_TITLE": "Page not found",

View File

@ -112,7 +112,7 @@
"IS_ADMIN": "是", "IS_ADMIN": "是",
"IS_NOT_ADMIN": "否", "IS_NOT_ADMIN": "否",
"ADD_USER_TITLE": "创建用户", "ADD_USER_TITLE": "创建用户",
"SAVE_SUCCESS": "添加用户成功", "SAVE_SUCCESS": "创建用户成功",
"DELETION_TITLE": "删除用户确认", "DELETION_TITLE": "删除用户确认",
"DELETION_SUMMARY": "你确认删除用户 {{param}}?", "DELETION_SUMMARY": "你确认删除用户 {{param}}?",
"DELETE_SUCCESS": "删除用户成功", "DELETE_SUCCESS": "删除用户成功",