Skip to content

Commit

Permalink
fix: 🐛 fix ui issues with missile objects
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Aug 16, 2024
1 parent ebb947f commit 222cef7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
7 changes: 5 additions & 2 deletions src/plugins/orbit-references/orbit-references.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KeepTrackApiEvents } from '@app/interfaces';
import { keepTrackApi } from '@app/keepTrackApi';
import { getEl } from '@app/lib/get-el';
import { getEl, hideEl, showEl } from '@app/lib/get-el';

import { CatalogManager } from '@app/singletons/catalog-manager';
import { StringifiedNumber } from '@app/static/sat-math';
Expand Down Expand Up @@ -30,9 +30,12 @@ export class OrbitReferences extends KeepTrackPlugin {
cbName: this.PLUGIN_NAME,
cb: (obj?: BaseObject) => {
// Skip this if there is no satellite object because the menu isn't open
if (!obj) {
if (!obj?.isSatellite()) {
hideEl('orbit-references-link');

return;
}
showEl('orbit-references-link');

if (!this.doOnce) {
getEl('sat-info-top-links').insertAdjacentHTML(
Expand Down
24 changes: 14 additions & 10 deletions src/plugins/select-sat-manager/sat-info-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,14 +903,16 @@ export class SatInfoBox extends KeepTrackPlugin {
</span>
</div>
${getEl('search') ? SatInfoBox.createSearchLinks_() : ''}
<div id="sun-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Sun">Draw sat to sun line...</div>
<div id="ric-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize RIC Vector">Draw sat to RIC line...</div>
<div id="nadir-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Earth">Draw sat to nadir line...</div>
<div id="sec-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Secondary Satellite">Draw sat to second sat line...</div>
<div id="draw-line-links">
<div id="sun-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Sun">Draw sat to sun line...</div>
<div id="ric-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize RIC Vector">Draw sat to RIC line...</div>
<div id="nadir-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Earth">Draw sat to nadir line...</div>
<div id="sec-angle-link" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Visualize Angle to Secondary Satellite">Draw sat to second sat line...</div>
</div>
</div>
<div id="sat-identifier-data">
<div class="sat-info-section-header">Identifiers</div>
Expand Down Expand Up @@ -1055,6 +1057,7 @@ export class SatInfoBox extends KeepTrackPlugin {

private static createSearchLinks_(): string {
return keepTrackApi.html`
<div id="search-links">
<div id="all-objects-link" class="link sat-infobox-links sat-only-info" data-position="top" data-delay="50"
data-tooltip="Find Related Objects">Find all objects from this launch...</div>
<div id="near-orbits-link" class="link sat-infobox-links sat-only-info" data-position="top" data-delay="50"
Expand All @@ -1064,7 +1067,8 @@ export class SatInfoBox extends KeepTrackPlugin {
<div id="near-objects-link2" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Find Nearby Objects">Find all objects within 200km...</div>
<div id="near-objects-link4" class="link sat-infobox-links" data-position="top" data-delay="50"
data-tooltip="Find Nearby Objects">Find all objects within 400km...</div>`;
data-tooltip="Find Nearby Objects">Find all objects within 400km...</div>
</div>`;
}

static resetMenuLocation(satInfoboxDom: HTMLElement, isShow = true) {
Expand Down Expand Up @@ -1600,7 +1604,7 @@ export class SatInfoBox extends KeepTrackPlugin {
if (!el) {
return;
}
hideEl(el.parentElement.id);
hideEl(el.parentElement);
},
);

Expand Down
6 changes: 5 additions & 1 deletion src/plugins/select-sat-manager/select-sat-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GetSatType, KeepTrackApiEvents, ToastMsgType } from '@app/interfaces';
import { keepTrackApi } from '@app/keepTrackApi';
import { getEl } from '@app/lib/get-el';
import { getEl, hideEl, showEl } from '@app/lib/get-el';
import { CameraType } from '@app/singletons/camera';

import { MissileObject } from '@app/singletons/catalog-manager/MissileObject';
Expand Down Expand Up @@ -120,6 +120,8 @@ export class SelectSatManager extends KeepTrackPlugin {
case SpaceObjectType.SPECIAL:
case SpaceObjectType.NOTIONAL:
case SpaceObjectType.UNKNOWN:
showEl('search-links');
showEl('draw-line-links');
this.selectSatObject_(obj as DetailedSatellite);
break;
case SpaceObjectType.PAYLOAD_OWNER:
Expand All @@ -133,6 +135,8 @@ export class SelectSatManager extends KeepTrackPlugin {
case SpaceObjectType.STAR:
return; // Do nothing
case SpaceObjectType.BALLISTIC_MISSILE:
hideEl('search-links');
hideEl('draw-line-links');
this.selectSatObject_(obj as MissileObject);
break;
default:
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/sensor-list/sensor-list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sensors } from '@app/catalogs/sensors';
import { KeepTrackApiEvents } from '@app/interfaces';
import { getClass } from '@app/lib/get-class';
import { getEl } from '@app/lib/get-el';
import { getEl, hideEl, showEl } from '@app/lib/get-el';
import { CameraType } from '@app/singletons/camera';
import { errorManagerInstance } from '@app/singletons/errorManager';
import { PersistenceManager, StorageKey } from '@app/singletons/persistence-manager';
Expand Down Expand Up @@ -163,10 +163,14 @@ export class SensorListPlugin extends KeepTrackPlugin {
cbName: 'sensor',
cb: (obj: BaseObject) => {
// Skip this if there is no satellite object because the menu isn't open
if (obj === null || typeof obj === 'undefined') {
if (!obj?.isSatellite()) {
hideEl('sensors-in-fov-link');

return;
}

showEl('sensors-in-fov-link');

if (keepTrackApi.getPlugin(SatInfoBox) !== null && !this.isSensorLinksAdded) {
getEl('sat-info-top-links').insertAdjacentHTML(
'beforeend',
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/short-term-fences/short-term-fences.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { KeepTrackApiEvents } from '@app/interfaces';
import { keepTrackApi } from '@app/keepTrackApi';
import { getEl } from '@app/lib/get-el';
import { getEl, hideEl, showEl } from '@app/lib/get-el';
import { slideInRight, slideOutLeft } from '@app/lib/slide';
import searchPng from '@public/img/icons/search.png';

Expand Down Expand Up @@ -96,9 +96,12 @@ export class ShortTermFences extends KeepTrackPlugin {
cbName: this.PLUGIN_NAME,
cb: (obj: BaseObject) => {
// Skip this if there is no satellite object because the menu isn't open
if (obj === null || typeof obj === 'undefined') {
if (!obj?.isSatellite()) {
hideEl('stf-on-object-link');

return;
}
showEl('stf-on-object-link');

if (keepTrackApi.getPlugin(SatInfoBox) && !this.isAddStfLinksOnce) {
getEl('sat-info-top-links').insertAdjacentHTML(
Expand Down
10 changes: 5 additions & 5 deletions src/singletons/draw-manager/line-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class LineManager {
}

createSatRicFrame(sat: DetailedSatellite | MissileObject | null): void {
if (!sat || sat instanceof MissileObject) {
if (!sat || !(sat instanceof DetailedSatellite)) {
return;
}

Expand All @@ -61,15 +61,15 @@ export class LineManager {
}

createSatToRef(sat: DetailedSatellite | MissileObject | null, ref: vec3, color?: vec4): void {
if (!sat || sat instanceof MissileObject) {
if (!sat || !(sat instanceof DetailedSatellite)) {
return;
}

this.add(new SatToRefLine(sat, ref, color));
}

createSat2Sun(sat: DetailedSatellite | MissileObject | null): void {
if (!sat || sat instanceof MissileObject) {
if (!sat || !(sat instanceof DetailedSatellite)) {
return;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ export class LineManager {
}

createSensorToSat(sensor: DetailedSensor | null, sat: DetailedSatellite | MissileObject | null, color?: vec4): void {
if (!sensor || !sat || sat instanceof MissileObject) {
if (!sensor || !sat || !(sat instanceof DetailedSatellite)) {
return;
}

Expand All @@ -136,7 +136,7 @@ export class LineManager {
}

createSensorToSatFovAndSelectedOnly(sensor: DetailedSensor | null, sat: DetailedSatellite | null, color?: vec4): void {
if (!sensor || !sat || sat instanceof MissileObject) {
if (!sensor || !sat || !(sat instanceof DetailedSatellite)) {
return;
}

Expand Down

0 comments on commit 222cef7

Please sign in to comment.