Compare commits
2 Commits
4bf07b0972
...
edafe0e4ec
| Author | SHA1 | Date | |
|---|---|---|---|
| edafe0e4ec | |||
| a1174e3b42 |
@@ -0,0 +1,3 @@
|
||||
interface GetConsumptionEntriesResponse {
|
||||
consumptions: ConsumptionEntry[];
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
@if (consumptionEntries$ | async; as consumptionEntries) {
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Distanz</th>
|
||||
<th>Menge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (entry of consumptionEntries; track entry.id) {
|
||||
<tr>
|
||||
<td>{{ entry.dateTime | date }}</td>
|
||||
<td>{{ entry.distance }} km</td>
|
||||
<td>{{ entry.amount }} l</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Distanz</th>
|
||||
<th>Menge</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (entry of consumptionEntries; track entry.id) {
|
||||
<tr>
|
||||
<td>{{ entry.dateTime | date }}</td>
|
||||
<td>{{ entry.distance }} km</td>
|
||||
<td>{{ entry.amount }} l</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AsyncPipe, DatePipe } from '@angular/common';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { Observable, tap } from 'rxjs';
|
||||
import { map, Observable, tap } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entries',
|
||||
@@ -16,12 +16,13 @@ export class EntriesComponent {
|
||||
protected readonly consumptionEntries$: Observable<ConsumptionEntry[]>;
|
||||
|
||||
constructor() {
|
||||
this.consumptionEntries$ = this.http.get<ConsumptionEntry[]>('/api/v1/consumptions')
|
||||
this.consumptionEntries$ = this.http.get<GetConsumptionEntriesResponse>('/api/v1/consumptions')
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
tap((response) => {
|
||||
console.log('Entries response:', response);
|
||||
}),
|
||||
map(response => response.consumptions)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Vegasco.Server.Api.Endpoints;
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Vegasco.Server.Api.Endpoints;
|
||||
using Vegasco.Server.ServiceDefaults;
|
||||
|
||||
namespace Vegasco.Server.Api.Common;
|
||||
@@ -36,6 +37,17 @@ internal static class StartupExtensions
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi("/swagger/{documentName}/swagger.json");
|
||||
app.UseSwaggerUI(o =>
|
||||
{
|
||||
// Create a Swagger endpoint for each API version
|
||||
IReadOnlyList<ApiVersionDescription> apiVersions = app.DescribeApiVersions();
|
||||
foreach (ApiVersionDescription apiVersionDescription in apiVersions)
|
||||
{
|
||||
string url = $"/swagger/{apiVersionDescription.GroupName}/swagger.json";
|
||||
string name = apiVersionDescription.GroupName.ToUpperInvariant();
|
||||
o.SwaggerEndpoint(url, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return app;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
|
||||
<PackageReference Include="StronglyTypedId" Version="1.0.0-beta08" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||
<PackageReference Include="StronglyTypedId.Templates" Version="1.0.0-beta08" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user