New Angular based web version #1
@@ -113,5 +113,8 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {AsyncPipe, CommonModule} from '@angular/common';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { RouterLink } from '@angular/router';
|
||||
@@ -19,10 +19,13 @@ import {
|
||||
} from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import {CarClient} from '../../../api/cars/car-client';
|
||||
import {ConsumptionClient} from '../../../api/consumptions/consumption-client';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entries',
|
||||
imports: [
|
||||
AsyncPipe,
|
||||
ButtonModule,
|
||||
CommonModule,
|
||||
DataViewModule,
|
||||
@@ -36,12 +39,14 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
styleUrl: './entries.component.scss'
|
||||
})
|
||||
export class EntriesComponent {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly consumptionClient = inject(ConsumptionClient);
|
||||
private readonly carClient = inject(CarClient);
|
||||
|
||||
protected readonly consumptionEntries$: Observable<ConsumptionEntry[]>;
|
||||
protected readonly cars$: Observable<Car[]>;
|
||||
|
||||
constructor() {
|
||||
this.consumptionEntries$ = this.http.get<GetConsumptionEntriesResponse>('/api/v1/consumptions')
|
||||
this.consumptionEntries$ = this.consumptionClient.getAll()
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
tap((response) => {
|
||||
@@ -49,5 +54,14 @@ export class EntriesComponent {
|
||||
}),
|
||||
map(response => response.consumptions)
|
||||
);
|
||||
|
||||
this.cars$ = this.carClient.getAll()
|
||||
.pipe(
|
||||
takeUntilDestroyed(),
|
||||
tap((response) => {
|
||||
console.log('Cars response:', response);
|
||||
}),
|
||||
map(response => response.cars)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user