diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts
index 4fab437..7c0dd24 100644
--- a/src/app/app.routing.ts
+++ b/src/app/app.routing.ts
@@ -164,6 +164,13 @@ export const appRoutes: Route[] = [
'app/modules/admin/member/unconnected/unconnected.module'
).then((m: any) => m.UnconnectedModule),
},
+ {
+ path: 'current-user',
+ loadChildren: () =>
+ import(
+ 'app/modules/admin/member/current-user/current-user.module'
+ ).then((m: any) => m.CurrentUserModule),
+ },
],
},
{
diff --git a/src/app/mock-api/apps/member/current-user/api.ts b/src/app/mock-api/apps/member/current-user/api.ts
new file mode 100644
index 0000000..5d7a357
--- /dev/null
+++ b/src/app/mock-api/apps/member/current-user/api.ts
@@ -0,0 +1,217 @@
+import { Injectable } from '@angular/core';
+import { assign, cloneDeep } from 'lodash-es';
+import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
+import { currentUsers as currentUsersData } from './data';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class MemberCurrentUserMockApi {
+ private _currentUsers: any[] = currentUsersData;
+
+ /**
+ * Constructor
+ */
+ constructor(private _fuseMockApiService: FuseMockApiService) {
+ // Register Mock API handlers
+ this.registerHandlers();
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Register Mock API handlers
+ */
+ registerHandlers(): void {
+ // -----------------------------------------------------------------------------------------------------
+ // @ CurrentUsers - GET
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onGet('api/apps/member/current-user/current-users', 300)
+ .reply(({ request }) => {
+ // Get available queries
+ const search = request.params.get('search');
+ const sort = request.params.get('sort') || 'name';
+ const order = request.params.get('order') || 'asc';
+ const page = parseInt(request.params.get('page') ?? '1', 10);
+ const size = parseInt(request.params.get('size') ?? '10', 10);
+
+ // Clone the currentUsers
+ let currentUsers: any[] | null = cloneDeep(this._currentUsers);
+
+ // Sort the currentUsers
+ if (sort === 'sku' || sort === 'name' || sort === 'active') {
+ currentUsers.sort((a, b) => {
+ const fieldA = a[sort].toString().toUpperCase();
+ const fieldB = b[sort].toString().toUpperCase();
+ return order === 'asc'
+ ? fieldA.localeCompare(fieldB)
+ : fieldB.localeCompare(fieldA);
+ });
+ } else {
+ currentUsers.sort((a, b) =>
+ order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
+ );
+ }
+
+ // If search exists...
+ if (search) {
+ // Filter the currentUsers
+ currentUsers = currentUsers.filter(
+ (contact: any) =>
+ contact.name &&
+ contact.name.toLowerCase().includes(search.toLowerCase())
+ );
+ }
+
+ // Paginate - Start
+ const currentUsersLength = currentUsers.length;
+
+ // Calculate pagination details
+ const begin = page * size;
+ const end = Math.min(size * (page + 1), currentUsersLength);
+ const lastPage = Math.max(Math.ceil(currentUsersLength / size), 1);
+
+ // Prepare the pagination object
+ let pagination = {};
+
+ // If the requested page number is bigger than
+ // the last possible page number, return null for
+ // currentUsers but also send the last possible page so
+ // the app can navigate to there
+ if (page > lastPage) {
+ currentUsers = null;
+ pagination = {
+ lastPage,
+ };
+ } else {
+ // Paginate the results by size
+ currentUsers = currentUsers.slice(begin, end);
+
+ // Prepare the pagination mock-api
+ pagination = {
+ length: currentUsersLength,
+ size: size,
+ page: page,
+ lastPage: lastPage,
+ startIndex: begin,
+ endIndex: end - 1,
+ };
+ }
+
+ // Return the response
+ return [
+ 200,
+ {
+ currentUsers,
+ pagination,
+ },
+ ];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ CurrentUsers - GET
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onGet('api/apps/member/current-user/current-user')
+ .reply(({ request }) => {
+ // Get the id from the params
+ const id = request.params.get('id');
+
+ // Clone the currentUsers
+ const currentUsers = cloneDeep(this._currentUsers);
+
+ // Find the currentUser
+ const currentUser = currentUsers.find((item: any) => item.id === id);
+
+ // Return the response
+ return [200, currentUser];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ CurrentUser - POST
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onPost('api/apps/member/current-user/current-user')
+ .reply(() => {
+ // Generate a new currentUser
+ const newCurrentUser = {
+ id: FuseMockApiUtils.guid(),
+ category: '',
+ name: 'A New User',
+ description: '',
+ tags: [],
+ sku: '',
+ barcode: '',
+ brand: '',
+ vendor: '',
+ stock: '',
+ reserved: '',
+ cost: '',
+ basePrice: '',
+ taxPercent: '',
+ price: '',
+ weight: '',
+ thumbnail: '',
+ images: [],
+ active: false,
+ };
+
+ // Unshift the new currentUser
+ this._currentUsers.unshift(newCurrentUser);
+
+ // Return the response
+ return [200, newCurrentUser];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ CurrentUser - PATCH
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onPatch('api/apps/member/current-user/current-user')
+ .reply(({ request }) => {
+ // Get the id and currentUser
+ const id = request.body.id;
+ const currentUser = cloneDeep(request.body.currentUser);
+
+ // Prepare the updated currentUser
+ let updatedCurrentUser = null;
+
+ // Find the currentUser and update it
+ this._currentUsers.forEach((item, index, currentUsers) => {
+ if (item.id === id) {
+ // Update the currentUser
+ currentUsers[index] = assign({}, currentUsers[index], currentUser);
+
+ // Store the updated currentUser
+ updatedCurrentUser = currentUsers[index];
+ }
+ });
+
+ // Return the response
+ return [200, updatedCurrentUser];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ CurrentUser - DELETE
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onDelete('api/apps/member/current-user/current-user')
+ .reply(({ request }) => {
+ // Get the id
+ const id = request.params.get('id');
+
+ // Find the currentUser and delete it
+ this._currentUsers.forEach((item, index) => {
+ if (item.id === id) {
+ this._currentUsers.splice(index, 1);
+ }
+ });
+
+ // Return the response
+ return [200, true];
+ });
+ }
+}
diff --git a/src/app/mock-api/apps/member/current-user/data.ts b/src/app/mock-api/apps/member/current-user/data.ts
new file mode 100644
index 0000000..0286d3b
--- /dev/null
+++ b/src/app/mock-api/apps/member/current-user/data.ts
@@ -0,0 +1,16 @@
+/* eslint-disable */
+
+export const currentUsers = [
+ {
+ id: 'aa100',
+ highRank: '[매장]kgon5',
+ rank: '회원',
+ level: 4,
+ nickname: 'aa100',
+ currentLocation: '메인',
+ cash: 0,
+ comp: 3111,
+ gameMoney: 0,
+ siteAddress: 'web4nova114.com',
+ },
+];
diff --git a/src/app/mock-api/common/navigation/data.ts b/src/app/mock-api/common/navigation/data.ts
index 8ed54f4..93e8827 100644
--- a/src/app/mock-api/common/navigation/data.ts
+++ b/src/app/mock-api/common/navigation/data.ts
@@ -60,6 +60,13 @@ export const defaultNavigation: FuseNavigationItem[] = [
icon: 'heroicons_outline:academic-cap',
link: '/member/unconnected',
},
+ {
+ id: 'member.current-user',
+ title: 'Current User',
+ type: 'basic',
+ icon: 'heroicons_outline:academic-cap',
+ link: '/member/current-user',
+ },
],
},
{
diff --git a/src/app/mock-api/index.ts b/src/app/mock-api/index.ts
index 4274d36..9cf809e 100644
--- a/src/app/mock-api/index.ts
+++ b/src/app/mock-api/index.ts
@@ -14,6 +14,7 @@ import { MailboxMockApi } from 'app/mock-api/apps/mailbox/api';
import { MemberUserMockApi } from 'app/mock-api/apps/member/user/api';
import { MemberCasinomoneyMockApi } from './apps/member/casinomoney/api';
import { MemberUnconnectedMockApi } from './apps/member/unconnected/api';
+import { MemberCurrentUserMockApi } from './apps/member/current-user/api';
import { MessagesMockApi } from 'app/mock-api/common/messages/api';
import { NavigationMockApi } from 'app/mock-api/common/navigation/api';
import { NotesMockApi } from 'app/mock-api/apps/notes/api';
@@ -48,6 +49,7 @@ export const mockApiServices = [
MemberUserMockApi,
MemberCasinomoneyMockApi,
MemberUnconnectedMockApi,
+ MemberCurrentUserMockApi,
MessagesMockApi,
NavigationMockApi,
NotesMockApi,
diff --git a/src/app/modules/admin/member/current-user/components/index.ts b/src/app/modules/admin/member/current-user/components/index.ts
new file mode 100644
index 0000000..04759eb
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/components/index.ts
@@ -0,0 +1,3 @@
+import { ListComponent } from './list.component';
+
+export const COMPONENTS = [ListComponent];
diff --git a/src/app/modules/admin/member/current-user/components/list.component.html b/src/app/modules/admin/member/current-user/components/list.component.html
new file mode 100644
index 0000000..6c6a499
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/components/list.component.html
@@ -0,0 +1,402 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0; else noCurrentUser">
+
+
+
+
+
+ 번호
+
+
+ 상위
+
+
+ 등급
+
+
+ 레벨
+
+
+ 아이디
+
+
+ 닉네임
+
+
+ 현재위치
+
+
+ 캐쉬
+
+
+ 게임중머니
+
+
+ 카지노->캐쉬
+
+
+ 콤프
+
+
+ 사이트
+
+
+ 쪽지보내기
+
+
+ 배팅내역
+
+
+ 로그아웃
+
+
+
+
+
+
+
+
+
+
+ {{ currentUser.index }}
+
+
+
+ {{ currentUser.highRank }}
+
+
+
+ {{ currentUser.rank }}
+
+
+
+ LV.{{ currentUser.level }}
+
+
+
+
+
+ {{ currentUser.id }}
+
+
+
+
+
+ {{ currentUser.nickname }}
+
+
+
+
+ {{ currentUser.currentLocation }}
+
+
+
+ 캐쉬{{ currentUser.cash }}
+
+
+
+
+
+
+
+
+ {{ currentUser.comp }}
+
+
+
+ {{ currentUser.siteAddress }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ There are no currentUser!
+
+
+
+
+
+
+
diff --git a/src/app/modules/admin/member/current-user/components/list.component.ts b/src/app/modules/admin/member/current-user/components/list.component.ts
new file mode 100644
index 0000000..584df77
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/components/list.component.ts
@@ -0,0 +1,198 @@
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ OnDestroy,
+ OnInit,
+ ViewChild,
+ ViewEncapsulation,
+} from '@angular/core';
+import {
+ FormBuilder,
+ FormControl,
+ FormGroup,
+ Validators,
+} from '@angular/forms';
+import { MatCheckboxChange } from '@angular/material/checkbox';
+import { MatPaginator } from '@angular/material/paginator';
+import { MatSort } from '@angular/material/sort';
+import {
+ debounceTime,
+ map,
+ merge,
+ Observable,
+ Subject,
+ switchMap,
+ takeUntil,
+} from 'rxjs';
+import { fuseAnimations } from '@fuse/animations';
+import { FuseConfirmationService } from '@fuse/services/confirmation';
+
+import { User } from '../../user/models/user';
+import { CurrentUser } from '../models/current-user';
+import { CurrentUserPagination } from '../models/current-user-pagination';
+import { CurrentUserService } from '../services/current-user.service';
+import { Router } from '@angular/router';
+
+@Component({
+ selector: 'currentUser-list',
+ templateUrl: './list.component.html',
+ styles: [
+ /* language=SCSS */
+ `
+ .inventory-grid {
+ grid-template-columns: 60px auto 40px;
+
+ @screen sm {
+ grid-template-columns: 60px auto 60px 72px;
+ }
+
+ @screen md {
+ grid-template-columns: 60px 60px auto 112px 72px;
+ }
+
+ @screen lg {
+ grid-template-columns: 60px 60px auto 112px 96px 96px 72px;
+ }
+ }
+ `,
+ ],
+ encapsulation: ViewEncapsulation.None,
+ changeDetection: ChangeDetectionStrategy.OnPush,
+ animations: fuseAnimations,
+})
+export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
+ @ViewChild(MatPaginator) private _paginator!: MatPaginator;
+ @ViewChild(MatSort) private _sort!: MatSort;
+
+ currentUsers$!: Observable;
+ users$!: Observable;
+
+ isLoading = false;
+ searchInputControl = new FormControl();
+ selectedCurrentUser?: CurrentUser;
+ pagination?: CurrentUserPagination;
+
+ private _unsubscribeAll: Subject = new Subject();
+
+ /**
+ * Constructor
+ */
+ constructor(
+ private _changeDetectorRef: ChangeDetectorRef,
+ private _fuseConfirmationService: FuseConfirmationService,
+ private _formBuilder: FormBuilder,
+ private _currentUserService: CurrentUserService,
+ private router: Router
+ ) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Lifecycle hooks
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * On init
+ */
+ ngOnInit(): void {
+ // Get the pagination
+ this._currentUserService.pagination$
+ .pipe(takeUntil(this._unsubscribeAll))
+ .subscribe((pagination: CurrentUserPagination | undefined) => {
+ // Update the pagination
+ this.pagination = pagination;
+
+ // Mark for check
+ this._changeDetectorRef.markForCheck();
+ });
+
+ // Get the products
+ this.currentUsers$ = this._currentUserService.currentUsers$;
+ }
+
+ /**
+ * After view init
+ */
+ ngAfterViewInit(): void {
+ if (this._sort && this._paginator) {
+ // Set the initial sort
+ this._sort.sort({
+ id: 'name',
+ start: 'asc',
+ disableClear: true,
+ });
+
+ // Mark for check
+ this._changeDetectorRef.markForCheck();
+
+ // If the currentUser changes the sort order...
+ this._sort.sortChange
+ .pipe(takeUntil(this._unsubscribeAll))
+ .subscribe(() => {
+ // Reset back to the first page
+ this._paginator.pageIndex = 0;
+ });
+
+ // Get products if sort or page changes
+ merge(this._sort.sortChange, this._paginator.page)
+ .pipe(
+ switchMap(() => {
+ this.isLoading = true;
+ return this._currentUserService.getCurrentUsers(
+ this._paginator.pageIndex,
+ this._paginator.pageSize,
+ this._sort.active,
+ this._sort.direction
+ );
+ }),
+ map(() => {
+ this.isLoading = false;
+ })
+ )
+ .subscribe();
+ }
+ }
+
+ /**
+ * On destroy
+ */
+ ngOnDestroy(): void {
+ // Unsubscribe from all subscriptions
+ this._unsubscribeAll.next(null);
+ this._unsubscribeAll.complete();
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ viewUserDetail(id: string): void {
+ let url: string = 'member/user/' + id;
+ this.router.navigateByUrl(url);
+ }
+ // -----------------------------------------------------------------------------------------------------
+ // @ Private methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Create product
+ */
+ __createProduct(): void {}
+
+ /**
+ * Toggle product details
+ *
+ * @param productId
+ */
+ __toggleDetails(productId: string): void {}
+
+ /**
+ * Track by function for ngFor loops
+ *
+ * @param index
+ * @param item
+ */
+ __trackByFn(index: number, item: any): any {
+ return item.id || index;
+ }
+}
diff --git a/src/app/modules/admin/member/current-user/current-user.module.ts b/src/app/modules/admin/member/current-user/current-user.module.ts
new file mode 100644
index 0000000..72fdeb9
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/current-user.module.ts
@@ -0,0 +1,49 @@
+import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
+
+import { MatButtonModule } from '@angular/material/button';
+import { MatFormFieldModule } from '@angular/material/form-field';
+import { MatIconModule } from '@angular/material/icon';
+import { MatInputModule } from '@angular/material/input';
+import { MatPaginatorModule } from '@angular/material/paginator';
+import { MatProgressBarModule } from '@angular/material/progress-bar';
+import { MatRippleModule } from '@angular/material/core';
+import { MatSortModule } from '@angular/material/sort';
+import { MatSelectModule } from '@angular/material/select';
+import { MatTooltipModule } from '@angular/material/tooltip';
+import { MatGridListModule } from '@angular/material/grid-list';
+import { MatSlideToggleModule } from '@angular/material/slide-toggle';
+import { MatRadioModule } from '@angular/material/radio';
+import { MatCardModule } from '@angular/material/card';
+
+import { TranslocoModule } from '@ngneat/transloco';
+
+import { SharedModule } from 'app/shared/shared.module';
+
+import { COMPONENTS } from './components';
+
+import { currentUserRoutes } from './current-user.routing';
+@NgModule({
+ declarations: [COMPONENTS],
+ imports: [
+ TranslocoModule,
+ SharedModule,
+ RouterModule.forChild(currentUserRoutes),
+
+ MatButtonModule,
+ MatFormFieldModule,
+ MatIconModule,
+ MatInputModule,
+ MatPaginatorModule,
+ MatProgressBarModule,
+ MatRippleModule,
+ MatSortModule,
+ MatSelectModule,
+ MatTooltipModule,
+ MatGridListModule,
+ MatSlideToggleModule,
+ MatRadioModule,
+ MatCardModule,
+ ],
+})
+export class CurrentUserModule {}
diff --git a/src/app/modules/admin/member/current-user/current-user.routing.ts b/src/app/modules/admin/member/current-user/current-user.routing.ts
new file mode 100644
index 0000000..8cb4efe
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/current-user.routing.ts
@@ -0,0 +1,24 @@
+import { Route } from '@angular/router';
+
+import { ListComponent } from './components/list.component';
+import { ViewComponent } from '../user/components/view.component';
+
+import { CurrentUsersResolver } from './resolvers/current-user.resolver';
+import { UserResolver } from '../user/resolvers/user.resolver';
+
+export const currentUserRoutes: Route[] = [
+ {
+ path: '',
+ component: ListComponent,
+ resolve: {
+ curretnUsers: CurrentUsersResolver,
+ },
+ },
+ {
+ path: ':id',
+ component: ViewComponent,
+ resolve: {
+ users: UserResolver,
+ },
+ },
+];
diff --git a/src/app/modules/admin/member/current-user/models/current-user-pagination.ts b/src/app/modules/admin/member/current-user/models/current-user-pagination.ts
new file mode 100644
index 0000000..2a2dadf
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/models/current-user-pagination.ts
@@ -0,0 +1,8 @@
+export interface CurrentUserPagination {
+ length: number;
+ size: number;
+ page: number;
+ lastPage: number;
+ startIndex: number;
+ endIndex: number;
+}
diff --git a/src/app/modules/admin/member/current-user/models/current-user.ts b/src/app/modules/admin/member/current-user/models/current-user.ts
new file mode 100644
index 0000000..75d62cb
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/models/current-user.ts
@@ -0,0 +1,13 @@
+export interface CurrentUser {
+ id?: string;
+ index?: number;
+ nickname?: string;
+ highRank?: string;
+ rank?: string;
+ level?: string;
+ currentLocation?: string;
+ cash?: number;
+ gameMoney?: number;
+ comp?: number;
+ siteAddress?: string;
+}
diff --git a/src/app/modules/admin/member/current-user/resolvers/current-user.resolver.ts b/src/app/modules/admin/member/current-user/resolvers/current-user.resolver.ts
new file mode 100644
index 0000000..ce539d8
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/resolvers/current-user.resolver.ts
@@ -0,0 +1,89 @@
+import { Injectable } from '@angular/core';
+import {
+ ActivatedRouteSnapshot,
+ Resolve,
+ Router,
+ RouterStateSnapshot,
+} from '@angular/router';
+import { catchError, Observable, throwError } from 'rxjs';
+
+import { CurrentUser } from '../models/current-user';
+import { CurrentUserPagination } from '../models/current-user-pagination';
+import { CurrentUserService } from '../services/current-user.service';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class CurrentUserResolver implements Resolve {
+ /**
+ * Constructor
+ */
+ constructor(
+ private _currentUserService: CurrentUserService,
+ private _router: Router
+ ) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Resolver
+ *
+ * @param route
+ * @param state
+ */
+ resolve(
+ route: ActivatedRouteSnapshot,
+ state: RouterStateSnapshot
+ ): Observable {
+ return this._currentUserService
+ .getCurrentUserById(route.paramMap.get('id'))
+ .pipe(
+ // Error here means the requested product is not available
+ catchError((error) => {
+ // Log the error
+ console.error(error);
+
+ // Get the parent url
+ const parentUrl = state.url.split('/').slice(0, -1).join('/');
+
+ // Navigate to there
+ this._router.navigateByUrl(parentUrl);
+
+ // Throw an error
+ return throwError(error);
+ })
+ );
+ }
+}
+
+@Injectable({
+ providedIn: 'root',
+})
+export class CurrentUsersResolver implements Resolve {
+ /**
+ * Constructor
+ */
+ constructor(private _currentUserService: CurrentUserService) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Resolver
+ *
+ * @param route
+ * @param state
+ */
+ resolve(
+ route: ActivatedRouteSnapshot,
+ state: RouterStateSnapshot
+ ): Observable<{
+ pagination: CurrentUserPagination;
+ currentUsers: CurrentUser[];
+ }> {
+ return this._currentUserService.getCurrentUsers();
+ }
+}
diff --git a/src/app/modules/admin/member/current-user/services/current-user.service.ts b/src/app/modules/admin/member/current-user/services/current-user.service.ts
new file mode 100644
index 0000000..0aabb7b
--- /dev/null
+++ b/src/app/modules/admin/member/current-user/services/current-user.service.ts
@@ -0,0 +1,158 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import {
+ BehaviorSubject,
+ filter,
+ map,
+ Observable,
+ of,
+ switchMap,
+ take,
+ tap,
+ throwError,
+} from 'rxjs';
+
+import { CurrentUser } from '../models/current-user';
+import { CurrentUserPagination } from '../models/current-user-pagination';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class CurrentUserService {
+ // Private
+ private __pagination = new BehaviorSubject(
+ undefined
+ );
+ private __currentUser = new BehaviorSubject(
+ undefined
+ );
+ private __currentUsers = new BehaviorSubject(
+ undefined
+ );
+
+ /**
+ * Constructor
+ */
+ constructor(private _httpClient: HttpClient) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Accessors
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Getter for pagination
+ */
+ get pagination$(): Observable {
+ return this.__pagination.asObservable();
+ }
+
+ /**
+ * Getter for currentUser
+ */
+ get currentUser$(): Observable {
+ return this.__currentUser.asObservable();
+ }
+
+ /**
+ * Getter for currentUsers
+ */
+ get currentUsers$(): Observable {
+ return this.__currentUsers.asObservable();
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Get currentUsers
+ *
+ *
+ * @param page
+ * @param size
+ * @param sort
+ * @param order
+ * @param search
+ */
+ getCurrentUsers(
+ page: number = 0,
+ size: number = 10,
+ sort: string = 'name',
+ order: 'asc' | 'desc' | '' = 'asc',
+ search: string = ''
+ ): Observable<{
+ pagination: CurrentUserPagination;
+ currentUsers: CurrentUser[];
+ }> {
+ return this._httpClient
+ .get<{ pagination: CurrentUserPagination; currentUsers: CurrentUser[] }>(
+ 'api/apps/member/current-user/current-users',
+ {
+ params: {
+ page: '' + page,
+ size: '' + size,
+ sort,
+ order,
+ search,
+ },
+ }
+ )
+ .pipe(
+ tap((response) => {
+ this.__pagination.next(response.pagination);
+ this.__currentUsers.next(response.currentUsers);
+ })
+ );
+ }
+
+ /**
+ * Get product by id
+ */
+ getCurrentUserById(id: string | null): Observable {
+ return this.__currentUsers.pipe(
+ take(1),
+ map((currentUsers) => {
+ // Find the product
+ const currentUser =
+ currentUsers?.find((item) => item.id === id) || undefined;
+
+ // Update the product
+ this.__currentUser.next(currentUser);
+
+ // Return the product
+ return currentUser;
+ }),
+ switchMap((product) => {
+ if (!product) {
+ return throwError('Could not found product with id of ' + id + '!');
+ }
+
+ return of(product);
+ })
+ );
+ }
+
+ /**
+ * Create product
+ */
+ createCurrentUser(): Observable {
+ return this.currentUsers$.pipe(
+ take(1),
+ switchMap((currentUsers) =>
+ this._httpClient
+ .post('api/apps/member/currentUser/product', {})
+ .pipe(
+ map((newCurrentUser) => {
+ // Update the currentUsers with the new product
+ if (!!currentUsers) {
+ this.__currentUsers.next([newCurrentUser, ...currentUsers]);
+ }
+
+ // Return the new product
+ return newCurrentUser;
+ })
+ )
+ )
+ );
+ }
+}
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 068cfc3..7adc722 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -13,5 +13,6 @@
"Powerball": "Powerball",
"Casino": "Casino",
"Evolution": "Evolution",
- "Slot": "Slot"
+ "Slot": "Slot",
+ "Current User": "Current User"
}
diff --git a/src/assets/i18n/ko.json b/src/assets/i18n/ko.json
index 0c5c3eb..42edda1 100644
--- a/src/assets/i18n/ko.json
+++ b/src/assets/i18n/ko.json
@@ -13,5 +13,6 @@
"Powerball": "파워볼",
"Casino": "카지노배팅리스트",
"Evolution": "에볼루션배팅리스트",
- "Slot": "슬롯배팅리스트"
+ "Slot": "슬롯배팅리스트",
+ "Current User": "현재접속자 & 쪽지전송"
}