Skip to content

Commit

Permalink
feat(efb): troubleshooting page
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz committed Jan 11, 2025
1 parent c2cc995 commit b6b02ae
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
1. [A380X/ND] Remove leading zeros from terrain elevation display - @BravoMike99 (bruno_pt99)
1. [A32NX/FWS] Fix autopilot instinctive disconnect button logic for 3D model - @flogross89 (floridude)
1. [A380X/EFIS] Fix VV pb indicator not turning on when TRK-FPA mode is selected - @heclak (Heclak)
1. [EFB] Added troubleshooting page, under about page, for advanced support - @tracernz (Mike)

## 0.12.0

Expand Down
31 changes: 17 additions & 14 deletions fbw-common/src/systems/instruments/src/EFB/Efb.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 FlyByWire Simulations
// Copyright (c) 2023-2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import React, { useContext, useEffect, useState } from 'react';
Expand Down Expand Up @@ -54,15 +54,16 @@ import { setFlightPlanProgress } from './Store/features/flightProgress';
import { Checklists, setAutomaticItemStates } from './Checklists/Checklists';
import { setAircraftChecklists, addTrackingChecklists } from './Store/features/checklists';
import { FlyPadPage } from './Settings/Pages/FlyPadPage';
import { NavigraphAuthProvider } from '../react/navigraph';
import { EventBus } from '@microsoft/msfs-sdk';
import { TroubleshootingContextProvider } from './TroubleshootingContext';

// './Assets/Efb.scss' is imported by the aircraft EFB instrument the wraps this file
import './Assets/Theme.css';
import './Assets/Slider.scss';

import 'react-toastify/dist/ReactToastify.css';
import './toast.css';
import { NavigraphAuthProvider } from '../react/navigraph';
import { EventBus } from '@microsoft/msfs-sdk';

