Compare commits
No commits in common. "5739d31cdf59727881b93f947e1fc83a5271081a" and "a6c006a68d93386271061659d4b87fe545591cbf" have entirely different histories.
5739d31cdf
...
a6c006a68d
@ -1 +1 @@
|
|||||||
rootProject.name = "casino"
|
rootProject.name = "lf12_starter_backend"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package de.szut.casino;
|
package de.szut.lf8_starter;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class CasinoApplication {
|
public class Lf12StarterApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CasinoApplication.class, args);
|
SpringApplication.run(Lf12StarterApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package de.szut.casino.config;
|
package de.szut.lf8_starter.config;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
package de.szut.lf8_starter.config;
|
||||||
|
|
||||||
|
|
||||||
|
import de.szut.lf8_starter.hello.HelloEntity;
|
||||||
|
import de.szut.lf8_starter.hello.HelloRepository;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SampleDataCreator implements ApplicationRunner {
|
||||||
|
|
||||||
|
private HelloRepository repository;
|
||||||
|
|
||||||
|
public SampleDataCreator(HelloRepository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(ApplicationArguments args) {
|
||||||
|
repository.save(new HelloEntity("Hallo Welt!"));
|
||||||
|
repository.save(new HelloEntity("Schöner Tag heute"));
|
||||||
|
repository.save(new HelloEntity("FooBar"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package de.szut.casino.exceptionHandling;
|
package de.szut.lf8_starter.exceptionHandling;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -1,4 +1,4 @@
|
|||||||
package de.szut.casino.exceptionHandling;
|
package de.szut.lf8_starter.exceptionHandling;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package de.szut.casino.exceptionHandling;
|
package de.szut.lf8_starter.exceptionHandling;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
@ -0,0 +1,98 @@
|
|||||||
|
package de.szut.lf8_starter.hello;
|
||||||
|
|
||||||
|
|
||||||
|
import de.szut.lf8_starter.exceptionHandling.ResourceNotFoundException;
|
||||||
|
import de.szut.lf8_starter.hello.dto.HelloCreateDto;
|
||||||
|
import de.szut.lf8_starter.hello.dto.HelloGetDto;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "hellos")
|
||||||
|
public class HelloController {
|
||||||
|
private final HelloService service;
|
||||||
|
private final HelloMapper helloMapper;
|
||||||
|
|
||||||
|
public HelloController(HelloService service, HelloMapper mappingService) {
|
||||||
|
this.service = service;
|
||||||
|
this.helloMapper = mappingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "creates a new hello with its id and message")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "201", description = "created hello",
|
||||||
|
content = {@Content(mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = HelloGetDto.class))}),
|
||||||
|
@ApiResponse(responseCode = "400", description = "invalid JSON posted",
|
||||||
|
content = @Content),
|
||||||
|
@ApiResponse(responseCode = "401", description = "not authorized",
|
||||||
|
content = @Content)})
|
||||||
|
@PostMapping
|
||||||
|
public HelloGetDto create(@RequestBody @Valid HelloCreateDto helloCreateDto) {
|
||||||
|
HelloEntity helloEntity = this.helloMapper.mapCreateDtoToEntity(helloCreateDto);
|
||||||
|
helloEntity = this.service.create(helloEntity);
|
||||||
|
return this.helloMapper.mapToGetDto(helloEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "delivers a list of hellos")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "list of hellos",
|
||||||
|
content = {@Content(mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = HelloGetDto.class))}),
|
||||||
|
@ApiResponse(responseCode = "401", description = "not authorized",
|
||||||
|
content = @Content)})
|
||||||
|
@GetMapping
|
||||||
|
public List<HelloGetDto> findAll() {
|
||||||
|
return this.service
|
||||||
|
.readAll()
|
||||||
|
.stream()
|
||||||
|
.map(e -> this.helloMapper.mapToGetDto(e))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "deletes a Hello by id")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "204", description = "delete successful"),
|
||||||
|
@ApiResponse(responseCode = "401", description = "not authorized",
|
||||||
|
content = @Content),
|
||||||
|
@ApiResponse(responseCode = "404", description = "resource not found",
|
||||||
|
content = @Content)})
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
@ResponseStatus(code = HttpStatus.NO_CONTENT)
|
||||||
|
public void deleteHelloById(@PathVariable long id) {
|
||||||
|
var entity = this.service.readById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
throw new ResourceNotFoundException("HelloEntity not found on id = " + id);
|
||||||
|
} else {
|
||||||
|
this.service.delete(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "find hellos by message")
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "List of hellos who have the given message",
|
||||||
|
content = {@Content(mediaType = "application/json",
|
||||||
|
schema = @Schema(implementation = HelloGetDto.class))}),
|
||||||
|
@ApiResponse(responseCode = "404", description = "qualification description does not exist",
|
||||||
|
content = @Content),
|
||||||
|
@ApiResponse(responseCode = "401", description = "not authorized",
|
||||||
|
content = @Content)})
|
||||||
|
@GetMapping("/findByMessage")
|
||||||
|
public List<HelloGetDto> findAllEmployeesByQualification(@RequestParam String message) {
|
||||||
|
return this.service
|
||||||
|
.findByMessage(message)
|
||||||
|
.stream()
|
||||||
|
.map(e -> this.helloMapper.mapToGetDto(e))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package de.szut.lf8_starter.hello;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "hello")
|
||||||
|
public class HelloEntity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public HelloEntity(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
package de.szut.lf8_starter.hello;
|
||||||
|
|
||||||
|
|
||||||
|
import de.szut.lf8_starter.hello.dto.HelloCreateDto;
|
||||||
|
import de.szut.lf8_starter.hello.dto.HelloGetDto;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class HelloMapper {
|
||||||
|
|
||||||
|
public HelloGetDto mapToGetDto(HelloEntity entity) {
|
||||||
|
return new HelloGetDto(entity.getId(), entity.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public HelloEntity mapCreateDtoToEntity(HelloCreateDto dto) {
|
||||||
|
var entity = new HelloEntity();
|
||||||
|
entity.setMessage(dto.getMessage());
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package de.szut.lf8_starter.hello;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface HelloRepository extends JpaRepository<HelloEntity, Long> {
|
||||||
|
|
||||||
|
|
||||||
|
List<HelloEntity> findByMessage(String message);
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package de.szut.lf8_starter.hello;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class HelloService {
|
||||||
|
private final HelloRepository repository;
|
||||||
|
|
||||||
|
public HelloService(HelloRepository repository) {
|
||||||
|
this.repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HelloEntity create(HelloEntity entity) {
|
||||||
|
return this.repository.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HelloEntity> readAll() {
|
||||||
|
return this.repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HelloEntity readById(long id) {
|
||||||
|
Optional<HelloEntity> optionalQualification = this.repository.findById(id);
|
||||||
|
if (optionalQualification.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return optionalQualification.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void delete(HelloEntity entity) {
|
||||||
|
this.repository.delete(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HelloEntity> findByMessage(String message) {
|
||||||
|
return this.repository.findByMessage(message);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package de.szut.lf8_starter.hello.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class HelloCreateDto {
|
||||||
|
|
||||||
|
@Size(min = 3, message = "at least length of 3")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public HelloCreateDto(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package de.szut.lf8_starter.hello.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class HelloGetDto {
|
||||||
|
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,5 @@
|
|||||||
package de.szut.casino.security;
|
package de.szut.lf8_starter.security;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@ -11,6 +9,9 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class KeycloakLogoutHandler implements LogoutHandler {
|
public class KeycloakLogoutHandler implements LogoutHandler {
|
@ -1,25 +1,29 @@
|
|||||||
package de.szut.casino.security;
|
package de.szut.lf8_starter.security;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.security.config.Customizer;
|
import org.springframework.security.config.Customizer;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
|
||||||
import org.springframework.security.core.session.SessionRegistry;
|
import org.springframework.security.core.session.SessionRegistry;
|
||||||
import org.springframework.security.core.session.SessionRegistryImpl;
|
import org.springframework.security.core.session.SessionRegistryImpl;
|
||||||
|
import org.springframework.security.oauth2.core.oidc.user.OidcUserAuthority;
|
||||||
|
import org.springframework.security.oauth2.core.user.OAuth2UserAuthority;
|
||||||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
|
||||||
|
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
|
||||||
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
import org.springframework.security.web.session.HttpSessionEventPublisher;
|
||||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
class KeycloakSecurityConfig {
|
class KeycloakSecurityConfig {
|
@ -0,0 +1,27 @@
|
|||||||
|
package de.szut.lf8_starter.welcome;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.security.Principal;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class WelcomeController {
|
||||||
|
|
||||||
|
@GetMapping("/welcome")
|
||||||
|
public String welcome() {
|
||||||
|
return "welcome to lf8_starter";
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/roles")
|
||||||
|
public ResponseEntity<?> getRoles(Authentication authentication) {
|
||||||
|
return ResponseEntity.ok(authentication.getAuthorities());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package de.szut.casino;
|
package de.szut.lf8_starter;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
2107
frontend/bun.lock
2107
frontend/bun.lock
File diff suppressed because it is too large
Load Diff
13383
frontend/package-lock.json
generated
Normal file
13383
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,11 @@
|
|||||||
"name": "lf10-starter2024",
|
"name": "lf10-starter2024",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "bunx @angular/cli",
|
"ng": "ng",
|
||||||
"start": "bunx @angular/cli serve --proxy-config src/proxy.conf.json",
|
"start": "ng serve --proxy-config src/proxy.conf.json",
|
||||||
"build": "bunx @angular/cli build",
|
"build": "ng build",
|
||||||
"watch": "bunx @angular/cli build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "bunx @angular/cli test"
|
"test": "ng test"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
6
frontend/src/app/Hello.ts
Normal file
6
frontend/src/app/Hello.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export class Hello {
|
||||||
|
constructor(public id?: number,
|
||||||
|
public message?: string,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
<h1>LF12 Starter</h1>
|
||||||
|
|
||||||
|
<a href="/hello">hello</a>
|
||||||
|
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
|
import {HelloListComponent} from "./hello-list/hello-list.component";
|
||||||
|
import {authGuard} from "./auth.guard";
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
|
{ path: 'hello', component: HelloListComponent , canActivate: [authGuard] }
|
||||||
];
|
];
|
||||||
|
8
frontend/src/app/hello-list/hello-list.component.html
Normal file
8
frontend/src/app/hello-list/hello-list.component.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<h3>List of Hellos</h3>
|
||||||
|
<ul>
|
||||||
|
@for(e of employees$ | async; track e.id) {
|
||||||
|
<li>
|
||||||
|
{{e.id }}, {{e.message}}
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
31
frontend/src/app/hello-list/hello-list.component.ts
Normal file
31
frontend/src/app/hello-list/hello-list.component.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import {Observable, of} from "rxjs";
|
||||||
|
import {Hello} from "../Hello";
|
||||||
|
import {HttpClient, HttpClientModule, HttpHeaders, provideHttpClient} from "@angular/common/http";
|
||||||
|
import {AsyncPipe} from "@angular/common";
|
||||||
|
import {KeycloakService} from "keycloak-angular";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-hello-list',
|
||||||
|
standalone: true,
|
||||||
|
imports: [
|
||||||
|
AsyncPipe
|
||||||
|
],
|
||||||
|
providers: [KeycloakService],
|
||||||
|
templateUrl: './hello-list.component.html',
|
||||||
|
styleUrl: './hello-list.component.css'
|
||||||
|
})
|
||||||
|
export class HelloListComponent {
|
||||||
|
employees$: Observable<Hello[]>;
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) {
|
||||||
|
this.employees$ = of([]);
|
||||||
|
this.fetchData();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchData() {
|
||||||
|
this.employees$ = this.http.get<Hello[]>('/backend/hellos');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user