닉네임 중복체크
This commit is contained in:
parent
71876494d5
commit
152994e63b
|
@ -36,6 +36,8 @@ import { Router } from '@angular/router';
|
||||||
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
import { RegistComposeComponent } from '../compose/regist-compose.component';
|
||||||
|
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
|
||||||
|
import { Site } from 'app/modules/protobuf/models/domain/site_pb';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'partner-list',
|
selector: 'partner-list',
|
||||||
templateUrl: './list.component.html',
|
templateUrl: './list.component.html',
|
||||||
|
@ -77,6 +79,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
searchInputControl = new FormControl();
|
searchInputControl = new FormControl();
|
||||||
selectedPartner?: Partner;
|
selectedPartner?: Partner;
|
||||||
pagination?: PartnerPagination;
|
pagination?: PartnerPagination;
|
||||||
|
sites!: Site[];
|
||||||
|
|
||||||
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
private _unsubscribeAll: Subject<any> = new Subject<any>();
|
||||||
|
|
||||||
|
@ -88,6 +91,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
private _fuseConfirmationService: FuseConfirmationService,
|
private _fuseConfirmationService: FuseConfirmationService,
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _partnerService: PartnerService,
|
private _partnerService: PartnerService,
|
||||||
|
private _siteService: SiteService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private _matDialog: MatDialog
|
private _matDialog: MatDialog
|
||||||
) {}
|
) {}
|
||||||
|
@ -113,6 +117,13 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
// Get the products
|
// Get the products
|
||||||
this.partners$ = this._partnerService.partners$;
|
this.partners$ = this._partnerService.partners$;
|
||||||
|
|
||||||
|
this._siteService
|
||||||
|
.listSites()
|
||||||
|
.then((result) => {
|
||||||
|
this.sites = result.getSitesList();
|
||||||
|
})
|
||||||
|
.catch((reson) => console.log(reson));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +214,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
__onClickRegist(event: MouseEvent): void {
|
__onClickRegist(event: MouseEvent): void {
|
||||||
const dialogRef = this._matDialog.open(RegistComposeComponent, {
|
const dialogRef = this._matDialog.open(RegistComposeComponent, {
|
||||||
data: { title: '대본', parentId: 'kgon2' },
|
data: { title: '대본', parentId: 'kgon2', sites: this.sites },
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe((result) => {
|
dialogRef.afterClosed().subscribe((result) => {
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<input matInput [formControlName]="'partnerId'" />
|
<input matInput [formControlName]="'partnerId'" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<!-- <div *ngFor="let f of sites">{{ f.getUrl() }}</div> -->
|
||||||
<!-- Cc -->
|
<!-- Cc -->
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>사이트명</mat-label>
|
<mat-label>사이트명</mat-label>
|
||||||
|
@ -32,6 +33,18 @@
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<!-- <mat-form-field>
|
||||||
|
<mat-label>사이트명</mat-label>
|
||||||
|
<mat-select [formControlName]="'siteName'" placeholder="사이트 선택">
|
||||||
|
<mat-option *ngFor="let site of sites" [value]="site.getId()">
|
||||||
|
{{ site.getUrl() }}
|
||||||
|
</mat-option>
|
||||||
|
</mat-select>
|
||||||
|
<mat-error *ngIf="composeForm.get('siteName')?.hasError('required')">
|
||||||
|
사이트명은 필수 입력입니다.
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field> -->
|
||||||
|
|
||||||
<!-- Bcc -->
|
<!-- Bcc -->
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>회원 아이디</mat-label>
|
<mat-label>회원 아이디</mat-label>
|
||||||
|
@ -69,10 +82,19 @@
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-label>닉네임</mat-label>
|
<mat-label>닉네임</mat-label>
|
||||||
<input matInput [formControlName]="'nickname'" />
|
<input
|
||||||
|
matInput
|
||||||
|
[formControlName]="'nickname'"
|
||||||
|
(focusout)="__checkNickname($event)"
|
||||||
|
/>
|
||||||
<mat-error *ngIf="composeForm.get('nickname')?.hasError('required')">
|
<mat-error *ngIf="composeForm.get('nickname')?.hasError('required')">
|
||||||
닉네임은 필수 입력입니다.
|
닉네임은 필수 입력입니다.
|
||||||
</mat-error>
|
</mat-error>
|
||||||
|
<mat-error
|
||||||
|
*ngIf="composeForm.get('nickname')?.hasError('nicknameDuplicate')"
|
||||||
|
>
|
||||||
|
닉네임이 중복됩니다.
|
||||||
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
|
@ -127,13 +149,9 @@
|
||||||
class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6"
|
class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6"
|
||||||
>
|
>
|
||||||
<div class="flex items-center mt-4 sm:mt-0">
|
<div class="flex items-center mt-4 sm:mt-0">
|
||||||
<!-- Discard -->
|
|
||||||
<button class="ml-auto sm:ml-0" mat-stroked-button (click)="discard()">
|
|
||||||
Discard
|
|
||||||
</button>
|
|
||||||
<!-- Save as draft -->
|
<!-- Save as draft -->
|
||||||
<button class="sm:mx-3" mat-stroked-button (click)="saveAsDraft()">
|
<button class="sm:mx-3" mat-stroked-button (click)="saveAsDraft()">
|
||||||
<span>Save as draft</span>
|
<span>취소</span>
|
||||||
</button>
|
</button>
|
||||||
<!-- Send -->
|
<!-- Send -->
|
||||||
<button
|
<button
|
||||||
|
@ -142,7 +160,7 @@
|
||||||
[color]="'primary'"
|
[color]="'primary'"
|
||||||
(click)="send()"
|
(click)="send()"
|
||||||
>
|
>
|
||||||
Send
|
등록
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,11 +7,14 @@ import {
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
|
||||||
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
|
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
|
||||||
|
import { Site } from 'app/modules/protobuf/models/domain/site_pb';
|
||||||
|
|
||||||
export interface RegistComposeData {
|
export interface RegistComposeData {
|
||||||
title: string;
|
title: string;
|
||||||
parentId: string;
|
parentId: string;
|
||||||
|
sites: Site[];
|
||||||
}
|
}
|
||||||
export interface RegistComposeResult {
|
export interface RegistComposeResult {
|
||||||
parentId: string;
|
parentId: string;
|
||||||
|
@ -34,10 +37,7 @@ export interface RegistComposeResult {
|
||||||
})
|
})
|
||||||
export class RegistComposeComponent implements OnInit {
|
export class RegistComposeComponent implements OnInit {
|
||||||
composeForm!: FormGroup;
|
composeForm!: FormGroup;
|
||||||
copyFields: { cc: boolean; bcc: boolean } = {
|
sites: any[] = [];
|
||||||
cc: false,
|
|
||||||
bcc: false,
|
|
||||||
};
|
|
||||||
// quillModules: any = {
|
// quillModules: any = {
|
||||||
// toolbar: [
|
// toolbar: [
|
||||||
// ['bold', 'italic', 'underline'],
|
// ['bold', 'italic', 'underline'],
|
||||||
|
@ -55,7 +55,12 @@ export class RegistComposeComponent implements OnInit {
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _identityService: IdentityService,
|
private _identityService: IdentityService,
|
||||||
private _changeDetectorRef: ChangeDetectorRef
|
private _changeDetectorRef: ChangeDetectorRef
|
||||||
) {}
|
) {
|
||||||
|
this.data.sites.map((v) => {
|
||||||
|
const a = v.toObject();
|
||||||
|
this.sites.push(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Lifecycle hooks
|
// @ Lifecycle hooks
|
||||||
|
@ -85,21 +90,6 @@ export class RegistComposeComponent implements OnInit {
|
||||||
// @ Public methods
|
// @ Public methods
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the copy field with the given field name
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
showCopyField(name: string): void {
|
|
||||||
// Return if the name is not one of the available names
|
|
||||||
if (name !== 'cc' && name !== 'bcc') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the field
|
|
||||||
this.copyFields[name] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save and close
|
* Save and close
|
||||||
*/
|
*/
|
||||||
|
@ -141,6 +131,21 @@ export class RegistComposeComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__checkNickname(event: FocusEvent): void {
|
||||||
|
const nickname = this.composeForm.get('nickname')?.value;
|
||||||
|
|
||||||
|
this._identityService
|
||||||
|
.checkNicknameForDuplication(nickname)
|
||||||
|
.then((isUse: boolean) => {
|
||||||
|
if (!!isUse) {
|
||||||
|
this.composeForm
|
||||||
|
.get('nickname')
|
||||||
|
?.setErrors({ nicknameDuplicate: true });
|
||||||
|
}
|
||||||
|
this._changeDetectorRef.markForCheck();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// checkSameName(): ValidatorFn {
|
// checkSameName(): ValidatorFn {
|
||||||
// return (control: AbstractControl): { [key: string]: any } | null => {
|
// return (control: AbstractControl): { [key: string]: any } | null => {
|
||||||
// if (
|
// if (
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||||
|
@ -29,6 +31,9 @@ import { partnerRoutes } from './partner.routing';
|
||||||
TranslocoModule,
|
TranslocoModule,
|
||||||
SharedModule,
|
SharedModule,
|
||||||
RouterModule.forChild(partnerRoutes),
|
RouterModule.forChild(partnerRoutes),
|
||||||
|
CommonModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
FormsModule,
|
||||||
|
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatFormFieldModule,
|
MatFormFieldModule,
|
||||||
|
|
|
@ -7,11 +7,14 @@ import { Error } from 'app/modules/protobuf/protobuf/rpc/error_pb';
|
||||||
import {
|
import {
|
||||||
CheckUsernameForDuplicationRequest,
|
CheckUsernameForDuplicationRequest,
|
||||||
CheckUsernameForDuplicationResponse,
|
CheckUsernameForDuplicationResponse,
|
||||||
|
CheckNicknameForDuplicationRequest,
|
||||||
|
CheckNicknameForDuplicationResponse,
|
||||||
CaptchaRequest,
|
CaptchaRequest,
|
||||||
CaptchaResponse,
|
CaptchaResponse,
|
||||||
} from 'app/modules/protobuf/c2se/common/identity_pb';
|
} from 'app/modules/protobuf/c2se/common/identity_pb';
|
||||||
import {
|
import {
|
||||||
SUBJECT_CHECK_USERNAME_FOR_DUPLICATION,
|
SUBJECT_CHECK_USERNAME_FOR_DUPLICATION,
|
||||||
|
SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
||||||
SUBJECT_CAPTCHA,
|
SUBJECT_CAPTCHA,
|
||||||
SUBJECT_SIGNIN,
|
SUBJECT_SIGNIN,
|
||||||
SigninRequest,
|
SigninRequest,
|
||||||
|
@ -57,6 +60,28 @@ export class IdentityService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkNicknameForDuplication(nickname: string): Promise<boolean> {
|
||||||
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
|
let req = new CheckNicknameForDuplicationRequest();
|
||||||
|
req.setNickname(nickname);
|
||||||
|
|
||||||
|
this.__natsService
|
||||||
|
.request<CheckNicknameForDuplicationResponse.Result>(
|
||||||
|
SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION,
|
||||||
|
req.serializeBinary(),
|
||||||
|
CheckNicknameForDuplicationResponse.deserializeBinary
|
||||||
|
)
|
||||||
|
.then((result) => {
|
||||||
|
console.log('success', result, result.getDuplicated());
|
||||||
|
resolve(result.getDuplicated());
|
||||||
|
})
|
||||||
|
.catch((e: Error) => {
|
||||||
|
console.log('failed', e);
|
||||||
|
reject(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
captcha(): Promise<CaptchaResponse.Result> {
|
captcha(): Promise<CaptchaResponse.Result> {
|
||||||
return new Promise<CaptchaResponse.Result>((resolve, reject) => {
|
return new Promise<CaptchaResponse.Result>((resolve, reject) => {
|
||||||
let req = new CaptchaRequest();
|
let req = new CaptchaRequest();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user