2019-09-18 15:02:21 +09:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
Input,
|
|
|
|
Output,
|
|
|
|
EventEmitter,
|
|
|
|
ViewChild,
|
2019-11-15 11:21:42 +09:00
|
|
|
ElementRef,
|
|
|
|
ChangeDetectorRef
|
2019-09-18 15:02:21 +09:00
|
|
|
} from '@angular/core';
|
|
|
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|
|
|
import { Company } from '@ucap-webmessenger/api-external';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'ucap-account-login',
|
|
|
|
templateUrl: './login.component.html',
|
|
|
|
styleUrls: ['./login.component.scss']
|
|
|
|
})
|
|
|
|
export class LoginComponent implements OnInit {
|
|
|
|
@Input()
|
2019-09-26 14:38:21 +09:00
|
|
|
companyList?: Company[];
|
2019-11-14 14:19:59 +09:00
|
|
|
@Input()
|
2019-12-15 14:49:04 +09:00
|
|
|
curCompanyCode?: string;
|
|
|
|
@Input()
|
2019-11-14 14:19:59 +09:00
|
|
|
loginBtnText?: string;
|
|
|
|
@Input()
|
|
|
|
loginBtnEnable: boolean;
|
2019-12-15 14:49:52 +09:00
|
|
|
@Input()
|
|
|
|
notiText?: string;
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-12-15 22:49:35 +09:00
|
|
|
@Input()
|
|
|
|
companyCode: string;
|
|
|
|
@Input()
|
|
|
|
loginId: string;
|
|
|
|
@Input()
|
|
|
|
rememberMe: boolean;
|
|
|
|
@Input()
|
|
|
|
autoLogin: boolean;
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
useRememberMe: boolean;
|
|
|
|
@Input()
|
|
|
|
useAutoLogin: boolean;
|
|
|
|
|
2019-09-18 15:02:21 +09:00
|
|
|
@Output()
|
|
|
|
login = new EventEmitter<{
|
|
|
|
companyCode: string;
|
|
|
|
loginId: string;
|
|
|
|
loginPw: string;
|
|
|
|
rememberMe: boolean;
|
2019-12-15 22:49:35 +09:00
|
|
|
autoLogin: boolean;
|
2019-09-18 15:02:21 +09:00
|
|
|
notValid: () => void;
|
|
|
|
}>();
|
2019-12-15 14:49:52 +09:00
|
|
|
@Output()
|
|
|
|
notiClick = new EventEmitter();
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
@ViewChild('loginPw', { static: true }) loginPwElementRef: ElementRef;
|
|
|
|
|
|
|
|
loginForm: FormGroup;
|
|
|
|
|
2019-10-15 09:31:33 +09:00
|
|
|
constructor(
|
|
|
|
private formBuilder: FormBuilder,
|
2019-12-15 22:49:35 +09:00
|
|
|
private changeDetectorRef: ChangeDetectorRef
|
2019-10-15 09:31:33 +09:00
|
|
|
) {}
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.loginForm = this.formBuilder.group({
|
2019-11-15 11:21:42 +09:00
|
|
|
companyCode: ['', [Validators.required]],
|
|
|
|
loginId: ['', [Validators.required]],
|
2019-10-15 09:31:33 +09:00
|
|
|
loginPw: ['', Validators.required],
|
2019-12-15 22:49:35 +09:00
|
|
|
rememberMe: [false],
|
|
|
|
autoLogin: [false]
|
2019-09-18 15:02:21 +09:00
|
|
|
});
|
2019-11-14 14:19:59 +09:00
|
|
|
|
2019-12-15 22:49:35 +09:00
|
|
|
if (!!this.rememberMe && this.rememberMe) {
|
|
|
|
this.loginForm.get('rememberMe').setValue(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!this.autoLogin && this.autoLogin) {
|
|
|
|
this.loginForm.get('autoLogin').setValue(true);
|
|
|
|
}
|
|
|
|
|
2019-12-15 14:49:04 +09:00
|
|
|
if (!!this.curCompanyCode) {
|
|
|
|
this.loginForm.get('companyCode').setValue(this.curCompanyCode);
|
|
|
|
}
|
2019-12-15 22:49:35 +09:00
|
|
|
if (!!this.loginId) {
|
|
|
|
this.loginForm.get('loginId').setValue(this.loginId);
|
2019-11-15 11:21:42 +09:00
|
|
|
}
|
|
|
|
|
2019-11-14 14:19:59 +09:00
|
|
|
if (!this.loginBtnText || this.loginBtnText.trim().length === 0) {
|
|
|
|
this.loginBtnText = 'LOGIN';
|
|
|
|
}
|
2019-12-15 22:49:35 +09:00
|
|
|
this.changeDetectorRef.detectChanges();
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
onClickLogin() {
|
|
|
|
this.login.emit({
|
|
|
|
companyCode: this.loginForm.get('companyCode').value,
|
|
|
|
loginId: this.loginForm.get('loginId').value,
|
|
|
|
loginPw: this.loginForm.get('loginPw').value,
|
2019-12-15 22:49:35 +09:00
|
|
|
rememberMe: this.loginForm.get('rememberMe').value,
|
|
|
|
autoLogin: this.loginForm.get('autoLogin').value,
|
2019-09-18 15:02:21 +09:00
|
|
|
notValid: () => {
|
|
|
|
this.loginPwElementRef.nativeElement.focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-12-15 14:49:52 +09:00
|
|
|
|
|
|
|
onClickNoti(): void {
|
|
|
|
this.notiClick.emit();
|
|
|
|
}
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|