From b6b02ae52c346a2cee25737e83b5befe1304f371 Mon Sep 17 00:00:00 2001 From: Michael Corcoran Date: Sat, 11 Jan 2025 23:00:58 +1300 Subject: [PATCH] feat(efb): troubleshooting page --- .github/CHANGELOG.md | 1 + .../src/systems/instruments/src/EFB/Efb.tsx | 31 +++--- .../src/EFB/Localization/data/en.json | 3 + .../src/EFB/Settings/Pages/AboutPage.tsx | 97 ++++++++++++------- .../Settings/Pages/TroubleshootingPage.tsx | 47 +++++++++ .../src/EFB/TroubleshootingContext.tsx | 25 +++++ 6 files changed, 154 insertions(+), 50 deletions(-) create mode 100644 fbw-common/src/systems/instruments/src/EFB/Settings/Pages/TroubleshootingPage.tsx create mode 100644 fbw-common/src/systems/instruments/src/EFB/TroubleshootingContext.tsx diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index c1009857cf2..50f04247069 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -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 diff --git a/fbw-common/src/systems/instruments/src/EFB/Efb.tsx b/fbw-common/src/systems/instruments/src/EFB/Efb.tsx index 6480b24342b..99884eef629 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Efb.tsx +++ b/fbw-common/src/systems/instruments/src/EFB/Efb.tsx @@ -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'; @@ -54,6 +54,9 @@ 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'; @@ -61,8 +64,6 @@ 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 @@ -523,16 +524,18 @@ export const EfbInstrument: React.FC = ({ failures, aircraft const [err, setErr] = useState(false); return ( - - setErr(false)} resetKeys={[err]}> - - - - - - - - - + + + setErr(false)} resetKeys={[err]}> + + + + + + + + + + ); }; diff --git a/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json b/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json index dc4e3590348..14b4edef027 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json +++ b/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json @@ -732,6 +732,9 @@ "ThrottleConfigurationReset": "Throttle Configuration Reset" }, "Title": "Settings", + "Troubleshooting": { + "Title": "Troubleshooting" + }, "Unrealistic": "Unrealistic", "flyPad": { "AutoBrightness": "Auto Brightness", diff --git a/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/AboutPage.tsx b/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/AboutPage.tsx index f0575801fed..9e9512bda34 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/AboutPage.tsx +++ b/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/AboutPage.tsx @@ -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'; @@ -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; @@ -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: }, + ]; + // Callback function to set sBuildVersion from the community panel const onSetPlayerData = (data: CommunityPanelPlayerData) => { setVersion(data.sBuildVersion); @@ -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 ( - -
-
-
+ + + +
- -

flyPadOS 3

+
+
+ +

flyPadOS 3

+
+ +

+ 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! +

+
+
+
+

© 2020-2024 FlyByWire Simulations and its contributors, all rights reserved.

+

Licensed under the GNU General Public License Version 3

-

- 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! -

-
-
-
-

© 2020-2024 FlyByWire Simulations and its contributors, all rights reserved.

-

Licensed under the GNU General Public License Version 3

-
- -
-

Build Info

-
- - - - - - - - - {sentryEnabled === SentryConsentState.Given && ( - - )} +
+

Build Info

+
+ + + + + + + + + {sentryEnabled === SentryConsentState.Given && ( + + )} +
+
+ +
+ + {t('Settings.Troubleshooting.Title')} + +
-
-
- + + + + ); }; diff --git a/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/TroubleshootingPage.tsx b/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/TroubleshootingPage.tsx new file mode 100644 index 00000000000..3fa0d0f04e0 --- /dev/null +++ b/fbw-common/src/systems/instruments/src/EFB/Settings/Pages/TroubleshootingPage.tsx @@ -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(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 ( + +
+        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')}
+      
+
+ ); +}; diff --git a/fbw-common/src/systems/instruments/src/EFB/TroubleshootingContext.tsx b/fbw-common/src/systems/instruments/src/EFB/TroubleshootingContext.tsx new file mode 100644 index 00000000000..23c6676fdc0 --- /dev/null +++ b/fbw-common/src/systems/instruments/src/EFB/TroubleshootingContext.tsx @@ -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(undefined as any); + +interface TroubleshootingContextProps { + eventBus: EventBus; +} + +export const TroubleshootingContextProvider: React.FC = ({ eventBus, children }) => { + const [errorLog, setErrorLog] = useState([] as string[]); + + eventBus + .getSubscriber() + .on('troubleshooting_log_error') + .handle((err) => setErrorLog([`${new Date().toISOString()}: ${err}`, ...errorLog])); + + return {children}; +}; + +export const useTroubleshooting = () => useContext(TroubleshootingContext);