diff --git a/README.md b/README.md index df08c33..3806a0b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Lf10Starter2024 +# Lf10StarterNew -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.2. +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.3. ## Development server @@ -24,4 +24,4 @@ Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To u ## Further help -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. diff --git a/angular.json b/angular.json index 64f0edf..988421e 100644 --- a/angular.json +++ b/angular.json @@ -92,5 +92,8 @@ } } } + }, + "cli": { + "analytics": "33c8483f-3876-4eb5-9c9b-1001cab9b273" } } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..a83a1d8 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3' + +volumes: + employee_postgres_data: + driver: local + +services: + postgres-employee: + container_name: postgres_employee + image: postgres:13.3 + volumes: + - employee_postgres_data:/var/lib/postgresql/data + environment: + POSTGRES_DB: employee_db + POSTGRES_USER: employee + POSTGRES_PASSWORD: secret + ports: + - "5432:5432" + + employee: + container_name: employee + image: berndheidemann/employee-management-service:1.0.4 + # image: berndheidemann/employee-management-service_without_keycloak:1.1 + environment: + spring.datasource.url: jdbc:postgresql://postgres-employee:5432/employee_db + spring.datasource.username: employee + spring.datasource.password: secret + ports: + - "8089:8089" + depends_on: + - postgres-employee diff --git a/getBearerToken.http b/getBearerToken.http new file mode 100644 index 0000000..e0429d9 --- /dev/null +++ b/getBearerToken.http @@ -0,0 +1,4 @@ +POST http://authproxy.szut.dev +Content-Type: application/x-www-form-urlencoded + +grant_type=password&client_id=employee-management-service&username=user&password=test diff --git a/package.json b/package.json index a8fa32a..68757f0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "ng serve --proxy-config src/proxy.conf.json", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test" diff --git a/src/app/Employee.ts b/src/app/Employee.ts new file mode 100644 index 0000000..1debefc --- /dev/null +++ b/src/app/Employee.ts @@ -0,0 +1,10 @@ +export class Employee { + constructor(public id?: number, + public lastName?: string, + public firstName?: string, + public street?: string, + public postcode?: string, + public city?: string, + public phone?: string) { + } +} diff --git a/src/app/app.component.html b/src/app/app.component.html index 36093e1..7e4c070 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,336 +1,2 @@ - - - - - - - - + - - -
-
-
- -

Hello, {{ title }}

-

Congratulations! Your app is running. 🎉

