sicherung ggggg

This commit is contained in:
2022-12-06 01:12:58 +01:00
parent 9c3cae8350
commit 5357f51bf2
8 changed files with 101 additions and 133 deletions

View File

@ -4,14 +4,21 @@ import FlightsTable from "./components/FlightsTable";
import SeasonTable from "./components/SeasonTable";
import {groupByMap} from './global/tools';
import flights from './data/HoPe_all_flights.json';
import {IFlight} from './interfaces/IFlights';
import {CFlight} from './classes/CFlight';
import {CSeason} from './classes/CSeason';
const data = flights.data;
const seasondataraw = groupByMap(data, i => i.FKSeason);
const data_raw = flights.data;
const data: CFlight[] = [];
const seasondata: CSeason[] = [];
for (let [key, value] of seasondataraw)
for (let fl of data_raw)
{
data.push(new CFlight(fl));
}
const seasondata_raw = groupByMap(data, i => i.FKSeason);
for (let [key, value] of seasondata_raw)
{
seasondata.push(new CSeason(key, value));
}

33
src/classes/CFlight.ts Normal file
View File

@ -0,0 +1,33 @@
import {CHour} from '../classes/CHour';
import {IKey} from '../interfaces/IKey';
export class CFlight implements IKey
{
public readonly IDFlight: string;
public readonly FlightDate: string;
public readonly TakeoffWaypointName: string;
public readonly Glider: string;
public readonly BestTaskDistance: string;
public readonly BestTaskType: string;
public readonly BestTaskPoints: string;
public readonly FlightDuration: CHour;
public readonly FKSeason: string;
constructor(inData: any)
{
this.IDFlight = inData.IDFlight;
this.FlightDate = inData.FlightDate;
this.TakeoffWaypointName = inData.TakeoffWaypointName;
this.Glider = inData.Glider;
this.BestTaskDistance = inData.BestTaskDistance;
this.BestTaskType = inData.BestTaskType;
this.BestTaskPoints = inData.BestTaskPoints;
this.FKSeason = inData.FKSeason;
this.FlightDuration = new CHour(+inData.FlightDuration);
}
public get key()
{
return +this.IDFlight;
}
}

View File

