Skip to content
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

Develop #955

Merged
merged 9 commits into from
Sep 29, 2024
9 changes: 7 additions & 2 deletions public/css/materialize-local.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ textarea.materialize-textarea {
line-height: 2rem !important;
}

.row {
margin-bottom: 1rem;
}

.input-field {
margin-top: 0 !important;
margin-bottom: 0 !important;
margin-top: 1rem 0 0 0;
padding-left: 1rem;
padding-right: 1rem;
}

.input-field.col label {
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/new-launch/new-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,16 @@ export class NewLaunch extends KeepTrackPlugin {
},
validationFunc: (data: any) => typeof data.satPos !== 'undefined',
error: () => {
if (!this.isDoingCalculations) {
// If we are not doing calculations, then it must have finished already.
return;
}

this.isDoingCalculations = false;
hideLoading();
uiManagerInstance.toast('Cruncher failed to meet requirement after multiple tries! Is this launch even possible?', ToastMsgType.critical);
},
maxRetries: 50,
});
};

Expand Down
30 changes: 17 additions & 13 deletions src/plugins/screenshot/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { KeepTrackApiEvents } from '@app/interfaces';
import { keepTrackApi } from '@app/keepTrackApi';
import { Classification } from '@app/static/classification';
import cameraPng from '@public/img/icons/camera.png';
import logoPng from '@public/img/kts-text-logo.png';
import { KeepTrackPlugin } from '../KeepTrackPlugin';