export interface EfbWrapperProps {
failures: FailureDefinition[]; // TODO: Move failure definition into VFS
Expand Down Expand Up @@ -523,16 +524,18 @@ export const EfbInstrument: React.FC<EfbInstrumentProps> = ({ failures, aircraft
const [err, setErr] = useState(false);

return (
<FailuresOrchestratorProvider failures={failures}>
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => setErr(false)} resetKeys={[err]}>
<Router>
<ModalProvider>
<EventBusContextProvider eventBus={eventBus}>
<Efb aircraftChecklistsProp={aircraftChecklists} />
</EventBusContextProvider>
</ModalProvider>
</Router>
</ErrorBoundary>
</FailuresOrchestratorProvider>
<TroubleshootingContextProvider eventBus={eventBus}>
<FailuresOrchestratorProvider failures={failures}>
<ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => setErr(false)} resetKeys={[err]}>
<Router>
<ModalProvider>
<EventBusContextProvider eventBus={eventBus}>
<Efb aircraftChecklistsProp={aircraftChecklists} />
</EventBusContextProvider>
</ModalProvider>
</Router>
</ErrorBoundary>
</FailuresOrchestratorProvider>
</TroubleshootingContextProvider>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@
"ThrottleConfigurationReset": "Throttle Configuration Reset"
},
"Title": "Settings",
"Troubleshooting": {
"Title": "Troubleshooting"
},
"Unrealistic": "Unrealistic",
"flyPad": {
"AutoBrightness": "Auto Brightness",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023-2024 FlyByWire Simulations
// Copyright (c) 2023-2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import React, { useEffect, useState } from 'react';
Expand All @@ -11,11 +11,15 @@ import {
SENTRY_CONSENT_KEY,
useSimVar,
} from '@flybywiresim/fbw-sdk';
import { t } from '@flybywiresim/flypad';
import { PageLink, pathify, t, TabRoutes, useEventBus } from '@flybywiresim/flypad';
import { SettingsPage } from '../Settings';
// @ts-ignore
import FbwTail from '../../Assets/FBW-Tail.svg';
import { useViewListenerEvent } from '../../Utils/listener';
import { Link, Route, Switch } from 'react-router-dom';
import { TroubleshootingPage } from 'instruments/src/EFB/Settings/Pages/TroubleshootingPage';

const baseAboutRoute = `/settings/${pathify('About')}`;

interface BuildInfoEntryProps {
title: string;
Expand Down Expand Up @@ -59,6 +63,10 @@ export const AboutPage = () => {
const [version, setVersion] = useSessionStorage('SIM_VERSION', '');
const [sentryEnabled] = usePersistentProperty(SENTRY_CONSENT_KEY, SentryConsentState.Refused);

const subTabs: PageLink[] = [
{ alias: t('Settings.Troubleshooting.Title'), name: 'Troubleshooting', component: <TroubleshootingPage /> },
];

// Callback function to set sBuildVersion from the community panel
const onSetPlayerData = (data: CommunityPanelPlayerData) => {
setVersion(data.sBuildVersion);
Expand All @@ -71,44 +79,61 @@ export const AboutPage = () => {
AircraftGithubVersionChecker.getBuildInfo(process.env.AIRCRAFT_PROJECT_PREFIX).then((info) => setBuildInfo(info));
}, [process.env.AIRCRAFT_PROJECT_PREFIX]);

useEventBus().pub('troubleshooting_log_error', 'Rendered troubleshooting page!', true, false);

return (
<SettingsPage name={t('Settings.About.Title')}>
<div className="pointer-events-none absolute inset-y-0 flex flex-col justify-center px-16">
<div className="flex flex-row items-center">
<div className="flex flex-col">
<Switch>
<Route exact path={baseAboutRoute}>
<SettingsPage name={t('Settings.About.Title')}>
<div className="absolute inset-y-0 flex flex-col justify-center px-16">
<div className="flex flex-row items-center">
<img className="w-[36px]" src={FbwTail} alt="" />
<h1 className="font-manrope ml-4 text-4xl font-bold">flyPadOS 3</h1>
<div className="flex flex-col">
<div className="flex flex-row items-center">
<img className="w-[36px]" src={FbwTail} alt="" />
<h1 className="font-manrope ml-4 text-4xl font-bold">flyPadOS 3</h1>
</div>

<p className="mt-3 text-2xl">
Made with love by contributors in Québec, Germany, the United States, Singapore, Indonesia, New
Zealand, Australia, Spain, the United Kingdom, France, the Netherlands, Sweden, and Switzerland!
</p>
</div>
</div>
<div className="mt-8 flex flex-col justify-center">
<p>&copy; 2020-2024 FlyByWire Simulations and its contributors, all rights reserved.</p>
<p>Licensed under the GNU General Public License Version 3</p>
</div>

<p className="mt-3 text-2xl">
Made with love by contributors in Québec, Germany, the United States, Singapore, Indonesia, New Zealand,
Australia, Spain, the United Kingdom, France, the Netherlands, Sweden, and Switzerland!
</p>
</div>
</div>
<div className="mt-8 flex flex-col justify-center">
<p>&copy; 2020-2024 FlyByWire Simulations and its contributors, all rights reserved.</p>
<p>Licensed under the GNU General Public License Version 3</p>
</div>

<div className="mt-16">
<h1 className="font-bold">Build Info</h1>
<div className="mt-4">
<BuildInfoEntry title="Sim Version" value={version} />
<BuildInfoEntry title="Aircraft Version" value={buildInfo?.version} />
<BuildInfoEntry title="Livery Title" value={title} />
<BuildInfoEntry title="Built" value={buildInfo?.built} />
<BuildInfoEntry title="Ref" value={buildInfo?.ref} />
<BuildInfoEntry title="SHA" value={buildInfo?.sha} underline={7} />
<BuildInfoEntry title="Event Name" value={buildInfo?.eventName} />
<BuildInfoEntry title="Pretty Release Name" value={buildInfo?.prettyReleaseName} />
{sentryEnabled === SentryConsentState.Given && (
<BuildInfoEntry title="Sentry Session ID" value={sessionId} />
)}
<div className="mt-16">
<h1 className="font-bold">Build Info</h1>
<div className="mt-4">
<BuildInfoEntry title="Sim Version" value={version} />
<BuildInfoEntry title="Aircraft Version" value={buildInfo?.version} />
<BuildInfoEntry title="Livery Title" value={title} />
<BuildInfoEntry title="Built" value={buildInfo?.built} />
<BuildInfoEntry title="Ref" value={buildInfo?.ref} />
<BuildInfoEntry title="SHA" value={buildInfo?.sha} underline={7} />
<BuildInfoEntry title="Event Name" value={buildInfo?.eventName} />
<BuildInfoEntry title="Pretty Release Name" value={buildInfo?.prettyReleaseName} />
{sentryEnabled === SentryConsentState.Given && (
<BuildInfoEntry title="Sentry Session ID" value={sessionId} />
)}
</div>
</div>

<div className="mt-16">
<Link
to={`${baseAboutRoute}/${pathify('Troubleshooting')}`}
className="rounded-md border-2 border-theme-highlight bg-theme-highlight px-5
py-2.5 text-theme-body transition duration-100 hover:bg-theme-body hover:text-theme-highlight"
>
{t('Settings.Troubleshooting.Title')}
</Link>
</div>
</div>
</div>
</div>
</SettingsPage>
</SettingsPage>
</Route>
<TabRoutes basePath={baseAboutRoute} tabs={subTabs} />
</Switch>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import React, { useEffect, useState } from 'react';
import { t } from '@flybywiresim/flypad';
import { SettingsPage } from '../Settings';
// @ts-ignore
import { useTroubleshooting } from '../../TroubleshootingContext';
import { AiracCycleFormatter, FacilityLoader } from '@microsoft/msfs-sdk';
import { AircraftGithubVersionChecker, BuildInfo } from 'shared/src';

// TODO merge navdata PR and use the proper function
function isMsfs2024() {
return (window.InputBar.MENU_BUTTON_A as any) === 'KEY_MENU_SR_VALID';
}

export const TroubleshootingPage = () => {
const errorLog = useTroubleshooting();
const [navDates, setNavDates] = useState('');
const [naviInstalled, setNaviInstalled] = useState(false);
const [buildInfo, setBuildInfo] = useState<BuildInfo | undefined>(undefined);

useEffect(() => {
fetch('/VFS/scenery/fs-base-jep/scenery/world/airaccycle.bgl', { method: 'HEAD' }).then((r) =>
setNaviInstalled(r.ok),
);

const formatter = AiracCycleFormatter.create('{eff({dd}{MON}{YY})}-{exp({dd}{MON}{YY})}({YYCC})');
setNavDates(formatter(FacilityLoader.getDatabaseCycles().current));

AircraftGithubVersionChecker.getBuildInfo(process.env.AIRCRAFT_PROJECT_PREFIX).then((info) => setBuildInfo(info));
}, []);

return (
<SettingsPage name={t('Settings.Troubleshooting.Title')}>
<pre className="w-full font-mono text-base">
Aircraft Version: {buildInfo?.version}
{'\n'}
MSFS2024: {isMsfs2024() ? 'True\n' : 'False\n'}
NavData Dates: {navDates + '\n'}
Navigraph NavData: {naviInstalled ? 'True\n' : 'False\n'}
{'\n'}
{errorLog.map((msg) => msg + '\n')}
</pre>
</SettingsPage>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2025 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { EventBus } from '@microsoft/msfs-sdk';
import React, { useContext, useState } from 'react';
import { TroubleshootingEvents } from 'shared/src/Troubleshooting';

const TroubleshootingContext = React.createContext<string[]>(undefined as any);

interface TroubleshootingContextProps {
eventBus: EventBus;
}

export const TroubleshootingContextProvider: React.FC<TroubleshootingContextProps> = ({ eventBus, children }) => {
const [errorLog, setErrorLog] = useState([] as string[]);

eventBus
.getSubscriber<TroubleshootingEvents>()
.on('troubleshooting_log_error')
.handle((err) => setErrorLog([`${new Date().toISOString()}: ${err}`, ...errorLog]));

return <TroubleshootingContext.Provider value={errorLog}>{children}</TroubleshootingContext.Provider>;
};

export const useTroubleshooting = () => useContext(TroubleshootingContext);

0 comments on commit b6b02ae

Please sign in to comment.