-
- -
-
- @for (item of [ - { title: 'Explore the Docs', link: 'https://angular.dev' }, - { title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' }, - { title: 'CLI Docs', link: 'https://angular.dev/tools/cli' }, - { title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' }, - { title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' }, - ]; track item.title) { - - {{ item.title }} - - - - - } -
- -
-
-
- - - - - - - - - - - diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 9610d39..bc98df0 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -14,16 +14,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have the 'lf10Starter2024' title`, () => { + it(`should have the 'lf10StarterNew' title`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('lf10Starter2024'); + expect(app.title).toEqual('lf10StarterNew'); }); it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, lf10Starter2024'); + expect(compiled.querySelector('h1')?.textContent).toContain('Hello, lf10StarterNew'); }); }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5e08f6e..593c1d8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,13 +1,15 @@ import { Component } from '@angular/core'; +import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; +import {EmployeeListComponent} from "./employee-list/employee-list.component"; @Component({ selector: 'app-root', standalone: true, - imports: [RouterOutlet], + imports: [CommonModule, EmployeeListComponent], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { - title = 'lf10Starter2024'; + title = 'lf10StarterNew'; } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index a1e7d6f..6c6ef60 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,8 +1,8 @@ -import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; +import { ApplicationConfig } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { - providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)] + providers: [provideRouter(routes)] }; diff --git a/src/app/employee-list/employee-list.component.css b/src/app/employee-list/employee-list.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/employee-list/employee-list.component.html b/src/app/employee-list/employee-list.component.html new file mode 100644 index 0000000..217b9d0 --- /dev/null +++ b/src/app/employee-list/employee-list.component.html @@ -0,0 +1,9 @@ +

LF10-Starter

+Wenn Sie in der EmployeeListComponent.ts ein gültiges Bearer-Token eintragen, sollten hier die Namen der in der Datenbank gespeicherten Mitarbeiter angezeigt werden! + diff --git a/src/app/employee-list/employee-list.component.spec.ts b/src/app/employee-list/employee-list.component.spec.ts new file mode 100644 index 0000000..081f497 --- /dev/null +++ b/src/app/employee-list/employee-list.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EmployeeListComponent } from './employee-list.component'; + +describe('EmployeeListComponent', () => { + let component: EmployeeListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [EmployeeListComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(EmployeeListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/employee-list/employee-list.component.ts b/src/app/employee-list/employee-list.component.ts new file mode 100644 index 0000000..b9684f0 --- /dev/null +++ b/src/app/employee-list/employee-list.component.ts @@ -0,0 +1,30 @@ +import { Component } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import {Observable, of} from "rxjs"; +import {HttpClient, HttpClientModule, HttpHeaders} from "@angular/common/http"; +import {Employee} from "../Employee"; + +@Component({ + selector: 'app-employee-list', + standalone: true, + imports: [CommonModule, HttpClientModule], + templateUrl: './employee-list.component.html', + styleUrl: './employee-list.component.css' +}) +export class EmployeeListComponent { + bearer = 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICIzUFQ0dldiNno5MnlQWk1EWnBqT1U0RjFVN0lwNi1ELUlqQWVGczJPbGU0In0.eyJleHAiOjE3MjU0NDQ5ODYsImlhdCI6MTcyNTQ0MTM4NiwianRpIjoiYzVhOTg4YzgtMWM0OC00MWRmLWIyODYtZjIzMTdkMmMwZjA4IiwiaXNzIjoiaHR0cHM6Ly9rZXljbG9hay5zenV0LmRldi9hdXRoL3JlYWxtcy9zenV0IiwiYXVkIjoiYWNjb3VudCIsInN1YiI6IjU1NDZjZDIxLTk4NTQtNDMyZi1hNDY3LTRkZTNlZWRmNTg4OSIsInR5cCI6IkJlYXJlciIsImF6cCI6ImVtcGxveWVlLW1hbmFnZW1lbnQtc2VydmljZSIsInNlc3Npb25fc3RhdGUiOiIyYmNlZTA0Zi1lNmUwLTQxM2MtYWE4OS02Yzc4NTJhNTk2OWQiLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbImh0dHA6Ly9sb2NhbGhvc3Q6NDIwMCJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsicHJvZHVjdF9vd25lciIsIm9mZmxpbmVfYWNjZXNzIiwiZGVmYXVsdC1yb2xlcy1zenV0IiwidW1hX2F1dGhvcml6YXRpb24iLCJ1c2VyIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJlbWFpbCBwcm9maWxlIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsInByZWZlcnJlZF91c2VybmFtZSI6InVzZXIifQ.UGHmGv2-sLLoHIuTusQ1OrPk0Jh_guDNtCREHsDntw49OvRamRYR8LvPp6GjXduyknY2HtFRTomWSWYItCRFfCoeyg9s4Umbo79uVJ7RYsNvMKYmM_6vyCHIOqT-5wEgECQzjR_F5aaa5F5IJERBcRuyf3BXfypS2w0yGqb7TLN99x8JF54J1DR_p9ejJJTKdrN19917a0WiQugh4Oj_xrRjjphwKGgfNkxSmVnpaPtHu1xHcIp-1BtSQx-2S_kSUMTCDURsI7brGAyRfhjRAgXi4GCDqz6-lbh7UZE2v8jEuZ1UR3RSipYJpdVRSTRD-VNdfqm9J4fsz_jtDOvCIg'; + employees$: Observable; + + constructor(private http: HttpClient) { + this.employees$ = of([]); + this.fetchData(); + } + + fetchData() { + this.employees$ = this.http.get('/backend/employees', { + headers: new HttpHeaders() + .set('Content-Type', 'application/json') + .set('Authorization', `Bearer ${this.bearer}`) + }); + } +} diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000..57614f9 Binary files /dev/null and b/src/favicon.ico differ diff --git a/src/index.html b/src/index.html index dc60a3f..dfd88fd 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - Lf10Starter2024 + Lf10StarterNew diff --git a/src/proxy.conf.json b/src/proxy.conf.json new file mode 100644 index 0000000..a1f39ee --- /dev/null +++ b/src/proxy.conf.json @@ -0,0 +1,11 @@ +{ + "/backend": { + "target": "http://localhost:8089/", + "secure": false, + "logLevel": "debug", + "pathRewrite": { + "^/backend": "" + }, + "changeOrigin": true + } +}