diff --git a/frontend/react/src/constants/constants.ts b/frontend/react/src/constants/constants.ts index 7e6675c8..9e825a4a 100644 --- a/frontend/react/src/constants/constants.ts +++ b/frontend/react/src/constants/constants.ts @@ -419,7 +419,8 @@ export const MAP_OPTIONS_DEFAULTS: MapOptions = { hideChromeWarning: false, hideSecureWarning: false, showMissionDrawings: false, - clusterGroundUnits: true + clusterGroundUnits: true, + showUnitCallsigns: true, }; export const MAP_HIDDEN_TYPES_DEFAULTS = { diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index be7e2216..b42e33c3 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -787,7 +787,3 @@ export function secondsToTimeString(seconds: number) { return `${zeroPad(hours, 2)}:${zeroPad(minutes, 2)}:${zeroPad(secs, 2)}`; } - -export function isTrustedEnvironment() { - return window.location.protocol === "https:"; -} diff --git a/frontend/react/src/types/types.ts b/frontend/react/src/types/types.ts index 8a3f600b..97b714f4 100644 --- a/frontend/react/src/types/types.ts +++ b/frontend/react/src/types/types.ts @@ -32,6 +32,7 @@ export type MapOptions = { hideSecureWarning: boolean; showMissionDrawings: boolean; clusterGroundUnits: boolean; + showUnitCallsigns: boolean; }; export type MapHiddenTypes = { diff --git a/frontend/react/src/ui/panels/coordinatespanel.tsx b/frontend/react/src/ui/panels/coordinatespanel.tsx index 06489307..f4ffa0c0 100644 --- a/frontend/react/src/ui/panels/coordinatespanel.tsx +++ b/frontend/react/src/ui/panels/coordinatespanel.tsx @@ -3,7 +3,7 @@ import { OlLocation } from "../components/ollocation"; import { LatLng } from "leaflet"; import { FaBullseye, FaChevronDown, FaChevronUp, FaJetFighter, FaMountain, FaCopy, FaXmark } from "react-icons/fa6"; import { BullseyesDataChangedEvent, CoordinatesFreezeEvent, MouseMovedEvent, SelectedUnitsChangedEvent, SelectionClearedEvent } from "../../events"; -import { computeBearingRangeString, ConvertDDToDMS, DDToDDM, isTrustedEnvironment, latLngToMGRS, mToFt, zeroAppend } from "../../other/utils"; +import { computeBearingRangeString, ConvertDDToDMS, DDToDDM, latLngToMGRS, mToFt, zeroAppend } from "../../other/utils"; import { Bullseye } from "../../mission/bullseye"; import { Unit } from "../../unit/unit"; import { getApp } from "../../olympusapp"; @@ -50,7 +50,7 @@ export function CoordinatesPanel(props: {}) { break; } - returnString += ` Elevation: ${Math.round(elevation)}`; + returnString += ` Elevation: ${Math.round(elevation)}ft`; return returnString; }; @@ -152,15 +152,17 @@ export function CoordinatesPanel(props: {}) { className="ml-auto flex w-[50%]" onClick={async (evt) => { evt.stopPropagation(); - setCopyCoordsOpen(true); - - if (isTrustedEnvironment()) { + + if (isSecureContext && navigator.clipboard) { try { await navigator.clipboard.writeText(copyableCoordinates); getApp().addInfoMessage(`Coordinates copied to clipboard: ${copyableCoordinates}`); } catch (err) { + setCopyCoordsOpen(true); console.error('Failed to copy text: ', err); } + } else { + setCopyCoordsOpen(true); } }} > @@ -172,18 +174,21 @@ export function CoordinatesPanel(props: {}) { > -
Copy Coords
+
Copy last click
, open && copyCoordsOpen && (
evt.stopPropagation()} > - +
setCopyCoordsOpen(false)}> diff --git a/frontend/react/src/ui/panels/optionsmenu.tsx b/frontend/react/src/ui/panels/optionsmenu.tsx index e0b5a84b..5c441744 100644 --- a/frontend/react/src/ui/panels/optionsmenu.tsx +++ b/frontend/react/src/ui/panels/optionsmenu.tsx @@ -121,6 +121,17 @@ export function OptionsMenu(props: { open: boolean; onClose: () => void; childre {}}> Show unit labels
+
getApp().getMap().setOption("showUnitCallsigns", !mapOptions.showUnitCallsigns)} + > + {}}> + Show unit Mission Editor callsigns +
void; childre gap-4 rounded-md p-2 dark:hover:bg-olympus-400 `} - onClick={() => getApp().getMap().setOption("showUnitTargets", !mapOptions.showUnitTargets)} + onClick={() => getApp().getMap().setOption("showUnitContacts", !mapOptions.showUnitContacts)} > - {}}> + {}}> Show detection lines
element.querySelector(".unit-altitude")).innerText = "FL" + zeroAppend(Math.floor(mToFt(this.#position.alt as number) / 100), 3); + (element.querySelector(".unit-altitude") as HTMLElement).innerText = "FL" + zeroAppend(Math.floor(mToFt(this.#position.alt as number) / 100), 3); if (element.querySelector(".unit-speed")) - (element.querySelector(".unit-speed")).innerText = String(Math.floor(msToKnots(this.#speed))) + "GS"; + (element.querySelector(".unit-speed") as HTMLElement).innerText = String(Math.floor(msToKnots(this.#speed))) + "GS"; /* Rotate elements according to heading */ element.querySelectorAll("[data-rotate-to-heading]").forEach((el) => { @@ -1856,10 +1859,10 @@ export abstract class Unit extends CustomMarker { ?.toggleAttribute( "data-is-cluster-leader", this.#isClusterLeader && - this.#clusterUnits.length > 1 && - getApp().getMap().getOptions().clusterGroundUnits && - getApp().getMap().getZoom() < CLUSTERING_ZOOM_TRANSITION && - !this.getSelected() + this.#clusterUnits.length > 1 && + getApp().getMap().getOptions().clusterGroundUnits && + getApp().getMap().getZoom() < CLUSTERING_ZOOM_TRANSITION && + !this.getSelected() ); if (this.#isClusterLeader && this.#clusterUnits.length > 1) { const clusterEl = element.querySelector(".unit-cluster-id") as HTMLElement; @@ -2433,7 +2436,7 @@ export abstract class AirUnit extends Unit { showCallsign: belongsToCommandedCoalition && /*TODO !getApp().getMap().getOptions().AWACSMode || */ this.getHuman(), rotateToHeading: false, showCluster: false, - showAlarmState: false + showAlarmState: false, } as ObjectIconOptions; } @@ -2590,7 +2593,7 @@ export class NavyUnit extends Unit { showCallsign: belongsToCommandedCoalition && /*TODO !getApp().getMap().getOptions().AWACSMode || */ this.getHuman(), rotateToHeading: false, showCluster: false, - showAlarmState: true + showAlarmState: true, } as ObjectIconOptions; }