2019-11-14 14:19:59 +09:00
|
|
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-09-26 14:38:21 +09:00
|
|
|
import { Store, select } from '@ngrx/store';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-09-26 14:38:21 +09:00
|
|
|
import { Company } from '@ucap-webmessenger/api-external';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-09-26 14:38:21 +09:00
|
|
|
import * as AppStore from '@app/store';
|
|
|
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
|
|
|
import * as CompanyStore from '@app/store/setting/company';
|
2019-11-14 14:19:59 +09:00
|
|
|
import { Observable, Subscription } from 'rxjs';
|
2019-10-02 17:12:51 +09:00
|
|
|
import { Router } from '@angular/router';
|
2019-11-14 14:19:59 +09:00
|
|
|
import { tap, map } from 'rxjs/operators';
|
|
|
|
import {
|
|
|
|
DialogService,
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
} from '@ucap-webmessenger/ui';
|
|
|
|
import { StringUtil } from '@ucap-webmessenger/core';
|
2019-12-15 14:49:52 +09:00
|
|
|
import {
|
|
|
|
NoticeDialogComponent,
|
|
|
|
NoticeDialogResult,
|
|
|
|
NoticeDialogData
|
|
|
|
} from '@app/layouts/messenger/dialogs/account/notice.dialog.component';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-page-account-login',
|
|
|
|
templateUrl: './login.page.component.html',
|
|
|
|
styleUrls: ['./login.page.component.scss']
|
|
|
|
})
|
2019-11-14 14:19:59 +09:00
|
|
|
export class LoginPageComponent implements OnInit, OnDestroy {
|
2019-09-26 14:38:21 +09:00
|
|
|
companyList$: Observable<Company[]>;
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-11-14 14:19:59 +09:00
|
|
|
loginFailureCount: Subscription;
|
|
|
|
|
|
|
|
defatulLoginBtnText: string;
|
|
|
|
loginBtnText: string;
|
|
|
|
loginBtnEnable: boolean;
|
|
|
|
|
|
|
|
timeChecker: any;
|
|
|
|
defatulWaitingTime: number;
|
|
|
|
waitingTime: number;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private router: Router,
|
|
|
|
private dialogService: DialogService
|
|
|
|
) {}
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
ngOnInit(): void {
|
2019-11-14 14:19:59 +09:00
|
|
|
this.defatulLoginBtnText = 'LOGIN';
|
|
|
|
this.defatulWaitingTime = 5 * 60; // sec
|
|
|
|
|
2019-09-26 14:38:21 +09:00
|
|
|
this.store.dispatch(
|
|
|
|
CompanyStore.companyList({
|
|
|
|
companyGroupCode: 'LG'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
this.companyList$ = this.store.pipe(
|
|
|
|
select(AppStore.SettingSelector.CompanySelector.companyList)
|
|
|
|
);
|
2019-11-14 14:19:59 +09:00
|
|
|
|
|
|
|
this.loginFailureCount = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.AccountSelector.AuthenticationSelector.loginFailCount),
|
|
|
|
map(count => {
|
|
|
|
if (count > 0) {
|
|
|
|
if (count < 5) {
|
|
|
|
this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
2019-11-29 16:08:24 +09:00
|
|
|
title: '로그인',
|
2019-11-14 14:19:59 +09:00
|
|
|
html: `아이디 또는 패스워드가<br/>일치하지 않습니다.`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count === 5) {
|
|
|
|
this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
2019-11-29 16:08:24 +09:00
|
|
|
title: '로그인',
|
2019-11-14 14:19:59 +09:00
|
|
|
html: `비밀번호 오류 횟수 초과입니다.<br/>비밀번호를 확인하신 후<br/>잠시 후 다시 시작해 주세요.`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.timeChecker = setInterval(() => this.getCheckTime(), 1000);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (!!this.timeChecker) {
|
|
|
|
clearInterval(this.timeChecker);
|
|
|
|
}
|
|
|
|
this.waitingTime = this.defatulWaitingTime;
|
|
|
|
this.loginBtnText = this.defatulLoginBtnText;
|
|
|
|
this.loginBtnEnable = true;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
if (!!this.loginFailureCount) {
|
|
|
|
this.loginFailureCount.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getCheckTime() {
|
|
|
|
if (this.waitingTime <= 0) {
|
|
|
|
// reset.
|
|
|
|
if (!!this.timeChecker) {
|
|
|
|
clearInterval(this.timeChecker);
|
|
|
|
}
|
|
|
|
this.waitingTime = this.defatulWaitingTime;
|
|
|
|
this.loginBtnText = this.defatulLoginBtnText;
|
|
|
|
this.loginBtnEnable = true;
|
|
|
|
} else {
|
|
|
|
// wait.
|
|
|
|
this.waitingTime = this.waitingTime - 1;
|
|
|
|
|
|
|
|
this.loginBtnText = `${StringUtil.zeroFill(
|
|
|
|
Math.floor(this.waitingTime / 60),
|
|
|
|
2
|
|
|
|
)}:${StringUtil.zeroFill(this.waitingTime % 60, 2)}`;
|
|
|
|
this.loginBtnEnable = false;
|
|
|
|
}
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
onLogin(value: {
|
|
|
|
companyCode: string;
|
|
|
|
loginId: string;
|
|
|
|
loginPw: string;
|
|
|
|
rememberMe: boolean;
|
|
|
|
notValid: () => void;
|
|
|
|
}) {
|
|
|
|
this.store.dispatch(
|
2019-09-24 09:23:30 +09:00
|
|
|
AuthenticationStore.webLogin({
|
2019-09-18 15:02:21 +09:00
|
|
|
loginInfo: {
|
|
|
|
companyCode: value.companyCode,
|
2019-09-27 12:53:21 +09:00
|
|
|
companyGroupType: 'C',
|
2019-09-18 15:02:21 +09:00
|
|
|
loginId: value.loginId,
|
|
|
|
loginPw: value.loginPw
|
|
|
|
},
|
|
|
|
rememberMe: value.rememberMe
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-02 17:12:51 +09:00
|
|
|
|
2019-12-15 14:49:52 +09:00
|
|
|
onClickNoti() {
|
|
|
|
// For Daesang,,
|
|
|
|
this.dialogService.open<
|
|
|
|
NoticeDialogComponent,
|
|
|
|
NoticeDialogData,
|
|
|
|
NoticeDialogResult
|
|
|
|
>(NoticeDialogComponent, {
|
|
|
|
width: '500px',
|
|
|
|
data: {
|
|
|
|
title: '이용시 주의사항',
|
|
|
|
html: `
|
|
|
|
<p>1. 메신저 계정/비밀번호를 타인에게 공유하지 않아야 합니다.</p>
|
|
|
|
<p>2. 회사 중요정보(고객정보 포함)를 업무상 필요한 인원에게 필요한 만큼만 공유해야 합니다.</p>
|
|
|
|
<p>3. 퇴근, 회의 등 자리를 비우는 경우 중요자료가 방치되지 않도록 주의하고, Clean Desk를 실천해야 합니다.</p>
|
|
|
|
<p>4. 메신저를 누군가 허락 없이 함부로 열람하고 그 내부 내용을 타인과 공유하지 않아야 합니다.</p>
|
|
|
|
<p>5. 공용PC에 메신저 사용 후 반드시 로그아웃 하시기 바랍니다.</p>
|
|
|
|
<p>6. 사내메신저는 업무용 협업도구입니다. 비업무용 소통을 자제하시기 바랍니다.</p>
|
|
|
|
<p>7. 업무상 인지한 정보(개인의 프라이버시 포함)나 일반인에게 공개되지 않은 회사기록을 통해 얻은 정보는 오직 회사의 이익을 위해서 활용하여야 하며 사외에 유출하거나 타인에게 알려주거나 업무 이외의 목적에 사용하여서는 아니 됩니다.</p>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
});
|
2019-10-02 17:12:51 +09:00
|
|
|
}
|
2019-12-15 14:49:52 +09:00
|
|
|
|
|
|
|
// onClickTemplate() {
|
|
|
|
// this.router.navigate(['/template']);
|
|
|
|
// }
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|