-
Notifications
You must be signed in to change notification settings - Fork 13
Alpha 0.1.9/518 add altitude warnings #585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bensgilbert
merged 18 commits into
release-alpha-0.1.10
from
alpha-0.1.9/518-add-altitude-warnings
Jun 22, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ad9f00f
Added kush's stuff
NexInfinite 5a1fb51
Fixing kush's branch (#539)
NexInfinite 1b5dd00
Alpha 0.1.9/523 new missions page (#545)
Kwash67 306382b
542 show error stack on error boundary (#543)
NexInfinite 9ea2523
Alpha 0.1.9/517 popout camera feed from dashboard (#541)
Jopat2409 eaa131f
Fix socket connection state not updating
1Blademaster 8ae6dbc
Merge branch 'release-alpha-0.1.9' of https://github.com/project-Falc…
NexInfinite d28fa2c
changed tab message (#549)
bensgilbert d03f4a3
Alpha 0.1.9/544 Support for displaying multiple batteries (#555)
bensgilbert b6389b7
Alpha 0.1.9/551 update mission centre to center on full mission (#552)
Kwash67 248f610
alert system
bensgilbert e7acea7
added descriptions to settings + new extendableNumber setting
bensgilbert 85a7efc
altitude alert system
bensgilbert 183370d
formatting
bensgilbert cd71148
slight style change for new alert button
bensgilbert 692cc5f
Merge remote-tracking branch 'origin/release-alpha-0.1.10' into alpha…
bensgilbert 5ff7d64
update alert settings location
bensgilbert 0e8f8b2
minor improvements
bensgilbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { Alert } from "@mantine/core" | ||
| import { IconAlertTriangle } from "@tabler/icons-react" | ||
| import { useMemo } from "react" | ||
| import { useAlerts } from "./alertProvider" | ||
|
|
||
| export const AlertCategory = { | ||
| Altitude: "Altitude", | ||
| Speed: "Speed", | ||
| } | ||
|
|
||
| export const AlertSeverity = { | ||
| Yellow: 1, | ||
| Orange: 2, | ||
| Red: 3, | ||
| } | ||
|
|
||
| const SeverityColor = { | ||
| [AlertSeverity.Yellow]: "yellow", | ||
| [AlertSeverity.Orange]: "orange", | ||
| [AlertSeverity.Red]: "red", | ||
| } | ||
|
|
||
| export default function AlertSection() { | ||
| const { alerts, dismissAlert } = useAlerts() | ||
|
|
||
| const sortedAlerts = useMemo(() => { | ||
| return alerts.toSorted((a1, a2) => a2.severity - a1.severity) | ||
| }, [alerts]) | ||
|
|
||
| return ( | ||
| <div className="space-y-2 max-w-sm"> | ||
| {sortedAlerts.map((alert) => ( | ||
| <div | ||
| className="bg-falcongrey-900/90" | ||
| key={alert.category} | ||
| style={{ borderRadius: "var(--mantine-radius-default)" }} | ||
| > | ||
| <Alert | ||
| variant="outline" | ||
| color={SeverityColor[alert.severity]} | ||
| withCloseButton | ||
| title={alert.category} | ||
| icon={<IconAlertTriangle />} | ||
| onClose={() => dismissAlert(alert.category, true)} | ||
| > | ||
| {alert.jsx} | ||
| </Alert> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* Alert | ||
| * { | ||
| * category: AlertCategory, | ||
| * severity: AlertSeverity, | ||
| * jsx: <></> | ||
| * } | ||
| */ | ||
|
|
||
| import { createContext, useContext, useRef, useState } from "react" | ||
|
|
||
| const AlertContext = createContext() | ||
|
|
||
| export default function AlertProvider({ children }) { | ||
| const [alerts, setAlerts] = useState([]) | ||
| const dismissedAlerts = useRef(new Map()) | ||
|
|
||
| function dispatchAlert(alert) { | ||
| if (dismissedAlerts.current.get(alert.category) >= alert.severity) return | ||
| dismissedAlerts.current.delete(alert.category) | ||
|
|
||
| const existingAlertIndex = alerts.findIndex( | ||
|
bensgilbert marked this conversation as resolved.
|
||
| (existingAlert) => existingAlert.category == alert.category, | ||
| ) | ||
| if (existingAlertIndex >= 0) { | ||
| alerts[existingAlertIndex] = alert | ||
| setAlerts([...alerts]) | ||
| } else { | ||
| setAlerts([...alerts, alert]) | ||
| } | ||
| } | ||
|
|
||
| function dismissAlert(category, manual) { | ||
| setAlerts((prevAlerts) => { | ||
| const alert = prevAlerts.find((a) => a.category === category) | ||
|
|
||
| if (manual) { | ||
| dismissedAlerts.current.set(category, alert.severity) | ||
| } else { | ||
| dismissedAlerts.current.delete(category) | ||
| } | ||
|
|
||
| return prevAlerts.filter((a) => a.category !== category) | ||
| }) | ||
| } | ||
|
|
||
| return ( | ||
| <AlertContext.Provider value={{ alerts, dispatchAlert, dismissAlert }}> | ||
| {children} | ||
| </AlertContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export const useAlerts = () => useContext(AlertContext) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| The missions screen. | ||
| The missions screen. | ||
| */ | ||
|
|
||
| // Base imports | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.