Compare commits
No commits in common. "main" and "chore/remove-material-styles" have entirely different histories.
main
...
chore/remo
@ -17,15 +17,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: "temurin"
|
distribution: "temurin"
|
||||||
java-version: "22"
|
java-version: "22"
|
||||||
- name: "Cache Gradle dependencies"
|
|
||||||
uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
|
working-directory: ./backend
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.gradle/caches
|
~/.gradle/caches
|
||||||
~/.gradle/wrapper
|
~/.gradle/wrapper
|
||||||
key: gradle-${{ runner.os }}-common
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
gradle-${{ runner.os }}-
|
${{ runner.os }}-gradle-
|
||||||
- name: "Prepare Gradle"
|
- name: "Prepare Gradle"
|
||||||
working-directory: ./backend
|
working-directory: ./backend
|
||||||
run: gradle clean
|
run: gradle clean
|
||||||
@ -46,14 +47,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install bun
|
- name: Install bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
- uses: actions/cache@v3
|
|
||||||
working-directory: ./frontend
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
frontend/node_modules/
|
|
||||||
key: ${{ runner.os }}-bun-
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bun-
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
@ -73,14 +66,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install bun
|
- name: Install bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
- uses: actions/cache@v3
|
|
||||||
working-directory: ./frontend
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
frontend/node_modules/
|
|
||||||
key: ${{ runner.os }}-bun-
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bun-
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
@ -100,22 +85,6 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install bun
|
- name: Install bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@v2
|
||||||
- uses: actions/cache@v3
|
|
||||||
working-directory: ./frontend
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
frontend/node_modules/
|
|
||||||
key: ${{ runner.os }}-bun-
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bun-
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
working-directory: ./frontend
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
frontend/dist/
|
|
||||||
key: ${{ runner.os }}-dist-
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-dist-
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
package de.szut.casino.user;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import de.szut.casino.user.dto.CreateUserDto;
|
|
||||||
import de.szut.casino.user.dto.GetUserDto;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
public class UserController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@GetMapping("/user/{id}")
|
|
||||||
public ResponseEntity<?> getUser(@PathVariable String id) {
|
|
||||||
if (id == null || !userService.exists(id)) {
|
|
||||||
return ResponseEntity.notFound().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok(userService.getUser(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/user")
|
|
||||||
public ResponseEntity<?> createUser(@RequestBody @Valid CreateUserDto userData) {
|
|
||||||
if (userService.exists(userData.getKeycloakId())) {
|
|
||||||
|
|
||||||
return this.redirect("/user/" + userData.getKeycloakId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok(userService.createUser(userData));
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/user")
|
|
||||||
public ResponseEntity<GetUserDto> getCurrentUser(@RequestHeader("Authorization") String token) {
|
|
||||||
GetUserDto userData = userService.getCurrentUser(token);
|
|
||||||
|
|
||||||
if (userData == null) {
|
|
||||||
return ResponseEntity.notFound().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ResponseEntity.ok(userData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseEntity<Object> redirect(String route) {
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("Location", route);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(headers, HttpStatus.FOUND);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package de.szut.casino.user;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.Entity;
|
|
||||||
import jakarta.persistence.GeneratedValue;
|
|
||||||
import jakarta.persistence.Id;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@Entity
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class UserEntity {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
@Column(unique = true)
|
|
||||||
private String keycloakId;
|
|
||||||
private String username;
|
|
||||||
private float balance;
|
|
||||||
|
|
||||||
public UserEntity(String keycloakId, String username, float balance) {
|
|
||||||
this.keycloakId = keycloakId;
|
|
||||||
this.username = username;
|
|
||||||
this.balance = balance;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package de.szut.casino.user;
|
|
||||||
|
|
||||||
import de.szut.casino.user.dto.CreateUserDto;
|
|
||||||
import de.szut.casino.user.dto.GetUserDto;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UserMappingService {
|
|
||||||
public GetUserDto mapToGetUserDto(UserEntity user) {
|
|
||||||
return new GetUserDto(user.getKeycloakId(), user.getUsername(), user.getBalance());
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity mapToUserEntity(CreateUserDto createUserDto) {
|
|
||||||
return new UserEntity(createUserDto.getKeycloakId(), createUserDto.getUsername(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
|||||||
package de.szut.casino.user;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
|
||||||
@Query("SELECT u FROM UserEntity u WHERE u.keycloakId = ?1")
|
|
||||||
Optional<UserEntity> findOneByKeycloakId(String keycloakId);
|
|
||||||
|
|
||||||
boolean existsByKeycloakId(String keycloakId);
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package de.szut.casino.user;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpMethod;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import de.szut.casino.user.dto.CreateUserDto;
|
|
||||||
import de.szut.casino.user.dto.GetUserDto;
|
|
||||||
import de.szut.casino.user.dto.KeycloakUserDto;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UserService {
|
|
||||||
@Autowired
|
|
||||||
private UserRepository userRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RestTemplate http;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserMappingService mappingService;
|
|
||||||
|
|
||||||
public UserEntity createUser(CreateUserDto createUserDto) {
|
|
||||||
UserEntity user = mappingService.mapToUserEntity(createUserDto);
|
|
||||||
userRepository.save(user);
|
|
||||||
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetUserDto getUser(String keycloakId) {
|
|
||||||
Optional<UserEntity> user = this.userRepository.findOneByKeycloakId(keycloakId);
|
|
||||||
|
|
||||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetUserDto getCurrentUser(String token) {
|
|
||||||
KeycloakUserDto userData = getKeycloakUserInfo(token);
|
|
||||||
|
|
||||||
if (userData == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Optional<UserEntity> user = this.userRepository.findOneByKeycloakId(userData.getSub());
|
|
||||||
|
|
||||||
return user.map(userEntity -> mappingService.mapToGetUserDto(userEntity)).orElse(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private KeycloakUserDto getKeycloakUserInfo(String token) {
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.set("Authorization", token);
|
|
||||||
ResponseEntity<KeycloakUserDto> response = this.http.exchange("http://localhost:9090/realms/LF12/protocol/openid-connect/userinfo", HttpMethod.GET, new HttpEntity<>(headers), KeycloakUserDto.class);
|
|
||||||
|
|
||||||
return response.getBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean exists(String keycloakId) {
|
|
||||||
return userRepository.existsByKeycloakId(keycloakId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package de.szut.casino.user.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class CreateUserDto {
|
|
||||||
private String keycloakId;
|
|
||||||
private String username;
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package de.szut.casino.user.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class GetUserDto {
|
|
||||||
private String keycloakId;
|
|
||||||
private String username;
|
|
||||||
private float balance;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package de.szut.casino.user.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class KeycloakUserDto {
|
|
||||||
private String sub;
|
|
||||||
private String preferred_username;
|
|
||||||
}
|
|
@ -1,3 +1,5 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
keycloak_data:
|
keycloak_data:
|
||||||
postgres_data_keycloak_db:
|
postgres_data_keycloak_db:
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 83 KiB |
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
Binary file not shown.
Before Width: | Height: | Size: 167 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 56 KiB |
Binary file not shown.
Before Width: | Height: | Size: 186 KiB |
@ -27,7 +27,7 @@ export const initializeKeycloak = (keycloak: KeycloakService) => async () =>
|
|||||||
onLoad: 'check-sso',
|
onLoad: 'check-sso',
|
||||||
silentCheckSsoRedirectUri: window.location.origin + '/silent-check-sso.html',
|
silentCheckSsoRedirectUri: window.location.origin + '/silent-check-sso.html',
|
||||||
checkLoginIframe: false,
|
checkLoginIframe: false,
|
||||||
redirectUri: window.location.origin + '/',
|
redirectUri: 'http://localhost:4200',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import { LandingComponent } from './feature/landing/landing.component';
|
import { LandingComponent } from './feature/landing/landing.component';
|
||||||
|
import { HomeComponent } from './feature/home/home.component';
|
||||||
import { authGuard } from './auth.guard';
|
import { authGuard } from './auth.guard';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
@ -7,13 +8,9 @@ export const routes: Routes = [
|
|||||||
path: '',
|
path: '',
|
||||||
component: LandingComponent,
|
component: LandingComponent,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'login/success',
|
|
||||||
loadComponent: () => import('./feature/login-success/login-success.component'),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'home',
|
path: 'home',
|
||||||
loadComponent: () => import('./feature/home/home.component'),
|
component: HomeComponent,
|
||||||
canActivate: [authGuard],
|
canActivate: [authGuard],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
import { CanActivateFn, Router } from '@angular/router';
|
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';
|
||||||
import { inject } from '@angular/core';
|
import { inject } from '@angular/core';
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
|
|
||||||
export const authGuard: CanActivateFn = async () => {
|
export const authGuard: CanActivateFn = async (
|
||||||
|
route: ActivatedRouteSnapshot,
|
||||||
|
state: RouterStateSnapshot
|
||||||
|
) => {
|
||||||
const keycloakService = inject(KeycloakService);
|
const keycloakService = inject(KeycloakService);
|
||||||
const router = inject(Router);
|
const isLoggedIn = keycloakService.isLoggedIn();
|
||||||
|
|
||||||
if (keycloakService.isLoggedIn()) {
|
if (isLoggedIn) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
router.navigate(['']);
|
const baseurl = window.location.origin;
|
||||||
|
|
||||||
|
keycloakService.login({
|
||||||
|
redirectUri: `${baseurl}${state.url}`,
|
||||||
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -1,91 +1,19 @@
|
|||||||
<app-navbar></app-navbar>
|
<app-navbar></app-navbar>
|
||||||
<div class="container mx-auto px-4 py-6 space-y-8">
|
|
||||||
<div class="flex justify-between items-center">
|
|
||||||
<div class="flex items-center space-x-4"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
<div class="grid grid-cols-3">
|
||||||
<div class="lg:col-span-3">
|
<div class="w-1/3 h-1/4">
|
||||||
<div class="flex justify-between items-center mb-6">
|
<p>Spiel Vorschau</p>
|
||||||
<h3 class="section-heading text-2xl">Beliebte Spiele</h3>
|
<p>Spiel Name</p>
|
||||||
<div class="flex space-x-2">
|
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||||
<button class="nav-button left-0">
|
</div>
|
||||||
<span class="material-icons">chevron_left</span>
|
<div class="w-1/3 h-1/4">
|
||||||
</button>
|
<p>Spiel Vorschau</p>
|
||||||
<button class="nav-button right-0">
|
<p>Spiel Name</p>
|
||||||
<span class="material-icons">chevron_right</span>
|
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||||
</button>
|
</div>
|
||||||
</div>
|
<div class="w-1/3 h-1/4">
|
||||||
</div>
|
<p>Spiel Vorschau</p>
|
||||||
|
<p>Spiel Name</p>
|
||||||
<div class="slider-container">
|
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||||
<div class="slider-grid">
|
|
||||||
<div class="card group" *ngFor="let game of featuredGames">
|
|
||||||
<div class="relative">
|
|
||||||
<img [src]="game.image" [alt]="game.name" class="w-full aspect-[4/3] object-cover" />
|
|
||||||
<div
|
|
||||||
class="absolute inset-0 bg-gradient-to-t from-deep-blue/90 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"
|
|
||||||
>
|
|
||||||
<div class="absolute bottom-4 left-4 right-4">
|
|
||||||
<h4 class="game-heading">{{ game.name }}</h4>
|
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-8">
|
|
||||||
<h3 class="section-heading text-2xl mb-6">Alle Spiele</h3>
|
|
||||||
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4">
|
|
||||||
<div class="card group" *ngFor="let game of allGames">
|
|
||||||
<div class="relative">
|
|
||||||
<img [src]="game.image" [alt]="game.name" class="w-full aspect-[4/3] object-cover" />
|
|
||||||
<div
|
|
||||||
class="absolute inset-0 bg-gradient-to-t from-deep-blue/90 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"
|
|
||||||
>
|
|
||||||
<div class="absolute bottom-4 left-4 right-4">
|
|
||||||
<h4 class="game-heading">{{ game.name }}</h4>
|
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="lg:col-span-1 space-y-6">
|
|
||||||
<div class="card p-4">
|
|
||||||
<h3 class="section-heading text-xl mb-4">Konto</h3>
|
|
||||||
<div class="space-y-4">
|
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
|
||||||
Transaktionen
|
|
||||||
</button>
|
|
||||||
<button class="bg-deep-blue-light hover:bg-deep-blue-contrast w-full py-2 rounded">
|
|
||||||
Kontoeinstellungen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card p-4">
|
|
||||||
<h3 class="section-heading text-xl mb-4">Letzte Transaktionen</h3>
|
|
||||||
<div class="space-y-3">
|
|
||||||
<div
|
|
||||||
class="flex justify-between items-center"
|
|
||||||
*ngFor="let transaction of recentTransactions"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<p class="text-sm font-medium">{{ transaction.type }}</p>
|
|
||||||
<p class="text-xs text-text-secondary">{{ transaction.date }}</p>
|
|
||||||
</div>
|
|
||||||
<span [class]="transaction.amount > 0 ? 'text-emerald' : 'text-accent-red'">
|
|
||||||
{{ transaction.amount | currency: 'EUR' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,93 +2,19 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
|||||||
import { KeycloakService } from 'keycloak-angular';
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { DepositComponent } from '../deposit/deposit.component';
|
import { DepositComponent } from '../deposit/deposit.component';
|
||||||
|
|
||||||
import { NavbarComponent } from '../../shared/components/navbar/navbar.component';
|
import { NavbarComponent } from '../../shared/components/navbar/navbar.component';
|
||||||
import { CurrencyPipe, NgFor } from '@angular/common';
|
|
||||||
|
|
||||||
interface Game {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
image: string;
|
|
||||||
}
|
|
||||||
interface Transaction {
|
|
||||||
id: string;
|
|
||||||
type: string;
|
|
||||||
amount: number;
|
|
||||||
date: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-homepage',
|
selector: 'app-homepage',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [NavbarComponent, CurrencyPipe, NgFor],
|
imports: [NavbarComponent],
|
||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export default class HomeComponent {
|
export class HomeComponent {
|
||||||
private keycloakService: KeycloakService = inject(KeycloakService);
|
private keycloakService: KeycloakService = inject(KeycloakService);
|
||||||
public dialog: MatDialog = inject(MatDialog);
|
public dialog: MatDialog = inject(MatDialog);
|
||||||
|
|
||||||
userAvatar = '/assets/images/default-avatar.png';
|
|
||||||
username = this.keycloakService.getUsername();
|
|
||||||
vipLevel = 1;
|
|
||||||
balance = 1000.0;
|
|
||||||
|
|
||||||
featuredGames: Game[] = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Poker',
|
|
||||||
image: '/poker.webp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Blackjack',
|
|
||||||
image: '/blackjack.webp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
name: 'Slots',
|
|
||||||
image: '/slots.webp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '4',
|
|
||||||
name: 'Plinko',
|
|
||||||
image: '/plinko.webp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '5',
|
|
||||||
name: 'Liars Dice',
|
|
||||||
image: '/liars-dice.webp',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '6',
|
|
||||||
name: 'Lootboxen',
|
|
||||||
image: '/lootbox.webp',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
allGames: Game[] = [...this.featuredGames];
|
|
||||||
|
|
||||||
recentTransactions: Transaction[] = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
type: 'Deposit',
|
|
||||||
amount: 100.0,
|
|
||||||
date: '2024-03-20',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
type: 'Withdrawal',
|
|
||||||
amount: -50.0,
|
|
||||||
date: '2024-03-19',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
type: 'Bonus',
|
|
||||||
amount: 25.0,
|
|
||||||
date: '2024-03-18',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
public logout() {
|
public logout() {
|
||||||
const baseUrl = window.location.origin;
|
const baseUrl = window.location.origin;
|
||||||
|
|
||||||
|
@ -26,21 +26,21 @@
|
|||||||
<div class="slider-grid">
|
<div class="slider-grid">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Slots</h3>
|
<h3 class="game-heading">Slots</h3>
|
||||||
<p class="game-text">Klassische Spielautomaten</p>
|
<p class="game-text">Klassische Spielautomaten</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Plinko</h3>
|
<h3 class="game-heading">Plinko</h3>
|
||||||
<p class="game-text">Spannendes Geschicklichkeitsspiel</p>
|
<p class="game-text">Spannendes Geschicklichkeitsspiel</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:block card">
|
<div class="hidden lg:block card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Blackjack</h3>
|
<h3 class="game-heading">Blackjack</h3>
|
||||||
<p class="game-text">Klassisches Kartenspiel</p>
|
<p class="game-text">Klassisches Kartenspiel</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
@ -50,21 +50,21 @@
|
|||||||
<div class="slider-grid">
|
<div class="slider-grid">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Poker</h3>
|
<h3 class="game-heading">Poker</h3>
|
||||||
<p class="game-text">Texas Hold'em & mehr</p>
|
<p class="game-text">Texas Hold'em & mehr</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Liars Dice</h3>
|
<h3 class="game-heading">Liars Dice</h3>
|
||||||
<p class="game-text">Würfelspiel mit Strategie</p>
|
<p class="game-text">Würfelspiel mit Strategie</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden lg:block card">
|
<div class="hidden lg:block card">
|
||||||
<div class="game-card-content">
|
<div class="game-card-content">
|
||||||
<h3 class="game-heading-sm">Lootboxen</h3>
|
<h3 class="game-heading">Lootboxen</h3>
|
||||||
<p class="game-text">Überraschungskisten</p>
|
<p class="game-text">Überraschungskisten</p>
|
||||||
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
<button class="button-base w-full py-2">Jetzt Spielen</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<p>Logging in...</p>
|
|
@ -1,26 +0,0 @@
|
|||||||
import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';
|
|
||||||
import { UserService } from '../../service/user.service';
|
|
||||||
import { KeycloakService } from 'keycloak-angular';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
|
|
||||||
@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 userService: UserService = inject(UserService);
|
|
||||||
private keycloakService: KeycloakService = inject(KeycloakService);
|
|
||||||
private router: Router = inject(Router);
|
|
||||||
|
|
||||||
async ngOnInit() {
|
|
||||||
const userProfile = await this.keycloakService.loadUserProfile();
|
|
||||||
const user = await this.userService.getOrCreateUser(userProfile);
|
|
||||||
sessionStorage.setItem('user', JSON.stringify(user));
|
|
||||||
|
|
||||||
this.router.navigate(['']);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
export interface User {
|
|
||||||
keycloakId: string;
|
|
||||||
username: string;
|
|
||||||
balance: number;
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import { inject, Injectable } from '@angular/core';
|
|
||||||
import { HttpClient } from '@angular/common/http';
|
|
||||||
import { KeycloakProfile } from 'keycloak-js';
|
|
||||||
import { catchError, EMPTY, Observable } from 'rxjs';
|
|
||||||
import { User } from '../model/User';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root',
|
|
||||||
})
|
|
||||||
export class UserService {
|
|
||||||
private http: HttpClient = inject(HttpClient);
|
|
||||||
|
|
||||||
public getUser(id: string): Observable<User | null> {
|
|
||||||
return this.http.get<User | null>(`/backend/user/${id}`).pipe(catchError(() => EMPTY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public createUser(id: string, username: string): Observable<User> {
|
|
||||||
return this.http.post<User>('/backend/user', {
|
|
||||||
keycloakId: id,
|
|
||||||
username: username,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getOrCreateUser(userProfile: KeycloakProfile) {
|
|
||||||
if (userProfile.id == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return await this.getUser(userProfile.id)
|
|
||||||
.toPromise()
|
|
||||||
.then(async (user) => {
|
|
||||||
if (user) {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await this.createUser(userProfile.id ?? '', userProfile.username ?? '').toPromise();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,16 +6,16 @@
|
|||||||
<span>Trustworthy Casino</span>
|
<span>Trustworthy Casino</span>
|
||||||
</a>
|
</a>
|
||||||
<div class="hidden md:flex items-center space-x-1">
|
<div class="hidden md:flex items-center space-x-1">
|
||||||
<a routerLink="/games" class="nav-link">Spiele</a>
|
<a routerLink="/games" class="nav-link">Games</a>
|
||||||
</div>
|
</div>
|
||||||
</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) {
|
||||||
<button (click)="login()" class="button-base px-4 py-1.5">Anmelden</button>
|
<button (click)="login()" class="button-base px-4 py-1.5">Login</button>
|
||||||
}
|
}
|
||||||
@if (isLoggedIn) {
|
@if (isLoggedIn) {
|
||||||
<button (click)="logout()" class="button-base px-4 py-1.5">Abmelden</button>
|
<button (click)="logout()" class="button-base px-4 py-1.5">Logout</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -55,13 +55,13 @@
|
|||||||
|
|
||||||
<div [class]="isMenuOpen ? 'block' : 'hidden'" class="md:hidden">
|
<div [class]="isMenuOpen ? 'block' : 'hidden'" class="md:hidden">
|
||||||
<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">Games</a>
|
||||||
<div class="pt-2 space-y-2">
|
<div class="pt-2 space-y-2">
|
||||||
@if (!isLoggedIn) {
|
@if (!isLoggedIn) {
|
||||||
<button (click)="login()" class="button-base w-full py-1.5">Anmelden</button>
|
<button (click)="login()" class="button-base w-full py-1.5">Login</button>
|
||||||
}
|
}
|
||||||
@if (isLoggedIn) {
|
@if (isLoggedIn) {
|
||||||
<button (click)="logout()" class="button-base w-full py-1.5">Abmelden</button>
|
<button (click)="logout()" class="button-base w-full py-1.5">Logout</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -18,7 +18,7 @@ export class NavbarComponent {
|
|||||||
login() {
|
login() {
|
||||||
try {
|
try {
|
||||||
const baseUrl = window.location.origin;
|
const baseUrl = window.location.origin;
|
||||||
this.keycloakService.login({ redirectUri: `${baseUrl}/login/success` });
|
this.keycloakService.login({ redirectUri: `${baseUrl}/home` });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Login failed:', error);
|
console.error('Login failed:', error);
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,10 @@ a {
|
|||||||
@apply font-bold text-text-primary;
|
@apply font-bold text-text-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-heading-sm {
|
.game-heading {
|
||||||
@apply font-bold text-text-primary text-sm mb-2;
|
@apply font-bold text-text-primary text-sm mb-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-heading-xl {
|
|
||||||
@apply font-bold text-text-primary text-xl mb-2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.game-text {
|
.game-text {
|
||||||
@apply text-text-secondary text-sm mb-4;
|
@apply text-text-secondary text-sm mb-4;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user