diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts
index bb2c8d7..b6b63ba 100644
--- a/src/app/app.routing.ts
+++ b/src/app/app.routing.ts
@@ -171,6 +171,18 @@ export const appRoutes: Route[] = [
},
],
},
+ {
+ path: 'game',
+ children: [
+ {
+ path: 'powerball',
+ loadChildren: () =>
+ import('app/modules/admin/game/powerball/powerball.module').then(
+ (m: any) => m.PowerballModule
+ ),
+ },
+ ],
+ },
],
},
];
diff --git a/src/app/mock-api/apps/game/powerball/api.ts b/src/app/mock-api/apps/game/powerball/api.ts
new file mode 100644
index 0000000..4c8e8a8
--- /dev/null
+++ b/src/app/mock-api/apps/game/powerball/api.ts
@@ -0,0 +1,216 @@
+import { Injectable } from '@angular/core';
+import { assign, cloneDeep } from 'lodash-es';
+import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
+import { powerballs as powerballsData } from './data';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class GamePowerballMockApi {
+ private _powerballs: any[] = powerballsData;
+
+ /**
+ * Constructor
+ */
+ constructor(private _fuseMockApiService: FuseMockApiService) {
+ // Register Mock API handlers
+ this.registerHandlers();
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Register Mock API handlers
+ */
+ registerHandlers(): void {
+ // -----------------------------------------------------------------------------------------------------
+ // @ Powerballs - GET
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onGet('api/apps/game/powerball/powerballs', 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 powerballs
+ let powerballs: any[] | null = cloneDeep(this._powerballs);
+
+ // Sort the powerballs
+ if (sort === 'sku' || sort === 'name' || sort === 'active') {
+ powerballs.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 {
+ powerballs.sort((a, b) =>
+ order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
+ );
+ }
+
+ // If search exists...
+ if (search) {
+ // Filter the powerballs
+ powerballs = powerballs.filter(
+ (contact: any) =>
+ contact.name &&
+ contact.name.toLowerCase().includes(search.toLowerCase())
+ );
+ }
+
+ // Paginate - Start
+ const powerballsLength = powerballs.length;
+
+ // Calculate pagination details
+ const begin = page * size;
+ const end = Math.min(size * (page + 1), powerballsLength);
+ const lastPage = Math.max(Math.ceil(powerballsLength / size), 1);
+
+ // Prepare the pagination object
+ let pagination = {};
+
+ // If the requested page number is bigger than
+ // the last possible page number, return null for
+ // powerballs but also send the last possible page so
+ // the app can navigate to there
+ if (page > lastPage) {
+ powerballs = null;
+ pagination = {
+ lastPage,
+ };
+ } else {
+ // Paginate the results by size
+ powerballs = powerballs.slice(begin, end);
+
+ // Prepare the pagination mock-api
+ pagination = {
+ length: powerballsLength,
+ size: size,
+ page: page,
+ lastPage: lastPage,
+ startIndex: begin,
+ endIndex: end - 1,
+ };
+ }
+
+ // Return the response
+ return [
+ 200,
+ {
+ powerballs,
+ pagination,
+ },
+ ];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Powerball - GET
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onGet('api/apps/game/powerball/powerball')
+ .reply(({ request }) => {
+ // Get the id from the params
+ const id = request.params.get('id');
+
+ // Clone the powerballs
+ const powerballs = cloneDeep(this._powerballs);
+
+ // Find the powerball
+ const powerball = powerballs.find((item: any) => item.id === id);
+
+ // Return the response
+ return [200, powerball];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Powerball - POST
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onPost('api/apps/gmae/powerball/powerball')
+ .reply(() => {
+ // Generate a new powerball
+ const newPowerball = {
+ id: FuseMockApiUtils.guid(),
+ startDate: '',
+ finishDate: '',
+ totalBetting: '',
+ winningMoney: '',
+ proceedingMoney: '',
+ calculate: '',
+ index: '',
+ division: '',
+ rank: '',
+ nickname: '',
+ bettingProgress: '',
+ odds: '',
+ bettingMoney: '',
+ hitMoney: '',
+ bettingTime: '',
+ result: '',
+ delete: '',
+ };
+
+ // Unshift the new powerball
+ this._powerballs.unshift(newPowerball);
+
+ // Return the response
+ return [200, newPowerball];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Powerball - PATCH
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onPatch('api/apps/game/powerball/powerball')
+ .reply(({ request }) => {
+ // Get the id and powerball
+ const id = request.body.id;
+ const powerball = cloneDeep(request.body.powerball);
+
+ // Prepare the updated powerball
+ let updatedPowerball = null;
+
+ // Find the powerball and update it
+ this._powerballs.forEach((item, index, powerballs) => {
+ if (item.id === id) {
+ // Update the powerball
+ powerballs[index] = assign({}, powerballs[index], powerball);
+
+ // Store the updated powerball
+ updatedPowerball = powerballs[index];
+ }
+ });
+
+ // Return the response
+ return [200, updatedPowerball];
+ });
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Powerball - DELETE
+ // -----------------------------------------------------------------------------------------------------
+ this._fuseMockApiService
+ .onDelete('api/apps/game/powerball/powerball')
+ .reply(({ request }) => {
+ // Get the id
+ const id = request.params.get('id');
+
+ // Find the powerball and delete it
+ this._powerballs.forEach((item, index) => {
+ if (item.id === id) {
+ this._powerballs.splice(index, 1);
+ }
+ });
+
+ // Return the response
+ return [200, true];
+ });
+ }
+}
diff --git a/src/app/mock-api/apps/game/powerball/data.ts b/src/app/mock-api/apps/game/powerball/data.ts
new file mode 100644
index 0000000..9f9c609
--- /dev/null
+++ b/src/app/mock-api/apps/game/powerball/data.ts
@@ -0,0 +1,23 @@
+/* eslint-disable */
+
+export const powerballs = [
+ {
+ startDate: '2022-01-01 00:00',
+ finishDate: '2022-06-21 23:59',
+ totalBetting: 800000,
+ winningMoney: 390000,
+ proceedingMoney: 0,
+ calculate: 410000,
+ index: '4',
+ division: '단식',
+ rank: '회원',
+ id: 'dsa01233',
+ nickname: '아메리카노',
+ bettingProgress: '1166031회 일반볼 오버',
+ odds: 1.95,
+ bettingMoney: 200000,
+ hitMoney: 390000,
+ bettingTime: '2022-04-24 22:36',
+ result: '실패',
+ },
+];
diff --git a/src/app/mock-api/common/navigation/data.ts b/src/app/mock-api/common/navigation/data.ts
index 47fab1d..8eff323 100644
--- a/src/app/mock-api/common/navigation/data.ts
+++ b/src/app/mock-api/common/navigation/data.ts
@@ -78,6 +78,22 @@ export const defaultNavigation: FuseNavigationItem[] = [
},
],
},
+ {
+ id: 'game',
+ title: 'Game',
+ subtitle: 'game managements',
+ type: 'group',
+ icon: 'heroicons_outline:home',
+ children: [
+ {
+ id: 'game.powerball',
+ title: 'Powerball',
+ type: 'basic',
+ icon: 'heroicons_outline:academic-cap',
+ link: '/game/powerball',
+ },
+ ],
+ },
];
export const compactNavigation: FuseNavigationItem[] = [
{
@@ -104,6 +120,14 @@ export const compactNavigation: FuseNavigationItem[] = [
icon: 'heroicons_outline:home',
children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
},
+ {
+ id: 'game',
+ title: 'Game',
+ subtitle: 'game managements',
+ type: 'group',
+ icon: 'heroicons_outline:home',
+ children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
+ },
];
export const futuristicNavigation: FuseNavigationItem[] = [
{
@@ -124,6 +148,12 @@ export const futuristicNavigation: FuseNavigationItem[] = [
type: 'group',
children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
},
+ {
+ id: 'game',
+ title: 'Game',
+ type: 'group',
+ children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
+ },
];
export const horizontalNavigation: FuseNavigationItem[] = [
{
@@ -147,4 +177,11 @@ export const horizontalNavigation: FuseNavigationItem[] = [
icon: 'heroicons_outline:home',
children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
},
+ {
+ id: 'game',
+ title: 'Game',
+ type: 'group',
+ icon: 'heroicons_outline:home',
+ children: [], // This will be filled from defaultNavigation so we don't have to manage multiple sets of the same navigation
+ },
];
diff --git a/src/app/mock-api/index.ts b/src/app/mock-api/index.ts
index dc39e27..857e063 100644
--- a/src/app/mock-api/index.ts
+++ b/src/app/mock-api/index.ts
@@ -23,6 +23,7 @@ import { ShortcutsMockApi } from 'app/mock-api/common/shortcuts/api';
import { TasksMockApi } from 'app/mock-api/apps/tasks/api';
import { UserMockApi } from 'app/mock-api/common/user/api';
import { BankDepositMockApi } from './apps/bank/deposit/api';
+import { GamePowerballMockApi } from './apps/game/powerball/api';
export const mockApiServices = [
AcademyMockApi,
@@ -49,5 +50,6 @@ export const mockApiServices = [
ShortcutsMockApi,
TasksMockApi,
UserMockApi,
- BankDepositMockApi
+ BankDepositMockApi,
+ GamePowerballMockApi,
];
diff --git a/src/app/modules/admin/game/powerball/components/index.ts b/src/app/modules/admin/game/powerball/components/index.ts
new file mode 100644
index 0000000..04759eb
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/components/index.ts
@@ -0,0 +1,3 @@
+import { ListComponent } from './list.component';
+
+export const COMPONENTS = [ListComponent];
diff --git a/src/app/modules/admin/game/powerball/components/list.component.html b/src/app/modules/admin/game/powerball/components/list.component.html
new file mode 100644
index 0000000..6f53f83
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/components/list.component.html
@@ -0,0 +1,365 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 파워볼
+ 카지노
+ 슬롯
+
+
+
+
+ 전체
+ 단폴
+ 조합
+
+
+
+
+ 리스트수
+ 40
+ 60
+ 80
+ 100
+
+
+
+
+ 전체금액
+ 100-50만미만
+ 50만-100만미만
+ 100만-200만이하
+ 300만초과
+
+
+
+
+ 진행목록
+ 당첨
+ 실패
+ 실패제외
+ 취소
+ 관리자취소
+ 전체목록
+
+
+
+
+ 아이디
+ 닉네임
+ 파워볼회차
+ 베팅번호
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0; else noPowerball">
+
+
+
+
+
+ 번호
+
+
+ 구분
+
+
등급
+
아이디
+
+ 베팅진행내역
+
+
+ 배당률
+
+
+ 베팅액
+
+
+ 배당적중금
+
+
+ 베팅시간
+
+
+ 결과
+
+
+ 취소/삭제 여부
+
+
+
+
+
+
+
+
+
+ {{ powerball.index }}
+
+
+
+ LV.{{ powerball.division }}
+
+
+
+
+
+
+
+
+ {{ powerball.id }}
+ ({{ powerball.nickname }})
+
+
+
+
+ {{ powerball.bettingProgress }}
+
+
+
+
+ {{ powerball.odds }}
+
+
+
+
+ {{ powerball.bettingMoney }}원
+
+
+
+
+ {{ powerball.hitMoney }}원
+
+
+
+
+ {{ powerball.bettingTime }}
+
+
+
+
+ {{ powerball.result }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ There are no powerball!
+
+
+
+
+
diff --git a/src/app/modules/admin/game/powerball/components/list.component.ts b/src/app/modules/admin/game/powerball/components/list.component.ts
new file mode 100644
index 0000000..c7bbb30
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/components/list.component.ts
@@ -0,0 +1,190 @@
+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 { Powerball } from '../models/powerball';
+import { PowerballPagination } from '../models/powerball-pagination';
+import { PowerballService } from '../services/powerball.service';
+
+@Component({
+ selector: 'powerball-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;
+
+ powerballs$!: Observable;
+
+ isLoading = false;
+ searchInputControl = new FormControl();
+ selectedPowerball?: Powerball;
+ pagination?: PowerballPagination;
+
+ private _unsubscribeAll: Subject = new Subject();
+
+ /**
+ * Constructor
+ */
+ constructor(
+ private _changeDetectorRef: ChangeDetectorRef,
+ private _fuseConfirmationService: FuseConfirmationService,
+ private _formBuilder: FormBuilder,
+ private _powerballService: PowerballService
+ ) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Lifecycle hooks
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * On init
+ */
+ ngOnInit(): void {
+ // Get the pagination
+ this._powerballService.pagination$
+ .pipe(takeUntil(this._unsubscribeAll))
+ .subscribe((pagination: PowerballPagination | undefined) => {
+ // Update the pagination
+ this.pagination = pagination;
+
+ // Mark for check
+ this._changeDetectorRef.markForCheck();
+ });
+
+ // Get the products
+ this.powerballs$ = this._powerballService.powerballs$;
+ }
+
+ /**
+ * After view init
+ */
+ ngAfterViewInit(): void {
+ if (this._sort && this._paginator) {
+ // Set the initial sort
+ this._sort.sort({
+ id: 'nickname',
+ start: 'asc',
+ disableClear: true,
+ });
+
+ // Mark for check
+ this._changeDetectorRef.markForCheck();
+
+ // If the powerball 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._powerballService.getPowerballs(
+ 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
+ // -----------------------------------------------------------------------------------------------------
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ 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/game/powerball/models/powerball-pagination.ts b/src/app/modules/admin/game/powerball/models/powerball-pagination.ts
new file mode 100644
index 0000000..6866a29
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/models/powerball-pagination.ts
@@ -0,0 +1,8 @@
+export interface PowerballPagination {
+ length: number;
+ size: number;
+ page: number;
+ lastPage: number;
+ startIndex: number;
+ endIndex: number;
+}
diff --git a/src/app/modules/admin/game/powerball/models/powerball.ts b/src/app/modules/admin/game/powerball/models/powerball.ts
new file mode 100644
index 0000000..f8a0a1d
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/models/powerball.ts
@@ -0,0 +1,20 @@
+export interface Powerball {
+ id: string;
+ nickname: string;
+ startDate: string;
+ finishDate: string;
+ totalBetting: string;
+ winningMoney: number;
+ proceedingMoney: number;
+ calculate: number;
+ index: string;
+ division: string;
+ rank: string;
+ bettingProgress: string;
+ odds: number;
+ bettingMoney: number;
+ hitMoney: number;
+ bettingTime: string;
+ result: string;
+ delete: string;
+}
diff --git a/src/app/modules/admin/game/powerball/powerball.module.ts b/src/app/modules/admin/game/powerball/powerball.module.ts
new file mode 100644
index 0000000..d43cd9b
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/powerball.module.ts
@@ -0,0 +1,42 @@
+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 { TranslocoModule } from '@ngneat/transloco';
+
+import { SharedModule } from 'app/shared/shared.module';
+
+import { COMPONENTS } from './components';
+
+import { powerballRoutes } from './powerball.routing';
+
+@NgModule({
+ declarations: [COMPONENTS],
+ imports: [
+ TranslocoModule,
+ SharedModule,
+ RouterModule.forChild(powerballRoutes),
+
+ MatButtonModule,
+ MatFormFieldModule,
+ MatIconModule,
+ MatInputModule,
+ MatPaginatorModule,
+ MatProgressBarModule,
+ MatRippleModule,
+ MatSortModule,
+ MatSelectModule,
+ MatTooltipModule,
+ ],
+})
+export class PowerballModule {}
diff --git a/src/app/modules/admin/game/powerball/powerball.routing.ts b/src/app/modules/admin/game/powerball/powerball.routing.ts
new file mode 100644
index 0000000..9d8bced
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/powerball.routing.ts
@@ -0,0 +1,15 @@
+import { Route } from '@angular/router';
+
+import { ListComponent } from './components/list.component';
+
+import { PowerballsResolver } from './resolvers/powerball.resolver';
+
+export const powerballRoutes: Route[] = [
+ {
+ path: '',
+ component: ListComponent,
+ resolve: {
+ deposits: PowerballsResolver,
+ },
+ },
+];
diff --git a/src/app/modules/admin/game/powerball/resolvers/powerball.resolver.ts b/src/app/modules/admin/game/powerball/resolvers/powerball.resolver.ts
new file mode 100644
index 0000000..fbe0c30
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/resolvers/powerball.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 { Powerball } from '../models/powerball';
+import { PowerballPagination } from '../models/powerball-pagination';
+import { PowerballService } from '../services/powerball.service';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class PowerballResolver implements Resolve {
+ /**
+ * Constructor
+ */
+ constructor(
+ private _powerballService: PowerballService,
+ private _router: Router
+ ) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Resolver
+ *
+ * @param route
+ * @param state
+ */
+ resolve(
+ route: ActivatedRouteSnapshot,
+ state: RouterStateSnapshot
+ ): Observable {
+ return this._powerballService
+ .getPowerballById(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 PowerballsResolver implements Resolve {
+ /**
+ * Constructor
+ */
+ constructor(private _powerballService: PowerballService) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Resolver
+ *
+ * @param route
+ * @param state
+ */
+ resolve(
+ route: ActivatedRouteSnapshot,
+ state: RouterStateSnapshot
+ ): Observable<{
+ pagination: PowerballPagination;
+ powerballs: Powerball[];
+ }> {
+ return this._powerballService.getPowerballs();
+ }
+}
diff --git a/src/app/modules/admin/game/powerball/services/powerball.service.ts b/src/app/modules/admin/game/powerball/services/powerball.service.ts
new file mode 100644
index 0000000..fddd2d1
--- /dev/null
+++ b/src/app/modules/admin/game/powerball/services/powerball.service.ts
@@ -0,0 +1,156 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import {
+ BehaviorSubject,
+ filter,
+ map,
+ Observable,
+ of,
+ switchMap,
+ take,
+ tap,
+ throwError,
+} from 'rxjs';
+
+import { Powerball } from '../models/powerball';
+import { PowerballPagination } from '../models/powerball-pagination';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class PowerballService {
+ // Private
+ private __pagination = new BehaviorSubject(
+ undefined
+ );
+ private __powerball = new BehaviorSubject(undefined);
+ private __powerballs = new BehaviorSubject(
+ undefined
+ );
+
+ /**
+ * Constructor
+ */
+ constructor(private _httpClient: HttpClient) {}
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Accessors
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Getter for pagination
+ */
+ get pagination$(): Observable {
+ return this.__pagination.asObservable();
+ }
+
+ /**
+ * Getter for powerball
+ */
+ get powerball$(): Observable {
+ return this.__powerball.asObservable();
+ }
+
+ /**
+ * Getter for powerballs
+ */
+ get powerballs$(): Observable {
+ return this.__powerballs.asObservable();
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Get powerballs
+ *
+ *
+ * @param page
+ * @param size
+ * @param sort
+ * @param order
+ * @param search
+ */
+ getPowerballs(
+ page: number = 0,
+ size: number = 10,
+ sort: string = 'nickname',
+ order: 'asc' | 'desc' | '' = 'asc',
+ search: string = ''
+ ): Observable<{
+ pagination: PowerballPagination;
+ powerballs: Powerball[];
+ }> {
+ return this._httpClient
+ .get<{ pagination: PowerballPagination; powerballs: Powerball[] }>(
+ 'api/apps/game/powerball/powerballs',
+ {
+ params: {
+ page: '' + page,
+ size: '' + size,
+ sort,
+ order,
+ search,
+ },
+ }
+ )
+ .pipe(
+ tap((response) => {
+ this.__pagination.next(response.pagination);
+ this.__powerballs.next(response.powerballs);
+ })
+ );
+ }
+
+ /**
+ * Get product by id
+ */
+ getPowerballById(id: string | null): Observable {
+ return this.__powerballs.pipe(
+ take(1),
+ map((powerballs) => {
+ // Find the product
+ const powerball =
+ powerballs?.find((item) => item.id === id) || undefined;
+
+ // Update the product
+ this.__powerball.next(powerball);
+
+ // Return the product
+ return powerball;
+ }),
+ switchMap((product) => {
+ if (!product) {
+ return throwError('Could not found product with id of ' + id + '!');
+ }
+
+ return of(product);
+ })
+ );
+ }
+
+ /**
+ * Create product
+ */
+ createPowerball(): Observable {
+ return this.powerballs$.pipe(
+ take(1),
+ switchMap((powerballs) =>
+ this._httpClient
+ .post('api/apps/game/powerball/product', {})
+ .pipe(
+ map((newPowerball) => {
+ // Update the powerballs with the new product
+ if (!!powerballs) {
+ this.__powerballs.next([newPowerball, ...powerballs]);
+ }
+
+ // Return the new product
+ return newPowerball;
+ })
+ )
+ )
+ );
+ }
+}
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index c0c8a31..c21b778 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -8,5 +8,6 @@
"Partner": "Partner",
"Analytics": "Analytics",
"Deposit": "Deposit",
- "Withdraw": "Withdraw"
+ "Withdraw": "Withdraw",
+ "Powerball": "Powerball"
}
diff --git a/src/assets/i18n/ko.json b/src/assets/i18n/ko.json
index a012a72..f441d33 100644
--- a/src/assets/i18n/ko.json
+++ b/src/assets/i18n/ko.json
@@ -8,5 +8,6 @@
"Partner": "파트너",
"Analytics": "Analytics",
"Deposit": "입금관리",
- "Withdraw": "출금관리"
+ "Withdraw": "출금관리",
+ "Powerball": "파워볼"
}