Merge pull request 'refactor: cleanup frontend code' (!183) from refactor-frontend into main
Reviewed-on: #183 Reviewed-by: Jan K9f <jan@kjan.email>
This commit is contained in:
commit
fc7bd0b70f
25 changed files with 17 additions and 101 deletions
|
@ -1,18 +0,0 @@
|
||||||
volumes:
|
|
||||||
casino-db-data:
|
|
||||||
|
|
||||||
services:
|
|
||||||
db:
|
|
||||||
image: postgres:17.5
|
|
||||||
container_name: casino-db
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
- casino-db-data:/var/lib/postgresql/data
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: postgresdb
|
|
||||||
POSTGRES_USER: postgres_user
|
|
||||||
POSTGRES_PASSWORD: postgres_pass
|
|
||||||
healthcheck:
|
|
||||||
test: "exit 0"
|
|
||||||
ports:
|
|
||||||
- "5432:5432"
|
|
|
@ -1,5 +1,6 @@
|
||||||
<div class="min-h-screen flex flex-col">
|
<div class="min-h-screen flex flex-col">
|
||||||
<main class="flex-grow">
|
<main class="flex-grow">
|
||||||
|
<app-navbar></app-navbar>
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
<app-footer></app-footer>
|
<app-footer></app-footer>
|
||||||
|
|
|
@ -2,11 +2,12 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { FooterComponent } from '@shared/components/footer/footer.component';
|
import { FooterComponent } from '@shared/components/footer/footer.component';
|
||||||
|
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, RouterOutlet, FooterComponent],
|
imports: [CommonModule, RouterOutlet, FooterComponent, NavbarComponent],
|
||||||
providers: [],
|
providers: [],
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrl: './app.component.css',
|
styleUrl: './app.component.css',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CanActivateFn, Router } from '@angular/router';
|
import { CanActivateFn, Router } from '@angular/router';
|
||||||
import { inject } from '@angular/core';
|
import { inject } from '@angular/core';
|
||||||
import { AuthService } from './service/auth.service';
|
import { AuthService } from '@service/auth.service';
|
||||||
|
|
||||||
export const authGuard: CanActivateFn = async () => {
|
export const authGuard: CanActivateFn = async () => {
|
||||||
const authService = inject(AuthService);
|
const authService = inject(AuthService);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar />
|
|
||||||
|
|
||||||
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
||||||
<div class="modal-card max-w-md w-full">
|
<div class="modal-card max-w-md w-full">
|
||||||
<h2 class="modal-heading text-center">Anmelden</h2>
|
<h2 class="modal-heading text-center">Anmelden</h2>
|
||||||
|
|
|
@ -4,12 +4,11 @@ import { Router, RouterLink } from '@angular/router';
|
||||||
import { LoginRequest } from '../../../model/auth/LoginRequest';
|
import { LoginRequest } from '../../../model/auth/LoginRequest';
|
||||||
import { AuthService } from '../../../service/auth.service';
|
import { AuthService } from '../../../service/auth.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-login',
|
selector: 'app-login',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, ReactiveFormsModule, RouterLink, NavbarComponent],
|
imports: [CommonModule, ReactiveFormsModule, RouterLink],
|
||||||
templateUrl: './login.component.html',
|
templateUrl: './login.component.html',
|
||||||
})
|
})
|
||||||
export class LoginComponent {
|
export class LoginComponent {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar />
|
|
||||||
|
|
||||||
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
<div class="min-h-screen bg-deep-blue flex items-center justify-center">
|
||||||
<div class="modal-card max-w-md w-full">
|
<div class="modal-card max-w-md w-full">
|
||||||
<h2 class="modal-heading text-center">Konto erstellen</h2>
|
<h2 class="modal-heading text-center">Konto erstellen</h2>
|
||||||
|
|
|
@ -4,12 +4,11 @@ import { Router, RouterLink } from '@angular/router';
|
||||||
import { RegisterRequest } from '../../../model/auth/RegisterRequest';
|
import { RegisterRequest } from '../../../model/auth/RegisterRequest';
|
||||||
import { AuthService } from '@service/auth.service';
|
import { AuthService } from '@service/auth.service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-register',
|
selector: 'app-register',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, ReactiveFormsModule, RouterLink, NavbarComponent],
|
imports: [CommonModule, ReactiveFormsModule, RouterLink],
|
||||||
templateUrl: './register.component.html',
|
templateUrl: './register.component.html',
|
||||||
})
|
})
|
||||||
export class RegisterComponent {
|
export class RegisterComponent {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
|
|
||||||
<div class="container mx-auto px-4 py-6 space-y-8">
|
<div class="container mx-auto px-4 py-6 space-y-8">
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
||||||
<div class="lg:col-span-3 space-y-6 flex flex-col gap-4">
|
<div class="lg:col-span-3 space-y-6 flex flex-col gap-4">
|
||||||
|
|
|
@ -10,7 +10,6 @@ import { BlackjackService } from '@blackjack/services/blackjack.service';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { GameResultComponent } from '@blackjack/components/game-result/game-result.component';
|
import { GameResultComponent } from '@blackjack/components/game-result/game-result.component';
|
||||||
import { GameState } from '@blackjack/enum/gameState';
|
import { GameState } from '@blackjack/enum/gameState';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { UserService } from '@service/user.service';
|
import { UserService } from '@service/user.service';
|
||||||
import { timer } from 'rxjs';
|
import { timer } from 'rxjs';
|
||||||
import { DebtDialogComponent } from '@shared/components/debt-dialog/debt-dialog.component';
|
import { DebtDialogComponent } from '@shared/components/debt-dialog/debt-dialog.component';
|
||||||
|
@ -21,7 +20,6 @@ import { AuthService } from '@service/auth.service';
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
NavbarComponent,
|
|
||||||
DealerHandComponent,
|
DealerHandComponent,
|
||||||
PlayerHandComponent,
|
PlayerHandComponent,
|
||||||
GameControlsComponent,
|
GameControlsComponent,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
|
|
||||||
<div class="container mx-auto px-4 py-6 space-y-8">
|
<div class="container mx-auto px-4 py-6 space-y-8">
|
||||||
<h1 class="text-3xl font-bold text-white mb-6">Spielautomaten</h1>
|
<h1 class="text-3xl font-bold text-white mb-6">Spielautomaten</h1>
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,12 @@ import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
inject,
|
inject,
|
||||||
OnInit,
|
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
signal,
|
signal,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { CommonModule, KeyValuePipe, NgClass, CurrencyPipe } from '@angular/common';
|
import { CommonModule, CurrencyPipe, KeyValuePipe, NgClass } from '@angular/common';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { UserService } from '@service/user.service';
|
import { UserService } from '@service/user.service';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
|
@ -26,7 +25,6 @@ interface SlotResult {
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
NavbarComponent,
|
|
||||||
KeyValuePipe,
|
KeyValuePipe,
|
||||||
NgClass,
|
NgClass,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
<div class="container mx-auto px-4 py-6 space-y-8">
|
<div class="container mx-auto px-4 py-6 space-y-8">
|
||||||
<div class="flex justify-between items-center">
|
<div class="flex justify-between items-center">
|
||||||
<div class="flex items-center space-x-4"></div>
|
<div class="flex items-center space-x-4"></div>
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { AsyncPipe, CurrencyPipe, DatePipe, NgFor } from '@angular/common';
|
||||||
import { DepositComponent } from '../deposit/deposit.component';
|
import { DepositComponent } from '../deposit/deposit.component';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ConfirmationComponent } from '@shared/components/confirmation/confirmation.component';
|
import { ConfirmationComponent } from '@shared/components/confirmation/confirmation.component';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { Game } from 'app/model/Game';
|
import { Game } from 'app/model/Game';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { TransactionService } from '@service/transaction.service';
|
import { TransactionService } from '@service/transaction.service';
|
||||||
|
@ -15,7 +14,6 @@ import { TransactionData } from '../../model/TransactionData';
|
||||||
selector: 'app-homepage',
|
selector: 'app-homepage',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
NavbarComponent,
|
|
||||||
CurrencyPipe,
|
CurrencyPipe,
|
||||||
NgFor,
|
NgFor,
|
||||||
DepositComponent,
|
DepositComponent,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
|
|
||||||
<div class="min-h-screen bg-deep-blue text-text-primary">
|
<div class="min-h-screen bg-deep-blue text-text-primary">
|
||||||
<div class="container mx-auto px-4 py-8 sm:py-12">
|
<div class="container mx-auto px-4 py-8 sm:py-12">
|
||||||
<div class="max-w-5xl mx-auto">
|
<div class="max-w-5xl mx-auto">
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { NgFor } from '@angular/common';
|
import { NgFor } from '@angular/common';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
import { AuthService } from '@service/auth.service';
|
import { AuthService } from '@service/auth.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-landing-page',
|
selector: 'app-landing-page',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [NavbarComponent, NgFor, RouterLink],
|
imports: [NgFor, RouterLink],
|
||||||
templateUrl: './landing.component.html',
|
templateUrl: './landing.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<p>Logging in...</p>
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { AuthService } from '../../service/auth.service';
|
|
||||||
import { OAuthService } from 'angular-oauth2-oidc';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-login-success',
|
|
||||||
standalone: true,
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './login-success.component.html',
|
|
||||||
styleUrl: './login-success.component.css',
|
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
||||||
})
|
|
||||||
export default class LoginSuccessComponent implements OnInit {
|
|
||||||
private authService: AuthService = inject(AuthService);
|
|
||||||
private oauthService: OAuthService = inject(OAuthService);
|
|
||||||
private router: Router = inject(Router);
|
|
||||||
|
|
||||||
async ngOnInit() {
|
|
||||||
try {
|
|
||||||
if (this.oauthService.hasValidAccessToken()) {
|
|
||||||
this.router.navigate(['/home']);
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.oauthService.hasValidAccessToken() || this.authService.getUser()) {
|
|
||||||
this.router.navigate(['/home']);
|
|
||||||
} else {
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error during login callback:', err);
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.authService.isLoggedIn()) {
|
|
||||||
this.router.navigate(['/home']);
|
|
||||||
} else {
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
|
|
||||||
<div class="container mx-auto px-4 py-6 space-y-8">
|
<div class="container mx-auto px-4 py-6 space-y-8">
|
||||||
<h1 class="text-3xl font-bold text-white mb-6">Lootbox Öffnen</h1>
|
<h1 class="text-3xl font-bold text-white mb-6">Lootbox Öffnen</h1>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { CommonModule } from '@angular/common';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { LootboxService } from '../services/lootbox.service';
|
import { LootboxService } from '../services/lootbox.service';
|
||||||
import { LootBox, Reward } from 'app/model/LootBox';
|
import { LootBox, Reward } from 'app/model/LootBox';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { UserService } from '@service/user.service';
|
import { UserService } from '@service/user.service';
|
||||||
import { User } from 'app/model/User';
|
import { User } from 'app/model/User';
|
||||||
import { AuthService } from '@service/auth.service';
|
import { AuthService } from '@service/auth.service';
|
||||||
|
@ -11,7 +10,7 @@ import { AuthService } from '@service/auth.service';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-lootbox-opening',
|
selector: 'app-lootbox-opening',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, NavbarComponent],
|
imports: [CommonModule],
|
||||||
templateUrl: './lootbox-opening.component.html',
|
templateUrl: './lootbox-opening.component.html',
|
||||||
styleUrls: ['./lootbox-opening.component.css'],
|
styleUrls: ['./lootbox-opening.component.css'],
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
<app-navbar></app-navbar>
|
|
||||||
<div class="container mx-auto px-4 py-6">
|
<div class="container mx-auto px-4 py-6">
|
||||||
<h1 class="text-3xl font-bold text-white mb-6">Lootboxen</h1>
|
<h1 class="text-3xl font-bold text-white mb-6">Lootboxen</h1>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { NavbarComponent } from '@shared/components/navbar/navbar.component';
|
|
||||||
import { LootboxService } from '../services/lootbox.service';
|
import { LootboxService } from '../services/lootbox.service';
|
||||||
import { LootBox } from 'app/model/LootBox';
|
import { LootBox } from 'app/model/LootBox';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
@ -12,7 +11,7 @@ import { UserService } from '@service/user.service';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-lootbox-selection',
|
selector: 'app-lootbox-selection',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [CommonModule, NavbarComponent],
|
imports: [CommonModule],
|
||||||
templateUrl: './lootbox-selection.component.html',
|
templateUrl: './lootbox-selection.component.html',
|
||||||
styleUrls: ['./lootbox-selection.component.css'],
|
styleUrls: ['./lootbox-selection.component.css'],
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hidden md:flex items-center space-x-4">
|
<div class="hidden md:flex items-center space-x-4">
|
||||||
@if (!isLoggedIn) {
|
@if (!isLoggedIn()) {
|
||||||
<a routerLink="/login" class="button-primary px-4 py-1.5">Anmelden</a>
|
<a routerLink="/login" class="button-primary px-4 py-1.5">Anmelden</a>
|
||||||
<a
|
<a
|
||||||
routerLink="/register"
|
routerLink="/register"
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
>Registrieren</a
|
>Registrieren</a
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@if (isLoggedIn) {
|
@if (isLoggedIn()) {
|
||||||
<div
|
<div
|
||||||
class="text-white font-bold bg-deep-blue-contrast rounded-full px-4 py-2 text-sm hover:bg-deep-blue-contrast/80 hover:cursor-pointer hover:scale-105 transition-all active:scale-95 select-none duration-300"
|
class="text-white font-bold bg-deep-blue-contrast rounded-full px-4 py-2 text-sm hover:bg-deep-blue-contrast/80 hover:cursor-pointer hover:scale-105 transition-all active:scale-95 select-none duration-300"
|
||||||
routerLink="/home"
|
routerLink="/home"
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
<div class="nav-mobile-menu">
|
<div class="nav-mobile-menu">
|
||||||
<a routerLink="/games" class="nav-mobile-link">Spiele</a>
|
<a routerLink="/games" class="nav-mobile-link">Spiele</a>
|
||||||
<div class="pt-2 space-y-2">
|
<div class="pt-2 space-y-2">
|
||||||
@if (!isLoggedIn) {
|
@if (!isLoggedIn()) {
|
||||||
<a routerLink="/login" class="button-primary w-full py-1.5 block text-center"
|
<a routerLink="/login" class="button-primary w-full py-1.5 block text-center"
|
||||||
>Anmelden</a
|
>Anmelden</a
|
||||||
>
|
>
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
>Registrieren</a
|
>Registrieren</a
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
@if (isLoggedIn) {
|
@if (isLoggedIn()) {
|
||||||
<button (click)="logout()" class="button-primary w-full py-1.5">Abmelden</button>
|
<button (click)="logout()" class="button-primary w-full py-1.5">Abmelden</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { AnimatedNumberComponent } from '@blackjack/components/animated-number/a
|
||||||
export class NavbarComponent implements OnInit, OnDestroy {
|
export class NavbarComponent implements OnInit, OnDestroy {
|
||||||
isMenuOpen = false;
|
isMenuOpen = false;
|
||||||
private authService: AuthService = inject(AuthService);
|
private authService: AuthService = inject(AuthService);
|
||||||
isLoggedIn = this.authService.isLoggedIn();
|
isLoggedIn = signal(this.authService.isLoggedIn());
|
||||||
|
|
||||||
private authSubscription!: Subscription;
|
private authSubscription!: Subscription;
|
||||||
public balance = signal(0);
|
public balance = signal(0);
|
||||||
|
@ -30,6 +30,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
||||||
this.authSubscription = this.authService.userSubject.subscribe({
|
this.authSubscription = this.authService.userSubject.subscribe({
|
||||||
next: (user) => {
|
next: (user) => {
|
||||||
this.balance.set(user?.balance ?? 0);
|
this.balance.set(user?.balance ?? 0);
|
||||||
|
this.isLoggedIn.set(this.authService.isLoggedIn());
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue