Base
This commit is contained in:
@@ -9,11 +9,7 @@ import {
|
||||
} from './constants';
|
||||
import { WASMDataF, WASMDataPax } from './types/WASMData';
|
||||
|
||||
interface IAppProps {
|
||||
commBus: ViewListener.ViewListener;
|
||||
}
|
||||
|
||||
const App: FC<IAppProps> = ({ commBus }) => {
|
||||
const App: FC = () => {
|
||||
const [SBUsername, setSBUsername] = useState<string>();
|
||||
const [WASMData, setWASMData] = useState<WASMDataPax | WASMDataF>();
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
@@ -29,6 +25,8 @@ const App: FC<IAppProps> = ({ commBus }) => {
|
||||
useEffect(() => {
|
||||
console.log('Initializing CommBus');
|
||||
|
||||
const commBus = RegisterViewListener('JS_LISTENER_COMM_BUS');
|
||||
|
||||
commBus.on(TFDI_SIMBRIEF_USERNAME_EVENT, usernameCallback);
|
||||
commBus.on(COMM_BUS_LIVE_DATA_EVENT, wasmCallback);
|
||||
|
||||
@@ -39,6 +37,8 @@ const App: FC<IAppProps> = ({ commBus }) => {
|
||||
return () => {
|
||||
commBus.off(TFDI_SIMBRIEF_USERNAME_EVENT, usernameCallback);
|
||||
commBus.off(COMM_BUS_LIVE_DATA_EVENT, wasmCallback);
|
||||
|
||||
commBus.unregister();
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { WASMDataF } from '../../types/WASMData';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlan } from '../../utils/TFDISBImport';
|
||||
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
|
||||
import { CoherentCallSBEntryF, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
@@ -59,7 +59,7 @@ const SBEntryF: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoadi
|
||||
const handleSB = async () => {
|
||||
setSBInFlight(true);
|
||||
|
||||
const SBResponse = await ImportFlightPlan(
|
||||
const SBResponse = await ImportFlightPlanKH(
|
||||
username,
|
||||
WASMData.limits.maxZFW,
|
||||
WASMData.limits.maxTOW,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react';
|
||||
import { GSX_SERVICE_CALLED, GSX_SERVICE_FINISHED } from '../../constants';
|
||||
import { WASMDataPax } from '../../types/WASMData';
|
||||
import { LoadingState, SimBrief } from '../../types/general';
|
||||
import { ImportFlightPlan } from '../../utils/TFDISBImport';
|
||||
import { ImportFlightPlanKH } from '../../utils/TFDISBImport';
|
||||
import { CoherentCallSBEntryPax, inRangeOf, loadAircraft, unloadAircraft } from '../../utils/utils';
|
||||
import CGSelect from '../CGSelect/CGSelect';
|
||||
import ActionBar from '../actionbar/ActionBar';
|
||||
@@ -59,7 +59,7 @@ const SBEntryPax: FC<SBEntryProps> = ({ WASMData, loadingState, username, setLoa
|
||||
const handleSB = async () => {
|
||||
setSBInFlight(true);
|
||||
|
||||
const SBResponse = await ImportFlightPlan(
|
||||
const SBResponse = await ImportFlightPlanKH(
|
||||
username,
|
||||
WASMData.limits.maxZFW,
|
||||
WASMData.limits.maxTOW,
|
||||
|
||||
@@ -3,8 +3,6 @@ import { createRoot } from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
class TFDiDesignMD11LoadManagerPanel extends TemplateElement {
|
||||
private commBus: ViewListener.ViewListener | undefined;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
@@ -12,20 +10,16 @@ class TFDiDesignMD11LoadManagerPanel extends TemplateElement {
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
|
||||
this.commBus = RegisterViewListener('JS_LISTENER_COMM_BUS');
|
||||
|
||||
const container = document.getElementById('react');
|
||||
if (container) {
|
||||
console.log('Starting React');
|
||||
const root = createRoot(container);
|
||||
root.render(createElement(App, { commBus: this.commBus }));
|
||||
root.render(createElement(App));
|
||||
}
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
|
||||
this.commBus?.unregister();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const getSimBriefFlightPlan = async (simBriefUsername: string) => {
|
||||
const getSimBriefFlightPlanKH = async (simBriefUsername: string) => {
|
||||
const flightPlanURL = `https://www.simbrief.com/api/xml.fetcher.php?username=${simBriefUsername}&json=1`;
|
||||
let response: Response;
|
||||
let success = false;
|
||||
@@ -15,14 +15,14 @@ const getSimBriefFlightPlan = async (simBriefUsername: string) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const ImportFlightPlan = async (
|
||||
export const ImportFlightPlanKH = async (
|
||||
username: string,
|
||||
maxZFW: number,
|
||||
maxTOW: number,
|
||||
maxFuel: number,
|
||||
isImperial: boolean
|
||||
) => {
|
||||
const flightPlan = await getSimBriefFlightPlan(username);
|
||||
const flightPlan = await getSimBriefFlightPlanKH(username);
|
||||
if (!flightPlan.success) {
|
||||
return {
|
||||
type: 'error',
|
||||
|
||||
Reference in New Issue
Block a user