aus Iflight soll jetzt CFlightProxy werden

This commit is contained in:
2022-12-05 23:09:56 +01:00
parent dfaa6f6c4c
commit 9c3cae8350
5 changed files with 68 additions and 31 deletions

15
.vscode/launch.json vendored Normal file
View File

@ -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}"
}
]
}

View File

@ -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;

View File

@ -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 },

View File

@ -65,12 +65,12 @@ export default function SortableTable<T>({ 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<T>({ headers, dataTbl }:
}
else
{
val_complete = (<td>{data}</td>);
val_complete = (<td key={key}>{data}</td>);
}
}
return val_complete;
}
function TableTr(
{headers,row_item}:
{headers, key, row_item}:
{
headers: THeader[],
key: number,
row_item: T
})
{
return(
<tr>
<tr key={key}>
{
headers.map((h_item) =>
headers.map((h_item, key) =>
{
var c: any = row_item; // workaround TS2322 TS7053
return ( <TableTd item={h_item} row_item={row_item} data={c[h_item.key]}></TableTd> );
return ( <TableTd item={h_item} key={key} row_item={row_item} data={c[h_item.key]}></TableTd> );
})}
</tr>
);
}
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(
<TableTr headers={headers} key={index} row_item = {flight} />
);
}
return(
<tbody>
{body}
</tbody>
);
}
function tableHeader(headers: THeader[])
{
@ -144,14 +171,9 @@ export default function SortableTable<T>({ headers, dataTbl }:
{tableHeader(headers)}
</tr>
</thead>
<tbody>
{sortedData.map((row_item) => {
return (
<TableTr headers={headers} row_item = {row_item} />
);
})}
</tbody>
{
tableBody( headers, sortedData )
}
</table>
);
}

View File

@ -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",