SeasonTable dazu

This commit is contained in:
2022-12-06 21:12:35 +01:00
parent f0f7f43a27
commit 9fb8a0aafb
6 changed files with 69 additions and 23 deletions

View File

@ -27,7 +27,7 @@ export default function App()
{
return(
<div className='App'>
{/* <SeasonTable seasondata = {seasondata} /> */}
<SeasonTable seasondata = {seasondata} />
<FlightsTable flightdata = {data}/>
</div>
);

View File

@ -30,6 +30,6 @@ export class CFlight implements IKey
public get key()
{
return +this.IDFlight;
return this.IDFlight;
}
}

View File

@ -1,31 +1,54 @@
import {CFlight} from '../classes/CFlight';
import {CHour} from '../classes/CHour';
import { IKey } from '../interfaces/IKey';
export class CSeason
export class CSeason implements IKey
{
id: string;
flighttime: CHour;
flights: CFlight[];
public readonly id: string;
public readonly distance: number;
public readonly points: number;
public readonly flightCount: number;
public readonly flighttime: CHour;
public readonly flighttimeDisp: string;
public readonly flights: CFlight[];
constructor(id: string, flights: CFlight[])
{
this.id = id;
this.flights = flights;
this.flighttime = new CHour(0)
this.calcFlighttime();
var Vals = this.calcValues();
this.distance = Vals.Dist;
this.points = Vals.Points;
this.flightCount = Vals.Count;
this.flighttimeDisp = this.flighttime.Print();
}
calcFlighttime()
public get key()
{
return this.id;
}
private calcValues()
{
var sumDist: number = 0;
var sumPoints: number = 0;
for (let f of this.flights)
{
const ftime: number = +f.FlightDuration;
this.flighttime.Add(new CHour(ftime));
}
}
this.flighttime.Add(f.FlightDuration);
get flightCount() : number
{
return this.flights.length;
sumDist += +f.BestTaskDistance;
sumPoints += +f.BestTaskPoints;
}
var count: number = this.flights.length;
return (
{
'Dist': sumDist,
'Points': sumPoints,
'Count': count,
});
}
}

View File

@ -12,11 +12,20 @@ function Link2Flight(u_key: string, key: string, row: any, data: string | null)
return val;
}
function Meter2Km(u_key: string, key: string, row: any, data: string | null)
export function Meter2Km(u_key: string, key: string, row: any, data: string | null)
{
var val: JSX.Element = <></>;
const numdata: number = +data! / 1000;
val = <td key={u_key}>{numdata}</td>;
val = <td key={u_key}>{numdata.toFixed(2)}</td>;
return val;
}
export function FixNachKomma00(u_key: string, key: string, row: any, data: string | null)
{
var val: JSX.Element = <></>;
const numdata: number = +data!;
val = <td key={u_key}>{numdata.toFixed(2)}</td>;
return val;
}
@ -30,7 +39,7 @@ export default function FlightsTable({flightdata}: {flightdata: CFlight[]})
{ key: "Glider", label: "Gleitschirm" },
{ key: "BestTaskDistance", label: "Strecke", callback: Meter2Km },
{ key: "BestTaskType", label: "Streckentyp" },
{ key: "BestTaskPoints", label: "Punkte" },
{ key: "BestTaskPoints", label: "Punkte", callback: FixNachKomma00 },
{ key: "FlightDurationDispl", label: "Dauer" }
];

View File

@ -1,9 +1,23 @@
import React from "react";
import SortableTable from "./SortableTable";
import {CSeason} from '../classes/CSeason';
import {THeader} from "./SortableTable";
import {Meter2Km, FixNachKomma00} from "./FlightsTable";
//export default function SeasonTable(seasondata: CSeason[])
export default function SeasonTable(seasondata: CSeason[])
export default function SeasonTable({seasondata}:{seasondata: CSeason[]})
{
return (<></>);
}
const headers: THeader[] = [
{ key: "id", label: "Saison" },
{ key: "flightCount", label: "Anzahl" },
{ key: "flighttimeDisp", label: "Dauer" },
{ key: "distance", label: "Strecke", callback: Meter2Km },
{ key: "points", label: "Punkte", callback: FixNachKomma00 }
];
return(
<div className='App'>
<SortableTable<CSeason> headers={headers} dataTbl={seasondata} ></SortableTable>
</div>
);
}

View File

@ -1,4 +1,4 @@
export interface IKey
{
key: number;
key: string;
}