Little test with AI + Add the equipment #8
+1
-1
@@ -33,7 +33,7 @@
|
|||||||
<mat-nav-list>
|
<mat-nav-list>
|
||||||
@for (stat of stats; track stat) {
|
@for (stat of stats; track stat) {
|
||||||
<mat-list-item matListItemLine>
|
<mat-list-item matListItemLine>
|
||||||
<label>{{ stat.id }} : {{ stat.values }}</label>
|
<label>{{ stat.label }} : {{ stat.hoursAndMinutes.hours }}h {{ stat.hoursAndMinutes.minutes }}m</label>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
}
|
}
|
||||||
</mat-nav-list>
|
</mat-nav-list>
|
||||||
|
|||||||
+35
-9
@@ -59,7 +59,13 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
"flightDate",
|
"flightDate",
|
||||||
"actions",
|
"actions",
|
||||||
];
|
];
|
||||||
public stats: Array<{ id: String | Number; values: String | Number }> = [];
|
public stats: Array<{
|
||||||
|
label: String;
|
||||||
|
hoursAndMinutes: {
|
||||||
|
hours: number;
|
||||||
|
minutes: number;
|
||||||
|
};
|
||||||
|
}> = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceComm: ServiceComm,
|
private serviceComm: ServiceComm,
|
||||||
@@ -92,6 +98,14 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
this.getDataForTable();
|
this.getDataForTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delete(item: TunnelFlight) {
|
||||||
|
let data: Array<TunnelFlight> = this.dataSourceTable.data;
|
||||||
|
data = data.filter((d) => d.id !== item.id);
|
||||||
|
|
||||||
|
this.dataSourceTable.data = data;
|
||||||
|
this.serviceTunnelFlight.deleteTunnelFlight(item);
|
||||||
|
}
|
||||||
|
|
||||||
private chartConfig() {
|
private chartConfig() {
|
||||||
this.barChartType = "bar";
|
this.barChartType = "bar";
|
||||||
this.barChartOptions = {
|
this.barChartOptions = {
|
||||||
@@ -190,15 +204,25 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
map((arr) => ({
|
map((arr) => ({
|
||||||
id: arr[0],
|
label: arr[0],
|
||||||
values: arr
|
values: arr
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.reduce((a, b) => Number(a) + Number(b), 0),
|
.reduce((a, b) => Number(a) + Number(b), 0),
|
||||||
|
hoursAndMinutes: {},
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.subscribe((p) => {
|
.subscribe((p) => {
|
||||||
console.log(p);
|
let newStat: {
|
||||||
this.stats.push(p);
|
label: String;
|
||||||
|
hoursAndMinutes: {
|
||||||
|
hours: number;
|
||||||
|
minutes: number;
|
||||||
|
};
|
||||||
|
} = {
|
||||||
|
label: p.label.toString(),
|
||||||
|
hoursAndMinutes: this.toHoursAndMinutes(+p.values),
|
||||||
|
};
|
||||||
|
this.stats.push(newStat);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,11 +309,13 @@ export class ListOfTunnelFlightsComponent implements OnInit {
|
|||||||
return beginDate;
|
return beginDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete(item: TunnelFlight) {
|
private toHoursAndMinutes(totalMinutes: number): {
|
||||||
let data: Array<TunnelFlight> = this.dataSourceTable.data;
|
hours: number;
|
||||||
data = data.filter((d) => d.id !== item.id);
|
minutes: number;
|
||||||
|
} {
|
||||||
|
const hours = Math.floor(totalMinutes / 60);
|
||||||
|
const minutes = totalMinutes % 60;
|
||||||
|
|
||||||
this.dataSourceTable.data = data;
|
return { hours, minutes };
|
||||||
this.serviceTunnelFlight.deleteTunnelFlight(item);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user