diff --git a/src/app/modules/admin/member/partner/components/list.component.ts b/src/app/modules/admin/member/partner/components/list.component.ts index 8bea23c..b64aed4 100644 --- a/src/app/modules/admin/member/partner/components/list.component.ts +++ b/src/app/modules/admin/member/partner/components/list.component.ts @@ -36,6 +36,8 @@ import { Router } from '@angular/router'; import { RegistComposeComponent } from '../compose/regist-compose.component'; 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({ selector: 'partner-list', templateUrl: './list.component.html', @@ -77,6 +79,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { searchInputControl = new FormControl(); selectedPartner?: Partner; pagination?: PartnerPagination; + sites!: Site[]; private _unsubscribeAll: Subject = new Subject(); @@ -88,6 +91,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, private _partnerService: PartnerService, + private _siteService: SiteService, private router: Router, private _matDialog: MatDialog ) {} @@ -113,6 +117,13 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { // Get the products 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 { const dialogRef = this._matDialog.open(RegistComposeComponent, { - data: { title: '대본', parentId: 'kgon2' }, + data: { title: '대본', parentId: 'kgon2', sites: this.sites }, }); dialogRef.afterClosed().subscribe((result) => { diff --git a/src/app/modules/admin/member/partner/compose/regist-compose.component.html b/src/app/modules/admin/member/partner/compose/regist-compose.component.html index e28e780..d8c9e7a 100644 --- a/src/app/modules/admin/member/partner/compose/regist-compose.component.html +++ b/src/app/modules/admin/member/partner/compose/regist-compose.component.html @@ -23,6 +23,7 @@ + 사이트명 @@ -32,6 +33,18 @@ + + 회원 아이디 @@ -69,10 +82,19 @@ 닉네임 - + 닉네임은 필수 입력입니다. + + 닉네임이 중복됩니다. + @@ -127,13 +149,9 @@ class="flex flex-col sm:flex-row sm:items-center justify-between mt-4 sm:mt-6" >
- -
diff --git a/src/app/modules/admin/member/partner/compose/regist-compose.component.ts b/src/app/modules/admin/member/partner/compose/regist-compose.component.ts index c6d5667..6c60772 100644 --- a/src/app/modules/admin/member/partner/compose/regist-compose.component.ts +++ b/src/app/modules/admin/member/partner/compose/regist-compose.component.ts @@ -7,11 +7,14 @@ import { } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 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 { Site } from 'app/modules/protobuf/models/domain/site_pb'; export interface RegistComposeData { title: string; parentId: string; + sites: Site[]; } export interface RegistComposeResult { parentId: string; @@ -34,10 +37,7 @@ export interface RegistComposeResult { }) export class RegistComposeComponent implements OnInit { composeForm!: FormGroup; - copyFields: { cc: boolean; bcc: boolean } = { - cc: false, - bcc: false, - }; + sites: any[] = []; // quillModules: any = { // toolbar: [ // ['bold', 'italic', 'underline'], @@ -55,7 +55,12 @@ export class RegistComposeComponent implements OnInit { private _formBuilder: FormBuilder, private _identityService: IdentityService, private _changeDetectorRef: ChangeDetectorRef - ) {} + ) { + this.data.sites.map((v) => { + const a = v.toObject(); + this.sites.push(a); + }); + } // ----------------------------------------------------------------------------------------------------- // @ Lifecycle hooks @@ -85,21 +90,6 @@ export class RegistComposeComponent implements OnInit { // @ 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 */ @@ -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 { // return (control: AbstractControl): { [key: string]: any } | null => { // if ( diff --git a/src/app/modules/admin/member/partner/partner.module.ts b/src/app/modules/admin/member/partner/partner.module.ts index e653ec2..1f83f7d 100644 --- a/src/app/modules/admin/member/partner/partner.module.ts +++ b/src/app/modules/admin/member/partner/partner.module.ts @@ -1,5 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; +import { CommonModule } from '@angular/common'; +import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -29,6 +31,9 @@ import { partnerRoutes } from './partner.routing'; TranslocoModule, SharedModule, RouterModule.forChild(partnerRoutes), + CommonModule, + ReactiveFormsModule, + FormsModule, MatButtonModule, MatFormFieldModule, diff --git a/src/app/modules/polyglot/member/services/identity.service.ts b/src/app/modules/polyglot/member/services/identity.service.ts index 3055192..e85f539 100644 --- a/src/app/modules/polyglot/member/services/identity.service.ts +++ b/src/app/modules/polyglot/member/services/identity.service.ts @@ -7,11 +7,14 @@ import { Error } from 'app/modules/protobuf/protobuf/rpc/error_pb'; import { CheckUsernameForDuplicationRequest, CheckUsernameForDuplicationResponse, + CheckNicknameForDuplicationRequest, + CheckNicknameForDuplicationResponse, CaptchaRequest, CaptchaResponse, } from 'app/modules/protobuf/c2se/common/identity_pb'; import { SUBJECT_CHECK_USERNAME_FOR_DUPLICATION, + SUBJECT_CHECK_NICKNAME_FOR_DUPLICATION, SUBJECT_CAPTCHA, SUBJECT_SIGNIN, SigninRequest, @@ -57,6 +60,28 @@ export class IdentityService { }); } + checkNicknameForDuplication(nickname: string): Promise { + return new Promise((resolve, reject) => { + let req = new CheckNicknameForDuplicationRequest(); + req.setNickname(nickname); + + this.__natsService + .request( + 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 { return new Promise((resolve, reject) => { let req = new CaptchaRequest();