From 297af2b95dd64e07a10f92257d8f4e452cfdabf3 Mon Sep 17 00:00:00 2001 From: ThompsonNye Date: Mon, 16 Jun 2025 18:49:07 +0200 Subject: [PATCH] Copy more from weight tracker --- .../edit-entry/edit-entry.component.html | 89 +++++++++++++++++++ .../edit-entry/edit-entry.component.scss | 0 .../edit-entry/edit-entry.component.ts | 50 +++++++++++ .../entries/entries/entries.component.html | 45 +++++----- .../entries/entries/entries.component.ts | 31 +++---- 5 files changed, 179 insertions(+), 36 deletions(-) create mode 100644 src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.html create mode 100644 src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.scss create mode 100644 src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.ts diff --git a/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.html b/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.html new file mode 100644 index 0000000..d5ba414 --- /dev/null +++ b/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.html @@ -0,0 +1,89 @@ +@if (!loaded) { + +} @else { +
+ +
+
+ + +
+ +
+ + +
+
+ +
+ + @if (rabbits$ | async; as rabbits) { + + } +
+ +
+ + @if (medicines$ | async; as medicines) { + + + {{ medicine.name }} ({{ medicine.abbreviation }}) + + + } +
+ +
+ + + + g + +
+ +
+ + +
+ +
+ + +
+ +
+} diff --git a/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.scss b/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.ts b/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.ts new file mode 100644 index 0000000..1b0d5ba --- /dev/null +++ b/src/Vegasco-Web/src/app/modules/entries/edit-entry/edit-entry.component.ts @@ -0,0 +1,50 @@ +import { AsyncPipe } from '@angular/common'; +import { Component, inject } from '@angular/core'; +import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; +import { ButtonModule } from 'primeng/button'; +import { ChipModule } from 'primeng/chip'; +import { DatePickerModule } from 'primeng/datepicker'; +import { FloatLabelModule } from 'primeng/floatlabel'; +import { InputGroupModule } from 'primeng/inputgroup'; +import { InputGroupAddonModule } from 'primeng/inputgroupaddon'; +import { InputNumberModule } from 'primeng/inputnumber'; +import { InputTextModule } from 'primeng/inputtext'; +import { MultiSelectModule } from 'primeng/multiselect'; +import { SelectModule } from 'primeng/select'; +import { SkeletonModule } from 'primeng/skeleton'; + +@Component({ + selector: 'app-edit-entry', + imports: [ + AsyncPipe, + ButtonModule, + ChipModule, + DatePickerModule, + FloatLabelModule, + InputGroupAddonModule, + InputGroupModule, + InputNumberModule, + InputTextModule, + MultiSelectModule, + ReactiveFormsModule, + SelectModule, + SkeletonModule, + ], + templateUrl: './edit-entry.component.html', + styleUrl: './edit-entry.component.scss' +}) +export class EditEntryComponent { + private readonly formBuilder = inject(FormBuilder); + + protected readonly formGroup = this.formBuilder.group({ + date: [null], + time: [null], + rabbit: [null, Validators.required], + weight: [ + null, + Validators.min(1), + ], + medicines: [[]], + comment: [null], + }); +} diff --git a/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.html b/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.html index 7cd05d7..f10990b 100644 --- a/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.html +++ b/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.html @@ -2,34 +2,37 @@
- +
- +
- @if (filteredWeightEntries$ | async; as weightEntries) { - - -
- @for (weightEntry of entries; track weightEntry.id) { - - } -
-
-
+ @if (consumptionEntries$ | async; as entries) { + + +
+ @for (entry of entries; track entry.id) { + {{ entry | json }} + + } +
+
+
} @else {
@for (_ of skeletonsIterationSource; track $index) { diff --git a/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.ts b/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.ts index 1bc6dc1..e024121 100644 --- a/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.ts +++ b/src/Vegasco-Web/src/app/modules/entries/entries/entries.component.ts @@ -1,24 +1,19 @@ import { CommonModule } from '@angular/common'; import { Component, inject } from '@angular/core'; -import { FormControl, ReactiveFormsModule } from '@angular/forms'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { ReactiveFormsModule } from '@angular/forms'; import { RouterLink } from '@angular/router'; -import { MessageService } from 'primeng/api'; import { ButtonModule } from 'primeng/button'; import { DataViewModule } from 'primeng/dataview'; -import { SelectModule } from 'primeng/select'; import { ScrollTopModule } from 'primeng/scrolltop'; +import { SelectModule } from 'primeng/select'; import { SkeletonModule } from 'primeng/skeleton'; import { - BehaviorSubject, - combineLatest, map, Observable, - of, - startWith, - tap, + tap } from 'rxjs'; -import { HttpClient } from '@angular/common/http'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { Client, GetConsumptions_ResponseDto } from '../../../shared/api/swagger.generated'; @Component({ selector: 'app-entries', @@ -36,18 +31,24 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; styleUrl: './entries.component.scss' }) export class EntriesComponent { - private readonly http = inject(HttpClient); + private readonly client = inject(Client); - protected readonly consumptionEntries$: Observable; + protected readonly consumptionEntries$: Observable; + + protected readonly rowsPerPageDefaultOption = 25; + protected readonly rowsPerPageOptions = [10, 25, 50, 100]; + protected readonly currentPageReportTemplate = '{currentPage} / {totalPages}'; + + protected readonly skeletonsIterationSource = Array(10).fill(0); constructor() { - this.consumptionEntries$ = this.http.get('/api/v1/consumptions') + this.consumptionEntries$ = this.client.consumptionsGET() .pipe( takeUntilDestroyed(), tap((response) => { console.log('Entries response:', response); }), - map(response => response.consumptions) - ); + map((response) => response.consumptions) + ) } }