-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb586cd
commit 9284914
Showing
26 changed files
with
715 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ POSTGRES_DB=pool | |
POSTGRES_PORT=5432 | ||
CHALLONGE_API_KEY=secret | ||
CHALLONGE_USERNAME=username | ||
MAX_TABLE_COUNT=11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './tables.actions'; | ||
export * from './tables.effects'; | ||
export * from './tables.reducer'; | ||
export * from './tables.selectors'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createActionGroup, emptyProps, props } from '@ngrx/store'; | ||
|
||
export const TablesActions = createActionGroup({ | ||
source: 'Tables', | ||
events: { | ||
'Get Count': emptyProps(), | ||
'Get Count Success': props<{ count: number }>(), | ||
'Get Count Error': props<{ error: string }>(), | ||
'Set Count': props<{ count: number }>(), | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Actions, ROOT_EFFECTS_INIT, createEffect, ofType } from '@ngrx/effects'; | ||
|
||
import { TablesActions } from './tables.actions'; | ||
import { TableService } from '../../services/table.service'; | ||
import { catchError, map, of, switchMap } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class TablesEffects { | ||
constructor( | ||
private actions$: Actions, | ||
private tableService: TableService, | ||
) { } | ||
|
||
init$ = createEffect(() => this.actions$.pipe( | ||
ofType(ROOT_EFFECTS_INIT), | ||
map(() => TablesActions.getCount()), | ||
)); | ||
|
||
getCount$ = createEffect(() => this.actions$.pipe( | ||
ofType(TablesActions.getCount), | ||
switchMap(() => this.tableService.count().pipe( | ||
map(({ count }) => TablesActions.getCountSuccess({ count })), | ||
catchError((error) => of(TablesActions.getCountError({ error }))), | ||
)), | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createReducer, on } from '@ngrx/store'; | ||
import { TablesActions } from './tables.actions'; | ||
|
||
export const stateKey = 'table-count'; | ||
|
||
export interface State { | ||
count: number; | ||
} | ||
|
||
export const initialState: State = { | ||
count: 1, | ||
} | ||
|
||
export const reducer = createReducer( | ||
initialState, | ||
on( | ||
TablesActions.getCountSuccess, | ||
TablesActions.setCount, | ||
(state, { count }) => ({ | ||
...state, | ||
count, | ||
}) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createFeatureSelector, createSelector } from '@ngrx/store'; | ||
import { State, stateKey } from './tables.reducer'; | ||
|
||
export const selectTablesState = createFeatureSelector<State>(stateKey); | ||
|
||
export const selectTablesCount = createSelector( | ||
selectTablesState, | ||
(state: State) => state.count | ||
); |
52 changes: 27 additions & 25 deletions
52
apps/dashboard/src/app/overlay/containers/home/home-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
<ul class="flex flex-wrap text-sm font-medium text-center text-gray-500 dark:text-gray-400 p-4"> | ||
<li class="mr-2" *ngFor="let table of tables"> | ||
<button | ||
type="button" | ||
(click)="setTable(table)" | ||
class="inline-block py-3 px-4 rounded-lg" | ||
[ngClass]="{ 'text-white bg-blue-600': table === currentTable, 'hover:bg-gray-800 hover:text-white': table != currentTable }" | ||
> | ||
Table {{ table }} | ||
</button> | ||
</li> | ||
<li> | ||
<a class="inline-block py-3 px-4 text-gray-400 cursor-not-allowed dark:text-gray-500"> <fa-icon [icon]="faPlus"></fa-icon> Add Table </a> | ||
</li> | ||
</ul> | ||
<div class="flex flex-row flex-none mt-5 h-52 justify-center items-center"> | ||
<ng-container *ngFor="let table of tables"> | ||
<pool-overlay-scoreboard [hidden]="table !== currentTable" [table]="table"></pool-overlay-scoreboard> | ||
</ng-container> | ||
</div> | ||
<div> | ||
<ng-container *ngFor="let table of tables"> | ||
<pool-overlay-controller [hidden]="table !== currentTable" [table]="table"></pool-overlay-controller> | ||
</ng-container> | ||
</div> | ||
<ng-container *ngIf="tables$ | async as tables"> | ||
<ul class="flex flex-wrap text-sm font-medium text-center text-gray-500 dark:text-gray-400 p-4"> | ||
<li class="mr-2" *ngFor="let table of tables"> | ||
<button | ||
type="button" | ||
(click)="setTable(table)" | ||
class="inline-block py-3 px-4 rounded-lg" | ||
[ngClass]="{ 'text-white bg-blue-600': table === currentTable, 'hover:bg-gray-800 hover:text-white': table != currentTable }" | ||
> | ||
Table {{ table }} | ||
</button> | ||
</li> | ||
<li> | ||
<a class="inline-block py-3 px-4 text-gray-400 cursor-not-allowed dark:text-gray-500"> <fa-icon [icon]="faPlus"></fa-icon> Add Table </a> | ||
</li> | ||
</ul> | ||
<div class="flex flex-row flex-none mt-5 h-52 justify-center items-center"> | ||
<ng-container *ngFor="let table of tables"> | ||
<pool-overlay-scoreboard [hidden]="table !== currentTable" [table]="table"></pool-overlay-scoreboard> | ||
</ng-container> | ||
</div> | ||
<div> | ||
<ng-container *ngFor="let table of tables"> | ||
<pool-overlay-controller [hidden]="table !== currentTable" [table]="table"></pool-overlay-controller> | ||
</ng-container> | ||
</div> | ||
</ng-container> |
9 changes: 8 additions & 1 deletion
9
apps/dashboard/src/app/overlay/containers/home/home-page.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Inject, Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { EnvironmentConfig, ENV_CONFIG } from '../models/environment-config.model'; | ||
import { ICount } from '../models/count.model'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class TableService { | ||
private apiURL: string; | ||
private apiVersion: string; | ||
private endpoint = 'table'; | ||
|
||
constructor( | ||
@Inject(ENV_CONFIG) config: EnvironmentConfig, | ||
private http: HttpClient, | ||
) { | ||
this.apiURL = config.environment.apiURL; | ||
this.apiVersion = config.environment.apiVersion; | ||
} | ||
|
||
public count(): Observable<ICount> { | ||
let url = `${this.apiURL}/${this.apiVersion}/${this.endpoint}/count`; | ||
return this.http.get<ICount>(url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.