SeasonTable dazu
This commit is contained in:
@ -27,7 +27,7 @@ export default function App()
|
||||
{
|
||||
return(
|
||||
<div className='App'>
|
||||
{/* <SeasonTable seasondata = {seasondata} /> */}
|
||||
<SeasonTable seasondata = {seasondata} />
|
||||
<FlightsTable flightdata = {data}/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -30,6 +30,6 @@ export class CFlight implements IKey
|
||||
|
||||
public get key()
|
||||
{
|
||||
return +this.IDFlight;
|
||||
return this.IDFlight;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
sumDist += +f.BestTaskDistance;
|
||||
sumPoints += +f.BestTaskPoints;
|
||||
}
|
||||
var count: number = this.flights.length;
|
||||
|
||||
return (
|
||||
{
|
||||
return this.flights.length;
|
||||
'Dist': sumDist,
|
||||
'Points': sumPoints,
|
||||
'Count': count,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -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" }
|
||||
];
|
||||
|
||||
|
||||
@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export interface IKey
|
||||
{
|
||||
key: number;
|
||||
key: string;
|
||||
}
|
||||
Reference in New Issue
Block a user