From 9c3cae8350eb611036492929d634ad0be197e8f8 Mon Sep 17 00:00:00 2001
From: Peter Hoppe
Date: Mon, 5 Dec 2022 23:09:56 +0100
Subject: [PATCH] aus Iflight soll jetzt CFlightProxy werden
---
.vscode/launch.json | 15 +++++++++
defs/IFlights.ts | 20 ++++++------
src/components/FlightsTable.tsx | 4 +--
src/components/SortableTable.tsx | 56 ++++++++++++++++++++++----------
tsconfig.json | 4 +--
5 files changed, 68 insertions(+), 31 deletions(-)
create mode 100644 .vscode/launch.json
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..b3da308
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ // Verwendet IntelliSense zum Ermitteln möglicher Attribute.
+ // Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
+ // Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "chrome",
+ "request": "launch",
+ "name": "Launch Chrome against localhost",
+ "url": "http://localhost:3000",
+ "webRoot": "${workspaceFolder}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/defs/IFlights.ts b/defs/IFlights.ts
index 9f294c4..be089fc 100644
--- a/defs/IFlights.ts
+++ b/defs/IFlights.ts
@@ -113,15 +113,15 @@ export interface IFlights {
// Stores the currently-being-typechecked object for error messages.
let obj: any = null;
-export class IFlightsProxy {
+export class CFlightsProxy {
public readonly success: boolean;
public readonly message: string;
public readonly meta: MetaProxy;
public readonly data: IFlightProxy[] | null;
- public static Parse(d: string): IFlightsProxy {
- return IFlightsProxy.Create(JSON.parse(d));
+ public static Parse(d: string): CFlightsProxy {
+ return CFlightsProxy.Create(JSON.parse(d));
}
- public static Create(d: any, field: string = 'root'): IFlightsProxy {
+ public static Create(d: any, field: string = 'root'): CFlightsProxy {
if (!field) {
obj = d;
field = "root";
@@ -139,13 +139,13 @@ export class IFlightsProxy {
checkArray(d.data, field + ".data");
if (d.data) {
for (let i = 0; i < d.data.length; i++) {
- d.data[i] = IFlightProxy.Create(d.data[i], field + ".data" + "[" + i + "]");
+ d.data[i] = CFlightProxy.Create(d.data[i], field + ".data" + "[" + i + "]");
}
}
if (d.data === undefined) {
d.data = null;
}
- return new IFlightsProxy(d);
+ return new CFlightsProxy(d);
}
private constructor(d: any) {
this.success = d.success;
@@ -180,7 +180,7 @@ export class MetaProxy {
}
}
-export class IFlightProxy {
+export class CFlightProxy {
public readonly IDFlight: string;
public readonly FKGliderCategory: string;
public readonly Category: string;
@@ -277,8 +277,8 @@ export class IFlightProxy {
public readonly TC: string;
public readonly US: string;
public readonly TS: string;
- public static Parse(d: string): IFlightProxy {
- return IFlightProxy.Create(JSON.parse(d));
+ public static Parse(d: string): CFlightProxy {
+ return CFlightProxy.Create(JSON.parse(d));
}
public static Create(d: any, field: string = 'root'): IFlightProxy {
if (!field) {
@@ -466,7 +466,7 @@ export class IFlightProxy {
checkString(d.TC, false, field + ".TC");
checkString(d.US, false, field + ".US");
checkString(d.TS, false, field + ".TS");
- return new IFlightProxy(d);
+ return new CFlightProxy(d);
}
private constructor(d: any) {
this.IDFlight = d.IDFlight;
diff --git a/src/components/FlightsTable.tsx b/src/components/FlightsTable.tsx
index 4e5eced..eba7554 100644
--- a/src/components/FlightsTable.tsx
+++ b/src/components/FlightsTable.tsx
@@ -21,8 +21,8 @@ function Meter2Km(key: string, row: any, data: string | null)
return val;
}
-export default function FlightsTable(flightdata: IFlight[])
-//export default function FlightsTable(flightdata: any)
+//export default function FlightsTable(flightdata: IFlight[])
+export default function FlightsTable(flightdata: any)
{
const headers: THeader[] = [
{ key: "IDFlight", label: "ID", visible: false },
diff --git a/src/components/SortableTable.tsx b/src/components/SortableTable.tsx
index 5762b26..3cf866d 100644
--- a/src/components/SortableTable.tsx
+++ b/src/components/SortableTable.tsx
@@ -65,12 +65,12 @@ export default function SortableTable({ headers, dataTbl }:
if (!sortKey) return tableData;
const order = reverse ? 'asc': 'desc';
-// const reval: T[] = orderBy(tableData, [sortKey], [order]);
- const reval: T[] = tableData;
+ //const reval: any = orderBy(tableData, [sortKey], [order]);
+ const reval: any[] = tableData;
return reval;
}
- function TableTd({ item, row_item, data } : {item: THeader, row_item: T, data: string | null})
+ function TableTd({ item, key, row_item, data } : {item: THeader, key: number, row_item: T, data: string | null})
{
var val_complete: JSX.Element = <>>;
if(item.visible === undefined || item.visible === true)
@@ -81,31 +81,58 @@ export default function SortableTable({ headers, dataTbl }:
}
else
{
- val_complete = ({data} | );
+ val_complete = ({data} | );
}
}
return val_complete;
}
function TableTr(
- {headers,row_item}:
+ {headers, key, row_item}:
{
headers: THeader[],
+ key: number,
row_item: T
})
{
return(
-
+
{
- headers.map((h_item) =>
+ headers.map((h_item, key) =>
{
var c: any = row_item; // workaround TS2322 TS7053
- return ( );
+ return ( );
})}
);
}
-
+
+ function dummy()
+ {
+ var val_complete: JSX.Element = <>>;
+ var a = 2+2;
+ return val_complete;
+ }
+
+ function tableBody(headers: THeader[], tableDataSorted : T[])
+ {
+ var body: JSX.Element[] = [];
+ const helpArr = tableDataSorted.toArray();
+ for(var flight of tableDataSorted)
+ {
+ var index: number = tableDataSorted.indexOf(flight);
+ body.push(
+
+ );
+
+ }
+
+ return(
+
+ {body}
+
+ );
+ }
function tableHeader(headers: THeader[])
{
@@ -144,14 +171,9 @@ export default function SortableTable({ headers, dataTbl }:
{tableHeader(headers)}
-
-
- {sortedData.map((row_item) => {
- return (
-
- );
- })}
-
+ {
+ tableBody( headers, sortedData )
+ }
);
}
diff --git a/tsconfig.json b/tsconfig.json
index 341e8ff..b2fe78f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "es7",
+ "target": "ES2015",
"lib": [
"dom",
"dom.iterable",
@@ -18,7 +18,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
- "jsx": "preserve"
+ "jsx": "react-jsx"
},
"include": [
"src",