diff --git a/backend/api/registrations/del.php b/backend/api/registrations/del.php new file mode 100644 index 0000000..48c857f --- /dev/null +++ b/backend/api/registrations/del.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/backend/libs/registration/registration.php b/backend/libs/registration/registration.php index cd4eb09..dab577d 100644 --- a/backend/libs/registration/registration.php +++ b/backend/libs/registration/registration.php @@ -199,7 +199,7 @@ function sendRegistrationMail($data) { $message = " Neue Anmeldung bei Li-Dance

{$data->firstname} {$data->lastname} aus {$data->city} hat sich angemeldet.

-

Btte bearbeite diese möglichst schnell: Zur Anmeldung

+

Btte bearbeite diese möglichst schnell: Zur Anmeldung

"; $header[] = 'MIME-Version: 1.0'; diff --git a/frontend/angular.json b/frontend/angular.json index 2c65be3..3a1bd02 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -58,6 +58,27 @@ ], "outputHashing": "all" }, + "lite": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "2mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.lite.ts" + } + ], + "outputHashing": "all" + }, "development": { "buildOptimizer": false, "optimization": false, diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts index fb28f4d..9a45db1 100644 --- a/frontend/src/app/app-routing.module.ts +++ b/frontend/src/app/app-routing.module.ts @@ -5,8 +5,13 @@ import { VisitsComponent } from './components/visits/visits.component'; import { VisitsDatetimeComponent } from './components/visits/visits-datetime/visits-datetime.component'; import { RegistrationWizardComponent } from './components/registrations/registration-wizard/registration-wizard.component'; import { RegistrationListComponent } from './components/registrations/registration-list/registration-list.component'; +import { environment } from 'src/environments/environment'; -const routes: Routes = [ +const publicRoutes: Routes = [ + { path: '**', component: RegistrationWizardComponent }, +]; + +const internalRoutes: Routes = [ { path: 'students', component: StudentListComponent }, { path: 'visits', component: VisitsComponent }, { path: 'registrations', component: RegistrationListComponent }, @@ -16,6 +21,9 @@ const routes: Routes = [ { path: '**', redirectTo: 'students' }, ]; +//const routes: Routes = publicRoutes; +const routes: Routes = environment.lite ? publicRoutes : internalRoutes; + @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule], diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index c4da062..7908846 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,5 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { MatIconRegistry } from '@angular/material/icon'; +import { Title } from '@angular/platform-browser'; +import { environment } from 'src/environments/environment'; @Component({ selector: 'li-root', @@ -9,12 +11,14 @@ import { MatIconRegistry } from '@angular/material/icon'; export class AppComponent implements OnInit { constructor( - private matIconReg: MatIconRegistry + private matIconReg: MatIconRegistry, + private titleService: Title ) {} title = 'li-dance-backoffice'; ngOnInit(): void { this.matIconReg.setDefaultFontSetClass('material-symbols-outlined'); + this.titleService.setTitle(environment.appTitle); } } \ No newline at end of file diff --git a/frontend/src/app/components/registrations/registration-list/registration-list.component.html b/frontend/src/app/components/registrations/registration-list/registration-list.component.html index 7f7543e..2f9d2e2 100644 --- a/frontend/src/app/components/registrations/registration-list/registration-list.component.html +++ b/frontend/src/app/components/registrations/registration-list/registration-list.component.html @@ -23,11 +23,17 @@ Geschlecht - {{element.gender}} + {{element | gender}} + + + Adresse + {{element | address}} + + - delete + delete diff --git a/frontend/src/app/components/registrations/registration-list/registration-list.component.ts b/frontend/src/app/components/registrations/registration-list/registration-list.component.ts index a011c16..e9451b5 100644 --- a/frontend/src/app/components/registrations/registration-list/registration-list.component.ts +++ b/frontend/src/app/components/registrations/registration-list/registration-list.component.ts @@ -41,6 +41,10 @@ export class RegistrationListComponent implements OnInit { this.dataSource.filter = filterValue.trim().toLowerCase(); } + public delete(registration: StudentRegistration): void { + this.registrationsService.del(registration).subscribe(_ => this.getData()); + } + private getData() { this.registrationsService.get().subscribe({ next: registrations => { diff --git a/frontend/src/app/pipes/address.pipe.ts b/frontend/src/app/pipes/address.pipe.ts index b1891a6..d311ccf 100644 --- a/frontend/src/app/pipes/address.pipe.ts +++ b/frontend/src/app/pipes/address.pipe.ts @@ -1,10 +1,11 @@ import { Pipe, PipeTransform } from '@angular/core'; import { Student } from '../models/student'; +import { StudentRegistration } from '../models/student-registration'; @Pipe({ name: 'address' }) export class AddressPipe implements PipeTransform { - transform(student: Student): string { - let result = `${student.street} ${student.house}${student.house_suffix}, ${student.zip} ${student.city}`; + transform(student: Student | StudentRegistration): string { + let result = `${student.street} ${student.house}, ${student.zip} ${student.city}`; return result.trim() === '0,' ? '' : result; } } diff --git a/frontend/src/app/pipes/gender.pipe.ts b/frontend/src/app/pipes/gender.pipe.ts index d9b06d6..bb324e6 100644 --- a/frontend/src/app/pipes/gender.pipe.ts +++ b/frontend/src/app/pipes/gender.pipe.ts @@ -1,14 +1,18 @@ import { Pipe, PipeTransform } from '@angular/core'; import { Student } from '../models/student'; +import { StudentRegistration } from '../models/student-registration'; @Pipe({ name: 'gender' }) export class GenderPipe implements PipeTransform { - transform(student: Student): string { + transform(student: Student | StudentRegistration): string { + console.log(student); switch (Number(student.gender)) { case 0: return 'M'; case 1: return 'W'; + case 2: + return 'D'; default: return '?'; } diff --git a/frontend/src/app/services/registrations/registrations.service.ts b/frontend/src/app/services/registrations/registrations.service.ts index e98fdd7..3c2cf17 100644 --- a/frontend/src/app/services/registrations/registrations.service.ts +++ b/frontend/src/app/services/registrations/registrations.service.ts @@ -3,28 +3,28 @@ import { HttpClient, HttpHeaders } from "@angular/common/http"; import { StudentRegistration } from "../../models/student-registration"; import { Observable } from "rxjs"; import { environment } from 'src/environments/environment'; +import * as moment from 'moment'; @Injectable({ providedIn: 'root' }) export class RegistrationsService { private readonly serviceName = 'registrations'; - private readonly headers = { headers: new HttpHeaders({ "Authorization": environment.apiKeyPublic })}; + private readonly publicHeaders = { headers: new HttpHeaders({ "Authorization": environment.apiKeyPublic })}; + private readonly internalHeaders = { headers: new HttpHeaders({ "Authorization": environment.apiKeyInternal })}; constructor(private http: HttpClient) { } public get(): Observable { return this.http.get( - `${environment.apiUrl}${this.serviceName}/get.php`, this.headers + `${environment.apiUrl}${this.serviceName}/get.php`, this.internalHeaders ); } public set(registration: StudentRegistration): Observable { - const formatDate = (date: Date): string => date.toISOString().split('T')[0]; - const payload = `firstname=${encodeURIComponent(registration.firstName)}&` + `lastname=${encodeURIComponent(registration.lastName)}&` + - `birthday=${encodeURIComponent(formatDate(registration.birthday))}&` + + `birthday=${encodeURIComponent(moment(registration.birthday).format('YYYY-MM-DD'))}&` + `gender=${encodeURIComponent(registration.gender)}&` + `street=${encodeURIComponent(registration.street)}&` + `house=${encodeURIComponent(registration.house)}&` + @@ -43,11 +43,20 @@ export class RegistrationsService { `returnDebitConsent=${encodeURIComponent(registration.returnDebitConsent)}&` + `dataStorageConsent=${encodeURIComponent(registration.dataStorageConsent)}&` + `multimediaConsent=${encodeURIComponent(registration.multimediaConsent)}`; - return this.http.post(`${environment.apiUrl}${this.serviceName}/set.php`, payload, - this.headers + this.publicHeaders ); } + + public del(registration: StudentRegistration): Observable { + const payload = `rid=${registration.rid}`; + + return this.http.post( + `${environment.apiUrl}${this.serviceName}/del.php`, + payload, + this.internalHeaders + ); + } } diff --git a/frontend/src/environments/environment.lite.ts b/frontend/src/environments/environment.lite.ts new file mode 100644 index 0000000..0cbcc80 --- /dev/null +++ b/frontend/src/environments/environment.lite.ts @@ -0,0 +1,8 @@ +export const environment = { + production: true, + lite: true, + appTitle: 'Li-Dance Registration', + apiUrl: 'https://li-dance.de/plan/api/', + apiKeyPublic: '754259b6-caf0-4eca-a1f6-812731adae79', + apiKeyInternal: '', +}; diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts index 014cd4b..f041237 100644 --- a/frontend/src/environments/environment.prod.ts +++ b/frontend/src/environments/environment.prod.ts @@ -1,5 +1,7 @@ export const environment = { production: true, + lite: false, + appTitle: 'Li-Dance Backoffice Suite', apiUrl: 'https://li-dance.de/plan/api/', apiKeyPublic: '754259b6-caf0-4eca-a1f6-812731adae79', apiKeyInternal: '1ca6fc7d-d5b8-473c-a44d-a8c9098e2940', diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts index a6aa7b8..63f3dd8 100644 --- a/frontend/src/environments/environment.ts +++ b/frontend/src/environments/environment.ts @@ -4,6 +4,8 @@ export const environment = { production: false, + lite: false, + appTitle: 'Li-Dance Backoffice Suite', apiUrl: 'https://li-dance.de/plan/api/', apiKeyPublic: '754259b6-caf0-4eca-a1f6-812731adae79', apiKeyInternal: '1ca6fc7d-d5b8-473c-a44d-a8c9098e2940', diff --git a/frontend/src/favicon.ico b/frontend/src/favicon.ico deleted file mode 100644 index 997406a..0000000 Binary files a/frontend/src/favicon.ico and /dev/null differ diff --git a/frontend/src/index.html b/frontend/src/index.html index 220a0c6..f8e9316 100644 --- a/frontend/src/index.html +++ b/frontend/src/index.html @@ -2,10 +2,11 @@ - Li-Dance Backoffice - + + - + +