diff --git a/src/app/modules/admin/member/user/components/list.component.html b/src/app/modules/admin/member/user/components/list.component.html index 5f80cb9..66297c6 100644 --- a/src/app/modules/admin/member/user/components/list.component.html +++ b/src/app/modules/admin/member/user/components/list.component.html @@ -184,8 +184,8 @@
- - + +
- +
쪽지보내기 -
diff --git a/src/app/modules/admin/member/user/components/list.component.ts b/src/app/modules/admin/member/user/components/list.component.ts index e1af5df..44a17b0 100644 --- a/src/app/modules/admin/member/user/components/list.component.ts +++ b/src/app/modules/admin/member/user/components/list.component.ts @@ -11,14 +11,22 @@ import { import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; -import { map, merge, Observable, Subject, switchMap, takeUntil } from 'rxjs'; +import { + map, + merge, + Observable, + of, + Subject, + switchMap, + takeUntil, +} from 'rxjs'; import { fuseAnimations } from '@fuse/animations'; import { FuseConfirmationService } from '@fuse/services/confirmation'; import { User } from '../models/user'; import { UserPagination } from '../models/user-pagination'; import { UserService } from '../services/user.service'; -import { Router } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { IdentityService } from 'app/modules/polyglot/identity/services/identity.service'; import { MatDialog } from '@angular/material/dialog'; import { CashComposeComponent } from '../compose/cash-compose.component'; @@ -26,6 +34,11 @@ import { CommissionComposeComponent } from '../compose/commission-compose.compon import { CompComposeComponent } from '../compose/comp-compose.component'; import { CouponComposeComponent } from '../compose/coupon-compose.component'; import { MessageComposeComponent } from '../compose/message-compose.component'; +import { ListMembersResponse } from 'app/modules/proto/c2se/member_pb'; +import { MemberModel, MemberState } from 'app/modules/proto/models/member_pb'; +import { MemberClass } from 'app/modules/proto/models/member_class_pb'; +import { MemberClassService } from 'app/modules/polyglot/member_class/services/member_class.service'; +import { result } from 'lodash'; @Component({ selector: 'user-list', @@ -66,7 +79,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatSort) private _sort!: MatSort; - users$!: Observable; + listMembers$!: Observable; __isSearchOpened = false; isLoading = false; @@ -74,6 +87,8 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { selectedUser?: User; pagination?: UserPagination; + memberClasses!: MemberClass[]; + signoutBlockConfigForm!: FormGroup; private _unsubscribeAll: Subject = new Subject(); @@ -83,10 +98,12 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { */ constructor( private _changeDetectorRef: ChangeDetectorRef, + private _activatedRoute: ActivatedRoute, private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, private _userService: UserService, private _identityService: IdentityService, + private _memberClassService: MemberClassService, private router: Router, private _matDialog: MatDialog ) {} @@ -111,7 +128,19 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { }); // Get the products - this.users$ = this._userService.users$; + this._memberClassService + .listMemberClasss() + .then((result) => (this.memberClasses = result.getMemberClassesList())); + + // Get the products + this._activatedRoute.data.subscribe((data) => { + let listMemberResult: ListMembersResponse.Result = data['listmembers']; + + this.listMembers$ = of(listMemberResult.getMembersList()); + + // Mark for check + this._changeDetectorRef.markForCheck(); + }); // Set signout block config this.__signoutBlockConfirmConfig(); @@ -297,4 +326,61 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { this.signoutBlockConfigForm.value ); } + + __getParentUsername(member: MemberModel): string { + if (!member.getParentMember()) { + return ''; + } + + const parentUsername = member.getParentMember()?.getUsername(); + const parentClassessId = member.getParentMember()?.getMemberClassId(); + + const findClass = this.findMemberClasses(parentClassessId); + + if (!findClass) { + return ''; + } + + return `[${findClass.getName()}]${parentUsername}`; + } + + __getMemberState(member: MemberModel): string { + const state = member.getState(); + let resultStr = ''; + + switch (state) { + case MemberState.NONE: + resultStr = '없음'; + break; + case MemberState.NORMAL: + resultStr = '정상'; + break; + case MemberState.PENDING: + resultStr = '대기'; + break; + case MemberState.WITHDRAWAL: + resultStr = '탈퇴'; + break; + case MemberState.DORMANCY: + resultStr = '휴면'; + break; + case MemberState.BLACKLIST: + resultStr = '블랙리스트'; + break; + case MemberState.SUSPENDED: + resultStr = '정지'; + break; + default: + break; + } + + return resultStr; + } + + private findMemberClasses(classId?: string): MemberClass | undefined { + if (!classId || classId === '') { + return undefined; + } + return this.memberClasses.find((mc) => mc.getId() === classId); + } } diff --git a/src/app/modules/admin/member/user/resolvers/user.resolver.ts b/src/app/modules/admin/member/user/resolvers/user.resolver.ts index db93d1d..30c208f 100644 --- a/src/app/modules/admin/member/user/resolvers/user.resolver.ts +++ b/src/app/modules/admin/member/user/resolvers/user.resolver.ts @@ -7,6 +7,11 @@ import { } from '@angular/router'; import { MemberService } from 'app/modules/polyglot/member/services/member.service'; import { GetMemberResponse } from 'app/modules/proto/c2se/member_pb'; +import { + ListMembersRequest, + ListMembersResponse, +} from 'app/modules/proto/c2se/member_pb'; + import { catchError, Observable, throwError } from 'rxjs'; import { User } from '../models/user'; @@ -85,6 +90,37 @@ export class UsersResolver implements Resolve { } } +@Injectable({ + providedIn: 'root', +}) +export class ListMemberResolver implements Resolve { + /** + * Constructor + */ + constructor(private _router: Router, private _memberService: MemberService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListMembersResponse.Result { + return this._memberService.listMembers(); + } +} + @Injectable({ providedIn: 'root', }) diff --git a/src/app/modules/admin/member/user/user.routing.ts b/src/app/modules/admin/member/user/user.routing.ts index 7069bdf..e5c731e 100644 --- a/src/app/modules/admin/member/user/user.routing.ts +++ b/src/app/modules/admin/member/user/user.routing.ts @@ -7,6 +7,7 @@ import { UsersResolver, UserResolver, MemberResolver, + ListMemberResolver, } from './resolvers/user.resolver'; export const userRoutes: Route[] = [ @@ -14,7 +15,7 @@ export const userRoutes: Route[] = [ path: '', component: ListComponent, resolve: { - users: UsersResolver, + listmembers: ListMemberResolver, }, }, {