From 5357f51bf269af88ad0d9ea17e5621bc0053f089 Mon Sep 17 00:00:00 2001
From: Peter Hoppe
Date: Tue, 6 Dec 2022 01:12:58 +0100
Subject: [PATCH] sicherung ggggg
---
src/App.tsx | 15 +++--
src/classes/CFlight.ts | 33 ++++++++++
src/classes/CSeason.ts | 6 +-
src/components/FlightsTable.tsx | 4 +-
src/components/SortableTable.tsx | 60 ++++++++++++-----
src/interfaces/IFlights.ts | 107 -------------------------------
src/interfaces/IKey.ts | 4 ++
tsconfig.json | 5 +-
8 files changed, 101 insertions(+), 133 deletions(-)
create mode 100644 src/classes/CFlight.ts
delete mode 100644 src/interfaces/IFlights.ts
create mode 100644 src/interfaces/IKey.ts
diff --git a/src/App.tsx b/src/App.tsx
index 16edb04..51701ea 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -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));
}
diff --git a/src/classes/CFlight.ts b/src/classes/CFlight.ts
new file mode 100644
index 0000000..99f849c
--- /dev/null
+++ b/src/classes/CFlight.ts
@@ -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;
+ }
+}
diff --git a/src/classes/CSeason.ts b/src/classes/CSeason.ts
index e0892b7..56434c1 100644
--- a/src/classes/CSeason.ts
+++ b/src/classes/CSeason.ts
@@ -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;
diff --git a/src/components/FlightsTable.tsx b/src/components/FlightsTable.tsx
index eba7554..4ffc940 100644
--- a/src/components/FlightsTable.tsx
+++ b/src/components/FlightsTable.tsx
@@ -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(
- headers={headers} dataTbl={flightdata} >
+ headers={headers} dataTbl={flightdata} >
);
}
diff --git a/src/components/SortableTable.tsx b/src/components/SortableTable.tsx
index 3cf866d..3d5e7c8 100644
--- a/src/components/SortableTable.tsx
+++ b/src/components/SortableTable.tsx
@@ -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({ headers, dataTbl }:
- { headers: THeader[], dataTbl: T[]})
+export default function SortableTable({ headers, dataTbl }:
+ { headers: THeader[], dataTbl: any })
{
const [sortKey, setSortKey] = useState(headers[0].key);
const [sortOrder, setSortOrder] = useState("ascn");
- const sortedData: T[] = sortData(
+ var sortedData: any = sortData(
{
tableData: dataTbl,
sortKey: sortKey,
@@ -57,7 +58,7 @@ export default function SortableTable({ headers, dataTbl }:
sortKey,
reverse,
}: {
- tableData: T[];
+ tableData: any;
sortKey: string;
reverse: boolean;
})
@@ -65,12 +66,13 @@ export default function SortableTable({ 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({ headers, dataTbl }:
}
function TableTr(
- {headers, key, row_item}:
+ {headers, row_item}:
{
headers: THeader[],
- key: number,
- row_item: T
+ row_item: any
})
{
return(
-
+
{
headers.map((h_item, key) =>
{
@@ -114,13 +115,41 @@ export default function SortableTable({ 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(
+ //
+ // | 1_ |
+ // 1_ |
+ // 1_ |
+ // 1_ |
+ // 1_ |
+ // 1_ |
+ //
);
+ // body.push(
+ //
+ // | 2_ |
+ // 2_ |
+ // 2_ |
+ // 2_ |
+ // 2_ |
+ // 2_ |
+ //
);
+ // body.push(
+ //
+ // | 3_ |
+ // 3_ |
+ // 3_ |
+ // 3_ |
+ // 3_ |
+ // 3_ |
+ //
);
+
for(var flight of tableDataSorted)
{
- var index: number = tableDataSorted.indexOf(flight);
+ var index: number = flight.key;
body.push(
);
@@ -138,8 +167,9 @@ export default function SortableTable({ headers, dataTbl }:
{
return(
headers.map(
- (row) =>
+ (row, key) =>
{
+ var a = key;
if(row.visible === undefined || row.visible === true)
{
return (
diff --git a/src/interfaces/IFlights.ts b/src/interfaces/IFlights.ts
deleted file mode 100644
index 7dbc6e4..0000000
--- a/src/interfaces/IFlights.ts
+++ /dev/null
@@ -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;
-}
\ No newline at end of file
diff --git a/src/interfaces/IKey.ts b/src/interfaces/IKey.ts
new file mode 100644
index 0000000..95418d1
--- /dev/null
+++ b/src/interfaces/IKey.ts
@@ -0,0 +1,4 @@
+export interface IKey
+{
+ key: number;
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index b2fe78f..41473fd 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -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",