bug fixed

This commit is contained in:
richard-loafle 2020-04-01 17:18:28 +09:00
parent 12c7550b03
commit 7a39d2e4aa
9 changed files with 120 additions and 78 deletions

10
package-lock.json generated
View File

@ -2272,8 +2272,9 @@
"dev": true "dev": true
}, },
"@ucap/ng-i18n": { "@ucap/ng-i18n": {
"version": "file:pack/ucap-ng-i18n-0.0.5.tgz", "version": "file:pack/ucap-ng-i18n-0.0.6.tgz",
"integrity": "sha512-P+MUurrVyLeRl4l7b4aLMG3/nPpZ54U1U2VQnAGb7OHNvZG/BJVzZqc2Z+YvnNXTe8PhMqkRfRysOZeu1AGj5A==" "integrity": "sha512-0vnoC3tAbXmcnsL1xy5Otswu75ZBht8wrI5Zz1mfSgYT/mnR9QoNkpCHiHfl/ILAJlKD0iBn+BBOrwTIprsJ/Q==",
"dev": true
}, },
"@ucap/ng-logger": { "@ucap/ng-logger": {
"version": "file:pack/ucap-ng-logger-0.0.1.tgz", "version": "file:pack/ucap-ng-logger-0.0.1.tgz",
@ -2401,9 +2402,8 @@
"dev": true "dev": true
}, },
"@ucap/ng-ui-authentication": { "@ucap/ng-ui-authentication": {
"version": "file:pack/ucap-ng-ui-authentication-0.0.5.tgz", "version": "file:pack/ucap-ng-ui-authentication-0.0.8.tgz",
"integrity": "sha512-NwsISychSVyCxVO3j13jNRtHbZpvKY2pb/WBATGPnkYrhaB4x7a+b4gXhWUCmO5QZoYrb2uBV4K9hXANr2Ergg==", "integrity": "sha512-n6pV113DuSD5TV4jAwrY/JJlhcBtNLHEFTTxrQ8QhFIMz9hgbRC6x4R/LF8q9kzx0BWQcgxGdfgY1oN3YoqGtg=="
"dev": true
}, },
"@ucap/ng-ui-organization": { "@ucap/ng-ui-organization": {
"version": "file:pack/ucap-ng-ui-organization-0.0.1.tgz", "version": "file:pack/ucap-ng-ui-organization-0.0.1.tgz",

View File

@ -144,7 +144,7 @@
"@ucap/ng-api-prompt": "file:pack/ucap-ng-api-prompt-0.0.1.tgz", "@ucap/ng-api-prompt": "file:pack/ucap-ng-api-prompt-0.0.1.tgz",
"@ucap/ng-api-public": "file:pack/ucap-ng-api-public-0.0.1.tgz", "@ucap/ng-api-public": "file:pack/ucap-ng-api-public-0.0.1.tgz",
"@ucap/ng-core": "file:pack/ucap-ng-core-0.0.1.tgz", "@ucap/ng-core": "file:pack/ucap-ng-core-0.0.1.tgz",
"@ucap/ng-i18n": "file:pack/ucap-ng-i18n-0.0.5.tgz", "@ucap/ng-i18n": "file:pack/ucap-ng-i18n-0.0.6.tgz",
"@ucap/ng-logger": "file:pack/ucap-ng-logger-0.0.1.tgz", "@ucap/ng-logger": "file:pack/ucap-ng-logger-0.0.1.tgz",
"@ucap/ng-native": "file:pack/ucap-ng-native-0.0.1.tgz", "@ucap/ng-native": "file:pack/ucap-ng-native-0.0.1.tgz",
"@ucap/ng-native-browser": "file:pack/ucap-ng-native-browser-0.0.1.tgz", "@ucap/ng-native-browser": "file:pack/ucap-ng-native-browser-0.0.1.tgz",
@ -170,7 +170,7 @@
"@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.3.tgz", "@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.3.tgz",
"@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.3.tgz", "@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.3.tgz",
"@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.3.tgz", "@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.3.tgz",
"@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.5.tgz", "@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.8.tgz",
"@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.1.tgz", "@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.1.tgz",
"@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz", "@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz",
"@ucap/ng-web-storage": "file:pack/ucap-ng-web-storage-0.0.1.tgz", "@ucap/ng-web-storage": "file:pack/ucap-ng-web-storage-0.0.1.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@ucap/ng-i18n", "name": "@ucap/ng-i18n",
"version": "0.0.5", "version": "0.0.6",
"publishConfig": { "publishConfig": {
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
}, },

View File

@ -13,6 +13,7 @@ import { StringMap, TOptions } from 'i18next';
import { I18nService } from '../services/i18n.service'; import { I18nService } from '../services/i18n.service';
import { UCAP_I18N_NAMESPACE } from '../types/token'; import { UCAP_I18N_NAMESPACE } from '../types/token';
import { ObjectUtil } from '../utils/object.util';
@Pipe({ name: 'ucapI18n', pure: false }) @Pipe({ name: 'ucapI18n', pure: false })
export class I18nPipe implements PipeTransform, OnDestroy { export class I18nPipe implements PipeTransform, OnDestroy {
@ -36,6 +37,13 @@ export class I18nPipe implements PipeTransform, OnDestroy {
key: string | string[], key: string | string[],
options?: TOptions<StringMap> options?: TOptions<StringMap>
): string { ): string {
if (
ObjectUtil.equals(key, this.lastKey) &&
ObjectUtil.equals(options, this.lastOptions)
) {
return this.value;
}
options = options || {}; options = options || {};
if (!!this.ns) { if (!!this.ns) {

View File

@ -0,0 +1,83 @@
export class ObjectUtil {
static equals(o1: any, o2: any): boolean {
if (o1 === o2) {
return true;
}
if (o1 === null || o2 === null) {
return false;
}
if (o1 !== o1 && o2 !== o2) {
return true; // NaN === NaN
}
const t1 = typeof o1;
const t2 = typeof o2;
let length: number;
let key: any;
let keySet: any;
if (t1 === t2 && t1 === 'object') {
if (Array.isArray(o1)) {
if (!Array.isArray(o2)) {
return false;
}
length = o1.length;
if (length === o2.length) {
for (key = 0; key < length; key++) {
if (!ObjectUtil.equals(o1[key], o2[key])) {
return false;
}
}
return true;
}
} else {
if (Array.isArray(o2)) {
return false;
}
keySet = Object.create(null);
for (key in o1) {
if (o1.hasOwnProperty(key)) {
if (!ObjectUtil.equals(o1[key], o2[key])) {
return false;
}
keySet[key] = true;
}
}
for (key in o2) {
if (!(key in keySet) && typeof o2[key] !== 'undefined') {
return false;
}
}
return true;
}
}
return false;
}
static isDefined(value: any): boolean {
return typeof value !== 'undefined' && value !== null;
}
static isObject(item: any): boolean {
return item && typeof item === 'object' && !Array.isArray(item);
}
static mergeDeep(target: any, source: any): any {
const output = Object.assign({}, target);
if (ObjectUtil.isObject(target) && ObjectUtil.isObject(source)) {
Object.keys(source).forEach((key: any) => {
if (ObjectUtil.isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] });
} else {
output[key] = ObjectUtil.mergeDeep(target[key], source[key]);
}
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "@ucap/ng-ui-authentication", "name": "@ucap/ng-ui-authentication",
"version": "0.0.5", "version": "0.0.8",
"publishConfig": { "publishConfig": {
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
}, },

View File

@ -9,6 +9,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { UiModule } from '@ucap/ng-ui'; import { UiModule } from '@ucap/ng-ui';
@ -46,6 +47,7 @@ export class AuthenticationUiRootModule {}
MatFormFieldModule, MatFormFieldModule,
MatIconModule, MatIconModule,
MatInputModule, MatInputModule,
MatProgressSpinnerModule,
MatSelectModule, MatSelectModule,
I18nModule, I18nModule,

View File

@ -3,7 +3,7 @@
<form name="loginForm" [formGroup]="loginForm" novalidate> <form name="loginForm" [formGroup]="loginForm" novalidate>
<mat-form-field <mat-form-field
[style.display]="!!curCompanyCode ? 'none' : 'block'" [style.display]="!!fixedCompanyCode ? 'none' : 'block'"
class="login-company" class="login-company"
> >
<mat-label>{{ 'login.fields.company' | ucapI18n }}</mat-label> <mat-label>{{ 'login.fields.company' | ucapI18n }}</mat-label>
@ -106,36 +106,15 @@
mat-raised-button mat-raised-button
class="submit-button bg-accent-dark" class="submit-button bg-accent-dark"
aria-label="LOG IN" aria-label="LOG IN"
[disabled]="loginForm.invalid || !loginBtnEnable" [disabled]="loginForm.invalid || disable"
(click)="onClickLogin()" (click)="onClickLogin()"
> >
{{ loginBtnText }} <ng-container *ngIf="!processing">
{{ 'login.labels.doLogin' | ucapI18n }}
</ng-container>
<mat-spinner *ngIf="processing"> </mat-spinner>
</button> </button>
<div
class="remember-forgot-password"
fxLayout="row"
fxLayout.xs="column"
fxLayoutAlign="space-between center"
>
<mat-checkbox
*ngIf="useRememberMe"
class="remember-me"
formControlName="rememberMe"
aria-label="Remember Me"
>
{{ 'login.labels.rememberMe' | ucapI18n }}
</mat-checkbox>
<mat-checkbox
*ngIf="useAutoLogin"
class="auto-login"
formControlName="autoLogin"
aria-label="Auto Login"
>
{{ 'login.labels.autoLogin' | ucapI18n }}
</mat-checkbox>
</div>
</form> </form>
<ng-content select="[ucapAuthenticationLogin='footer']"></ng-content> <ng-content select="[ucapAuthenticationLogin='footer']"></ng-content>

View File

@ -25,40 +25,29 @@ import { Company } from '@ucap/api-external';
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
@Input() @Input()
companyList: Company[]; companyList: Company[];
@Input() @Input()
curCompanyCode: string; fixedCompanyCode: string;
@Input()
loginBtnText: string;
@Input()
loginBtnEnable: boolean;
@Input()
notiText: string;
@Input() @Input()
companyCode: string; companyCode: string;
@Input()
loginId: string;
@Input()
rememberMe: boolean;
@Input()
autoLogin: boolean;
@Input() @Input()
useRememberMe: boolean; loginId: string;
@Input() @Input()
useAutoLogin: boolean; disable = false;
@Input()
processing = false;
@Output() @Output()
login = new EventEmitter<{ login = new EventEmitter<{
companyCode: string; companyCode: string;
loginId: string; loginId: string;
loginPw: string; loginPw: string;
rememberMe: boolean;
autoLogin: boolean;
notValid: () => void; notValid: () => void;
}>(); }>();
@Output()
notiClick = new EventEmitter();
@ViewChild('loginPw', { static: true }) loginPwElementRef: ElementRef; @ViewChild('loginPw', { static: true }) loginPwElementRef: ElementRef;
@ -75,8 +64,8 @@ export class LoginComponent implements OnInit {
ngOnInit() { ngOnInit() {
const companyCodeValidators: ValidatorFn[] = [Validators.required]; const companyCodeValidators: ValidatorFn[] = [Validators.required];
this.companyCodeFormControl.setValidators(companyCodeValidators); this.companyCodeFormControl.setValidators(companyCodeValidators);
if (!!this.curCompanyCode) { if (!!this.fixedCompanyCode) {
this.companyCodeFormControl.setValue(this.curCompanyCode); this.companyCodeFormControl.setValue(this.fixedCompanyCode);
} }
const loginIdValidators: ValidatorFn[] = [Validators.required]; const loginIdValidators: ValidatorFn[] = [Validators.required];
this.loginIdFormControl.setValidators(loginIdValidators); this.loginIdFormControl.setValidators(loginIdValidators);
@ -89,22 +78,9 @@ export class LoginComponent implements OnInit {
this.loginForm = this.formBuilder.group({ this.loginForm = this.formBuilder.group({
companyCodeFormControl: this.companyCodeFormControl, companyCodeFormControl: this.companyCodeFormControl,
loginIdFormControl: this.loginIdFormControl, loginIdFormControl: this.loginIdFormControl,
loginPwFormControl: this.loginPwFormControl, loginPwFormControl: this.loginPwFormControl
rememberMe: [false],
autoLogin: [false]
}); });
if (!!this.rememberMe && this.rememberMe) {
this.loginForm.get('rememberMe').setValue(true);
}
if (!!this.autoLogin && this.autoLogin) {
this.loginForm.get('autoLogin').setValue(true);
}
if (!this.loginBtnText || this.loginBtnText.trim().length === 0) {
this.loginBtnText = 'LOGIN';
}
this.changeDetectorRef.detectChanges(); this.changeDetectorRef.detectChanges();
} }
@ -113,15 +89,9 @@ export class LoginComponent implements OnInit {
companyCode: this.loginForm.get('companyCodeFormControl').value, companyCode: this.loginForm.get('companyCodeFormControl').value,
loginId: this.loginForm.get('loginIdFormControl').value, loginId: this.loginForm.get('loginIdFormControl').value,
loginPw: this.loginForm.get('loginPwFormControl').value, loginPw: this.loginForm.get('loginPwFormControl').value,
rememberMe: this.loginForm.get('rememberMe').value,
autoLogin: this.loginForm.get('autoLogin').value,
notValid: () => { notValid: () => {
this.loginPwElementRef.nativeElement.focus(); this.loginPwElementRef.nativeElement.focus();
} }
}); });
} }
onClickNoti(): void {
this.notiClick.emit();
}
} }