export class Screenshot extends KeepTrackPlugin {
Expand All @@ -36,6 +37,13 @@ export class Screenshot extends KeepTrackPlugin {
this.saveHiResPhoto('4k');
};

logo: HTMLImageElement;
constructor() {
super();
this.logo = new Image();
this.logo.src = logoPng;
}

// This is 'disabled' since it does not turn green after being clicked like other buttons.
isIconDisabled = true;

Expand Down Expand Up @@ -127,33 +135,28 @@ export class Screenshot extends KeepTrackPlugin {

link.download = 'keeptrack.png';

const d = new Date();
const n = d.getUTCFullYear();
const copyrightStr = !settingsManager.copyrightOveride ? `©${n} KEEPTRACK.SPACE` : '';

link.href = Screenshot.watermarkedDataUrl_(copyrightStr);
link.href = this.watermarkedDataUrl_();
link.click();
this.queuedScreenshot_ = false;
}

private static watermarkedDataUrl_(text: string) {
private watermarkedDataUrl_() {
const canvas = keepTrackApi.getRenderer().domElement;

const tempCanvas = document.createElement('canvas');
const tempCtx = tempCanvas.getContext('2d');
const cw = tempCanvas.width;
const ch = tempCanvas.height;
const logoWidth = 200;
const logoHeight = 200;
const logoX = canvas.width - logoWidth - 50;
const logoY = canvas.height - logoHeight - 50;

tempCanvas.width = canvas.width;
tempCanvas.height = canvas.height;

tempCtx.drawImage(canvas, 0, 0);
tempCtx.font = '24px nasalization';
let textWidth = tempCtx.measureText(text).width;

tempCtx.globalAlpha = 1.0;
tempCtx.fillStyle = 'white';
tempCtx.fillText(text, cw - textWidth - 30, ch - 30);
tempCtx.drawImage(this.logo, logoX, logoY, logoWidth, logoHeight);

const { classificationstr, classificationColor } = Screenshot.calculateClassificationText_();

Expand All @@ -163,7 +166,8 @@ export class Screenshot extends KeepTrackPlugin {

tempCtx.fillStyle = classificationColor;

textWidth = tempCtx.measureText(classificationstr).width;
const textWidth = tempCtx.measureText(classificationstr).width;

tempCtx.fillText(classificationstr, cw / 2 - textWidth, ch - 20);
tempCtx.fillText(classificationstr, cw / 2 - textWidth, 34);
}
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/select-sat-manager/sat-info-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@ export class SatInfoBox extends KeepTrackPlugin {
getEl(SatInfoBox.containerId_).style.maxHeight = '80%';
document.documentElement.style.setProperty('--search-box-bottom', '0px');
getEl(SatInfoBox.containerId_).classList.remove('satinfo-fixed');

getEl('search-results').style.maxHeight = '80%';
});
}

Expand All @@ -1096,6 +1098,7 @@ export class SatInfoBox extends KeepTrackPlugin {
satInfobox.addEventListener('mousedown', (e: any) => {
if (e.button === 2) {
SatInfoBox.resetMenuLocation(satInfobox);
getEl('search-results').style.maxHeight = '';
}
});
}
Expand Down
169 changes: 72 additions & 97 deletions src/plugins/sensor/custom-sensor-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,104 +42,79 @@ export class CustomSensorPlugin extends KeepTrackPlugin {

sideMenuElementName: string = 'custom-sensor-menu';
sideMenuElementHtml: string = keepTrackApi.html`
<div class="row">
<form id="customSensor">
<div class="row">
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Name of the Sensor">
<input id="cs-uiName" type="text" value="Custom Sensor" />
<label for="cs-uiName" class="active">Sensor Name</label>
</div>
</div>
<div class="row">
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Latitude in Decimal Form (ex: 43.283)">
<input id="cs-lat" type="text" value="0" />
<label for="cs-lat" class="active">Latitude</label>
</div>
</div>
<div class="row">
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Longitude in Decimal Form (ex: -73.283)">
<input id="cs-lon" type="text" value="0" />
<label for="cs-lon" class="active">Longitude</label>
</div>
</div>
<div class="row">
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in kilometers (ex: 0.645)">
<input id="cs-hei" type="text" value="0" />
<label for="cs-hei" class="active">Elevation Above Sea Level (Km)</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<select id="cs-type">
<option value="Observer">Observer</option>
<option value="Optical">Optical</option>
<option value="Phased Array Radar">Phased Array Radar</option>
<option value="Mechanical">Mechanical</option>
</select>
<label>Type of Sensor</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div class="switch row" data-position="top" data-delay="50" data-tooltip="Is this Sensor a Telescope?">
<label>
<input id="cs-telescope" type="checkbox" checked="false" />
<span class="lever"></span>
Telescope
</label>
</div>
</div>
</div>
<div class="row">
<div id="cs-minaz-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Azimuth in degrees (ex: 50)">
<input id="cs-minaz" type="text" value="0" />
<label for="cs-minaz" class="active">Minimum Azimuth</label>
</div>
</div>
<div class="row">
<div id="cs-maxaz-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Azimuth in degrees (ex: 120)">
<input id="cs-maxaz" type="text" value="360" />
<label for="cs-maxaz" class="active">Maximum Azimuth</label>
</div>
</div>
<div class="row">
<div id="cs-minel-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in degrees (ex: 10)">
<input id="cs-minel" type="text" value="10" />
<label for="cs-minel" class="active">Minimum Elevation</label>
</div>
</div>
<div class="row">
<div id="cs-maxel-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in degrees (ex: 90)">
<input id="cs-maxel" type="text" value="90" />
<label for="cs-maxel" class="active">Maximum Elevation</label>
</div>
</div>
<div class="row">
<div id="cs-minrange-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Range in kilometers (ex: 500)">
<input id="cs-minrange" type="text" value="100" />
<label for="cs-minrange" class="active">Minimum Range</label>
</div>
</div>
<div class="row">
<div id="cs-maxrange-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Range in kilometers (ex: 20000)">
<input id="cs-maxrange" type="text" value="50000" />
<label for="cs-maxrange" class="active">Maximum Range</label>
</div>
</div>
<div class="center-align">
<button id="cs-replace" class="btn btn-ui waves-effect waves-light" name="action">Replace Sensor &#9658;</button>
<br />
<br />
<button id="cs-submit" class="btn btn-ui waves-effect waves-light" type="submit" name="action">Add Custom Sensor &#9658;</button>
<br />
<br />
<button id="cs-clear" class="btn btn-ui waves-effect waves-light" name="action">Clear Custom Sensors &#9658;</button>
<br />
<br />
<button id="cs-geolocation" class="btn btn-ui waves-effect waves-light" name="search">Use Geolocation &#9658;</button>
<form id="customSensor">
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Name of the Sensor">
<input id="cs-uiName" type="text" value="Custom Sensor" />
<label for="cs-uiName" class="active">Sensor Name</label>
</div>
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Latitude in Decimal Form (ex: 43.283)">
<input id="cs-lat" type="text" value="0" />
<label for="cs-lat" class="active">Latitude</label>
</div>
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Longitude in Decimal Form (ex: -73.283)">
<input id="cs-lon" type="text" value="0" />
<label for="cs-lon" class="active">Longitude</label>
</div>
<div class="input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in kilometers (ex: 0.645)">
<input id="cs-hei" type="text" value="0" />
<label for="cs-hei" class="active">Elevation Above Sea Level (Km)</label>
</div>
<div class="input-field col s12">
<select id="cs-type">
<option value="Observer">Observer</option>
<option value="Optical">Optical</option>
<option value="Phased Array Radar">Phased Array Radar</option>
<option value="Mechanical">Mechanical</option>
</select>
<label>Type of Sensor</label>
</div>
<div class="input-field col s12">
<div class="switch row" data-position="top" data-delay="50" data-tooltip="Is this Sensor a Telescope?">
<label>
<input id="cs-telescope" type="checkbox" checked="false" />
<span class="lever"></span>
Telescope
</label>
</div>
</form>
</div>`;
</div>
<div id="cs-minaz-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Azimuth in degrees (ex: 50)">
<input id="cs-minaz" type="text" value="0" />
<label for="cs-minaz" class="active">Minimum Azimuth</label>
</div>
<div id="cs-maxaz-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Azimuth in degrees (ex: 120)">
<input id="cs-maxaz" type="text" value="360" />
<label for="cs-maxaz" class="active">Maximum Azimuth</label>
</div>
<div id="cs-minel-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in degrees (ex: 10)">
<input id="cs-minel" type="text" value="10" />
<label for="cs-minel" class="active">Minimum Elevation</label>
</div>
<div id="cs-maxel-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Elevation in degrees (ex: 90)">
<input id="cs-maxel" type="text" value="90" />
<label for="cs-maxel" class="active">Maximum Elevation</label>
</div>
<div id="cs-minrange-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Range in kilometers (ex: 500)">
<input id="cs-minrange" type="text" value="100" />
<label for="cs-minrange" class="active">Minimum Range</label>
</div>
<div id="cs-maxrange-div" class="start-hidden input-field col s12" data-position="top" data-delay="50" data-tooltip="Range in kilometers (ex: 20000)">
<input id="cs-maxrange" type="text" value="50000" />
<label for="cs-maxrange" class="active">Maximum Range</label>
</div>
<div class="center-align">
<button id="cs-replace" class="btn btn-ui waves-effect waves-light" name="action">Replace Sensor &#9658;</button>
<br />
<br />
<button id="cs-submit" class="btn btn-ui waves-effect waves-light" type="submit" name="action">Add Custom Sensor &#9658;</button>
<br />
<br />
<button id="cs-clear" class="btn btn-ui waves-effect waves-light" name="action">Clear Custom Sensors &#9658;</button>
<br />
<br />
<button id="cs-geolocation" class="btn btn-ui waves-effect waves-light" name="search">Use Geolocation &#9658;</button>
</div>
</form>
`;
sideMenuSettingsHtml: string = keepTrackApi.html`
<div class="row" style="margin: 0 10px;">
<div id="custom-sensors-sensor-list">
Expand Down
13 changes: 11 additions & 2 deletions src/plugins/sensor/look-angles-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ export class LookAnglesPlugin extends KeepTrackPlugin {
this.lastlooksArray_ = looksArray;

// Populate the Side Menu
LookAnglesPlugin.populateSideMenuTable_(looksArray, timeManagerInstance);
this.populateSideMenuTable_(looksArray, timeManagerInstance);

return looksArray;
}

private static populateSideMenuTable_(lookAngleData: TearrData[], timeManagerInstance: TimeManager) {
private populateSideMenuTable_(lookAngleData: TearrData[], timeManagerInstance: TimeManager) {
const tbl = <HTMLTableElement>getEl('looks'); // Identify the table to update

tbl.innerHTML = ''; // Clear the table from old object data
Expand Down Expand Up @@ -299,6 +299,15 @@ export class LookAnglesPlugin extends KeepTrackPlugin {
for (const lookAngleRow of lookAngleData) {
LookAnglesPlugin.populateSideMenuRow_({ tbl, tdT, lookAngleRow, timeManagerInstance, tdE, tdA, tdR, tdType });
}

if (lookAngleData.length === 0) {
const tr = tbl.insertRow();
const td = tr.insertCell();
const searchLength = (this.lengthOfLookAngles_ * 24).toFixed(1);

td.colSpan = 4;
td.appendChild(document.createTextNode(`Satellite is not visible for the next ${searchLength} hours.`));
}
}

private static populateSideMenuRow_(
Expand Down
27 changes: 20 additions & 7 deletions src/plugins/sensor/multi-site-look-angles-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,25 @@ export class MultiSiteLookAnglesPlugin extends KeepTrackPlugin {

const sensorButton = document.createElement('button');

sensorButton.classList.add('btn', 'btn-ui', 'waves-effect', 'waves-light');
sensorButton.classList.add('btn', 'darken-3', 'btn-ui', 'waves-effect', 'waves-light');
if (this.disabledSensors_.includes(sensor)) {
sensorButton.classList.add('btn-red');
sensorButton.classList.add('red');
} else {
sensorButton.classList.add('green');
}

allSensors.push(sensor);

sensorButton.innerText = sensor.uiName ?? sensor.shortName ?? sensor.objName;
sensorButton.addEventListener('click', () => {
if (sensorButton.classList.contains('btn-red')) {
sensorButton.classList.remove('btn-red');
if (sensorButton.classList.contains('red')) {
sensorButton.classList.remove('red');
sensorButton.classList.add('green');
this.disabledSensors_.splice(this.disabledSensors_.indexOf(sensor), 1);
keepTrackApi.getSoundManager().play(SoundNames.TOGGLE_ON);
} else {
sensorButton.classList.add('btn-red');
sensorButton.classList.add('red');
sensorButton.classList.remove('green');
this.disabledSensors_.push(sensor);
keepTrackApi.getSoundManager().play(SoundNames.TOGGLE_OFF);
}
Expand Down Expand Up @@ -259,7 +263,7 @@ export class MultiSiteLookAnglesPlugin extends KeepTrackPlugin {
// eslint-disable-next-line no-unused-expressions
isResetToDefault ? sensorManagerInstance.setCurrentSensor(null) : sensorManagerInstance.setCurrentSensor(tempSensor);

MultiSiteLookAnglesPlugin.populateMultiSiteTable_(multiSiteArray);
this.populateMultiSiteTable_(multiSiteArray);
}

private static propagateMultiSite_(now: Date, satrec: SatelliteRecord, sensor: DetailedSensor): TearrData {
Expand All @@ -286,7 +290,7 @@ export class MultiSiteLookAnglesPlugin extends KeepTrackPlugin {

}

private static populateMultiSiteTable_(multiSiteArray: TearrData[]) {
private populateMultiSiteTable_(multiSiteArray: TearrData[]) {
const sensorManagerInstance = keepTrackApi.getSensorManager();
const staticSet = keepTrackApi.getCatalogManager().staticSet;

Expand Down Expand Up @@ -341,5 +345,14 @@ export class MultiSiteLookAnglesPlugin extends KeepTrackPlugin {
sensorManagerInstance.setSensor(sensor, sensor.sensorId);
});
}

if (multiSiteArray.length === 0) {
const tr = tbl.insertRow();
const td = tr.insertCell();
const searchLength = (this.lengthOfLookAngles_ * 24).toFixed(1);

td.colSpan = 4;
td.appendChild(document.createTextNode(`Satellite is not visible for the next ${searchLength} hours.`));
}
}
}
Loading
Loading