From 550f8bb209a638146e5586e4f7b00e3d38e7bac6 Mon Sep 17 00:00:00 2001 From: Flo Date: Mon, 26 Aug 2024 12:48:10 +0000 Subject: [PATCH] first base version --- src/app/app.component.html | 2 +- src/app/app.component.ts | 4 +- src/app/app.module.ts | 2 +- src/app/app.service.ts | 21 ---------- src/app/core/auth/auth.module.ts | 2 +- .../confirm-registration.component.html | 24 +++++++++++- .../confirm-registration.component.ts | 31 +++++++++++++++ .../components/login/login.component.html | 2 +- .../registration/registration.component.html | 25 +++++++++++- .../registration/registration.component.ts | 25 ++++++++++++ .../core/components/home/home.component.html | 23 ++++++++++- .../core/components/home/home.component.ts | 28 +++++++++++++ .../navigation/navigation.component.html | 19 +++++---- .../navigation/navigation.component.ts | 9 +++++ src/app/core/core.module.ts | 7 +++- .../confirm-registration-request.model.ts | 14 +++++++ .../models/register-user-request.model.ts | 7 ++++ src/app/core/services/app.service.ts | 30 ++++++++++++++ src/app/core/services/auth.service.ts | 32 +++++++++++++++ .../components/card/card.component.html | 39 ++++++++++--------- .../components/form/form.component.html | 21 ---------- .../components/form/form.component.scss | 0 .../shared/components/form/form.component.ts | 12 ------ .../paginator/paginator.component.html | 14 ++++--- .../tab-control/tab-control.component.html | 20 ---------- .../tab-control/tab-control.component.scss | 0 .../tab-control/tab-control.component.ts | 30 -------------- .../components/table/table.component.html | 29 +++++++------- .../components/table/table.component.ts | 8 ---- src/app/shared/shared.module.ts | 6 --- src/styles.scss | 13 ++----- tailwind.config.js | 17 +++++++- 32 files changed, 331 insertions(+), 185 deletions(-) delete mode 100644 src/app/app.service.ts create mode 100644 src/app/core/models/confirm-registration-request.model.ts create mode 100644 src/app/core/models/register-user-request.model.ts create mode 100644 src/app/core/services/app.service.ts delete mode 100644 src/app/shared/components/form/form.component.html delete mode 100644 src/app/shared/components/form/form.component.scss delete mode 100644 src/app/shared/components/form/form.component.ts delete mode 100644 src/app/shared/components/tab-control/tab-control.component.html delete mode 100644 src/app/shared/components/tab-control/tab-control.component.scss delete mode 100644 src/app/shared/components/tab-control/tab-control.component.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index 0680b43..90c6b64 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index eef36c1..beaa4c8 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { AuthService } from './core/services/auth.service'; +import { AppService } from './core/services/app.service'; @Component({ selector: 'app-root', @@ -8,7 +9,8 @@ import { AuthService } from './core/services/auth.service'; }) export class AppComponent implements OnInit { constructor( - private authService: AuthService + private authService: AuthService, + private appService: AppService, ) { } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5c578f8..871884c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,8 +11,8 @@ import { CoreModule } from './core/core.module'; import { AuthGuard } from './core/guards/auth.guard'; const routes: Routes = [ - { path: 'auth', loadChildren: () => import('./core/auth/auth.module').then(m => m.AuthModule) }, { path: 'home', component: HomeComponent, canActivate: [AuthGuard] }, + { path: 'auth', loadChildren: () => import('./core/auth/auth.module').then(m => m.AuthModule) }, { path: '', redirectTo: 'home', pathMatch: 'full' }, ]; diff --git a/src/app/app.service.ts b/src/app/app.service.ts deleted file mode 100644 index e65248d..0000000 --- a/src/app/app.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable({ - providedIn: 'root' -}) -export class AppService { - - private username: string|null; - - constructor() { - this.username = null; - } - - public getUsername(): string|null { - return this.username; - } - - public setUsername(name: string|null): void { - this.username = name; - } -} diff --git a/src/app/core/auth/auth.module.ts b/src/app/core/auth/auth.module.ts index 82680d8..883512c 100644 --- a/src/app/core/auth/auth.module.ts +++ b/src/app/core/auth/auth.module.ts @@ -9,7 +9,7 @@ import { ReactiveFormsModule } from '@angular/forms'; const routes: Routes = [ { path: 'login', component: LoginComponent }, { path: 'registration', component: RegistrationComponent }, - { path: 'registration/:id', component: ConfirmRegistrationComponent }, + { path: 'registration/:registrationId', component: ConfirmRegistrationComponent }, { path: '', redirectTo: 'login', pathMatch: 'full' }, ]; diff --git a/src/app/core/auth/components/confirm-registration/confirm-registration.component.html b/src/app/core/auth/components/confirm-registration/confirm-registration.component.html index 6465355..463299d 100644 --- a/src/app/core/auth/components/confirm-registration/confirm-registration.component.html +++ b/src/app/core/auth/components/confirm-registration/confirm-registration.component.html @@ -1 +1,23 @@ -

confirm-registration works!

+
+
+ +
+

+ Beekeeper +

+

+ Registrierung Abschließen +

+
+ +
+
+ + +
+
+ + +
+ +
diff --git a/src/app/core/auth/components/confirm-registration/confirm-registration.component.ts b/src/app/core/auth/components/confirm-registration/confirm-registration.component.ts index 977a152..45f15ea 100644 --- a/src/app/core/auth/components/confirm-registration/confirm-registration.component.ts +++ b/src/app/core/auth/components/confirm-registration/confirm-registration.component.ts @@ -1,4 +1,8 @@ import { Component } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { filter } from 'rxjs'; +import { AuthService } from 'src/app/core/services/auth.service'; @Component({ selector: 'app-confirm-registration', @@ -6,5 +10,32 @@ import { Component } from '@angular/core'; styleUrls: ['./confirm-registration.component.scss'] }) export class ConfirmRegistrationComponent { + confirmRegistrationForm = new FormGroup({ + password: new FormControl('', [Validators.required]), + passwordConfirmation: new FormControl('', [Validators.required]), + }); + registrationId: string | undefined; + + constructor( + private authService: AuthService, + private activatedRoute: ActivatedRoute + ) { + this.activatedRoute.params.subscribe( + (params) => { + this.registrationId = params['registrationId']; + } + ) + } + + confirm(): void { + if (this.registrationId === undefined) + return; + + this.authService.confirmRegistration({ + id: this.registrationId!, + password: this.confirmRegistrationForm.value.password!, + passwordConfirmation: this.confirmRegistrationForm.value.passwordConfirmation! + }); + } } diff --git a/src/app/core/auth/components/login/login.component.html b/src/app/core/auth/components/login/login.component.html index d840111..c45b672 100644 --- a/src/app/core/auth/components/login/login.component.html +++ b/src/app/core/auth/components/login/login.component.html @@ -20,5 +20,5 @@

Neu hier? Jetzt registrieren!

- + diff --git a/src/app/core/auth/components/registration/registration.component.html b/src/app/core/auth/components/registration/registration.component.html index d2f7abe..47a244b 100644 --- a/src/app/core/auth/components/registration/registration.component.html +++ b/src/app/core/auth/components/registration/registration.component.html @@ -1 +1,24 @@ -

registration works!

+
+
+ +
+

+ Beekeeper +

+

+ Registrierung +

+
+ +
+
+ + +
+
+ + +

Bereits registiert? Jetzt anmelden!

+
+ +
diff --git a/src/app/core/auth/components/registration/registration.component.ts b/src/app/core/auth/components/registration/registration.component.ts index 2330af4..613781b 100644 --- a/src/app/core/auth/components/registration/registration.component.ts +++ b/src/app/core/auth/components/registration/registration.component.ts @@ -1,4 +1,8 @@ import { Component } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { filter } from 'rxjs'; +import { AuthService } from 'src/app/core/services/auth.service'; @Component({ selector: 'app-registration', @@ -6,5 +10,26 @@ import { Component } from '@angular/core'; styleUrls: ['./registration.component.scss'] }) export class RegistrationComponent { + registrationForm = new FormGroup({ + mail: new FormControl('', [Validators.required]), + username: new FormControl('', [Validators.required]), + }); + constructor( + private authService: AuthService, + private router: Router + ) { + this.authService.currentState$.pipe( + filter(state => state !== undefined) + ).subscribe(state => { + this.router.navigateByUrl('/home'); + }); + } + + login(): void { + this.authService.register({ + mail: this.registrationForm.value.mail!, + username: this.registrationForm.value.username! + }); + } } diff --git a/src/app/core/components/home/home.component.html b/src/app/core/components/home/home.component.html index d696ec9..9194b82 100644 --- a/src/app/core/components/home/home.component.html +++ b/src/app/core/components/home/home.component.html @@ -1,5 +1,24 @@ -
- +
+ + I'm working + + + + I'm working + + + + I'm working + + +
+ + + +
+ + +
\ No newline at end of file diff --git a/src/app/core/components/home/home.component.ts b/src/app/core/components/home/home.component.ts index b1f2660..a6cf3ac 100644 --- a/src/app/core/components/home/home.component.ts +++ b/src/app/core/components/home/home.component.ts @@ -1,5 +1,11 @@ import { Component } from '@angular/core'; import { RequestService } from 'src/app/core/services/request.service'; +import { ColumnDefinition } from 'src/app/shared/components/table/table.component'; + +interface Colony { + name: string; + +} @Component({ selector: 'app-home', @@ -7,6 +13,28 @@ import { RequestService } from 'src/app/core/services/request.service'; styleUrls: ['./home.component.scss'], }) export class HomeComponent { + + columns: ColumnDefinition[] = [ + { + header: 'Name', + columnFunction: (colony:Colony) => colony.name, + routerLink: (colony:Colony) => '#', + }, + { + header: 'Name2', + columnFunction: (colony:Colony) => colony.name, + } + ]; + + colonies: Colony[] = [ + { + name: 'Die Römer' + }, + { + name: 'Die Griechen' + } + ]; + constructor(public requestService: RequestService) { } } diff --git a/src/app/core/components/navigation/navigation.component.html b/src/app/core/components/navigation/navigation.component.html index fb4201f..ce01861 100644 --- a/src/app/core/components/navigation/navigation.component.html +++ b/src/app/core/components/navigation/navigation.component.html @@ -1,17 +1,17 @@ -