@ -1,13 +1,13 @@
import {IFlight} from '../interfaces/IFlights';
import {CFlight} from '../classes/CFlight';
import {CHour} from '../classes/CHour';
export class CSeason
{
id: string;
flighttime: CHour;
flights: IFlight[];
flights: CFlight[];
constructor(id: string, flights: IFlight[])
constructor(id: string, flights: CFlight[])
{
this.id = id;
this.flights = flights;

View File

@ -1,7 +1,7 @@
import React from "react";
import SortableTable from "./SortableTable";
import {THeader} from "./SortableTable";
import {IFlight} from '../interfaces/IFlights';
import {CFlight} from '../classes/CFlight';
function Link2Flight(key: string, row: any, data: string | null)
{
@ -36,7 +36,7 @@ export default function FlightsTable(flightdata: any)
return(
<div className='App'>
<SortableTable<IFlight> headers={headers} dataTbl={flightdata} ></SortableTable>
<SortableTable<CFlight> headers={headers} dataTbl={flightdata} ></SortableTable>
</div>
);
}

View File

@ -1,6 +1,7 @@
import React from "react";
import { orderBy } from 'natural-orderby';
import { MouseEventHandler, useState } from "react";
import { IKey } from "../interfaces/IKey";
export interface ITableTdCallback {(key: string, row: any, data: string | null): JSX.Element};
export type THeader = { key: string; label: string; visible?: boolean; callback?: ITableTdCallback };
@ -33,13 +34,13 @@ function SortButton({
);
}
export default function SortableTable<T>({ headers, dataTbl }:
{ headers: THeader[], dataTbl: T[]})
export default function SortableTable<T extends IKey>({ headers, dataTbl }:
{ headers: THeader[], dataTbl: any })
{
const [sortKey, setSortKey] = useState<string>(headers[0].key);
const [sortOrder, setSortOrder] = useState<TSortOrder>("ascn");
const sortedData: T[] = sortData(
var sortedData: any = sortData(
{
tableData: dataTbl,
sortKey: sortKey,
@ -57,7 +58,7 @@ export default function SortableTable<T>({ headers, dataTbl }:
sortKey,
reverse,
}: {
tableData: T[];
tableData: any;
sortKey: string;
reverse: boolean;
})
@ -65,12 +66,13 @@ export default function SortableTable<T>({ headers, dataTbl }:
if (!sortKey) return tableData;
const order = reverse ? 'asc': 'desc';
//const reval: any = orderBy(tableData, [sortKey], [order]);
const reval: any[] = tableData;
// var helpArr: any = tableData;
// const reval: any = orderBy(helpArr, [sortKey], [order]);
const reval = tableData;
return reval;
}
function TableTd({ item, key, row_item, data } : {item: THeader, key: number, row_item: T, data: string | null})
function TableTd({ item, key, row_item, data } : {item: THeader, key: number, row_item: any, data: string | null})
{
var val_complete: JSX.Element = <></>;
if(item.visible === undefined || item.visible === true)
@ -88,15 +90,14 @@ export default function SortableTable<T>({ headers, dataTbl }:
}
function TableTr(
{headers, key, row_item}:
{headers, row_item}:
{
headers: THeader[],
key: number,
row_item: T
row_item: any
})
{
return(
<tr key={key}>
<tr key={row_item.key}>
{
headers.map((h_item, key) =>
{
@ -114,13 +115,41 @@ export default function SortableTable<T>({ headers, dataTbl }:
return val_complete;
}
function tableBody(headers: THeader[], tableDataSorted : T[])
function tableBody(headers: THeader[], tableDataSorted : any)
{
var body: JSX.Element[] = [];
const helpArr = tableDataSorted.toArray();
// body.push(
// <tr key='1'>
// <td key='1_1'>1_</td>
// <td key='1_2'>1_</td>
// <td key='1_3'>1_</td>
// <td key='1_4'>1_</td>
// <td key='1_5'>1_</td>
// <td key='1_6'>1_</td>
// </tr>);
// body.push(
// <tr key='2'>
// <td key='2_1'>2_</td>
// <td key='2_2'>2_</td>
// <td key='2_3'>2_</td>
// <td key='2_4'>2_</td>
// <td key='2_5'>2_</td>
// <td key='2_6'>2_</td>
// </tr>);
// body.push(
// <tr key='3'>
// <td key='3_1'>3_</td>
// <td key='3_2'>3_</td>
// <td key='3_3'>3_</td>
// <td key='3_4'>3_</td>
// <td key='3_5'>3_</td>
// <td key='3_6'>3_</td>
// </tr>);
for(var flight of tableDataSorted)
{
var index: number = tableDataSorted.indexOf(flight);
var index: number = flight.key;
body.push(
<TableTr headers={headers} key={index} row_item = {flight} />
);
@ -138,8 +167,9 @@ export default function SortableTable<T>({ headers, dataTbl }:
{
return(
headers.map(
(row) =>
(row, key) =>
{
var a = key;
if(row.visible === undefined || row.visible === true)
{
return (

View File

@ -1,107 +0,0 @@
export interface IFlights {
success: boolean;
message: string;
meta: Meta;
data?: (IFlight)[] | null;
}
export interface Meta {
totalCount: number;
}
export interface IFlight {
IDFlight: string;
FKGliderCategory: string;
Category: string;
FKCompetitionClass: string;
FKCompetitionClassDesired?: null;
CompetitionClass: string;
FKLaunchtype: string;
Launchtype: string;
FKPilot: string;
FirstName: string;
LastName: string;
Nationality: string;
FKFederation?: string | null;
ClubID?: string | null;
ClubName?: string | null;
Glider: string;
FKGlider?: string | null;
FKGliderBrand?: string | null;
GliderBrand?: string | null;
FKGliderClassification: string;
GliderClassification: string;
FKSeason: string;
FlightDate: string;
UtcOffset: string;
FlightStartTime: string;
FlightEndTime: string;
FlightDuration: string;
FirstLat: string;
FirstLng: string;
LastLat: string;
LastLng: string;
FlightMinLat: string;
FlightMaxLat: string;
FlightMinLng: string;
FlightMaxLng: string;
TakeoffCountry: string;
FKTakeoffWaypoint: string;
TakeoffWaypointOffset: string;
TakeoffLocation?: string | null;
TakeoffWaypointName: string;
FKClosestWaypoint?: string | null;
ClosestWaypointOffset?: string | null;
LandingCountry: string;
FKLandingWaypoint?: string | null;
LandingWaypointOffset?: string | null;
LandingWaypointName?: string | null;
LandingLocation?: string | null;
LinearDistance: string;
MaxLinearDistance: string;
ArcDistance?: string | null;
FKBestTaskType: string;
BestTaskType: string;
BestTaskTypeKey: string;
BestTaskDistance: string;
BestTaskPoints: string;
BestTaskDuration: string;
MaxSpeed?: string | null;
GroundSpeed?: string | null;
BestTaskSpeed: string;
TakeoffAltitude: string;
MaxAltitude: string;
MinAltitude: string;
ElevationGain?: string | null;
MeanAltitudeDiff: string;
MaxClimb: string;
MinClimb: string;
Dataversion: string;
ValidBRecordsCount?: string | null;
AirspaceViolationLevel?: string | null;
UserReviewComment: string;
UserReviewStatus: string;
ReviewRequired: string;
ReviewReason: string;
ReviewStatus: string;
ReviewComment: string;
ReviewBy: string;
ReviewTime?: null;
CommentsEnabled: string;
CountComments: string;
HasPhotos: string;
IsBigSmileCandidate: string;
WxcCivlID?: string | null;
WxcNacStatus?: string | null;
WxcSync?: string | null;
WxcSyncTS?: string | null;
IgcFilename: string;
IgcFileHash: string;
GRecordStatus: string;
GValidationMessage: string;
IsNew: string;
CanRetract: string;
StatisticsValid: string;
UC?: string | null;
TC: string;
US: string;
TS: string;
}

4
src/interfaces/IKey.ts Normal file
View File

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

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2015",
"target": "ES5",
"lib": [
"dom",
"dom.iterable",
@ -18,7 +18,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"downlevelIteration": true
},
"include": [
"src",