diff --git a/src/interfaces.ts b/src/interfaces.ts index bee09a0c8..7f0ae61c3 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -193,7 +193,14 @@ export type SatPassTimes = { time: Date; }; -export type ToastMsgType = 'standby' | 'normal' | 'caution' | 'serious' | 'critical' | 'error'; +export enum ToastMsgType { + standby = 'standby', + normal = 'normal', + caution = 'caution', + serious = 'serious', + critical = 'critical', + error = 'error', +} export type GeolocationPosition = { coords: { diff --git a/src/plugins/analysis/analysis.ts b/src/plugins/analysis/analysis.ts index e0e622289..b8fd13b44 100644 --- a/src/plugins/analysis/analysis.ts +++ b/src/plugins/analysis/analysis.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents, lookanglesRow } from '@app/interfaces'; +import { KeepTrackApiEvents, lookanglesRow, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { clickAndDragWidth } from '@app/lib/click-and-drag'; import { getEl } from '@app/lib/get-el'; @@ -419,7 +419,7 @@ export class AnalysisMenu extends KeepTrackPlugin { // Check if there is a sensor if (sensors.length <= 0 || !sensors[0] || typeof sensors[0].minAz === 'undefined') { - keepTrackApi.getUiManager().toast('Sensor\'s format incorrect. Did you select a sensor first?', 'critical'); + keepTrackApi.getUiManager().toast('Sensor\'s format incorrect. Did you select a sensor first?', ToastMsgType.critical); return []; } @@ -664,7 +664,7 @@ export class AnalysisMenu extends KeepTrackPlugin { const sensorManagerInstance = keepTrackApi.getSensorManager(); if (!sensorManagerInstance.isSensorSelected()) { - keepTrackApi.getUiManager().toast('You must select a sensor first!', 'critical'); + keepTrackApi.getUiManager().toast('You must select a sensor first!', ToastMsgType.critical); } else { AnalysisMenu.findBestPasses(sats, sensorManagerInstance.getSensor()); } diff --git a/src/plugins/dops/dops.ts b/src/plugins/dops/dops.ts index eff457a53..c74a5dc82 100644 --- a/src/plugins/dops/dops.ts +++ b/src/plugins/dops/dops.ts @@ -3,7 +3,7 @@ import { getEl } from '@app/lib/get-el'; import { showLoading } from '@app/lib/showLoading'; import gpsPng from '@public/img/icons/gps.png'; -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import type { CatalogManager } from '@app/singletons/catalog-manager'; import type { GroupsManager } from '@app/singletons/groups-manager'; import { GroupType } from '@app/singletons/object-group'; @@ -112,7 +112,7 @@ export class DopsPlugin extends KeepTrackPlugin { keepTrackApi .getUiManager() - .toast(`HDOP: ${gpsDOP.hdop}
VDOP: ${gpsDOP.vdop}
PDOP: ${gpsDOP.pdop}
GDOP: ${gpsDOP.gdop}
TDOP: ${gpsDOP.tdop}`, 'normal', true); + .toast(`HDOP: ${gpsDOP.hdop}
VDOP: ${gpsDOP.vdop}
PDOP: ${gpsDOP.pdop}
GDOP: ${gpsDOP.gdop}
TDOP: ${gpsDOP.tdop}`, ToastMsgType.normal, true); } break; } diff --git a/src/plugins/edit-sat/edit-sat.ts b/src/plugins/edit-sat/edit-sat.ts index fe342bdf4..d3b083e89 100644 --- a/src/plugins/edit-sat/edit-sat.ts +++ b/src/plugins/edit-sat/edit-sat.ts @@ -1,4 +1,4 @@ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { showLoading } from '@app/lib/showLoading'; @@ -308,7 +308,7 @@ export class EditSat extends KeepTrackPlugin { orbitManagerInstance.changeOrbitBufferData(sat.id, object.tle1, object.tle2); sat.active = true; } else { - uiManagerInstance.toast('Failed to propagate satellite. Try different parameters or if you are confident they are correct report this issue.', 'caution', true); + uiManagerInstance.toast('Failed to propagate satellite. Try different parameters or if you are confident they are correct report this issue.', ToastMsgType.caution, true); } } @@ -370,7 +370,7 @@ export class EditSat extends KeepTrackPlugin { const upOrDown = SatMath.getDirection(mainsat, timeManagerInstance.simulationTimeObj); if (upOrDown === 'Error') { - uiManagerInstance.toast('Cannot calculate direction of satellite. Try again later.', 'caution'); + uiManagerInstance.toast('Cannot calculate direction of satellite. Try again later.', ToastMsgType.caution); } const simulationTimeObj = timeManagerInstance.simulationTimeObj; @@ -394,7 +394,7 @@ export class EditSat extends KeepTrackPlugin { const tle2 = TLEs[1]; if (tle1 === 'Error') { - uiManagerInstance.toast(`${tle2}`, 'critical', true); + uiManagerInstance.toast(`${tle2}`, ToastMsgType.critical, true); return; } @@ -409,9 +409,9 @@ export class EditSat extends KeepTrackPlugin { orbitManagerInstance.changeOrbitBufferData(id, tle1, tle2); /* - * + * * Reload Menu with new TLE - * + * */ const obj2 = this.selectSatManager_.getSelectedSat(GetSatType.EXTRA_ONLY); @@ -503,7 +503,7 @@ export class EditSat extends KeepTrackPlugin { sat.editTle(tle1, tle2); keepTrackApi.getMainCamera().zoomTarget = ZoomValue.GEO; } else { - keepTrackApi.getUiManager().toast('Failed to propagate satellite. Try different parameters or if you are confident they are correct report this issue.', 'caution', true); + keepTrackApi.getUiManager().toast('Failed to propagate satellite. Try different parameters or if you are confident they are correct report this issue.', ToastMsgType.caution, true); } } diff --git a/src/plugins/find-sat/find-sat.ts b/src/plugins/find-sat/find-sat.ts index aa28afa02..7ded88c3f 100644 --- a/src/plugins/find-sat/find-sat.ts +++ b/src/plugins/find-sat/find-sat.ts @@ -1,6 +1,6 @@ /* eslint-disable prefer-const */ /* eslint-disable complexity */ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { getEl } from '@app/lib/get-el'; import { getUnique } from '@app/lib/get-unique'; import { hideLoading, showLoading } from '@app/lib/showLoading'; @@ -111,7 +111,7 @@ export class FindSatPlugin extends KeepTrackPlugin { const uiManagerInstance = keepTrackApi.getUiManager(); if (possibles.length >= limit) { - uiManagerInstance.toast(`Too many results, limited to ${limit}`, 'serious'); + uiManagerInstance.toast(`Too many results, limited to ${limit}`, ToastMsgType.serious); } possibles = possibles.slice(0, limit); @@ -462,11 +462,11 @@ The search will then find all satellites within those inclinations and display t this.lastResults = FindSatPlugin.searchSats(searchParams as SearchSatParams); if (this.lastResults.length === 0) { - uiManagerInstance.toast('No Satellites Found', 'critical'); + uiManagerInstance.toast('No Satellites Found', ToastMsgType.critical); } } catch (e) { if (e.message === 'No Search Criteria Entered') { - uiManagerInstance.toast('No Search Criteria Entered', 'critical'); + uiManagerInstance.toast('No Search Criteria Entered', ToastMsgType.critical); } } } diff --git a/src/plugins/gamepad/gamepad.ts b/src/plugins/gamepad/gamepad.ts index d33d56a59..f7159e588 100644 --- a/src/plugins/gamepad/gamepad.ts +++ b/src/plugins/gamepad/gamepad.ts @@ -1,5 +1,5 @@ /* eslint-disable class-methods-use-this */ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { CameraType } from '@app/singletons/camera'; import { Radians } from 'ootk'; @@ -25,13 +25,13 @@ export class GamepadPlugin { } }); window.addEventListener('gamepaddisconnected', () => { - keepTrackApi.getUiManager().toast('Gamepad disconnected', 'critical'); + keepTrackApi.getUiManager().toast('Gamepad disconnected', ToastMsgType.critical); this.currentController = null; }); } initializeGamepad(gamepad: Gamepad): void { - keepTrackApi.getUiManager().toast('Gamepad connected', 'normal'); + keepTrackApi.getUiManager().toast('Gamepad connected', ToastMsgType.normal); // Only initialize once if (!this.currentController) { diff --git a/src/plugins/missile/missile.ts b/src/plugins/missile/missile.ts index 8bf0b5e8b..cbfc7d9be 100644 --- a/src/plugins/missile/missile.ts +++ b/src/plugins/missile/missile.ts @@ -1,6 +1,7 @@ /* eslint-disable complexity */ /* eslint-disable max-statements */ /* eslint-disable max-lines-per-function */ +import { ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { RADIUS_OF_EARTH } from '@app/lib/constants'; import { MissileObject } from '@app/singletons/catalog-manager/MissileObject'; @@ -501,7 +502,7 @@ export class Missile { BurnRate, WarheadMass, )) / - GoalDistance, + GoalDistance, ) * 100; if ( Missile.testTrajectory_( @@ -761,11 +762,11 @@ export class Missile { ThrustAngle = (90 - AngleCoefficient * - (1.5336118956 + - 0.00443173537387 * Altitude - - 9.30373890848 * 10 ** -8 * Altitude ** 2 + - 8.37838197732 * 10 ** -13 * Altitude ** 3 - - 2.71228576626 * 10 ** -18 * Altitude ** 4)) * + (1.5336118956 + + 0.00443173537387 * Altitude - + 9.30373890848 * 10 ** -8 * Altitude ** 2 + + 8.37838197732 * 10 ** -13 * Altitude ** 3 - + 2.71228576626 * 10 ** -18 * Altitude ** 4)) * 0.0174533; // (Degrees) } else { @@ -931,13 +932,13 @@ export class Missile { return null; } if (TargetLatitude > 90 || TargetLatitude < -90) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: Target Latitude must be
between 90 and -90 degrees'; return null; } if (TargetLongitude > 180 || TargetLongitude < -180) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: Target Longitude must be
between 90 and -90 degrees'; return null; @@ -960,14 +961,14 @@ export class Missile { const [EstLatList, EstLongList, , ArcLength, EstDistanceList, GoalDistance] = Missile.calcCoordinates_(CurrentLatitude, CurrentLongitude, TargetLatitude, TargetLongitude); if (ArcLength < 320000) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: This missile has a minimum distance of 320 km.'; return null; } if (ArcLength > MaxMissileRange * 1000) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = `Error: This missile has a maximum distance of ${MaxMissileRange} km.`; return null; @@ -1241,7 +1242,7 @@ export class Missile { } if (minAltitudeTrue === (minAltitude * 3) / 2) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: This distance is too close for the selected missile.'; return null; diff --git a/src/plugins/missile/missileManager.ts b/src/plugins/missile/missileManager.ts index fd1aebaf7..6dfcdae69 100644 --- a/src/plugins/missile/missileManager.ts +++ b/src/plugins/missile/missileManager.ts @@ -13,6 +13,7 @@ import { MissileObject } from '@app/singletons/catalog-manager/MissileObject'; import { CruncerMessageTypes } from '@app/webworker/positionCruncher'; import { DEG2RAD, EciVec3, Kilometers, MILLISECONDS_TO_DAYS, RAD2DEG, Sensor, Sgp4, SpaceObjectType, ecfRad2rae, eci2ecf, eci2lla } from 'ootk'; import { SatInfoBox } from '../select-sat-manager/sat-info-box'; +import { SettingsMenuPlugin } from '../settings-menu/settings-menu'; let BurnRate: number, EarthMass: number, EarthRadius: number, FuelDensity: number, G: number, R: number, WarheadMass: number, h: number; const missileArray: any[] = []; @@ -197,13 +198,13 @@ export const Missile = ( return 0; } if (TargetLatitude > 90 || TargetLatitude < -90) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: Target Latitude must be
between 90 and -90 degrees'; return 0; } if (TargetLongitude > 180 || TargetLongitude < -180) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: Target Longitude must be
between 90 and -90 degrees'; return 0; @@ -231,14 +232,14 @@ export const Missile = ( const [EstLatList, EstLongList, , ArcLength, EstDistanceList, GoalDistance] = calculateCoordinates_(CurrentLatitude, CurrentLongitude, TargetLatitude, TargetLongitude); if (ArcLength < 320000) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: This missile has a minimum distance of 320 km.'; return 0; } if (ArcLength > MaxMissileRange * 1000) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = `Error: This missile has a maximum distance of ${MaxMissileRange} km.`; return 0; @@ -499,7 +500,7 @@ export const Missile = ( } if (minAltitudeTrue === (minAltitude * 3) / 2) { - missileManager.lastMissileErrorType = 'critical'; + missileManager.lastMissileErrorType = ToastMsgType.critical; missileManager.lastMissileError = 'Error: This distance is too close for the selected missile.'; return 0; @@ -548,7 +549,7 @@ export const Missile = ( missileManager.missileArray = missileArray; } missileManager.missilesInUse++; - missileManager.lastMissileErrorType = 'normal'; + missileManager.lastMissileErrorType = ToastMsgType.normal; missileManager.lastMissileError = `Missile Named RV_${missileObj.id}
has been created.`; return 1; // Successful Launch @@ -674,17 +675,17 @@ export const getMissileTEARR = (missile: MissileObject, sensors?: Sensor[]) => { } } else if ( (currentTEARR.az >= sensor.minAz && - currentTEARR.az <= sensor.maxAz && - currentTEARR.el >= sensor.minEl && - currentTEARR.el <= sensor.maxEl && - currentTEARR.rng <= sensor.maxRng && - currentTEARR.rng >= sensor.minRng) || - (currentTEARR.az >= sensor.minAz2 && - currentTEARR.az <= sensor.maxAz2 && - currentTEARR.el >= sensor.minEl2 && - currentTEARR.el <= sensor.maxEl2 && - currentTEARR.rng <= sensor.maxRng2 && - currentTEARR.rng >= sensor.minRng2) + currentTEARR.az <= sensor.maxAz && + currentTEARR.el >= sensor.minEl && + currentTEARR.el <= sensor.maxEl && + currentTEARR.rng <= sensor.maxRng && + currentTEARR.rng >= sensor.minRng) || + (currentTEARR.az >= sensor.minAz2 && + currentTEARR.az <= sensor.maxAz2 && + currentTEARR.el >= sensor.minEl2 && + currentTEARR.el <= sensor.maxEl2 && + currentTEARR.rng <= sensor.maxRng2 && + currentTEARR.rng >= sensor.minRng2) ) { currentTEARR.inView = true; } else { @@ -1158,7 +1159,7 @@ export const getMissileTEARR = (missile: MissileObject, sensors?: Sensor[]) => { * if (ArcLength > MaxMissileRange * 1000) { * // console.debug('Error: This missile has a maximum distance of ' + MaxMissileRange + ' km.'); * // console.debug('Please choose different target coordinates.'); - * missileManager.lastMissileErrorType = 'critical'; + * missileManager.lastMissileErrorType = ToastMsgType.critical; * missileManager.lastMissileError = 'Error: This missile has a maximum distance of ' + MaxMissileRange + ' km.'; * return 0; * } @@ -1498,7 +1499,7 @@ export const getMissileTEARR = (missile: MissileObject, sensors?: Sensor[]) => { * console.log(AltitudeList); * console.log(`Required Altitude ${minAltitude}`); * if (MaxAltitude < minAltitude) { - * missileManager.lastMissileErrorType = 'critical'; + * missileManager.lastMissileErrorType = ToastMsgType.critical; * missileManager.lastMissileError = `Failed Min Altitude Check! Max Altitude ${MaxAltitude} km.`; * return -1; * } @@ -1656,14 +1657,14 @@ export const getMissileTEARR = (missile: MissileObject, sensors?: Sensor[]) => { * } * if (TargetLatitude > 90 || TargetLatitude < -90) { * // console.debug('Error: Target Latitude must be between 90 and -90 degrees'); - * missileManager.lastMissileErrorType = 'critical'; + * missileManager.lastMissileErrorType = ToastMsgType.critical; * missileManager.lastMissileError = 'Error: Target Latitude must be
between 90 and -90 degrees'; * return 0; * } * if (TargetLongitude > 180 || TargetLongitude < -180) { * // console.debug('Error: Target Longitude must be between 180 and -180 degrees'); * console.log(TargetLongitude); - * missileManager.lastMissileErrorType = 'critical'; + * missileManager.lastMissileErrorType = ToastMsgType.critical; * missileManager.lastMissileError = 'Error: Target Longitude must be
between 180 and -180 degrees'; * return 0; * } @@ -1712,7 +1713,7 @@ export const getMissileTEARR = (missile: MissileObject, sensors?: Sensor[]) => { * if (ArcLength > MaxMissileRange * 1000) { * // console.debug('Error: This missile has a maximum distance of ' + MaxMissileRange + ' km.'); * // console.debug('Please choose different target coordinates.'); - * missileManager.lastMissileErrorType = 'critical'; + * missileManager.lastMissileErrorType = ToastMsgType.critical; * missileManager.lastMissileError = 'Error: This missile has a maximum distance of ' + MaxMissileRange + ' km.'; * return 0; * } diff --git a/src/plugins/missile/missilePlugin.ts b/src/plugins/missile/missilePlugin.ts index 78b1bba49..76cf83659 100644 --- a/src/plugins/missile/missilePlugin.ts +++ b/src/plugins/missile/missilePlugin.ts @@ -1,6 +1,6 @@ /* eslint-disable new-cap */ /* eslint-disable max-statements */ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { clickAndDragWidth } from '@app/lib/click-and-drag'; import { getEl } from '@app/lib/get-el'; @@ -116,19 +116,19 @@ export const missileSubmit = (): void => { missileManager.MassRaidPre(launchTime, sim); } if (type !== 0) { - uiManagerInstance.toast(`${sim} Loaded`, 'standby', true); + uiManagerInstance.toast(`${sim} Loaded`, ToastMsgType.standby, true); } if (type === 0) { if (target === -1) { // Custom Target if (isNaN(tgtLat)) { - uiManagerInstance.toast('Invalid Target Latitude!', 'critical'); + uiManagerInstance.toast('Invalid Target Latitude!', ToastMsgType.critical); getEl('loading-screen').style.display = 'none'; return; } if (isNaN(tgtLon)) { - uiManagerInstance.toast('Invalid Target Longitude!', 'critical'); + uiManagerInstance.toast('Invalid Target Longitude!', ToastMsgType.critical); getEl('loading-screen').style.display = 'none'; return; @@ -141,13 +141,13 @@ export const missileSubmit = (): void => { if (isSub) { if (isNaN(lauLat)) { - uiManagerInstance.toast('Invalid Launch Latitude!', 'critical'); + uiManagerInstance.toast('Invalid Launch Latitude!', ToastMsgType.critical); getEl('loading-screen').style.display = 'none'; return; } if (isNaN(lauLon)) { - uiManagerInstance.toast('Invalid Launch Longitude!', 'critical'); + uiManagerInstance.toast('Invalid Launch Longitude!', ToastMsgType.critical); getEl('loading-screen').style.display = 'none'; return; diff --git a/src/plugins/new-launch/new-launch.ts b/src/plugins/new-launch/new-launch.ts index 3b6be52a5..1a63a97d5 100644 --- a/src/plugins/new-launch/new-launch.ts +++ b/src/plugins/new-launch/new-launch.ts @@ -1,4 +1,4 @@ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { hideLoading, showLoadingSticky } from '@app/lib/showLoading'; @@ -182,7 +182,7 @@ export class NewLaunch extends KeepTrackPlugin { /* * if (sat.inclination < launchLat) { - * uiManagerInstance.toast(`Satellite Inclination Lower than Launch Latitude!`, 'critical'); + * uiManagerInstance.toast(`Satellite Inclination Lower than Launch Latitude!`, ToastMsgType.critical); * return; * } * Set time to 0000z for relative time. @@ -210,11 +210,11 @@ export class NewLaunch extends KeepTrackPlugin { if (tle1 === 'Error' || tle1.length !== 69 || tle2.length !== 69) { if (tle1 === 'Error') { - uiManagerInstance.toast(`Failed to Create TLE: ${tle2}`, 'critical'); + uiManagerInstance.toast(`Failed to Create TLE: ${tle2}`, ToastMsgType.critical); } else if (tle1.length !== 69) { - uiManagerInstance.toast(`Invalid TLE1 Created: length is not 69 - ${tle1}`, 'critical'); + uiManagerInstance.toast(`Invalid TLE1 Created: length is not 69 - ${tle1}`, ToastMsgType.critical); } else if (tle2.length !== 69) { - uiManagerInstance.toast(`Invalid TLE2 Created: length is not 69 - ${tle2}`, 'critical'); + uiManagerInstance.toast(`Invalid TLE2 Created: length is not 69 - ${tle2}`, ToastMsgType.critical); } // We have to change the time for the TLE creation, but it failed, so revert it. @@ -225,7 +225,7 @@ export class NewLaunch extends KeepTrackPlugin { return; } - uiManagerInstance.toast('Time is now relative to launch time.', 'standby'); + uiManagerInstance.toast('Time is now relative to launch time.', ToastMsgType.standby); keepTrackApi.getSoundManager()?.play(SoundNames.LIFT_OFF); // Prevent caching of old TLEs @@ -254,7 +254,7 @@ export class NewLaunch extends KeepTrackPlugin { orbitManagerInstance.changeOrbitBufferData(id, tle1, tle2); } else { - uiManagerInstance.toast('Failed Altitude Test - Try a Different Satellite!', 'critical'); + uiManagerInstance.toast('Failed Altitude Test - Try a Different Satellite!', ToastMsgType.critical); } waitForCruncher({ @@ -263,14 +263,14 @@ export class NewLaunch extends KeepTrackPlugin { this.isDoingCalculations = false; hideLoading(); - uiManagerInstance.toast('Launch Nominal Created!', 'standby'); + uiManagerInstance.toast('Launch Nominal Created!', ToastMsgType.standby); uiManagerInstance.searchManager.doSearch(sat.sccNum); }, validationFunc: (data: any) => typeof data.satPos !== 'undefined', error: () => { this.isDoingCalculations = false; hideLoading(); - uiManagerInstance.toast('Cruncher failed to meet requirement after multiple tries! Is this launch even possible?', 'critical'); + uiManagerInstance.toast('Cruncher failed to meet requirement after multiple tries! Is this launch even possible?', ToastMsgType.critical); }, }); }; diff --git a/src/plugins/plot-analysis/ric-plots.ts b/src/plugins/plot-analysis/ric-plots.ts index dd23f603a..ee74e86e4 100644 --- a/src/plugins/plot-analysis/ric-plots.ts +++ b/src/plugins/plot-analysis/ric-plots.ts @@ -1,4 +1,4 @@ -import { EChartsData, KeepTrackApiEvents } from '@app/interfaces'; +import { EChartsData, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { SatMathApi } from '@app/singletons/sat-math-api'; @@ -27,12 +27,12 @@ export class RicPlot extends KeepTrackPlugin { isIconDisabledOnLoad = true; bottomIconCallback = () => { if (this.selectSatManager_.selectedSat === -1) { - keepTrackApi.getUiManager().toast('Select a Satellite First!', 'critical'); + keepTrackApi.getUiManager().toast('Select a Satellite First!', ToastMsgType.critical); return; } if (!this.selectSatManager_.secondarySatObj) { - keepTrackApi.getUiManager().toast('Select a Secondary Satellite First!', 'critical'); + keepTrackApi.getUiManager().toast('Select a Secondary Satellite First!', ToastMsgType.critical); return; } diff --git a/src/plugins/satellite-fov/satellite-fov.ts b/src/plugins/satellite-fov/satellite-fov.ts index 7bd094456..738973ef8 100644 --- a/src/plugins/satellite-fov/satellite-fov.ts +++ b/src/plugins/satellite-fov/satellite-fov.ts @@ -20,7 +20,7 @@ * ///////////////////////////////////////////////////////////////////////////// */ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import removePng from '@public/img/icons/remove.png'; @@ -274,35 +274,35 @@ export class SatelliteFov extends KeepTrackPlugin { const toast = keepTrackApi.getUiManager().toast.bind(keepTrackApi.getUiManager()); if (isNaN(fovAngle) || fovAngle <= 0 || fovAngle > 180) { - toast('Field of View must be a number between 0 and 180 degrees.', 'critical'); + toast('Field of View must be a number between 0 and 180 degrees.', ToastMsgType.critical); (getEl('sat-fov-default-fov-angle') as HTMLInputElement).value = '3'; return; } if (isNaN(red) || red < 0 || red > 1) { - toast('Red color value must be a number between 0 and 1.', 'critical'); + toast('Red color value must be a number between 0 and 1.', ToastMsgType.critical); (getEl('sat-fov-default-red') as HTMLInputElement).value = '0.5'; return; } if (isNaN(green) || green < 0 || green > 1) { - toast('Green color value must be a number between 0 and 1.', 'critical'); + toast('Green color value must be a number between 0 and 1.', ToastMsgType.critical); (getEl('sat-fov-default-green') as HTMLInputElement).value = '0.5'; return; } if (isNaN(blue) || blue < 0 || blue > 1) { - toast('Blue color value must be a number between 0 and 1.', 'critical'); + toast('Blue color value must be a number between 0 and 1.', ToastMsgType.critical); (getEl('sat-fov-default-blue') as HTMLInputElement).value = '0.5'; return; } if (isNaN(opacity) || opacity < 0 || opacity > 1) { - toast('Opacity value must be a number between 0 and 1.', 'critical'); + toast('Opacity value must be a number between 0 and 1.', ToastMsgType.critical); (getEl('sat-fov-default-opacity') as HTMLInputElement).value = '0.15'; return; diff --git a/src/plugins/satellite-photos/satellite-photos.ts b/src/plugins/satellite-photos/satellite-photos.ts index ac34df738..040dec7ac 100644 --- a/src/plugins/satellite-photos/satellite-photos.ts +++ b/src/plugins/satellite-photos/satellite-photos.ts @@ -2,7 +2,7 @@ import { openColorbox } from '@app/lib/colorbox'; import { getEl } from '@app/lib/get-el'; import { lat2pitch, lon2yaw } from '@app/lib/transforms'; -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { errorManagerInstance } from '@app/singletons/errorManager'; import photoManagerPng from '@public/img/icons/photoManager.png'; @@ -170,7 +170,7 @@ export class SatellitePhotos extends KeepTrackPlugin { } else { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast('Can\'t load pictures from the future. Loading most recent photos.', 'caution'); + uiManagerInstance.toast('Can\'t load pictures from the future. Loading most recent photos.', ToastMsgType.caution); propTime = new Date(Date.now() - 1000 * 60 * 30); } const year = propTime.getUTCFullYear(); diff --git a/src/plugins/satellite-view/satellite-view.ts b/src/plugins/satellite-view/satellite-view.ts index c1c1b4689..76add7b06 100644 --- a/src/plugins/satellite-view/satellite-view.ts +++ b/src/plugins/satellite-view/satellite-view.ts @@ -20,6 +20,7 @@ * ///////////////////////////////////////////////////////////////////////////// */ +import { ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { shake } from '@app/lib/shake'; @@ -56,7 +57,7 @@ export class SatelliteViewPlugin extends KeepTrackPlugin { } else { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast('Select a Satellite First!', 'caution'); + uiManagerInstance.toast('Select a Satellite First!', ToastMsgType.caution); shake(getEl(this.bottomIconElementName)); } }; diff --git a/src/plugins/select-sat-manager/sat-info-box.ts b/src/plugins/select-sat-manager/sat-info-box.ts index 161bd62db..69a110809 100644 --- a/src/plugins/select-sat-manager/sat-info-box.ts +++ b/src/plugins/select-sat-manager/sat-info-box.ts @@ -1,7 +1,7 @@ /* eslint-disable max-lines */ /* eslint-disable complexity */ /* eslint-disable max-statements */ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { openColorbox } from '@app/lib/colorbox'; import { getEl, hideEl, showEl } from '@app/lib/get-el'; @@ -152,7 +152,7 @@ export class SatInfoBox extends KeepTrackPlugin { .getUiManager() .toast( `Satellite ${sat.sccNum} is not in orbit!
Sim time is ${timeManagerInstance.simulationTimeObj.toUTCString()}.
Be sure to check you have the right TLE.`, - 'error', + ToastMsgType.error, true, ); this.selectSatManager_.selectSat(-1); @@ -529,7 +529,7 @@ export class SatInfoBox extends KeepTrackPlugin { private drawLineToSat_() { keepTrackApi.getSoundManager().play(SoundNames.CLICK); if (this.selectSatManager_.secondarySat == -1) { - keepTrackApi.getUiManager().toast('No Secondary Satellite Selected', 'caution'); + keepTrackApi.getUiManager().toast('No Secondary Satellite Selected', ToastMsgType.caution); } lineManagerInstance.create(LineTypes.SENSOR_TO_SAT, [this.selectSatManager_.selectedSat, this.selectSatManager_.secondarySat], 'b'); } diff --git a/src/plugins/select-sat-manager/select-sat-manager.ts b/src/plugins/select-sat-manager/select-sat-manager.ts index ef0fa5efd..a0fe638a2 100644 --- a/src/plugins/select-sat-manager/select-sat-manager.ts +++ b/src/plugins/select-sat-manager/select-sat-manager.ts @@ -1,4 +1,4 @@ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { CameraType } from '@app/singletons/camera'; @@ -262,7 +262,7 @@ export class SelectSatManager extends KeepTrackPlugin { .join(','); if (searchStr.length === 0) { - keepTrackApi.getUiManager().toast('No satellites found for this owner/manufacturer', 'caution', false); + keepTrackApi.getUiManager().toast('No satellites found for this owner/manufacturer', ToastMsgType.caution, false); } else { keepTrackApi.getUiManager().searchManager.doSearch(searchStr); keepTrackApi.getMainCamera().changeZoom(0.9); diff --git a/src/plugins/sensor/sensor-info-plugin.ts b/src/plugins/sensor/sensor-info-plugin.ts index 4403cf40c..8e8f526ec 100644 --- a/src/plugins/sensor/sensor-info-plugin.ts +++ b/src/plugins/sensor/sensor-info-plugin.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl, hideEl, showEl } from '@app/lib/get-el'; import { LineManager, LineTypes } from '@app/singletons/draw-manager/line-manager'; @@ -195,7 +195,7 @@ export class SensorInfoPlugin extends KeepTrackPlugin { const sensors = keepTrackApi.getSensorManager().currentSensors; if (sensors.length !== 1) { - keepTrackApi.getUiManager().toast('Please Select Only One Sensor', 'caution'); + keepTrackApi.getUiManager().toast('Please Select Only One Sensor', ToastMsgType.caution); } // Draw Line to Sun from Sensor @@ -238,7 +238,7 @@ export class SensorInfoPlugin extends KeepTrackPlugin { const sensors = keepTrackApi.getSensorManager().currentSensors; if (sensors.length !== 1) { - keepTrackApi.getUiManager().toast('Please Select Only One Sensor', 'caution'); + keepTrackApi.getUiManager().toast('Please Select Only One Sensor', ToastMsgType.caution); } // Draw Line to Sun from Sensor diff --git a/src/plugins/settings-menu/settings-menu.ts b/src/plugins/settings-menu/settings-menu.ts index 432fb4b2f..4785aaf29 100644 --- a/src/plugins/settings-menu/settings-menu.ts +++ b/src/plugins/settings-menu/settings-menu.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { rgbCss } from '@app/lib/rgbCss'; @@ -711,14 +711,14 @@ export class SettingsMenuPlugin extends KeepTrackPlugin { if (isNaN(newFieldOfView)) { (getEl('satFieldOfView')).value = '30'; - uiManagerInstance.toast('Invalid field of view value!', 'critical'); + uiManagerInstance.toast('Invalid field of view value!', ToastMsgType.critical); } const maxSearchSats = parseInt((getEl('maxSearchSats')).value); if (isNaN(maxSearchSats)) { (getEl('maxSearchSats')).value = settingsManager.searchLimit.toString(); - uiManagerInstance.toast('Invalid max search sats value!', 'critical'); + uiManagerInstance.toast('Invalid max search sats value!', ToastMsgType.critical); } else { settingsManager.searchLimit = maxSearchSats; uiManagerInstance.searchManager.doSearch(keepTrackApi.getUiManager().searchManager.getCurrentSearch()); diff --git a/src/plugins/time-machine/time-machine.ts b/src/plugins/time-machine/time-machine.ts index e047fee10..2a626682e 100644 --- a/src/plugins/time-machine/time-machine.ts +++ b/src/plugins/time-machine/time-machine.ts @@ -1,3 +1,4 @@ +import { ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import type { ColorSchemeManager } from '@app/singletons/color-scheme-manager'; @@ -94,12 +95,12 @@ export class TimeMachine extends KeepTrackPlugin { if (year >= 57 && year < 100) { const timeMachineString = (settingsManager.timeMachineString(year.toString()) || `Time Machine In Year 19${year}!`); - keepTrackApi.getUiManager().toast(timeMachineString, 'normal', settingsManager.timeMachineLongToast); + keepTrackApi.getUiManager().toast(timeMachineString, ToastMsgType.normal, settingsManager.timeMachineLongToast); } else { const yearStr = year < 10 ? `0${year}` : `${year}`; const timeMachineString = (settingsManager.timeMachineString(yearStr) || `Time Machine In Year 20${yearStr}!`); - keepTrackApi.getUiManager().toast(timeMachineString, 'normal', settingsManager.timeMachineLongToast); + keepTrackApi.getUiManager().toast(timeMachineString, ToastMsgType.normal, settingsManager.timeMachineLongToast); } } diff --git a/src/plugins/timeline-satellite/satellite-timeline.ts b/src/plugins/timeline-satellite/satellite-timeline.ts index d2d2b70b5..890bb927f 100644 --- a/src/plugins/timeline-satellite/satellite-timeline.ts +++ b/src/plugins/timeline-satellite/satellite-timeline.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { errorManagerInstance } from '@app/singletons/errorManager'; @@ -50,7 +50,7 @@ export class SatelliteTimeline extends KeepTrackPlugin { } if (keepTrackApi.getPlugin(WatchlistPlugin).watchlistList.length === 0 && keepTrackApi.getPlugin(SelectSatManager).selectedSat === -1) { - keepTrackApi.getUiManager().toast('Add Satellites to Watchlist or Select a Satellite', 'caution'); + keepTrackApi.getUiManager().toast('Add Satellites to Watchlist or Select a Satellite', ToastMsgType.caution); shake(getEl(this.bottomIconElementName)); return; diff --git a/src/plugins/tracking-impact-predict/tracking-impact-predict.ts b/src/plugins/tracking-impact-predict/tracking-impact-predict.ts index 1401a2700..e1f2bc732 100644 --- a/src/plugins/tracking-impact-predict/tracking-impact-predict.ts +++ b/src/plugins/tracking-impact-predict/tracking-impact-predict.ts @@ -2,7 +2,7 @@ import { errorManagerInstance } from '@app/singletons/errorManager'; import sputnickPng from '@public/img/icons/sputnick.png'; import './tracking-impact-predict.css'; -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { getEl } from '@app/lib/get-el'; import { showLoading } from '@app/lib/showLoading'; import { keepTrackApi } from '../../keepTrackApi'; @@ -147,7 +147,7 @@ export class TrackingImpactPredict extends KeepTrackPlugin { const sat = keepTrackApi.getCatalogManager().sccNum2Sat(parseInt(this.tipList_[row].NORAD_CAT_ID)); if (!sat) { - keepTrackApi.getUiManager().toast('Satellite appears to have decayed!', 'caution'); + keepTrackApi.getUiManager().toast('Satellite appears to have decayed!', ToastMsgType.caution); return; } diff --git a/src/plugins/watchlist/watchlist-overlay.ts b/src/plugins/watchlist/watchlist-overlay.ts index 8645a53ea..c1b1f557e 100644 --- a/src/plugins/watchlist/watchlist-overlay.ts +++ b/src/plugins/watchlist/watchlist-overlay.ts @@ -1,4 +1,4 @@ -import { GetSatType, KeepTrackApiEvents, SatPassTimes } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, SatPassTimes, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { dateFormat } from '@app/lib/dateFormat'; import { getEl } from '@app/lib/get-el'; @@ -35,7 +35,7 @@ export class WatchlistOverlay extends KeepTrackPlugin { } if (keepTrackApi.getPlugin(WatchlistPlugin).watchlistList.length === 0) { - keepTrackApi.getUiManager().toast('Add Satellites to Watchlist!', 'caution'); + keepTrackApi.getUiManager().toast('Add Satellites to Watchlist!', ToastMsgType.caution); shake(getEl('menu-info-overlay')); return; @@ -46,7 +46,7 @@ export class WatchlistOverlay extends KeepTrackPlugin { } if (this.watchlistPlugin_.watchlistList.length === 0 && !this.watchlistPlugin_.isWatchlistChanged) { - keepTrackApi.getUiManager().toast('Add Satellites to Watchlist!', 'caution'); + keepTrackApi.getUiManager().toast('Add Satellites to Watchlist!', ToastMsgType.caution); shake(getEl('menu-info-overlay')); this.nextPassArray = []; @@ -158,7 +158,7 @@ export class WatchlistOverlay extends KeepTrackPlugin { if (inView === 1 && this.watchlistPlugin_.watchlistInViewList[i] === false) { // Is inview and wasn't previously this.watchlistPlugin_.watchlistInViewList[i] = true; - uiManagerInstance.toast(`Satellite ${sat.sccNum} is In Field of View!`, 'normal'); + uiManagerInstance.toast(`Satellite ${sat.sccNum} is In Field of View!`, ToastMsgType.normal); lineManagerInstance.create( LineTypes.SELECTED_SENSOR_TO_SAT_IF_IN_FOV, [sat.id, keepTrackApi.getCatalogManager().getSensorFromSensorName(keepTrackApi.getSensorManager().currentSensors[0].name)], @@ -169,7 +169,7 @@ export class WatchlistOverlay extends KeepTrackPlugin { if (inView === 0 && this.watchlistPlugin_.watchlistInViewList[i] === true) { // Isn't inview and was previously this.watchlistPlugin_.watchlistInViewList[i] = false; - uiManagerInstance.toast(`Satellite ${sat.sccNum} left Field of View!`, 'standby'); + uiManagerInstance.toast(`Satellite ${sat.sccNum} left Field of View!`, ToastMsgType.standby); keepTrackApi.getOrbitManager().removeInViewOrbit(this.watchlistPlugin_.watchlistList[i]); } } diff --git a/src/plugins/watchlist/watchlist.ts b/src/plugins/watchlist/watchlist.ts index f71c79e92..5b52367dc 100644 --- a/src/plugins/watchlist/watchlist.ts +++ b/src/plugins/watchlist/watchlist.ts @@ -23,7 +23,7 @@ * ///////////////////////////////////////////////////////////////////////////// */ -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { clickAndDragWidth } from '@app/lib/click-and-drag'; import { getEl } from '@app/lib/get-el'; @@ -164,7 +164,7 @@ export class WatchlistPlugin extends KeepTrackPlugin { } } if (newWatchlist.length > 0) { - keepTrackApi.getUiManager().toast(`Watchlist Loaded with ${newWatchlist.length} Satellites`, 'normal'); + keepTrackApi.getUiManager().toast(`Watchlist Loaded with ${newWatchlist.length} Satellites`, ToastMsgType.normal); } this.updateWatchlist({ updateWatchlistList: newWatchlist, updateWatchlistInViewList: _watchlistInViewList, isSkipSearch: true }); diff --git a/src/settings/settings.ts b/src/settings/settings.ts index d4e4628b1..88fd31c3b 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -19,7 +19,7 @@ * ///////////////////////////////////////////////////////////////////////////// */ -import { KeepTrackApiEvents, SensorGeolocation } from '@app/interfaces'; +import { KeepTrackApiEvents, SensorGeolocation, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import { ColorSchemeColorMap } from '@app/singletons/color-scheme-manager'; @@ -1432,10 +1432,10 @@ export class SettingsManager { if (id >= 0) { keepTrackApi.getPlugin(SelectSatManager)?.selectSat(id); } else { - keepTrackApi.getUiManager().toast(`Invalid Satellite: ${val}`, 'error'); + keepTrackApi.getUiManager().toast(`Invalid Satellite: ${val}`, ToastMsgType.error); } } else { - keepTrackApi.getUiManager().toast(`Invalid Satellite: ${val}`, 'error'); + keepTrackApi.getUiManager().toast(`Invalid Satellite: ${val}`, ToastMsgType.error); } } }, 2000); @@ -1455,7 +1455,7 @@ export class SettingsManager { if (parseInt(val) > 0) { this.searchLimit = parseInt(val); } else { - keepTrackApi.getUiManager().toast(`Invalid search limit: ${val}`, 'error'); + keepTrackApi.getUiManager().toast(`Invalid search limit: ${val}`, ToastMsgType.error); } break; case 'console': diff --git a/src/singletons/camera.ts b/src/singletons/camera.ts index 7b0ac3305..611fd7ed8 100644 --- a/src/singletons/camera.ts +++ b/src/singletons/camera.ts @@ -22,7 +22,7 @@ * ///////////////////////////////////////////////////////////////////////////// */ -import { KeepTrackApiEvents, SatShader } from '@app/interfaces'; +import { KeepTrackApiEvents, SatShader, ToastMsgType } from '@app/interfaces'; import { RADIUS_OF_EARTH, ZOOM_EXP } from '@app/lib/constants'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import { mat4, quat, vec3 } from 'gl-matrix'; @@ -784,27 +784,27 @@ export class Camera { switch (this.cameraType) { case CameraType.DEFAULT: - uiManagerInstance.toast('Earth Centered Camera Mode', 'standby'); + uiManagerInstance.toast('Earth Centered Camera Mode', ToastMsgType.standby); this.zoomTarget = 0.5; break; case CameraType.OFFSET: - uiManagerInstance.toast('Offset Camera Mode', 'standby'); + uiManagerInstance.toast('Offset Camera Mode', ToastMsgType.standby); break; case CameraType.FIXED_TO_SAT: - uiManagerInstance.toast('Fixed to Satellite Camera Mode', 'standby'); + uiManagerInstance.toast('Fixed to Satellite Camera Mode', ToastMsgType.standby); break; case CameraType.FPS: - uiManagerInstance.toast('Free Camera Mode', 'standby'); + uiManagerInstance.toast('Free Camera Mode', ToastMsgType.standby); break; case CameraType.PLANETARIUM: - uiManagerInstance.toast('Planetarium Camera Mode', 'standby'); + uiManagerInstance.toast('Planetarium Camera Mode', ToastMsgType.standby); LegendManager.change('planetarium'); break; case CameraType.SATELLITE: - uiManagerInstance.toast('Satellite Camera Mode', 'standby'); + uiManagerInstance.toast('Satellite Camera Mode', ToastMsgType.standby); break; case CameraType.ASTRONOMY: - uiManagerInstance.toast('Astronomy Camera Mode', 'standby'); + uiManagerInstance.toast('Astronomy Camera Mode', ToastMsgType.standby); LegendManager.change('astronomy'); break; default: diff --git a/src/singletons/errorManager.ts b/src/singletons/errorManager.ts index 676d456fb..db69c5775 100644 --- a/src/singletons/errorManager.ts +++ b/src/singletons/errorManager.ts @@ -1,3 +1,4 @@ +import { ToastMsgType } from '@app/interfaces'; import { Options } from 'new-github-issue-url'; import { keepTrackApi } from '../keepTrackApi'; import { isThisNode } from '../static/isThisNode'; @@ -44,7 +45,7 @@ export class ErrorManager { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast(toastMsg, 'error', true); + uiManagerInstance.toast(toastMsg, ToastMsgType.error, true); if (isThisNode()) { throw e; @@ -74,7 +75,7 @@ ${e.stack}`, if (this.ALLOW_WARN) { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast(msg, 'serious', true); + uiManagerInstance.toast(msg, ToastMsgType.serious, true); } // eslint-disable-next-line no-console @@ -85,7 +86,7 @@ ${e.stack}`, if (this.ALLOW_INFO) { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast(msg, 'normal', true); + uiManagerInstance.toast(msg, ToastMsgType.normal, true); } if (this.isDebug) { console.info(msg); @@ -96,7 +97,7 @@ ${e.stack}`, if (this.ALLOW_LOG) { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast(msg, 'normal', true); + uiManagerInstance.toast(msg, ToastMsgType.normal, true); } if (this.isDebug) { console.log(msg); @@ -107,7 +108,7 @@ ${e.stack}`, if (this.ALLOW_DEBUG) { const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast(msg, 'standby', true); + uiManagerInstance.toast(msg, ToastMsgType.standby, true); // eslint-disable-next-line no-debugger debugger; } diff --git a/src/singletons/input-manager/keyboard-input.ts b/src/singletons/input-manager/keyboard-input.ts index f5284d94a..020c1d0c6 100644 --- a/src/singletons/input-manager/keyboard-input.ts +++ b/src/singletons/input-manager/keyboard-input.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { getEl } from '@app/lib/get-el'; import { SettingsMenuPlugin } from '@app/plugins/settings-menu/settings-menu'; @@ -158,9 +158,9 @@ export class KeyboardInput { case 'L': settingsManager.isDrawOrbits = !settingsManager.isDrawOrbits; if (settingsManager.isDrawOrbits) { - uiManagerInstance.toast('Orbits On', 'normal'); + uiManagerInstance.toast('Orbits On', ToastMsgType.normal); } else { - uiManagerInstance.toast('Orbits Off', 'standby'); + uiManagerInstance.toast('Orbits Off', ToastMsgType.standby); } SettingsMenuPlugin.syncOnLoad(); break; @@ -209,7 +209,7 @@ export class KeyboardInput { keepTrackApi.getMainCamera().resetCamera(); break; case 't': - uiManagerInstance.toast('Time Set to Real Time', 'normal'); + uiManagerInstance.toast('Time Set to Real Time', ToastMsgType.normal); timeManagerInstance.changeStaticOffset(0); // Reset to Current Time settingsManager.isPropRateChange = true; break; @@ -283,16 +283,16 @@ export class KeyboardInput { if (settingsManager.isPropRateChange && !settingsManager.isAlwaysHidePropRate && timeManagerInstance.propRate0 !== timeManagerInstance.propRate) { if (timeManagerInstance.propRate > 1.01 || timeManagerInstance.propRate < 0.99) { if (timeManagerInstance.propRate < 10) { - uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, 'standby'); + uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, ToastMsgType.standby); } if (timeManagerInstance.propRate >= 10 && timeManagerInstance.propRate < 60) { - uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, 'caution'); + uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, ToastMsgType.caution); } if (timeManagerInstance.propRate >= 60) { - uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, 'serious'); + uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, ToastMsgType.serious); } } else { - uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, 'normal'); + uiManagerInstance.toast(`Propagation Speed: ${timeManagerInstance.propRate.toFixed(1)}x`, ToastMsgType.normal); } } diff --git a/src/singletons/input-manager/mouse-input.ts b/src/singletons/input-manager/mouse-input.ts index 4c2b5f741..f261ff0be 100644 --- a/src/singletons/input-manager/mouse-input.ts +++ b/src/singletons/input-manager/mouse-input.ts @@ -1,6 +1,6 @@ /* eslint-disable no-unreachable */ // eslint-disable-next-line max-classes-per-file -import { GetSatType, KeepTrackApiEvents } from '@app/interfaces'; +import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import { SoundNames } from '@app/plugins/sounds/SoundNames'; @@ -438,7 +438,7 @@ export class MouseInput { this.latLon = eci2lla({ x: this.dragPosition[0], y: this.dragPosition[1], z: this.dragPosition[2] }, gmst); } - uiManagerInstance.toast(`Lat: ${this.latLon.lat.toFixed(3)}
Lon: ${this.latLon.lon.toFixed(3)}`, 'normal', true); + uiManagerInstance.toast(`Lat: ${this.latLon.lat.toFixed(3)}
Lon: ${this.latLon.lon.toFixed(3)}`, ToastMsgType.normal, true); break; case 'view-sat-info-rmb': keepTrackApi.getPlugin(SelectSatManager)?.selectSat(this.clickedSat); @@ -452,7 +452,7 @@ export class MouseInput { const intldes = catalogManagerInstance.getSat(this.clickedSat, GetSatType.EXTRA_ONLY)?.intlDes; if (!intldes) { - uiManagerInstance.toast('Time 1 is Invalid!', 'serious'); + uiManagerInstance.toast('Time 1 is Invalid!', ToastMsgType.serious); } const searchStr = intldes.slice(0, 8); diff --git a/src/singletons/mobileManager.ts b/src/singletons/mobileManager.ts index 67885ed44..8a9527504 100644 --- a/src/singletons/mobileManager.ts +++ b/src/singletons/mobileManager.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { Kilometers } from 'ootk'; import { keepTrackApi } from '../keepTrackApi'; import { getEl } from '../lib/get-el'; @@ -12,7 +12,7 @@ export class MobileManager { if (!keepTrackApi.isInitialized) { if (MobileManager.checkIfMobileDevice()) { if (!settingsManager.isMobileModeEnabled) { - keepTrackApi.getUiManager().toast('Full Version of KeepTrack is not available on mobile devices. Please use a desktop browser to access the full version.', 'normal'); + keepTrackApi.getUiManager().toast('Full Version of KeepTrack is not available on mobile devices. Please use a desktop browser to access the full version.', ToastMsgType.normal); } settingsManager.isMobileModeEnabled = true; diff --git a/src/singletons/scene.ts b/src/singletons/scene.ts index 526d4a439..4220b4f12 100644 --- a/src/singletons/scene.ts +++ b/src/singletons/scene.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { KeepTrack } from '@app/keeptrack'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import { SettingsMenuPlugin } from '@app/plugins/settings-menu/settings-menu'; @@ -95,7 +95,7 @@ export class Scene { settingsManager.isDrawAurora || settingsManager.isDrawMilkyWay) && !KeepTrack.isFpsAboveLimit(this.averageDrawTime as Milliseconds, 30)) { - keepTrackApi.getUiManager().toast('Your computer is struggling! Disabling some visual effects in settings.', 'caution'); + keepTrackApi.getUiManager().toast('Your computer is struggling! Disabling some visual effects in settings.', ToastMsgType.caution); settingsManager.isDisableMoon = true; settingsManager.isDrawSun = false; settingsManager.isDrawAurora = false; diff --git a/src/singletons/search-manager.ts b/src/singletons/search-manager.ts index ac15eeee8..12f9cca29 100644 --- a/src/singletons/search-manager.ts +++ b/src/singletons/search-manager.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { SatInfoBox } from '@app/plugins/select-sat-manager/sat-info-box'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import type { CatalogManager } from '@app/singletons/catalog-manager'; @@ -266,7 +266,7 @@ export class SearchManager { if (idList.length === 0) { if (settingsManager.lastSearch?.length > settingsManager.minimumSearchCharacters) { - uiManagerInstance.toast('No Results Found', 'serious', false); + uiManagerInstance.toast('No Results Found', ToastMsgType.serious, false); } this.hideResults(); diff --git a/src/singletons/time-manager.ts b/src/singletons/time-manager.ts index 7de2612aa..5a32f0871 100644 --- a/src/singletons/time-manager.ts +++ b/src/singletons/time-manager.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { CruncerMessageTypes } from '@app/webworker/positionCruncher'; import { Milliseconds } from 'ootk'; import { keepTrackApi } from '../keepTrackApi'; @@ -160,7 +160,7 @@ export class TimeManager { this.timeTextStrEmpty_ = ''; this.propFrozen = Date.now(); // for when propRate 0 - this.realTime = this.propFrozen; // (initialized as Date.now) + this.realTime = this.propFrozen; // (initialized as Date.now) this.propRate = 1.0; // time rate multiplier for propagation // Initialize @@ -170,7 +170,7 @@ export class TimeManager { setNow(realTime: Milliseconds) { this.realTime = realTime; - this.lastTime = this.simulationTimeObj.getTime(); + this.lastTime = this.simulationTimeObj.getTime(); // NOTE: This should be the only regular call to calculateSimulationTime!! this.calculateSimulationTime(); @@ -188,16 +188,16 @@ export class TimeManager { if (this.propRate > 1.01 || this.propRate < 0.99) { if (this.propRate < 10) { - uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, 'standby'); + uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, ToastMsgType.standby); } if (this.propRate >= 10 && this.propRate < 60) { - uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, 'caution'); + uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, ToastMsgType.caution); } if (this.propRate >= 60) { - uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, 'serious'); + uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, ToastMsgType.serious); } } else { - uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, 'normal'); + uiManagerInstance.toast(`Propagation Speed: ${this.propRate.toFixed(1)}x`, ToastMsgType.normal); } } diff --git a/src/singletons/uiManager.ts b/src/singletons/uiManager.ts index 106b78861..effa33f42 100644 --- a/src/singletons/uiManager.ts +++ b/src/singletons/uiManager.ts @@ -137,35 +137,32 @@ export class UiManager { this.dismissAllToasts(); }); - type = type || 'standby'; + type = type || ToastMsgType.standby; if (isLong) { toastMsg.timeRemaining = UiManager.LONG_TIMER_DELAY; } switch (type) { - case 'standby': + case ToastMsgType.standby: toastMsg.$el[0].style.background = 'var(--statusDarkStandby)'; keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); break; - case 'normal': - toastMsg.$el[0].style.background = 'var(--statusDarkNormal)'; - keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); - break; - case 'caution': + case ToastMsgType.caution: toastMsg.$el[0].style.background = 'var(--statusDarkCaution)'; keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); break; - case 'serious': + case ToastMsgType.serious: toastMsg.$el[0].style.background = 'var(--statusDarkSerious)'; keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); break; - case 'critical': + case ToastMsgType.critical: toastMsg.$el[0].style.background = 'var(--statusDarkCritical)'; keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); break; - case 'error': + case ToastMsgType.error: toastMsg.$el[0].style.background = 'var(--statusDarkCritical)'; keepTrackApi.getSoundManager()?.play(SoundNames.ERROR); break; + case ToastMsgType.normal: default: toastMsg.$el[0].style.background = 'var(--statusDarkNormal)'; keepTrackApi.getSoundManager()?.play(SoundNames.WARNING); @@ -197,44 +194,44 @@ export class UiManager { switch (newScheme.name) { case 'default': case 'group': - this.toast('Color Scheme Changed to Object Types', 'normal', false); + this.toast('Color Scheme Changed to Object Types', ToastMsgType.normal, false); break; case 'velocity': - this.toast('Color Scheme Changed to Velocity', 'normal', false); + this.toast('Color Scheme Changed to Velocity', ToastMsgType.normal, false); break; case 'sunlight': - this.toast('Color Scheme Changed to Sunlight', 'normal', false); + this.toast('Color Scheme Changed to Sunlight', ToastMsgType.normal, false); break; case 'countries': case 'groupCountries': - this.toast('Color Scheme Changed to Countries', 'normal', false); + this.toast('Color Scheme Changed to Countries', ToastMsgType.normal, false); break; case 'leo': - this.toast('Color Scheme Changed to Near Earth', 'normal', false); + this.toast('Color Scheme Changed to Near Earth', ToastMsgType.normal, false); break; case 'geo': - this.toast('Color Scheme Changed to Deep Space', 'normal', false); + this.toast('Color Scheme Changed to Deep Space', ToastMsgType.normal, false); break; case 'ageOfElset': - this.toast('Color Scheme Changed to Elset Age', 'normal', false); + this.toast('Color Scheme Changed to Elset Age', ToastMsgType.normal, false); break; case 'rcs': - this.toast('Color Scheme Changed to Radar Cross Section', 'normal', false); + this.toast('Color Scheme Changed to Radar Cross Section', ToastMsgType.normal, false); break; case 'smallsats': - this.toast('Color Scheme Changed to Small Satellites', 'normal', false); + this.toast('Color Scheme Changed to Small Satellites', ToastMsgType.normal, false); break; case 'lostobjects': - this.toast('Color Scheme Changed to Lost Objects', 'normal', false); + this.toast('Color Scheme Changed to Lost Objects', ToastMsgType.normal, false); break; case 'neighbors': - this.toast('Color Scheme Changed to Orbit Density', 'normal', false); + this.toast('Color Scheme Changed to Orbit Density', ToastMsgType.normal, false); break; case 'confidence': - this.toast('Color Scheme Changed to Confidence', 'normal', false); + this.toast('Color Scheme Changed to Confidence', ToastMsgType.normal, false); break; default: - this.toast(`Color Scheme Changed to ${newScheme.name}`, 'normal', false); + this.toast(`Color Scheme Changed to ${newScheme.name}`, ToastMsgType.normal, false); console.debug(`${newScheme.name} missing from alert list!`); break; } diff --git a/src/static/url-manager.ts b/src/static/url-manager.ts index 6d4510b9d..2ad5e87d7 100644 --- a/src/static/url-manager.ts +++ b/src/static/url-manager.ts @@ -1,4 +1,4 @@ -import { KeepTrackApiEvents } from '@app/interfaces'; +import { KeepTrackApiEvents, ToastMsgType } from '@app/interfaces'; import { keepTrackApi } from '@app/keepTrackApi'; import { SelectSatManager } from '@app/plugins/select-sat-manager/select-sat-manager'; import { DetailedSatellite } from 'ootk'; @@ -106,7 +106,7 @@ export abstract class UrlManager { if (urlSatId !== null && catalogManagerInstance.getObject(urlSatId).active) { keepTrackApi.getPlugin(SelectSatManager)?.selectSat(urlSatId); } else { - uiManagerInstance.toast(`International Designator "${val.toUpperCase()}" was not found!`, 'caution', true); + uiManagerInstance.toast(`International Designator "${val.toUpperCase()}" was not found!`, ToastMsgType.caution, true); } }, }); @@ -124,7 +124,7 @@ export abstract class UrlManager { if (urlSatId !== null) { keepTrackApi.getPlugin(SelectSatManager)?.selectSat(urlSatId); } else { - uiManagerInstance.toast(`Satellite "${val.toUpperCase()}" was not found!`, 'caution', true); + uiManagerInstance.toast(`Satellite "${val.toUpperCase()}" was not found!`, ToastMsgType.caution, true); } }, }); @@ -139,7 +139,7 @@ export abstract class UrlManager { (getEl('missile')).click(); const uiManagerInstance = keepTrackApi.getUiManager(); - uiManagerInstance.toast('Missile launched!', 'normal', false); + uiManagerInstance.toast('Missile launched!', ToastMsgType.normal, false); } private static handleDateParam_(val: string) { @@ -147,7 +147,7 @@ export abstract class UrlManager { const timeManagerInstance = keepTrackApi.getTimeManager(); if (isNaN(parseInt(val))) { - uiManagerInstance.toast(`Date value of "${val}" is not a proper unix timestamp!`, 'caution', true); + uiManagerInstance.toast(`Date value of "${val}" is not a proper unix timestamp!`, ToastMsgType.caution, true); return; } @@ -160,7 +160,7 @@ export abstract class UrlManager { let rate = parseFloat(val); if (isNaN(rate)) { - uiManagerInstance.toast(`Propagation rate of "${rate}" is not a valid float!`, 'caution', true); + uiManagerInstance.toast(`Propagation rate of "${rate}" is not a valid float!`, ToastMsgType.caution, true); return; } @@ -185,7 +185,7 @@ export abstract class UrlManager { uiManagerInstance.doSearch(decodedVal); if (settingsManager.lastSearchResults.length === 0) { - uiManagerInstance.toast(`Search for "${val}" found nothing!`, 'caution', true); + uiManagerInstance.toast(`Search for "${val}" found nothing!`, ToastMsgType.caution, true); uiManagerInstance.searchManager.hideResults(); } } diff --git a/test/satellite-view.test.ts b/test/satellite-view.test.ts index d6ad97ce7..5bb4b6dcc 100644 --- a/test/satellite-view.test.ts +++ b/test/satellite-view.test.ts @@ -67,7 +67,7 @@ describe('SatelliteViewPlugin_class', () => { keepTrackApi.runEvent(KeepTrackApiEvents.uiManagerFinal); keepTrackContainer.registerSingleton(Singletons.MainCamera, mockCameraManager); keepTrackApi.runEvent(KeepTrackApiEvents.bottomMenuClick, 'menu-satview'); - expect(uiManagerInstance.toast).toHaveBeenCalledWith('Select a Satellite First!', 'serious', true); + expect(uiManagerInstance.toast).toHaveBeenCalledWith('Select a Satellite First!', ToastMsgType.serious, true); }); // Tests that a toast message is not displayed when a satellite is selected and trying to activate Satellite Camera Mode