mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Merge main into codex/fix-cctv-session-admission
Main's Street View budget tests in the media feed-type file now mount the provider through the shared CCTV test harness, which also resets the Google rate-limit setting.
This commit is contained in:
commit
23efd3b343
196 files changed
+21064
-562
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { followedOf } from '../data/followed.js';
|
||||
import { readEntityRecord } from '../data/entityRecords.js';
|
||||
import { nextTick } from 'vue';
|
||||
import { nextTick, watch } from 'vue';
|
||||
import { resolveImageryHost } from '../layers/weather/imageryHost.js';
|
||||
import { ShellFacade } from './shellFacade.js';
|
||||
import { AircraftDisplay } from './aircraftDisplay.js';
|
||||
@@ -25,6 +25,7 @@ import { CctvControls } from './cctv.js';
|
||||
import { StreetLevelControls } from './streetLevelControls.js';
|
||||
import { createWildlifeSightingCard } from './wildlifeSightingCard.js';
|
||||
import { RadioControls } from './radio.js';
|
||||
import { LiveControls } from './liveControls.js';
|
||||
import { LocalSdrControls } from './localSdrControls.js';
|
||||
import { LocationNavigation } from './locationNavigation.js';
|
||||
import { bindCameraOrientationControls } from './cameraOrientationControls.js';
|
||||
@@ -62,6 +63,8 @@ import { applyLocaleChoice } from './localePicker.js';
|
||||
import { PanelNavigation } from './panelNavigation.js';
|
||||
import { applicationPinia, createUiRuntime } from './vueRuntime.js';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { useStationStore } from './stores/station.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
import { useMissionReplayStore } from './stores/missionReplay.js';
|
||||
@@ -1034,8 +1037,12 @@ export class StyleManager extends ShellFacade {
|
||||
}
|
||||
|
||||
_initGlobalContextPanel() {
|
||||
const { radioLayer, militaryInstallationsLayer, militaryAwarenessLayer } =
|
||||
this.services;
|
||||
const {
|
||||
radioLayer,
|
||||
militaryInstallationsLayer,
|
||||
militaryAwarenessLayer,
|
||||
satellitesLayer,
|
||||
} = this.services;
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
this._contextControls = new ContextControls({
|
||||
elements: {
|
||||
@@ -1075,6 +1082,39 @@ export class StyleManager extends ShellFacade {
|
||||
militaryAwarenessLayer?.subscribeDirectionOverlay?.((view) =>
|
||||
awarenessDirectionStore.publish(view),
|
||||
);
|
||||
// The STATION section: the selected space station's moving parts, as
|
||||
// the satellites layer presents them; its controls reach the layer.
|
||||
const stationStore = useStationStore(applicationPinia());
|
||||
this._stationPanelUnsubscribe?.();
|
||||
if (this._stationOwner) stationStore.detach(this._stationOwner);
|
||||
this._stationOwner = null;
|
||||
stationStore.publish(null);
|
||||
if (satellitesLayer?.getStationActions)
|
||||
this._stationOwner = stationStore.connect(
|
||||
satellitesLayer.getStationActions(),
|
||||
);
|
||||
this._stationPanelUnsubscribe = satellitesLayer?.subscribeStationPanel?.(
|
||||
(view) => stationStore.publish(view),
|
||||
);
|
||||
// The LIVE section: streams attached to whatever the tracking layers
|
||||
// select, in the platform's own player, loaded only once Play is pressed.
|
||||
this._liveControls?.destroy();
|
||||
const liveStore = useLiveStore(applicationPinia());
|
||||
this._liveControls = new LiveControls({
|
||||
store: liveStore,
|
||||
actions: {
|
||||
getLayer: (layerId) =>
|
||||
this._dataManager?.layers?.get(layerId)?.module ?? null,
|
||||
scheduleLayout: () => this._scheduleRightPanelLayout(),
|
||||
},
|
||||
});
|
||||
// The Cockpit briefing offers its LIVE page while a stream is on offer.
|
||||
this._liveOfferedUnwatch?.();
|
||||
this._liveOfferedUnwatch = watch(
|
||||
() => liveStore.view !== null,
|
||||
(offered) => this.cockpitView?.setBriefLiveOffered?.(offered),
|
||||
{ immediate: true },
|
||||
);
|
||||
}
|
||||
|
||||
_initSpaceMissionsPanel() {
|
||||
@@ -1975,6 +2015,14 @@ export class StyleManager extends ShellFacade {
|
||||
this.services?.streetLevelLayer?.attachNavigation?.(null);
|
||||
this._streetLevelControls?.destroy();
|
||||
this._radioControls?.destroy();
|
||||
this._liveControls?.destroy();
|
||||
this._liveOfferedUnwatch?.();
|
||||
this._liveOfferedUnwatch = null;
|
||||
this._stationPanelUnsubscribe?.();
|
||||
this._stationPanelUnsubscribe = null;
|
||||
if (this._stationOwner)
|
||||
useStationStore(applicationPinia()).detach(this._stationOwner);
|
||||
this._stationOwner = null;
|
||||
this._localSdrControls?.destroy();
|
||||
this._awarenessPanelUnsubscribe?.();
|
||||
this._awarenessPanelUnsubscribe = null;
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
// src/ui/cctvPickerOpening.test.mjs — the picker and the opening camera.
|
||||
// The opening camera follows the view until someone picks one. The picker
|
||||
// shows it as its own option; a native select fires no change for the
|
||||
// option it already shows, so FOCUS keeps that camera, and leaving the list
|
||||
// without a choice lets it follow the view.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import cctvLayer, {
|
||||
_setCctvCoverageStateForTest,
|
||||
_setCctvOverlayHostForTest,
|
||||
reopenNearestCamera,
|
||||
} from '../data/cctv.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { CctvControls } from './cctvControls.js';
|
||||
import { useCctvStore } from './stores/cctv.js';
|
||||
import CctvPanel from './views/panels/CctvPanel.vue';
|
||||
|
||||
const TRAFALGAR = [51.508, -0.128];
|
||||
const CAMBRIDGE = [51.513, -0.129];
|
||||
|
||||
function record(id, [lat, lon]) {
|
||||
return {
|
||||
camera: {
|
||||
id,
|
||||
name: `Camera ${id}`,
|
||||
city: 'London',
|
||||
lat,
|
||||
lon,
|
||||
headingDeg: 41,
|
||||
pitchDeg: -5,
|
||||
fovDeg: 56,
|
||||
rangeM: 210,
|
||||
mountHeightM: 100,
|
||||
groundElevationM: 0,
|
||||
},
|
||||
coverageEntities: [],
|
||||
projection: null,
|
||||
activationDone: true,
|
||||
groundResolved: {},
|
||||
groundSamples: {},
|
||||
groundPrior: 0,
|
||||
frustumGeometry: null,
|
||||
frustumPositions: null,
|
||||
probeClampRangeM: null,
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, lat, 100),
|
||||
};
|
||||
}
|
||||
|
||||
function viewerAt([lat, lon]) {
|
||||
const viewer = {
|
||||
isDestroyed: () => false,
|
||||
eye: { lat, lon, height: 300 },
|
||||
scene: {
|
||||
canvas: { clientWidth: 1200, clientHeight: 800 },
|
||||
cartesianToCanvasCoordinates: () => undefined,
|
||||
primitives: { add: (p) => p, remove: () => true },
|
||||
requestRender() {},
|
||||
},
|
||||
};
|
||||
// The layer reads the eye and flies through the renderer's camera port.
|
||||
viewer.draw = bindFakeDraw(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ ...viewer.eye }),
|
||||
on: () => () => {},
|
||||
followed: null,
|
||||
flyToBounds() {},
|
||||
},
|
||||
}).draw;
|
||||
return viewer;
|
||||
}
|
||||
|
||||
/** A settled move: the view is now over `[lat, lon]`. */
|
||||
function settleOver(viewer, [lat, lon]) {
|
||||
viewer.eye = { lat, lon, height: 300 };
|
||||
return reopenNearestCamera();
|
||||
}
|
||||
|
||||
/**
|
||||
* CCTV opened at Trafalgar Square, then a settled move re-opened it at
|
||||
* Cambridge Circus; the panel is connected to the layer.
|
||||
*/
|
||||
async function reopenedAtCambridge(t) {
|
||||
_setCctvOverlayHostForTest({
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
});
|
||||
// Activation builds the frame image and asks for ground heights; this test
|
||||
// has no server. happy-dom's request timeout would hold the run open 30 s.
|
||||
const originalImage = globalThis.Image;
|
||||
const originalFetch = globalThis.fetch;
|
||||
const originalTimeout = AbortSignal.timeout;
|
||||
globalThis.Image = class {};
|
||||
globalThis.fetch = async () => {
|
||||
throw new TypeError('no server in this test');
|
||||
};
|
||||
AbortSignal.timeout = () => new AbortController().signal;
|
||||
const trafalgar = record('a-trafalgar', TRAFALGAR);
|
||||
const cambridge = record('b-cambridge', CAMBRIDGE);
|
||||
// enable() assigned the opening camera without activating it.
|
||||
trafalgar.activationDone = false;
|
||||
const viewer = viewerAt(TRAFALGAR);
|
||||
_setCctvCoverageStateForTest({
|
||||
viewer,
|
||||
records: [trafalgar, cambridge],
|
||||
activeCameraId: 'a-trafalgar',
|
||||
enabled: true,
|
||||
openingCameraProvisional: true,
|
||||
});
|
||||
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(CctvPanel).use(pinia);
|
||||
app.mount(host);
|
||||
const select = document.getElementById('cctv-camera-select');
|
||||
const controls = new CctvControls({
|
||||
elements: {
|
||||
_cctvPanel: document.getElementById('cctv-panel'),
|
||||
_cctvSelect: select,
|
||||
_cctvFocusBtn: document.getElementById('cctv-focus-btn'),
|
||||
},
|
||||
cctv: cctvLayer,
|
||||
actions: {
|
||||
isEnabled: () => true,
|
||||
toggleEnabled: async () => true,
|
||||
runExplicitFocus(select, focus) {
|
||||
const cameraId = select();
|
||||
if (cameraId) focus(cameraId);
|
||||
},
|
||||
setParams: (params) => cctvLayer.setParams(params),
|
||||
setPanelCollapsed() {},
|
||||
syncViewport() {},
|
||||
},
|
||||
store: useCctvStore(pinia),
|
||||
});
|
||||
controls.connect();
|
||||
t.after(() => {
|
||||
controls.destroy();
|
||||
app.unmount();
|
||||
globalThis.Image = originalImage;
|
||||
globalThis.fetch = originalFetch;
|
||||
AbortSignal.timeout = originalTimeout;
|
||||
_setCctvOverlayHostForTest();
|
||||
_setCctvCoverageStateForTest({ enabled: false });
|
||||
});
|
||||
|
||||
assert.equal(settleOver(viewer, CAMBRIDGE), true);
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
return { viewer, select };
|
||||
}
|
||||
|
||||
test('the opening camera shows as its own option', async (t) => {
|
||||
const { select } = await reopenedAtCambridge(t);
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
const shown = select.options[select.selectedIndex];
|
||||
assert.equal(shown.hidden, false);
|
||||
assert.equal(shown.disabled, false);
|
||||
assert.equal(
|
||||
[...select.options].filter((option) => option.value === 'b-cambridge')
|
||||
.length,
|
||||
1,
|
||||
'the list shows the camera once',
|
||||
);
|
||||
assert.ok([...select.options].every((option) => !option.hidden));
|
||||
});
|
||||
|
||||
test('FOCUS on the shown camera keeps it after a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
const focus = document.getElementById('cctv-focus-btn');
|
||||
assert.equal(focus.disabled, false);
|
||||
focus.click();
|
||||
// The click handler waits for the layer switch before it picks.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), false);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
});
|
||||
|
||||
test('leaving the picker without a pick lets the camera follow a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
select.focus();
|
||||
select.blur();
|
||||
await nextTick();
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), true);
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'a-trafalgar');
|
||||
assert.equal(select.value, 'a-trafalgar');
|
||||
});
|
||||
@@ -46,6 +46,48 @@ export const COCKPIT_BRIEF_PAGES = [
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* The fourth page, LIVE: the ridden subject's live video, the LIVE section
|
||||
* of Context in the card. Offered only while a stream is on offer (the
|
||||
* `gev-live` store's view is not null); the automatic cycle never turns to it.
|
||||
*/
|
||||
export const COCKPIT_LIVE_BRIEF_PAGE = Object.freeze({
|
||||
id: 'live',
|
||||
kickerKey: msg('LIVE VIDEO'),
|
||||
subtitleKey: msg('STREAM ATTACHED TO THE SUBJECT'),
|
||||
// Attribution stays English; the page itself credits the stream's owner.
|
||||
source: 'YOUTUBE EMBEDDED PLAYER · MUTED',
|
||||
});
|
||||
|
||||
/**
|
||||
* The pages on offer: the three fixed ones, and LIVE after them while the
|
||||
* ridden subject has a stream.
|
||||
* @param {boolean} liveOffered
|
||||
* @returns {readonly object[]}
|
||||
*/
|
||||
export function cockpitBriefPages(liveOffered) {
|
||||
return liveOffered
|
||||
? [...COCKPIT_BRIEF_PAGES, COCKPIT_LIVE_BRIEF_PAGE]
|
||||
: COCKPIT_BRIEF_PAGES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the automatic cycle goes from the page at `index`: the next page
|
||||
* that is not LIVE (video is never started by the cycle), wrapping; null
|
||||
* while LIVE is the shown page, where the cycle waits as it does under the
|
||||
* pointer.
|
||||
* @param {readonly object[]} pages
|
||||
* @param {number} index
|
||||
* @returns {number|null}
|
||||
*/
|
||||
export function briefCycleTarget(pages, index) {
|
||||
if (pages[index]?.id === 'live') return null;
|
||||
const count = pages.length;
|
||||
let next = (index + 1) % count;
|
||||
if (pages[next]?.id === 'live') next = (next + 1) % count;
|
||||
return next;
|
||||
}
|
||||
|
||||
// The cycle toggle's tooltip, as literal keys for the extractor.
|
||||
export const CYCLE_HELP_KEYS = Object.freeze({
|
||||
on: msg(
|
||||
|
||||
@@ -9,8 +9,9 @@ import {
|
||||
formatCockpitWindDirection,
|
||||
} from './cockpitPresentation.js';
|
||||
import {
|
||||
COCKPIT_BRIEF_PAGES,
|
||||
CYCLE_HELP_KEYS,
|
||||
briefCycleTarget,
|
||||
cockpitBriefPages,
|
||||
createBriefState,
|
||||
newsWindowFooter,
|
||||
} from './cockpitBriefPages.js';
|
||||
@@ -48,11 +49,17 @@ export function publishBriefView() {
|
||||
});
|
||||
}
|
||||
|
||||
/** The pages on offer now: three, or four with LIVE while a stream is. */
|
||||
function briefPages() {
|
||||
return cockpitBriefPages(this.briefLiveOffered === true);
|
||||
}
|
||||
|
||||
export function showBriefPage(index, { manual = false } = {}) {
|
||||
if (this.destroyed) return;
|
||||
const count = COCKPIT_BRIEF_PAGES.length;
|
||||
const pages = briefPages.call(this);
|
||||
const count = pages.length;
|
||||
this.briefPageIndex = ((Number(index) % count) + count) % count;
|
||||
const page = COCKPIT_BRIEF_PAGES[this.briefPageIndex];
|
||||
const page = pages[this.briefPageIndex];
|
||||
Object.assign(this.brief, {
|
||||
pageIndex: this.briefPageIndex,
|
||||
pageId: page.id,
|
||||
@@ -101,6 +108,20 @@ export function relocalizeBrief() {
|
||||
this.renderRegionalBriefStatus(this.brief.news.state, this.lastSubjectInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offer or withdraw the LIVE page, as the ridden subject's stream comes and
|
||||
* goes. A LIVE page shown as its stream goes falls back to Live Signals;
|
||||
* otherwise the shown page stays and its position counts the pages anew.
|
||||
*/
|
||||
export function setBriefLiveOffered(offered) {
|
||||
if (this.destroyed) return;
|
||||
const next = offered === true;
|
||||
if (next === this.briefLiveOffered) return;
|
||||
this.briefLiveOffered = next;
|
||||
const count = cockpitBriefPages(next).length;
|
||||
this.showBriefPage(this.briefPageIndex < count ? this.briefPageIndex : 0);
|
||||
}
|
||||
|
||||
export function setBriefAutoRotate(enabled) {
|
||||
if (this.destroyed) return;
|
||||
this.briefAutoRotateEnabled = Boolean(enabled);
|
||||
@@ -129,7 +150,13 @@ export function startBriefRotation({ reset = false } = {}) {
|
||||
this.signalStream?.contains(document.activeElement) === true;
|
||||
const isInteracting = hasPointer || hasFocus;
|
||||
if (!isInteracting) {
|
||||
this.showBriefPage(this.briefPageIndex + 1);
|
||||
// The cycle never turns to the LIVE page, and waits while it is shown:
|
||||
// video starts and stops on request only.
|
||||
const target = briefCycleTarget(
|
||||
briefPages.call(this),
|
||||
this.briefPageIndex,
|
||||
);
|
||||
if (target !== null) this.showBriefPage(target);
|
||||
}
|
||||
this.startBriefRotation();
|
||||
}, COCKPIT_BRIEF_ROTATE_MS);
|
||||
|
||||
@@ -8,18 +8,24 @@ import { fileURLToPath } from 'node:url';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { createBriefState } from './cockpitBriefPages.js';
|
||||
import {
|
||||
briefCycleTarget,
|
||||
cockpitBriefPages,
|
||||
createBriefState,
|
||||
} from './cockpitBriefPages.js';
|
||||
import {
|
||||
maybeRefreshRegionalBrief,
|
||||
publishBriefView,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
setBriefAutoRotate,
|
||||
setBriefLiveOffered,
|
||||
showBriefPage,
|
||||
updateLocalPosition,
|
||||
} from './cockpitBriefing.js';
|
||||
import { setSignalCollapsed } from './cockpitLayout.js';
|
||||
import { useCockpitStore } from './stores/cockpit.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import CockpitBriefing from './views/panels/CockpitBriefing.vue';
|
||||
|
||||
function fixture(t) {
|
||||
@@ -35,9 +41,11 @@ function fixture(t) {
|
||||
destroyed: false,
|
||||
briefPageIndex: 0,
|
||||
briefAutoRotateEnabled: false,
|
||||
briefLiveOffered: false,
|
||||
brief: createBriefState(),
|
||||
publishBrief: (view) => store.publishBrief(view),
|
||||
publishBriefView,
|
||||
showBriefPage,
|
||||
scheduleContextLayout() {},
|
||||
startBriefRotation() {},
|
||||
stopBriefRotation() {},
|
||||
@@ -49,11 +57,50 @@ function fixture(t) {
|
||||
[...document.querySelectorAll('[data-cockpit-brief-page]')]
|
||||
.filter((page) => !page.hidden)
|
||||
.map((page) => page.dataset.cockpitBriefPage);
|
||||
// The tabs on offer: the LIVE tab is in the markup but hidden without a stream.
|
||||
const current = () =>
|
||||
[...document.querySelectorAll('[data-cockpit-brief-index]')].map((tab) =>
|
||||
tab.getAttribute('aria-current'),
|
||||
[...document.querySelectorAll('[data-cockpit-brief-index]')]
|
||||
.filter((tab) => !tab.hidden)
|
||||
.map((tab) => tab.getAttribute('aria-current'));
|
||||
// A stream on offer for the ridden subject, as LiveControls publishes it;
|
||||
// the briefing then offers its LIVE page.
|
||||
const liveStore = useLiveStore(pinia);
|
||||
const liveActed = [];
|
||||
liveStore.connect({
|
||||
cycleLive: (direction) => liveActed.push(['cycle', direction]),
|
||||
playLive: () => liveActed.push(['play']),
|
||||
stopLive: () => liveActed.push(['stop']),
|
||||
retryLive: () => liveActed.push(['retry']),
|
||||
hideLive: (where) => liveActed.push(['hide', where]),
|
||||
});
|
||||
const offerLive = async (view) => {
|
||||
liveStore.publish(
|
||||
view && {
|
||||
label: 'ISS (ZARYA)',
|
||||
streams: [
|
||||
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
|
||||
{ id: 'iss-crew', title: 'Live video and audio', owner: 'NASA' },
|
||||
],
|
||||
index: 0,
|
||||
count: 2,
|
||||
current: {
|
||||
id: 'iss-exterior',
|
||||
title: 'Exterior cameras',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: 'NASA video, via YouTube',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
},
|
||||
state: 'idle',
|
||||
reason: null,
|
||||
...view,
|
||||
},
|
||||
);
|
||||
return { $, text, owner, visiblePages, current };
|
||||
setBriefLiveOffered.call(owner, view !== null);
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
return { $, text, owner, visiblePages, current, offerLive, liveActed };
|
||||
}
|
||||
|
||||
const INFO = { latitude: 30.25, longitude: -97.75 };
|
||||
@@ -111,6 +158,157 @@ test('pages, the cycle toggle and the source follow the controller', async (t) =
|
||||
assert.match(auto.title, /^Stop automatic page cycling/);
|
||||
});
|
||||
|
||||
test('without a stream the briefing keeps its three pages and hides the LIVE tab', async (t) => {
|
||||
const { $, text, owner, visiblePages } = fixture(t);
|
||||
const liveTab = $('[data-cockpit-brief-index="3"]');
|
||||
assert.equal(liveTab.hidden, true);
|
||||
assert.equal(liveTab.textContent, 'LIVE');
|
||||
assert.equal(liveTab.getAttribute('aria-label'), 'Show Live Video');
|
||||
assert.equal(
|
||||
$('[data-cockpit-brief-page="live"]').querySelector('*'),
|
||||
null,
|
||||
'no page body without a stream',
|
||||
);
|
||||
// Next from Local wraps to Live Signals, past the page not on offer.
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 3');
|
||||
});
|
||||
|
||||
test('with a stream the LIVE page is the fourth, reached by the arrows and its tab', async (t) => {
|
||||
const { $, text, owner, visiblePages, current, offerLive } = fixture(t);
|
||||
await offerLive({});
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 4');
|
||||
const liveTab = $('[data-cockpit-brief-index="3"]');
|
||||
assert.equal(liveTab.hidden, false);
|
||||
assert.deepEqual(current(), ['true', 'false', 'false', 'false']);
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, owner.briefPageIndex + 1);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['live']);
|
||||
assert.deepEqual(current(), ['false', 'false', 'false', 'true']);
|
||||
assert.equal(text('#cockpit-brief-kicker'), 'LIVE VIDEO');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-subtitle'),
|
||||
'STREAM ATTACHED TO THE SUBJECT',
|
||||
);
|
||||
assert.equal(text('#cockpit-brief-position'), '4 / 4');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'YOUTUBE EMBEDDED PLAYER · MUTED',
|
||||
);
|
||||
assert.equal($('#cockpit-signal-stream').dataset.briefPage, 'live');
|
||||
// The page shows what the LIVE section shows, with the player's own screen.
|
||||
const page = $('[data-cockpit-brief-page="live"]');
|
||||
assert.equal(
|
||||
page.querySelector('.cockpit-live-subject strong').textContent,
|
||||
'ISS (ZARYA)',
|
||||
);
|
||||
assert.equal(text('#cockpit-live-stream-title'), 'Exterior cameras · 1/2');
|
||||
assert.ok($('#cockpit-live-player-host'));
|
||||
assert.ok($('#cockpit-live-previous'));
|
||||
assert.ok($('#cockpit-live-next'));
|
||||
assert.equal(text('#cockpit-live-badge-text'), 'OFF');
|
||||
assert.equal(text('#cockpit-live-status'), 'Click to play');
|
||||
assert.ok($('#cockpit-live-play'), 'Play, under the IP notice');
|
||||
assert.match(
|
||||
page.querySelector('.cockpit-live-privacy').textContent,
|
||||
/sees your IP address/,
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-live-watch-link').getAttribute('href'),
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
);
|
||||
// Next from LIVE wraps to Live Signals.
|
||||
showBriefPage.call(owner, owner.briefPageIndex + 1);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 4');
|
||||
});
|
||||
|
||||
test('the LIVE page loads the stream only on Play, stops it when left, and its controls reach LiveControls', async (t) => {
|
||||
const { $, owner, offerLive, liveActed } = fixture(t);
|
||||
await offerLive({});
|
||||
assert.deepEqual(liveActed, [], 'riding the station loads no player');
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
$('#cockpit-live-play').click();
|
||||
assert.deepEqual(liveActed, [['play']]);
|
||||
await offerLive({ state: 'playing' });
|
||||
const page = $('[data-cockpit-brief-page="live"]');
|
||||
assert.equal($('#cockpit-live-badge-text').textContent, 'ON AIR');
|
||||
assert.equal(
|
||||
page.querySelector('.live-dot').classList.contains('on-air'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
page.querySelector('.live-screen').classList.contains('active'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('#cockpit-live-status').textContent, 'Live');
|
||||
$('#cockpit-live-next').click();
|
||||
$('#cockpit-live-previous').click();
|
||||
assert.deepEqual(liveActed, [['play'], ['cycle', 1], ['cycle', -1]]);
|
||||
// Leaving the page stops what plays there.
|
||||
showBriefPage.call(owner, 0);
|
||||
await nextTick();
|
||||
assert.deepEqual(liveActed.at(-1), ['hide', 'cockpit']);
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
await offerLive({ state: 'offline', reason: 'timeout' });
|
||||
const card = page.querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('offline'), true);
|
||||
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
|
||||
$('#cockpit-live-retry').click();
|
||||
assert.deepEqual(liveActed.at(-1), ['retry']);
|
||||
await offerLive({ state: 'unavailable', reason: 'error-150' });
|
||||
assert.equal($('#cockpit-live-retry'), null);
|
||||
assert.equal(
|
||||
$('#cockpit-live-status').textContent,
|
||||
'This stream cannot play here',
|
||||
);
|
||||
});
|
||||
|
||||
test('the stream going while LIVE is shown falls back to Live Signals with three pages', async (t) => {
|
||||
const { $, text, owner, visiblePages, offerLive } = fixture(t);
|
||||
await offerLive({});
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['live']);
|
||||
await offerLive(null);
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 3');
|
||||
assert.equal($('[data-cockpit-brief-index="3"]').hidden, true);
|
||||
// Going on another page, the page stays and only the count changes.
|
||||
showBriefPage.call(owner, 1);
|
||||
await offerLive({});
|
||||
assert.deepEqual(visiblePages(), ['news']);
|
||||
assert.equal(text('#cockpit-brief-position'), '2 / 4');
|
||||
// Offering what is already offered changes nothing.
|
||||
const views = [];
|
||||
owner.publishBrief = (view) => views.push(view);
|
||||
setBriefLiveOffered.call(owner, true);
|
||||
assert.equal(views.length, 0);
|
||||
});
|
||||
|
||||
test('the automatic cycle never turns to the LIVE page and waits while it is shown', () => {
|
||||
const three = cockpitBriefPages(false);
|
||||
assert.deepEqual(
|
||||
[0, 1, 2].map((index) => briefCycleTarget(three, index)),
|
||||
[1, 2, 0],
|
||||
);
|
||||
const four = cockpitBriefPages(true);
|
||||
assert.equal(four.length, 4);
|
||||
assert.equal(four[3].id, 'live');
|
||||
assert.deepEqual(
|
||||
[0, 1, 2].map((index) => briefCycleTarget(four, index)),
|
||||
[1, 2, 0],
|
||||
'Local goes back to Live Signals, past LIVE',
|
||||
);
|
||||
assert.equal(briefCycleTarget(four, 3), null, 'shown by hand, LIVE stays');
|
||||
});
|
||||
|
||||
test('regional news and local conditions render what the region returned', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
renderRegionalBriefStatus.call(owner, 'loading', INFO);
|
||||
|
||||
@@ -26,10 +26,12 @@ import {
|
||||
import { update } from './cockpitCamera.js';
|
||||
import {
|
||||
beginOrbital,
|
||||
orbitalViewSignal,
|
||||
endOrbital,
|
||||
resetOrbitalLook,
|
||||
jumpToSensorSwath,
|
||||
onOrbitalWheel,
|
||||
stepOrbitalMount,
|
||||
stepOrbitalZoom,
|
||||
turnOrbitalLook,
|
||||
updateOrbital,
|
||||
@@ -77,6 +79,7 @@ import {
|
||||
publishBriefView,
|
||||
showBriefPage,
|
||||
setBriefAutoRotate,
|
||||
setBriefLiveOffered,
|
||||
startBriefRotation,
|
||||
stopBriefRotation,
|
||||
updateLocalPosition,
|
||||
@@ -273,6 +276,8 @@ export class CockpitViewController {
|
||||
this.signalSignatures = new Map();
|
||||
this.briefPageIndex = 0;
|
||||
this.briefAutoRotateEnabled = false;
|
||||
/** Whether the briefing offers its LIVE page (the subject has a stream). */
|
||||
this.briefLiveOffered = false;
|
||||
// Cockpit's views render what these receive.
|
||||
this.publishPresence = publish.presence ?? (() => {});
|
||||
this.publishBrief = publish.brief ?? (() => {});
|
||||
@@ -403,6 +408,10 @@ export class CockpitViewController {
|
||||
else if (target?.closest?.('#cockpit-orbital-zoom-out'))
|
||||
this.stepOrbitalZoom(-1);
|
||||
else if (target?.closest?.('#cockpit-orbital-nadir')) this.orbitalNadir();
|
||||
else if (target?.closest?.('#cockpit-orbital-view-next'))
|
||||
this.nextOrbitalView();
|
||||
else if (target?.closest?.('#cockpit-orbital-view-previous'))
|
||||
this.previousOrbitalView();
|
||||
else if (target?.closest?.('#cockpit-orbital-sensor'))
|
||||
this.jumpToSensorSwath();
|
||||
});
|
||||
@@ -456,6 +465,26 @@ export class CockpitViewController {
|
||||
beginOrbital() {
|
||||
return beginOrbital.call(this);
|
||||
}
|
||||
|
||||
orbitalViewSignal(info) {
|
||||
return orbitalViewSignal.call(this, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's right arrow: step to the station's next view.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
nextOrbitalView() {
|
||||
return stepOrbitalMount.call(this, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's left arrow: step back to the view before.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
previousOrbitalView() {
|
||||
return stepOrbitalMount.call(this, -1);
|
||||
}
|
||||
endOrbital() {
|
||||
return endOrbital.call(this);
|
||||
}
|
||||
@@ -713,6 +742,9 @@ export class CockpitViewController {
|
||||
setBriefAutoRotate(enabled) {
|
||||
return setBriefAutoRotate.call(this, enabled);
|
||||
}
|
||||
setBriefLiveOffered(offered) {
|
||||
return setBriefLiveOffered.call(this, offered);
|
||||
}
|
||||
startBriefRotation(options) {
|
||||
return startBriefRotation.call(this, options);
|
||||
}
|
||||
|
||||
@@ -116,8 +116,19 @@ function sitePosition(site) {
|
||||
: null;
|
||||
}
|
||||
|
||||
/** The mapped site a canvas position shows, through the layer's picks. */
|
||||
/**
|
||||
* The mapped site a canvas position shows: through the layer's own lookup
|
||||
* where it has one (`findAt`: the dot, the site entity or the label box the
|
||||
* overlay paints, which is what a click lands on from orbit), else through
|
||||
* its pick ids.
|
||||
*/
|
||||
function siteAt(controller, position) {
|
||||
try {
|
||||
const found = sitesLayer(controller)?.findAt?.(position) ?? null;
|
||||
if (found) return found;
|
||||
} catch {
|
||||
// Fall through to the pick ids.
|
||||
}
|
||||
let picked = null;
|
||||
try {
|
||||
picked = findQuery(controller.viewer)?.pick(position.x, position.y) ?? null;
|
||||
@@ -289,8 +300,9 @@ export function routeSceneClick() {
|
||||
}
|
||||
return input.onClick((event) => {
|
||||
// Another layer's card or label painted on top takes the click: the site
|
||||
// under it does not focus, and the click does not end a held focus.
|
||||
if (isUnderOtherCard(event)) return;
|
||||
// under it does not focus, and the click does not end a held focus. A
|
||||
// site's own label is not another layer's: it focuses that site.
|
||||
if (isUnderOtherCard(event, [SITES_LAYER_ID])) return;
|
||||
this.onOrbitalClick(event?.position);
|
||||
});
|
||||
}
|
||||
@@ -303,15 +315,26 @@ export function routeSceneClick() {
|
||||
* held from its last record). Also rebuilds
|
||||
* the orbital Live Signals rows on their own clock.
|
||||
* @param {object} state The orbital session.
|
||||
* @param {{direction: object, up: object, right: object}} nadir This
|
||||
* frame's nadir frame.
|
||||
* @param {{x: number, y: number, z: number}} position The satellite, ECEF.
|
||||
* @param {{direction: object, up: object, right: object}} nadir The frame
|
||||
* the look turns about this frame: the nadir one, or a station view's.
|
||||
* @param {{x: number, y: number, z: number}} position Where the camera is,
|
||||
* ECEF: the satellite, or the station view's point on it.
|
||||
* @param {number} nowMs
|
||||
* @param {{direction: object, up: object, right: object}|null} [trueNadir]
|
||||
* The nadir frame when `nadir` is a station view's: the rows still word
|
||||
* their angles from straight down.
|
||||
* @returns {boolean} True when it placed `state.lookView` itself.
|
||||
*/
|
||||
export function updateOrbitalFocus(state, nadir, position, nowMs) {
|
||||
export function updateOrbitalFocus(
|
||||
state,
|
||||
nadir,
|
||||
position,
|
||||
nowMs,
|
||||
trueNadir = null,
|
||||
) {
|
||||
state.focusFrame = {
|
||||
nadir,
|
||||
trueNadir,
|
||||
position: { x: position.x, y: position.y, z: position.z },
|
||||
};
|
||||
// After a satellite switch the first frame on the new satellite (the hop
|
||||
@@ -465,13 +488,21 @@ export function orbitalSitesInReach(info) {
|
||||
});
|
||||
state.listedSites = remembered;
|
||||
const focusKey = state.focus?.key ?? null;
|
||||
const positions = new Map(candidates.map((c) => [c.key, c.position]));
|
||||
// Reach is measured about the frame the look turns in; the angle shown
|
||||
// is always from straight down, also from a station view.
|
||||
const shownOffNadir = (key, offNadirDeg) => {
|
||||
if (!frame.trueNadir) return offNadirDeg;
|
||||
const look = focusLook(frame.trueNadir, frame.position, positions.get(key));
|
||||
return Number.isFinite(look?.offNadirDeg) ? look.offNadirDeg : offNadirDeg;
|
||||
};
|
||||
return {
|
||||
entries: pointsInReach(candidates, {
|
||||
nadir: frame.nadir,
|
||||
satellite: frame.position,
|
||||
}).map(({ key, offNadirDeg }) => ({
|
||||
site: byId.get(key),
|
||||
offNadirDeg,
|
||||
offNadirDeg: shownOffNadir(key, offNadirDeg),
|
||||
focused: key === focusKey,
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -41,10 +41,34 @@ const FRAME_MS = 16;
|
||||
|
||||
/** Satellites the layer knows, by NORAD id: the ridden one and its neighbours. */
|
||||
const SATELLITES = Object.freeze({
|
||||
25544: { name: 'ISS (ZARYA)', lat: 30, lon: -97, alt: 420_000, cls: 'stations' },
|
||||
49260: { name: 'LANDSAT 9', lat: 31.5, lon: -95, alt: 705_000, cls: 'imaging' },
|
||||
40697: { name: 'SENTINEL-2A', lat: 26, lon: -99, alt: 786_000, cls: 'imaging' },
|
||||
99001: { name: 'DEB FRAGMENT', lat: 30.2, lon: -97.1, alt: 430_000, cls: 'debris' },
|
||||
25544: {
|
||||
name: 'ISS (ZARYA)',
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
alt: 420_000,
|
||||
cls: 'stations',
|
||||
},
|
||||
49260: {
|
||||
name: 'LANDSAT 9',
|
||||
lat: 31.5,
|
||||
lon: -95,
|
||||
alt: 705_000,
|
||||
cls: 'imaging',
|
||||
},
|
||||
40697: {
|
||||
name: 'SENTINEL-2A',
|
||||
lat: 26,
|
||||
lon: -99,
|
||||
alt: 786_000,
|
||||
cls: 'imaging',
|
||||
},
|
||||
99001: {
|
||||
name: 'DEB FRAGMENT',
|
||||
lat: 30.2,
|
||||
lon: -97.1,
|
||||
alt: 430_000,
|
||||
cls: 'debris',
|
||||
},
|
||||
});
|
||||
|
||||
/** Mapped sites as the installations layer keeps them. */
|
||||
@@ -58,6 +82,8 @@ const SITES = Object.freeze({
|
||||
lon: -96.5,
|
||||
memberNames: ['North Field'],
|
||||
at: { x: 100, y: 100 },
|
||||
// Where the overlay paints its label box: nothing picks there.
|
||||
labelAt: { x: 140, y: 70 },
|
||||
},
|
||||
bravo: {
|
||||
id: 'osm:military:way/202',
|
||||
@@ -102,7 +128,11 @@ function installationsLayer() {
|
||||
withPosition(record) {
|
||||
return {
|
||||
...record,
|
||||
position: Cesium.Cartesian3.fromDegrees(record.longitude, record.latitude, 0),
|
||||
position: Cesium.Cartesian3.fromDegrees(
|
||||
record.longitude,
|
||||
record.latitude,
|
||||
0,
|
||||
),
|
||||
};
|
||||
},
|
||||
// As the layer's own: loaded installations within `rangeM` of
|
||||
@@ -119,7 +149,10 @@ function installationsLayer() {
|
||||
from,
|
||||
Cesium.Cartographic.fromDegrees(record.longitude, record.latitude),
|
||||
);
|
||||
return { ...layer.withPosition(record), distanceM: geodesic.surfaceDistance };
|
||||
return {
|
||||
...layer.withPosition(record),
|
||||
distanceM: geodesic.surfaceDistance,
|
||||
};
|
||||
})
|
||||
.filter((record) => record.distanceM <= rangeM)
|
||||
.sort((a, b) => a.distanceM - b.distanceM)
|
||||
@@ -135,6 +168,17 @@ function installationsLayer() {
|
||||
const id = hit?.meta?.installationId ?? null;
|
||||
return id ? layer.getById(id) : null;
|
||||
},
|
||||
// As the layer's: the label box the overlay paints, where no primitive
|
||||
// picks (the dot is left to the pick ids here).
|
||||
findAt(position) {
|
||||
const site = Object.values(SITES).find(
|
||||
(s) =>
|
||||
s.labelAt &&
|
||||
s.labelAt.x === position?.x &&
|
||||
s.labelAt.y === position?.y,
|
||||
);
|
||||
return site ? layer.getById(site.id) : null;
|
||||
},
|
||||
};
|
||||
return layer;
|
||||
}
|
||||
@@ -192,7 +236,11 @@ function satellitesLayer(viewer) {
|
||||
},
|
||||
// As the layer's: the nearest shown satellites, bounded, with the
|
||||
// asked-for ids and classes left out.
|
||||
getNearestPositions(center, maxCount = 8, { excludeIds = [], excludeClasses = [] } = {}) {
|
||||
getNearestPositions(
|
||||
center,
|
||||
maxCount = 8,
|
||||
{ excludeIds = [], excludeClasses = [] } = {},
|
||||
) {
|
||||
layer.calls.push(['nearest']);
|
||||
const skip = new Set(excludeIds.map(String));
|
||||
return layer
|
||||
@@ -216,7 +264,9 @@ function satellitesLayer(viewer) {
|
||||
if (!positions.has(id)) return false;
|
||||
layer.calls.push(['track', id]);
|
||||
layer.tracked = id;
|
||||
followEntity(viewer, { position: { getValue: () => layer.position(id) } });
|
||||
followEntity(viewer, {
|
||||
position: { getValue: () => layer.position(id) },
|
||||
});
|
||||
return true;
|
||||
},
|
||||
setCockpitSubject(noradId) {
|
||||
@@ -236,7 +286,11 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(
|
||||
defineComponent(() => () => [h(ContextView), h(IntelHudView), h(CockpitView)]),
|
||||
defineComponent(() => () => [
|
||||
h(ContextView),
|
||||
h(IntelHudView),
|
||||
h(CockpitView),
|
||||
]),
|
||||
).use(pinia);
|
||||
app.mount(host);
|
||||
useHudStore(pinia);
|
||||
@@ -278,7 +332,10 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
handler.stockDouble = ({ position }) => {
|
||||
handler.stockDoubleClicks += 1;
|
||||
const picked = picks.get(`${position.x},${position.y}`);
|
||||
followEntity(viewer, picked ? { position: { getValue: () => null } } : null);
|
||||
followEntity(
|
||||
viewer,
|
||||
picked ? { position: { getValue: () => null } } : null,
|
||||
);
|
||||
};
|
||||
// The viewer's stock handler holds them, so the scene's input has them to
|
||||
// hold off.
|
||||
@@ -376,7 +433,11 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
globalThis.matchMedia = previousMatchMedia;
|
||||
performance.now = originalNow;
|
||||
Date.now = originalDateNow;
|
||||
document.body.classList.remove('cockpit-mode', 'cockpit-bridge', 'cockpit-orbit');
|
||||
document.body.classList.remove(
|
||||
'cockpit-mode',
|
||||
'cockpit-bridge',
|
||||
'cockpit-orbit',
|
||||
);
|
||||
});
|
||||
|
||||
const frame = () => {
|
||||
@@ -456,7 +517,10 @@ function missDeg(shot, key) {
|
||||
|
||||
/** The camera's angle from nadir, degrees. */
|
||||
function offNadir(shot) {
|
||||
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return angleDeg(shot.direction, toCentre);
|
||||
}
|
||||
|
||||
@@ -467,7 +531,10 @@ function siteOffNadir(shot, key) {
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return angleDeg(line, toCentre);
|
||||
}
|
||||
|
||||
@@ -522,7 +589,9 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
|
||||
assert.ok(shown.length <= 5, 'five rows at most');
|
||||
assert.equal(shown[0].title, 'TRACK ACQUIRED', 'the track row stays first');
|
||||
// Two site rows, nearest to nadir first, then the satellites (debris out).
|
||||
const sitesShown = shown.filter((row) => row.target?.layerId === 'military-installations');
|
||||
const sitesShown = shown.filter(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
);
|
||||
assert.deepEqual(
|
||||
sitesShown.map((row) => row.target.id).sort(),
|
||||
[SITES.alpha.id, SITES.bravo.id].sort(),
|
||||
@@ -531,16 +600,33 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
|
||||
assert.match(row.detail, /^(BASE|AIRFIELD) · OFF-NADIR \d+\.\d°$/);
|
||||
assert.match(row.className, /nearby actionable/);
|
||||
}
|
||||
const satellitesShown = shown.filter((row) => row.target?.layerId === 'satellites');
|
||||
assert.deepEqual(satellitesShown.map((row) => row.title), ['LANDSAT 9', 'SENTINEL-2A']);
|
||||
assert.match(satellitesShown[0].detail, /^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/);
|
||||
const satellitesShown = shown.filter(
|
||||
(row) => row.target?.layerId === 'satellites',
|
||||
);
|
||||
assert.deepEqual(
|
||||
satellitesShown.map((row) => row.title),
|
||||
['LANDSAT 9', 'SENTINEL-2A'],
|
||||
);
|
||||
assert.match(
|
||||
satellitesShown[0].detail,
|
||||
/^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/,
|
||||
);
|
||||
// Each row names its own action.
|
||||
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Keep the camera on Camp Alpha');
|
||||
assert.equal(satelliteRow(scene, 49260).getAttribute('aria-label'), 'Ride LANDSAT 9');
|
||||
assert.equal(
|
||||
siteRow(scene, 'alpha').getAttribute('aria-label'),
|
||||
'Keep the camera on Camp Alpha',
|
||||
);
|
||||
assert.equal(
|
||||
satelliteRow(scene, 49260).getAttribute('aria-label'),
|
||||
'Ride LANDSAT 9',
|
||||
);
|
||||
// Rebuilt on the clock, rows keep their keys and times.
|
||||
const before = shown.map((row) => [row.key, row.time]);
|
||||
await refreshRows(scene);
|
||||
assert.deepEqual(rows(scene).map((row) => [row.key, row.time]), before);
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => [row.key, row.time]),
|
||||
before,
|
||||
);
|
||||
});
|
||||
|
||||
test('a site row turns the camera onto it, holds it, and reads its off-nadir angle', async (t) => {
|
||||
@@ -552,11 +638,17 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
|
||||
// The first frames turn part of the way: no jump onto the site.
|
||||
assert.ok(missDeg(scene.frame(), 'alpha') > 5, 'still turning');
|
||||
const largest = run(scene, LAND_FRAMES);
|
||||
assert.ok(largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
|
||||
assert.ok(
|
||||
largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG,
|
||||
`turned ${largest}° in a frame`,
|
||||
);
|
||||
for (let i = 0; i < 20; i += 1) {
|
||||
scene.satellites.move(0.002, 0.002);
|
||||
const shot = scene.frame();
|
||||
assert.ok(missDeg(shot, 'alpha') < 1e-5, `frame ${i}: ${missDeg(shot, 'alpha')}°`);
|
||||
assert.ok(
|
||||
missDeg(shot, 'alpha') < 1e-5,
|
||||
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < 8; i += 1) scene.frame();
|
||||
await settle();
|
||||
@@ -566,14 +658,20 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
|
||||
`OFF-NADIR ${siteOffNadir(shot, 'alpha').toFixed(1)}°`,
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-focus').textContent, 'FOCUS · Camp Alpha');
|
||||
assert.equal($('#cockpit-orbital-look-readout').getAttribute('aria-live'), 'off');
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-look-readout').getAttribute('aria-live'),
|
||||
'off',
|
||||
);
|
||||
assert.equal(store.orbital.footprintKm, null);
|
||||
assert.match($('.cockpit-orbital-swath').textContent, /^SWATH ≈ [\d.]+ KM$/);
|
||||
// The held site's row reads as the subject does, first among the sites.
|
||||
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
|
||||
assert.match(held.className, /^track actionable$/);
|
||||
assert.match(held.detail, /^FOCUS · BASE · OFF-NADIR/);
|
||||
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Release the camera from Camp Alpha');
|
||||
assert.equal(
|
||||
siteRow(scene, 'alpha').getAttribute('aria-label'),
|
||||
'Release the camera from Camp Alpha',
|
||||
);
|
||||
// The held site's FOCUS is a status, worded apart from the FOCUS command.
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('es');
|
||||
@@ -600,7 +698,10 @@ test('another site row switches the focus; the held site row ends it', async (t)
|
||||
assert.ok(largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5);
|
||||
await settle();
|
||||
assert.match(rows(scene).find((row) => row.target?.id === SITES.alpha.id).className, /^nearby/);
|
||||
assert.match(
|
||||
rows(scene).find((row) => row.target?.id === SITES.alpha.id).className,
|
||||
/^nearby/,
|
||||
);
|
||||
siteRow(scene, 'bravo').click();
|
||||
assert.equal(cockpit.orbital.focus, null);
|
||||
const back = run(scene, LAND_FRAMES, { drift: 0 });
|
||||
@@ -617,7 +718,11 @@ test('a click on a site marker focuses it through the layer; a click elsewhere e
|
||||
run(scene, LAND_FRAMES);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id, 'kept on a second click');
|
||||
assert.equal(
|
||||
cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'kept on a second click',
|
||||
);
|
||||
const focused = offNadir(scene.shots.at(-1));
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(cockpit.orbital.focus, null);
|
||||
@@ -640,18 +745,26 @@ test('a click a tool owns is left alone', async (t) => {
|
||||
const lease = claimPointer('draw');
|
||||
t.after(() => releasePointer(lease));
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(scene.cockpit.orbital.focus ?? null, null, 'no focus while drawing');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus ?? null,
|
||||
null,
|
||||
'no focus while drawing',
|
||||
);
|
||||
releasePointer(lease);
|
||||
scene.click(SITES.alpha.at);
|
||||
const again = claimPointer('draw');
|
||||
t.after(() => releasePointer(again));
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'kept while drawing');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'kept while drawing',
|
||||
);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a site under another
|
||||
// layer's card does not focus, and a click there does not end a held focus.
|
||||
test('another layer\'s card over the orbital view keeps the click', async (t) => {
|
||||
test("another layer's card over the orbital view keeps the click", async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
@@ -663,7 +776,11 @@ test('another layer\'s card over the orbital view keeps the click', async (t) =>
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'covered: kept');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'covered: kept',
|
||||
);
|
||||
});
|
||||
|
||||
test('a double-click on a site focuses it and keeps the orbital view', async (t) => {
|
||||
@@ -678,7 +795,11 @@ test('a double-click on a site focuses it and keeps the orbital view', async (t)
|
||||
scene.doubleClick(SITES.bravo.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
|
||||
scene.doubleClick(SITES.far.at);
|
||||
assert.equal(handler.stockDoubleClicks, 0, 'beyond reach: not focused, not tracked');
|
||||
assert.equal(
|
||||
handler.stockDoubleClicks,
|
||||
0,
|
||||
'beyond reach: not focused, not tracked',
|
||||
);
|
||||
scene.frame();
|
||||
assert.equal(cockpit.active, true);
|
||||
scene.doubleClick(EMPTY_GROUND);
|
||||
@@ -720,8 +841,15 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
assert.ok(status, 'a status row says why no site is listed');
|
||||
assert.equal(status.detail, 'ENABLE MAPPED INSTALLATIONS FOR SITE PINGS');
|
||||
assert.equal(status.className, 'warning');
|
||||
assert.ok(!rows(scene).some((row) => row.target?.layerId === 'military-installations'));
|
||||
assert.equal(rows(scene).filter((row) => row.target?.layerId === 'satellites').length, 2);
|
||||
assert.ok(
|
||||
!rows(scene).some(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
rows(scene).filter((row) => row.target?.layerId === 'satellites').length,
|
||||
2,
|
||||
);
|
||||
scene.sites.enabled = true;
|
||||
await refreshRows(scene);
|
||||
assert.ok(!rows(scene).some((row) => row.title === 'SITES STANDBY'));
|
||||
@@ -732,7 +860,11 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
const loaded = scene.sites.records;
|
||||
scene.sites.records = loaded.filter((r) => r.id !== SITES.bravo.id);
|
||||
run(scene, 10);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.bravo.id, 'kept through a reload');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.bravo.id,
|
||||
'kept through a reload',
|
||||
);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5, 'still centred');
|
||||
scene.sites.records = loaded;
|
||||
// A row the list shows works even if the layer just dropped its site.
|
||||
@@ -745,7 +877,10 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites, viewer, modeEvents } = scene;
|
||||
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'no history yet');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.title.startsWith('RETURN')),
|
||||
'no history yet',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
run(scene, 5);
|
||||
const before = Cesium.Cartesian3.clone(scene.shots.at(-1).destination);
|
||||
@@ -755,21 +890,36 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
satelliteRow(scene, 49260).click();
|
||||
const newTrack = cockpit.signalItems.filter((item) => item.key === 'track');
|
||||
assert.equal(newTrack.length, 1);
|
||||
assert.ok(newTrack[0].timestamp > firstTrack.timestamp, 'the new ride’s own time');
|
||||
assert.deepEqual(satellites.calls.slice(-2), [['track', 49260], ['subject', 49260]]);
|
||||
assert.ok(
|
||||
newTrack[0].timestamp > firstTrack.timestamp,
|
||||
'the new ride’s own time',
|
||||
);
|
||||
assert.deepEqual(satellites.calls.slice(-2), [
|
||||
['track', 49260],
|
||||
['subject', 49260],
|
||||
]);
|
||||
assert.equal(followedOf(viewer), null, 'the Cockpit keeps the camera');
|
||||
assert.equal(cockpit.subjectId, 49260);
|
||||
assert.equal(cockpit.orbital.focus, null, 'the focus is reset');
|
||||
assert.equal(modeEvents.at(-1)?.active, true);
|
||||
await settle();
|
||||
const shown = rows(scene);
|
||||
assert.deepEqual([shown[0].title, shown[0].detail], ['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW']);
|
||||
assert.deepEqual(
|
||||
[shown[0].title, shown[0].detail],
|
||||
['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW'],
|
||||
);
|
||||
assert.equal(shown.filter((row) => row.title === 'TRACK ACQUIRED').length, 1);
|
||||
const back = shown.find((row) => row.title === 'RETURN · ISS (ZARYA)');
|
||||
assert.ok(back, 'a RETURN row while there is history');
|
||||
assert.equal(back.detail, 'PREVIOUS SATELLITE');
|
||||
assert.equal(satelliteRow(scene, 25544).getAttribute('aria-label'), 'Return to ISS (ZARYA)');
|
||||
assert.ok(!shown.some((row) => row.title === 'ISS (ZARYA)'), 'listed once, as RETURN');
|
||||
assert.equal(
|
||||
satelliteRow(scene, 25544).getAttribute('aria-label'),
|
||||
'Return to ISS (ZARYA)',
|
||||
);
|
||||
assert.ok(
|
||||
!shown.some((row) => row.title === 'ISS (ZARYA)'),
|
||||
'listed once, as RETURN',
|
||||
);
|
||||
|
||||
// The camera hops along the way, never in one jump.
|
||||
const target = satellites.position(49260);
|
||||
@@ -779,11 +929,20 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) {
|
||||
const shot = scene.frame();
|
||||
assert.equal(cockpit.active, true, `still in orbit at frame ${i}`);
|
||||
largestStep = Math.max(largestStep, Cesium.Cartesian3.distance(previous, shot.destination));
|
||||
largestStep = Math.max(
|
||||
largestStep,
|
||||
Cesium.Cartesian3.distance(previous, shot.destination),
|
||||
);
|
||||
previous = shot.destination;
|
||||
}
|
||||
assert.ok(largestStep < hopM * 0.1, `largest step ${largestStep} m of ${hopM} m`);
|
||||
assert.ok(Cesium.Cartesian3.distance(previous, target) < 1, 'landed on the satellite');
|
||||
assert.ok(
|
||||
largestStep < hopM * 0.1,
|
||||
`largest step ${largestStep} m of ${hopM} m`,
|
||||
);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(previous, target) < 1,
|
||||
'landed on the satellite',
|
||||
);
|
||||
run(scene, LAND_FRAMES, { drift: 0 });
|
||||
assert.ok(offNadir(scene.shots.at(-1)) < 1e-6, 'looking at nadir');
|
||||
|
||||
@@ -799,10 +958,16 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
satelliteRow(scene, 25544).click();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
await settle();
|
||||
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'back at the start');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.title.startsWith('RETURN')),
|
||||
'back at the start',
|
||||
);
|
||||
scene.frame();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.ok(!satellites.calls.some(([, id]) => id === 99001), 'debris never offered');
|
||||
assert.ok(
|
||||
!satellites.calls.some(([, id]) => id === 99001),
|
||||
'debris never offered',
|
||||
);
|
||||
});
|
||||
|
||||
test('while the camera hops, no stale rows; on landing, rows measured from the new satellite', async (t) => {
|
||||
@@ -821,15 +986,32 @@ test('while the camera hops, no stale rows; on landing, rows measured from the n
|
||||
scene.refreshCard();
|
||||
await settle();
|
||||
assert.ok(cockpit.orbital.hop, 'still hopping');
|
||||
assert.deepEqual(rows(scene).map((row) => row.title), ['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)']);
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => row.title),
|
||||
['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)'],
|
||||
);
|
||||
// Landed: the first frame on the satellite rebuilds them at once.
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) scene.frame();
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1)
|
||||
scene.frame();
|
||||
await settle();
|
||||
shown = rows(scene);
|
||||
assert.ok(shown.some((row) => row.target?.layerId === 'military-installations'), 'sites back');
|
||||
const satellitesShown = shown.filter((row) => row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites');
|
||||
assert.ok(!satellitesShown.some((row) => row.title === 'LANDSAT 9'), 'never the ridden one');
|
||||
assert.equal(satellitesShown.filter((row) => row.target.id === '25544').length, 1, 'ISS only as RETURN');
|
||||
assert.ok(
|
||||
shown.some((row) => row.target?.layerId === 'military-installations'),
|
||||
'sites back',
|
||||
);
|
||||
const satellitesShown = shown.filter(
|
||||
(row) =>
|
||||
row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites',
|
||||
);
|
||||
assert.ok(
|
||||
!satellitesShown.some((row) => row.title === 'LANDSAT 9'),
|
||||
'never the ridden one',
|
||||
);
|
||||
assert.equal(
|
||||
satellitesShown.filter((row) => row.target.id === '25544').length,
|
||||
1,
|
||||
'ISS only as RETURN',
|
||||
);
|
||||
});
|
||||
|
||||
test('RETURN to a satellite that left the catalogue offers the one before it', async (t) => {
|
||||
@@ -846,7 +1028,10 @@ test('RETURN to a satellite that left the catalogue offers the one before it', a
|
||||
satelliteRow(scene, 49260).click();
|
||||
assert.equal(cockpit.subjectId, 40697, 'still on the same satellite');
|
||||
await settle();
|
||||
assert.ok(rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'), 'the one before');
|
||||
assert.ok(
|
||||
rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'),
|
||||
'the one before',
|
||||
);
|
||||
satelliteRow(scene, 25544).click();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
});
|
||||
@@ -858,7 +1043,11 @@ test('with Installations off no site is offered, by row, list or click', async (
|
||||
sites.enabled = false;
|
||||
await refreshRows(scene);
|
||||
assert.ok(rows(scene).some((row) => row.title === 'SITES STANDBY'));
|
||||
assert.equal(cockpit.orbital.listedSites.size, 0, 'nothing kept to focus from');
|
||||
assert.equal(
|
||||
cockpit.orbital.listedSites.size,
|
||||
0,
|
||||
'nothing kept to focus from',
|
||||
);
|
||||
assert.equal(cockpit.toggleOrbitalFocus(SITES.alpha.id), false);
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(cockpit.orbital.focus ?? null, null);
|
||||
@@ -873,7 +1062,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
|
||||
scene.frame();
|
||||
assert.equal(cockpit.orbital.focusReleasing, true);
|
||||
const view = { ...cockpit.orbital.lookView };
|
||||
assert.ok(Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1, 'still turned');
|
||||
assert.ok(
|
||||
Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1,
|
||||
'still turned',
|
||||
);
|
||||
cockpit.onKeyDown({
|
||||
key: 'ArrowUp',
|
||||
target: document.body,
|
||||
@@ -886,7 +1078,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
|
||||
Math.abs(cockpit.orbital.lookTarget.yawDeg - view.yawDeg) < 1e-6,
|
||||
'across kept',
|
||||
);
|
||||
assert.ok(cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg, 'tilted on up');
|
||||
assert.ok(
|
||||
cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg,
|
||||
'tilted on up',
|
||||
);
|
||||
});
|
||||
|
||||
test('leaving orbit leaves no orbital rows to act on', async (t) => {
|
||||
@@ -901,7 +1096,10 @@ test('leaving orbit leaves no orbital rows to act on', async (t) => {
|
||||
assert.equal(scene.cockpit.toggleOrbitalFocus(SITES.bravo.id), false);
|
||||
assert.equal(scene.cockpit.onOrbitalClick(SITES.bravo.at), false);
|
||||
assert.equal(scene.cockpit.rideOrbitalSatellite(49260), false);
|
||||
assert.equal(scene.cockpit.handleOrbitalSignalClick('satellites', '49260'), false);
|
||||
assert.equal(
|
||||
scene.cockpit.handleOrbitalSignalClick('satellites', '49260'),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('NADIR and Home end a focus; an arrow takes the view over where it is', async (t) => {
|
||||
@@ -944,7 +1142,12 @@ test('reduced motion cuts onto the site, back, and between satellites', async (t
|
||||
assert.ok(offNadir(scene.frame()) < 1e-6, 'back at once');
|
||||
satelliteRow(scene, 49260).click();
|
||||
const shot = scene.frame();
|
||||
assert.ok(Cesium.Cartesian3.distance(shot.destination, scene.satellites.position(49260)) < 1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(
|
||||
shot.destination,
|
||||
scene.satellites.position(49260),
|
||||
) < 1,
|
||||
);
|
||||
});
|
||||
|
||||
test('stopping the Cockpit leaves both clicks to the renderer', async (t) => {
|
||||
@@ -975,11 +1178,21 @@ test('the focused site keeps its row after nearer sites push it down', async (t)
|
||||
sources: [],
|
||||
});
|
||||
await refreshRows(scene);
|
||||
const sitesShown = rows(scene).filter((row) => row.target?.layerId === 'military-installations');
|
||||
const sitesShown = rows(scene).filter(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
);
|
||||
assert.equal(sitesShown.length, 2);
|
||||
assert.equal(sitesShown[0].target.id, SITES.alpha.id, 'the focused site is kept, first');
|
||||
assert.equal(
|
||||
sitesShown[0].target.id,
|
||||
SITES.alpha.id,
|
||||
'the focused site is kept, first',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(scene.cockpit.orbital.focus, null, 'its row still ends the focus');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus,
|
||||
null,
|
||||
'its row still ends the focus',
|
||||
);
|
||||
});
|
||||
|
||||
test('a site the layer drops in a reload keeps its row, and its row still focuses it', async (t) => {
|
||||
@@ -990,13 +1203,24 @@ test('a site the layer drops in a reload keeps its row, and its row still focuse
|
||||
// The thinned view reloads without Camp Alpha for a moment.
|
||||
scene.sites.records = loaded.filter((r) => r.id !== SITES.alpha.id);
|
||||
await refreshRows(scene);
|
||||
assert.deepEqual(rows(scene).map((row) => row.key), before, 'the rows hold still');
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => row.key),
|
||||
before,
|
||||
'the rows hold still',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(scene.cockpit.orbital.focus?.key, SITES.alpha.id, 'focused from its row');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus?.key,
|
||||
SITES.alpha.id,
|
||||
'focused from its row',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
// Gone for good: after a while it leaves the rows.
|
||||
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
|
||||
assert.ok(!rows(scene).some((row) => row.target?.id === SITES.alpha.id), 'forgotten later');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.target?.id === SITES.alpha.id),
|
||||
'forgotten later',
|
||||
);
|
||||
});
|
||||
|
||||
test('shown rows keep their places while they still qualify', async (t) => {
|
||||
@@ -1021,12 +1245,174 @@ test('shown rows keep their places while they still qualify', async (t) => {
|
||||
const sitesAfter = rows(scene)
|
||||
.filter((row) => row.target?.layerId === 'military-installations')
|
||||
.map((row) => row.target.id);
|
||||
assert.deepEqual(sitesAfter, sitesBefore, 'no row moves while its site is in reach');
|
||||
assert.deepEqual(
|
||||
sitesAfter,
|
||||
sitesBefore,
|
||||
'no row moves while its site is in reach',
|
||||
);
|
||||
// Once a shown site leaves the list, the nearer one takes its slot.
|
||||
scene.sites.records = scene.sites.records.filter((r) => r.id !== SITES.bravo.id);
|
||||
scene.sites.records = scene.sites.records.filter(
|
||||
(r) => r.id !== SITES.bravo.id,
|
||||
);
|
||||
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
|
||||
assert.ok(
|
||||
rows(scene).some((row) => row.target?.id === 'osm:military:way/999'),
|
||||
'the nearer site fills the freed slot',
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* A view from the station: its camera 20 m above the satellite, looking 65°
|
||||
* below level toward the north, as the satellites layer gives it. Camp Alpha,
|
||||
* about 120 km to the north-east of a satellite 420 km up, is some 74°
|
||||
* below level from it: within the view's reach.
|
||||
*/
|
||||
function stationMount(scene) {
|
||||
const position = scene.satellites.position(25544);
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||
const axis = (x, y, z) =>
|
||||
Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(x, y, z),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const down = (65 * Math.PI) / 180;
|
||||
const direction = axis(0, Math.cos(down), -Math.sin(down));
|
||||
const up = axis(0, Math.sin(down), Math.cos(down));
|
||||
return {
|
||||
position: Cesium.Cartesian3.add(
|
||||
position,
|
||||
Cesium.Cartesian3.multiplyByScalar(
|
||||
axis(0, 0, 1),
|
||||
20,
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
direction,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
|
||||
key: 'zarya',
|
||||
label: 'ZARYA',
|
||||
noradId: 25544,
|
||||
card: null,
|
||||
views: [
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: null },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
test('from a station view, a site row turns the camera onto it from the view’s own point and holds it', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites } = scene;
|
||||
satellites.getCockpitMount = () => stationMount(scene);
|
||||
scene.frame();
|
||||
await refreshRows(scene);
|
||||
const mount = stationMount(scene);
|
||||
// Camp Alpha lies below and to the north-east, within 45° of the view.
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') > 5, 'not centred yet');
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
run(scene, LAND_FRAMES, { drift: 0 });
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
const shot = scene.frame();
|
||||
// From the view's camera point on the station, not the satellite's.
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(
|
||||
shot.destination,
|
||||
stationMount(scene).position,
|
||||
) < 1e-6,
|
||||
);
|
||||
assert.ok(
|
||||
missDeg(shot, 'alpha') < 1e-4,
|
||||
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
|
||||
);
|
||||
}
|
||||
// The same site from straight down would be off the view's direction.
|
||||
assert.ok(angleDeg(mount.direction, scene.shots.at(-1).direction) > 1);
|
||||
// Its row still words the angle from straight down, not from the view.
|
||||
await refreshRows(scene);
|
||||
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
|
||||
const fromNadir = siteOffNadir(scene.shots.at(-1), 'alpha');
|
||||
const shown = Number(/OFF-NADIR ([\d.]+)°/.exec(held.detail)[1]);
|
||||
assert.ok(Math.abs(shown - fromNadir) < 0.2, `${shown}° vs ${fromNadir}°`);
|
||||
|
||||
// Switching views ends the focus: the new view looks its own way.
|
||||
cockpit.nextOrbitalView();
|
||||
assert.ok(!cockpit.orbital.focus);
|
||||
});
|
||||
|
||||
test('from a station view, a site beyond 45° of where the view looks is not focused', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites } = scene;
|
||||
// The view looks south; Camp Alpha is to the north-east, behind it.
|
||||
satellites.getCockpitMount = () => {
|
||||
const mount = stationMount(scene);
|
||||
const flip = (v) => Cesium.Cartesian3.negate(v, new Cesium.Cartesian3());
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(
|
||||
scene.satellites.position(25544),
|
||||
);
|
||||
const south = Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(0, -0.87, -0.5),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const up = Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(0, -0.5, 0.87),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return {
|
||||
...mount,
|
||||
direction: south,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(south, up, new Cesium.Cartesian3()),
|
||||
unused: flip,
|
||||
};
|
||||
};
|
||||
scene.frame();
|
||||
await refreshRows(scene);
|
||||
const row = siteRow(scene, 'alpha');
|
||||
if (row) row.click();
|
||||
else cockpit.toggleOrbitalFocus?.(SITES.alpha.id);
|
||||
assert.ok(!cockpit.orbital.focus);
|
||||
});
|
||||
|
||||
test("a click on a site's label box focuses it, as one on its dot does", async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, handler, sites } = scene;
|
||||
// No dot is drawn at the label's place: the layer's own lookup is what
|
||||
// finds the site there, through the label box the overlay paints.
|
||||
assert.equal(sites.findByPick(null), null, 'no draw item at the label');
|
||||
assert.equal(sites.findAt(SITES.alpha.labelAt)?.id, SITES.alpha.id);
|
||||
// The overlay reports the label box as the card on top there, as it does
|
||||
// for an interactive entry: the site's own label is not another layer's.
|
||||
const labels = [SITES.alpha.labelAt];
|
||||
setClickCardHitTest((x, y) =>
|
||||
labels.some((at) => at.x === x && at.y === y)
|
||||
? { sourceId: 'military-installations', entryId: SITES.alpha.id }
|
||||
: null,
|
||||
);
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
scene.click(SITES.alpha.labelAt);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
assert.equal(handler.stockClicks, 1, 'Cesium still gets the click');
|
||||
run(scene, LAND_FRAMES);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
|
||||
// The label of the focused site again keeps it; another site's dot
|
||||
// switches.
|
||||
scene.click(SITES.alpha.labelAt);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
scene.click(SITES.bravo.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
|
||||
});
|
||||
@@ -159,7 +159,7 @@ export function switchOrbitalSatellite(noradId) {
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · NADIR VIEW', { label: info.name }),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
this.updateOrbitalHud(info);
|
||||
this.refreshOrbitalSignals?.();
|
||||
|
||||
+165
-26
@@ -1,5 +1,6 @@
|
||||
/** The orbital (satellite) view of the Cockpit controller: camera, zoom, look and HUD. */
|
||||
import { isFollowing } from '../data/followed.js';
|
||||
import { clone } from '../geo/vector.js';
|
||||
import { cameraOf, canvasOf, findGlobe } from '../render/rendererOf.js';
|
||||
import { formatNumber, msg, t } from '../i18n/index.js';
|
||||
import {
|
||||
@@ -34,6 +35,10 @@ import {
|
||||
import { cockpitUiUpdateDue } from '../cockpitMath.js';
|
||||
import { createPlaceTracker, nearPlaceRadiusKm } from '../data/placeBelow.js';
|
||||
import { isPointerFree } from '../data/inputOwnership.js';
|
||||
import {
|
||||
issNextMountView,
|
||||
issPreviousMountView,
|
||||
} from '../layers/satellites/issMounts.js';
|
||||
import { zoomableSwathKm } from '../layers/satellites/sensors.js';
|
||||
import {
|
||||
easeOrbitalLook,
|
||||
@@ -41,7 +46,10 @@ import {
|
||||
releaseOrbitalFocus,
|
||||
updateOrbitalFocus,
|
||||
} from './cockpitOrbitalFocus.js';
|
||||
import { orbitalEyePosition } from './cockpitOrbitalSatellites.js';
|
||||
import {
|
||||
orbitalEyePosition,
|
||||
switchOrbitalSatellite,
|
||||
} from './cockpitOrbitalSatellites.js';
|
||||
import {
|
||||
COCKPIT_CONTEXT_UPDATE_MS,
|
||||
COCKPIT_HUD_UPDATE_MS,
|
||||
@@ -84,6 +92,15 @@ export function beginOrbital() {
|
||||
// A zoom step in flight: the magnification it started from and when.
|
||||
transition: null,
|
||||
previousUp: null,
|
||||
// The station's view shown (its key and name) and the views on offer;
|
||||
// null and none for any other satellite. The key is kept while the
|
||||
// model is away, so the same view comes back with it.
|
||||
mountKey: null,
|
||||
mount: null,
|
||||
mountViews: [],
|
||||
// A view of a module with no catalog entry (the Cupola) carries the
|
||||
// card shown in place of the entry it rides; null otherwise.
|
||||
mountCard: null,
|
||||
altitudeM: null,
|
||||
verticalFov: null,
|
||||
lastBriefMs: 0,
|
||||
@@ -270,8 +287,49 @@ export function updateOrbital(nowMs) {
|
||||
);
|
||||
if (!position) return;
|
||||
const state = this.orbital;
|
||||
// The station is ridden from a point on its 3D model, looking along it,
|
||||
// in place of the straight-down picture (the satellites layer says where).
|
||||
const mount =
|
||||
this.services.satellitesLayer?.getCockpitMount?.(state.mountKey) ?? null;
|
||||
if (mount?.key) state.mountKey = mount.key;
|
||||
state.mountViews = mount?.views ?? [];
|
||||
state.mountCard = mount?.card ?? null;
|
||||
// Each view belongs to an entry of its own (Nauka, the ISS, Poisk, the
|
||||
// docked vehicle). The Cockpit rides that entry, so the readout, the TLE
|
||||
// and the signals describe the module the view is from, not the one first
|
||||
// selected. The switch lands on the next frame; one that fails is not
|
||||
// retried until the view changes.
|
||||
if (
|
||||
mount?.noradId !== null &&
|
||||
mount?.noradId !== undefined &&
|
||||
String(mount.noradId) !== String(this.subjectId) &&
|
||||
state.mountSwitchFailed !== mount.key
|
||||
) {
|
||||
if (switchOrbitalSatellite.call(this, mount.noradId)) return;
|
||||
state.mountSwitchFailed = mount.key;
|
||||
}
|
||||
// The model can load after entry, and the picture then changes under the
|
||||
// TRACK ACQUIRED line that named it: say which it is now.
|
||||
const riding = mount !== null;
|
||||
const changed = state.riding !== undefined && state.riding !== riding;
|
||||
state.riding = riding;
|
||||
if (changed) {
|
||||
this.signalItems = (this.signalItems ?? []).filter(
|
||||
(item) => item.key !== 'track',
|
||||
);
|
||||
this.signalSignatures?.delete('track');
|
||||
this.pushCockpitSignal(
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
}
|
||||
state.mount = mount ? mount.label || '' : null;
|
||||
// On the satellite, or on the way to it after Previous/Next.
|
||||
const eye = orbitalEyePosition(state, position, nowMs);
|
||||
const eye = mount
|
||||
? clone(mount.position)
|
||||
: orbitalEyePosition(state, position, nowMs);
|
||||
// Track-up: the ground track at the top, so the picture scrolls along it.
|
||||
// A geostationary satellite has no track and stays north-up.
|
||||
const nadir = nadirOrientation(eye, {
|
||||
@@ -291,15 +349,28 @@ export function updateOrbital(nowMs) {
|
||||
this.lastSubjectInfo = info;
|
||||
goToZoom.call(this, maxZoom);
|
||||
}
|
||||
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js).
|
||||
if (!updateOrbitalFocus.call(this, state, nadir, eye, nowMs))
|
||||
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js),
|
||||
// in the frame the arrows turn: from a station view, its own, from its
|
||||
// camera point on the station. The same ±45° reach holds about it.
|
||||
if (
|
||||
!updateOrbitalFocus.call(
|
||||
this,
|
||||
state,
|
||||
mount ?? nadir,
|
||||
eye,
|
||||
nowMs,
|
||||
mount ? nadir : null,
|
||||
)
|
||||
)
|
||||
state.lookView = easeOrbitalLook(
|
||||
state,
|
||||
nowMs - (state.lookLastMs || nowMs),
|
||||
{ immediate: prefersReducedMotion() },
|
||||
);
|
||||
state.lookLastMs = nowMs;
|
||||
const view = offNadirOrientation(nadir, {
|
||||
// The arrows tilt the view about its own frame: the nadir one, or the
|
||||
// mount's.
|
||||
const view = offNadirOrientation(mount ?? nadir, {
|
||||
northDeg: state.lookView.pitchDeg,
|
||||
eastDeg: state.lookView.yawDeg,
|
||||
});
|
||||
@@ -470,9 +541,19 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
northDeg: state.lookView?.pitchDeg ?? 0,
|
||||
eastDeg: state.lookView?.yawDeg ?? 0,
|
||||
});
|
||||
// Riding the station from a mount on its model: the view's name, and no
|
||||
// ground readings, which describe the nadir picture.
|
||||
const mount = state.mount ?? null;
|
||||
// A module with no catalog entry of its own shows its own card: its name,
|
||||
// what it is and a few facts, in place of the entry's identity and TLE.
|
||||
const card = mount !== null ? (state.mountCard ?? null) : null;
|
||||
this.publishOrbital({
|
||||
name: info.name,
|
||||
classLabel: info.classLabel || '',
|
||||
name: card ? card.name : info.name,
|
||||
mount,
|
||||
facts: card ? card.facts.map((fact) => t(fact)) : null,
|
||||
// How many views the station offers: the arrows show with two or more.
|
||||
mountViews: mount === null ? 0 : (state.mountViews?.length ?? 0),
|
||||
classLabel: card ? t(card.classLabel) : info.classLabel || '',
|
||||
altitudeM: info.altitudeM,
|
||||
velocityMps: Number.isFinite(info.velocityMps) ? info.velocityMps : null,
|
||||
latitude: info.latitude,
|
||||
@@ -480,12 +561,12 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
zoom: state.zoom,
|
||||
zoomSteps: ORBITAL_ZOOM_LADDER.filter((step) => step <= maxZoom),
|
||||
maxZoom,
|
||||
footprintKm: offset ? null : footprintKm,
|
||||
footprintKm: offset || mount !== null ? null : footprintKm,
|
||||
// The imaging sensor's swath, drawn to scale; null without one. The
|
||||
// SENSOR step's zoom is null when the swath lies outside 1x..maxZoom.
|
||||
// Looking past the limb there is no ground for it to cover: no sensor.
|
||||
sensor:
|
||||
swathKm === null || !seesEarth
|
||||
swathKm === null || !seesEarth || mount !== null
|
||||
? null
|
||||
: {
|
||||
label: info.sensor?.label ?? null,
|
||||
@@ -503,18 +584,22 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
transition: { ...transition },
|
||||
look: {
|
||||
offset,
|
||||
readout: focus
|
||||
? wordFocusOffNadir(focus)
|
||||
: offset
|
||||
? wordOffNadir(state.lookTarget, { trackUp })
|
||||
: '',
|
||||
// From a mount the tilt is about the mount's frame, not the nadir.
|
||||
readout:
|
||||
mount !== null
|
||||
? ''
|
||||
: focus
|
||||
? wordFocusOffNadir(focus)
|
||||
: offset
|
||||
? wordOffNadir(state.lookTarget, { trackUp })
|
||||
: '',
|
||||
// The mapped point the view is held on, or null.
|
||||
focus: focus ? { key: focus.key, label: focus.label } : null,
|
||||
// Off nadir, the ground width at the view's centre, approximated from
|
||||
// the nadir footprint (`offNadirSwathScale`); 1 and null at nadir.
|
||||
swathScale,
|
||||
swathKm:
|
||||
offset && seesEarth && Number.isFinite(footprintKm)
|
||||
mount === null && offset && seesEarth && Number.isFinite(footprintKm)
|
||||
? footprintKm * swathScale
|
||||
: null,
|
||||
},
|
||||
@@ -523,23 +608,45 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
trackUp,
|
||||
northDeg: trackUp ? (360 - info.groundTrackDeg) % 360 : 0,
|
||||
place: state.place,
|
||||
noradId: info.noradId ?? null,
|
||||
cosparId: info.cosparId ?? null,
|
||||
tle: info.tle ?? null,
|
||||
noradId: card ? null : (info.noradId ?? null),
|
||||
cosparId: card ? null : (info.cosparId ?? null),
|
||||
tle: card ? null : (info.tle ?? null),
|
||||
// Read on the HUD's cadence, so the age stays current without a timer.
|
||||
// The gap between the TLE's epoch and the time the satellite is shown
|
||||
// at (the world clock's), either side: SGP4 drifts both ways.
|
||||
tleAgeMs: Number.isFinite(info.tle?.epochMs)
|
||||
? Math.abs(
|
||||
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
|
||||
info.tle.epochMs,
|
||||
)
|
||||
: null,
|
||||
owner: info.owner ?? null,
|
||||
operator: info.operator ?? null,
|
||||
tleAgeMs:
|
||||
!card && Number.isFinite(info.tle?.epochMs)
|
||||
? Math.abs(
|
||||
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
|
||||
info.tle.epochMs,
|
||||
)
|
||||
: null,
|
||||
owner: card ? null : (info.owner ?? null),
|
||||
operator: card ? t(card.operator) : (info.operator ?? null),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The TRACK ACQUIRED line for a satellite subject: which picture it gets.
|
||||
* The station is ridden from a mount on its 3D model (once that is loaded);
|
||||
* every other satellite looks straight down.
|
||||
* @param {object} info Satellite subject.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function orbitalViewSignal(info) {
|
||||
// A running session knows; on entry, before its first frame, the layer does.
|
||||
const riding =
|
||||
this.orbital?.riding ??
|
||||
Boolean(
|
||||
this.services.satellitesLayer?.getCockpitMount?.(
|
||||
this.orbital?.mountKey ?? null,
|
||||
),
|
||||
);
|
||||
return riding
|
||||
? t('{label} · STATION VIEW', { label: info.name })
|
||||
: t('{label} · NADIR VIEW', { label: info.name });
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the orbital view on entry and after a language switch: the HUD,
|
||||
* the local page and a regional brief for the sub-satellite point.
|
||||
@@ -556,6 +663,38 @@ export function updateOrbitalHud(info, nowMs = performance.now()) {
|
||||
updateOrbitalContext.call(this, info, nowMs, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's arrows: move to its next view (from Nauka, from Zarya,
|
||||
* from Poisk, from the Cupola, from Kibo, from a docked vehicle) or the one
|
||||
* before, wrapping round, looking the way that view looks.
|
||||
* @param {number} [direction] 1 for the next view, -1 for the one before.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
export function stepOrbitalMount(direction = 1) {
|
||||
if (!this.active || this.subjectKind !== 'satellite' || !this.orbital)
|
||||
return false;
|
||||
const state = this.orbital;
|
||||
const step = direction < 0 ? issPreviousMountView : issNextMountView;
|
||||
const next =
|
||||
state.mount === null ? null : step(state.mountViews, state.mountKey);
|
||||
if (!next) return false;
|
||||
state.mountKey = next.key;
|
||||
state.mount = next.label || '';
|
||||
state.mountCard = next.card ?? null;
|
||||
state.mountSwitchFailed = null;
|
||||
// A ground focus was aimed from the old view: it ends with it.
|
||||
if (state.focus) {
|
||||
state.focus = null;
|
||||
state.focusReleasing = false;
|
||||
this.refreshOrbitalSignals?.();
|
||||
}
|
||||
// Each view has its own way of looking: the look goes back to it.
|
||||
state.lookTarget = { ...NADIR_LOOK };
|
||||
state.lookView = { ...NADIR_LOOK };
|
||||
presentNow.call(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Re-apply the field of view and publish after a zoom or look change. */
|
||||
function presentNow() {
|
||||
const state = this.orbital;
|
||||
|
||||
@@ -1466,3 +1466,535 @@ test('back to nadir from past the limb, the sensor waits for the view', async (t
|
||||
await settle();
|
||||
assert.ok(store.orbital.sensor, 'back on the Earth');
|
||||
});
|
||||
|
||||
/** A mount on the station: 20 m from the satellite's position, looking along the track. */
|
||||
function stationMount() {
|
||||
const centre = satellitePosition();
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(centre);
|
||||
const axis = (x, y, z) =>
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(x, y, z),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const direction = axis(0, 1, 0);
|
||||
const up = axis(0, 0, 1);
|
||||
return {
|
||||
position: Cesium.Cartesian3.add(
|
||||
centre,
|
||||
Cesium.Cartesian3.multiplyByScalar(up, 20, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
direction,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
|
||||
label: 'ZARYA',
|
||||
};
|
||||
}
|
||||
|
||||
test('the station is ridden from its mount: the camera sits there and looks along it', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const mount = stationMount();
|
||||
satellites.getCockpitMount = () => mount;
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
const shot = shots.at(-1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(shot.destination, mount.position, 1e-9),
|
||||
'the camera is at the mount, not at the satellite',
|
||||
);
|
||||
near(
|
||||
angleDeg(shot.direction, mount.direction),
|
||||
0,
|
||||
'looks along the mount',
|
||||
1e-9,
|
||||
);
|
||||
near(angleDeg(shot.up, mount.up), 0, 'the mount is upright', 1e-9);
|
||||
|
||||
// The HUD names the view and drops what describes the nadir picture.
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
assert.equal(store.orbital.footprintKm, null);
|
||||
assert.equal(store.orbital.sensor, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · ZARYA',
|
||||
);
|
||||
assert.equal($('.cockpit-orbital-reticle'), null);
|
||||
assert.equal($('.cockpit-orbital-north'), null);
|
||||
assert.match($('.cockpit-help').textContent, /ARROWS LOOK/);
|
||||
assert.match($('.cockpit-help').textContent, /HOME RESET/);
|
||||
assert.doesNotMatch($('.cockpit-help').textContent, /NADIR/);
|
||||
|
||||
// The arrows turn the view about the mount's own frame, and Home returns.
|
||||
press(cockpit, 'ArrowRight');
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
const turned = shots.at(-1);
|
||||
near(angleDeg(turned.direction, mount.direction), 5, 'one step is 5°', 1e-6);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.dot(turned.direction, mount.right) > 0,
|
||||
'right turns toward the mount’s right',
|
||||
);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(turned.destination, mount.position, 1e-9),
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-nadir').textContent, 'RESET');
|
||||
assert.equal($('#cockpit-orbital-look-readout').textContent, '');
|
||||
press(cockpit, 'Home');
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'Home', 1e-9);
|
||||
});
|
||||
|
||||
test('without a mount the same satellite keeps the nadir picture, and gets it back', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const position = satellitePosition();
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
Cesium.Cartesian3.normalize(position, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const signals = [];
|
||||
cockpit.pushCockpitSignal = (key, kind, title, detail) =>
|
||||
signals.push(detail);
|
||||
// The model has not loaded yet: straight down, as for any satellite.
|
||||
satellites.getCockpitMount = () => null;
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.deepEqual(signals, [], 'nothing changed: nothing to say');
|
||||
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir', 1e-9);
|
||||
assert.equal(store.orbital.mount, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'ORBITAL VIEW · NADIR',
|
||||
);
|
||||
assert.ok($('.cockpit-orbital-reticle'));
|
||||
|
||||
// It loads: the view moves to the mount. It goes again: back to nadir.
|
||||
const mount = stationMount();
|
||||
satellites.getCockpitMount = () => mount;
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'mount', 1e-9);
|
||||
// The TRACK ACQUIRED line follows the picture, once per change.
|
||||
cockpit.update();
|
||||
assert.deepEqual(signals, ['ISS (ZARYA) · STATION VIEW']);
|
||||
satellites.getCockpitMount = () => null;
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.deepEqual(signals, [
|
||||
'ISS (ZARYA) · STATION VIEW',
|
||||
'ISS (ZARYA) · NADIR VIEW',
|
||||
]);
|
||||
assert.equal(store.orbital.mount, null);
|
||||
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir again', 1e-9);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(shots.at(-1).destination, position, 1e-6),
|
||||
);
|
||||
});
|
||||
|
||||
/** The station's views as the satellites layer offers them, by key. */
|
||||
function stationViews({ docked = true } = {}) {
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA' },
|
||||
{ key: 'zarya', label: 'ZARYA' },
|
||||
...(docked ? [{ key: 'docked', label: 'PROGRESS-MS 34' }] : []),
|
||||
];
|
||||
const base = stationMount();
|
||||
// Each view sits a different distance above the satellite's position.
|
||||
const heights = { nauka: 10, zarya: 20, docked: 30 };
|
||||
const asked = [];
|
||||
return {
|
||||
asked,
|
||||
views,
|
||||
heightOf(shot) {
|
||||
return Math.round(
|
||||
Cesium.Cartesian3.distance(shot.destination, satellitePosition()),
|
||||
);
|
||||
},
|
||||
getCockpitMount(key) {
|
||||
asked.push(key);
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return {
|
||||
...base,
|
||||
position: Cesium.Cartesian3.add(
|
||||
satellitePosition(),
|
||||
Cesium.Cartesian3.multiplyByScalar(
|
||||
base.up,
|
||||
heights[view.key],
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
key: view.key,
|
||||
label: view.label,
|
||||
views,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('the station opens on its first view and the arrows step through the rest', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const station = stationViews();
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
const frame = async () => {
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
// Nothing was chosen: the layer is asked for its first view, Nauka's,
|
||||
// though the entry ridden is ISS (ZARYA).
|
||||
assert.equal(station.asked[0], null);
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
assert.equal(store.orbital.mountViews, 3);
|
||||
assert.equal(station.heightOf(shots.at(-1)), 10);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · NAUKA',
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-view-next').getAttribute('aria-label'),
|
||||
'Next station view',
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-view-previous').getAttribute('aria-label'),
|
||||
'Previous station view',
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-view-name').textContent, 'NAUKA');
|
||||
|
||||
// A look off to one side is dropped by the step: each view looks its own way.
|
||||
press(cockpit, 'ArrowRight');
|
||||
await frame();
|
||||
assert.equal(store.orbital.look.offset, true);
|
||||
|
||||
// The button, as a click anywhere inside it.
|
||||
$('#cockpit-orbital-view-next').dispatchEvent(
|
||||
new Event('click', { bubbles: true }),
|
||||
);
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'ZARYA', 'named at once, before a frame');
|
||||
await frame();
|
||||
assert.equal(station.asked.at(-1), 'zarya');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 20);
|
||||
assert.equal(store.orbital.look.offset, false);
|
||||
near(
|
||||
angleDeg(shots.at(-1).direction, stationMount().direction),
|
||||
0,
|
||||
'reset',
|
||||
1e-9,
|
||||
);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · ZARYA',
|
||||
);
|
||||
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 30);
|
||||
// Round again to the first.
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 10);
|
||||
});
|
||||
|
||||
test('the chosen view is kept while the model is away, and one view has no arrows', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const station = stationViews({ docked: false });
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
// A second per frame: the HUD republishes on its own cadence.
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.mountViews, 2);
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
// The model goes: nadir, no control, nothing to step.
|
||||
satellites.getCockpitMount = () => null;
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, null);
|
||||
assert.equal(store.orbital.mountViews, 0);
|
||||
assert.equal($('#cockpit-orbital-view-next'), null);
|
||||
assert.equal($('#cockpit-orbital-view-previous'), null);
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
// It comes back: the same view is asked for again.
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
await frame();
|
||||
assert.equal(station.asked.at(-1), 'zarya');
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
|
||||
// A station offering a single view shows no control.
|
||||
station.views.length = 1;
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA', 'the view on offer');
|
||||
assert.equal(store.orbital.mountViews, 1);
|
||||
assert.equal($('#cockpit-orbital-view-next'), null);
|
||||
assert.equal($('#cockpit-orbital-view-previous'), null);
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
});
|
||||
|
||||
test('the view arrows do nothing outside a station view', async (t) => {
|
||||
const { cockpit, clock } = await orbitAt(t);
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
assert.equal(cockpit.previousOrbitalView(), false);
|
||||
cockpit.exit();
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
assert.equal(cockpit.previousOrbitalView(), false);
|
||||
});
|
||||
|
||||
test('each station view rides its own entry, so the card describes that module', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
// The layer, as it behaves: tracking another entry makes it the subject.
|
||||
const names = {
|
||||
25544: 'ISS (ZARYA)',
|
||||
49044: 'ISS (NAUKA)',
|
||||
36086: 'POISK',
|
||||
68837: 'PROGRESS-MS 34',
|
||||
};
|
||||
let subject = { ...ISS, noradId: 68837, id: '68837', name: names[68837] };
|
||||
const tracked = [];
|
||||
satellites.getCockpitSubject = () => ({ ...subject });
|
||||
satellites.trackById = (noradId) => {
|
||||
tracked.push(Number(noradId));
|
||||
const id = Number(noradId);
|
||||
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
|
||||
return true;
|
||||
};
|
||||
cockpit.subjectId = 68837;
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
{ key: 'poisk', label: 'POISK', noradId: 36086 },
|
||||
{ key: 'docked', label: 'PROGRESS-MS 34', noradId: 68837 },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
// Entered on the Progress; the view opens on Nauka and rides Nauka.
|
||||
await frame();
|
||||
await frame();
|
||||
assert.deepEqual(tracked, [49044]);
|
||||
assert.equal(cockpit.subjectId, 49044);
|
||||
assert.equal(store.orbital.name, 'ISS (NAUKA)');
|
||||
assert.equal($('.cockpit-orbital-name').textContent, 'ISS (NAUKA)');
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
|
||||
// Each step rides the next view's entry.
|
||||
for (const [noradId, name] of [
|
||||
[25544, 'ISS (ZARYA)'],
|
||||
[36086, 'POISK'],
|
||||
[68837, 'PROGRESS-MS 34'],
|
||||
[49044, 'ISS (NAUKA)'],
|
||||
]) {
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(cockpit.subjectId, noradId);
|
||||
assert.equal(store.orbital.name, name);
|
||||
assert.equal($('.cockpit-orbital-name').textContent, name);
|
||||
}
|
||||
assert.deepEqual(tracked, [49044, 25544, 36086, 68837, 49044]);
|
||||
});
|
||||
|
||||
test('a view with no entry, or one that cannot be ridden, keeps the subject', async (t) => {
|
||||
const { cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const base = stationMount();
|
||||
let views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: null },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
let asked = 0;
|
||||
satellites.trackById = () => {
|
||||
asked += 1;
|
||||
return false;
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
// No entry for Nauka: the ISS stays the subject, and nothing is tracked.
|
||||
await frame();
|
||||
assert.equal(asked, 0);
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
// An entry the layer will not track: asked once, not every frame.
|
||||
views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
];
|
||||
await frame();
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(asked, 1);
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(document.body.classList.contains('cockpit-orbit'), true);
|
||||
});
|
||||
|
||||
const CUPOLA_CARD = Object.freeze({
|
||||
name: 'CUPOLA',
|
||||
classLabel: 'OBSERVATION MODULE · ISS',
|
||||
operator: 'European Space Agency (ESA)',
|
||||
facts: ['7 WINDOWS', 'LAUNCHED 8 FEB 2010 · STS-130'],
|
||||
});
|
||||
|
||||
test('a view with a card of its own shows it in place of the entry’s identity', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.name, 'ISS (ZARYA)');
|
||||
assert.equal(store.orbital.noradId, 25544);
|
||||
assert.equal(store.orbital.facts, null);
|
||||
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
// Same entry ridden (nothing to switch), the Cupola's own card shown.
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(store.orbital.mount, 'CUPOLA');
|
||||
assert.equal(store.orbital.name, 'CUPOLA');
|
||||
assert.equal($('.cockpit-orbital-name').textContent, 'CUPOLA');
|
||||
assert.equal(store.orbital.classLabel, 'OBSERVATION MODULE · ISS');
|
||||
assert.equal(store.orbital.operator, 'European Space Agency (ESA)');
|
||||
assert.equal(store.orbital.noradId, null);
|
||||
assert.equal(store.orbital.tle, null);
|
||||
assert.equal(store.orbital.owner, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-ident-text').textContent,
|
||||
'7 WINDOWS · LAUNCHED 8 FEB 2010 · STS-130',
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-tle-toggle'), null);
|
||||
// Altitude, velocity and the sub-satellite point are the station's still.
|
||||
assert.ok($('.cockpit-orbital-altitude').textContent.length > 0);
|
||||
|
||||
// Back round to Zarya: the entry's own card again.
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
assert.equal(store.orbital.name, 'ISS (ZARYA)');
|
||||
assert.equal(store.orbital.noradId, 25544);
|
||||
assert.equal(store.orbital.facts, null);
|
||||
});
|
||||
|
||||
test('leaving a station view selects Nauka; leaving any other keeps the satellite', async (t) => {
|
||||
const { cockpit, satellites, clock } = await orbitAt(t);
|
||||
const names = { 25544: 'ISS (ZARYA)', 49044: 'ISS (NAUKA)' };
|
||||
let subject = { ...ISS };
|
||||
const tracked = [];
|
||||
satellites.getCockpitSubject = () => ({ ...subject });
|
||||
satellites.trackById = (noradId) => {
|
||||
const id = Number(noradId);
|
||||
tracked.push(id);
|
||||
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
|
||||
return true;
|
||||
};
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
await frame();
|
||||
// On the Cupola, riding the ISS's entry, when the Cockpit is left.
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
satellites.calls.length = 0;
|
||||
tracked.length = 0;
|
||||
assert.equal(cockpit.exit(), true);
|
||||
assert.deepEqual(tracked, [49044], 'Nauka is selected');
|
||||
assert.deepEqual(satellites.calls, [
|
||||
['subject', null],
|
||||
['refocus', 49044],
|
||||
]);
|
||||
});
|
||||
|
||||
test('leaving the plain orbital view refocuses the satellite ridden', async (t) => {
|
||||
const { cockpit, satellites } = await orbitAt(t);
|
||||
const tracked = [];
|
||||
satellites.trackById = (noradId) => {
|
||||
tracked.push(noradId);
|
||||
return true;
|
||||
};
|
||||
satellites.calls.length = 0;
|
||||
assert.equal(cockpit.exit(), true);
|
||||
assert.deepEqual(tracked, []);
|
||||
assert.deepEqual(satellites.calls, [
|
||||
['subject', null],
|
||||
['refocus', 25544],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the left arrow steps back through the views, wrapping round', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const station = stationViews();
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
const frame = async () => {
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
// From the first view back to the last.
|
||||
$('#cockpit-orbital-view-previous').dispatchEvent(
|
||||
new Event('click', { bubbles: true }),
|
||||
);
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
await frame();
|
||||
// The camera is at the docked vehicle's view (30 m up in this stand-in).
|
||||
assert.equal(station.heightOf(shots.at(-1)), 30);
|
||||
assert.equal(cockpit.previousOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
});
|
||||
@@ -678,7 +678,7 @@ export function enter({ kind = null } = {}) {
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · NADIR VIEW', { label: info.name }),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
} else if (vessel) {
|
||||
this.pushCockpitSignal(
|
||||
@@ -739,6 +739,14 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
const vesselSubject = this.subjectKind === 'vessel' ? this.subjectId : null;
|
||||
const satelliteSubject =
|
||||
this.subjectKind === 'satellite' ? this.subjectId : null;
|
||||
// Leaving a view from a station selects the station's home entry (the
|
||||
// ISS's Nauka, Tiangong's Tianhe), whichever view or entry it ended on:
|
||||
// the station's first view, and the one it opens on.
|
||||
const station = this.orbital;
|
||||
const stationHome =
|
||||
satelliteSubject !== null && station && station.mount != null
|
||||
? (station.mountViews?.[0]?.noradId ?? null)
|
||||
: null;
|
||||
this.active = false;
|
||||
this.subjectKind = null;
|
||||
this.subjectProvider = null;
|
||||
@@ -810,8 +818,20 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
// Back to the selected vessel's map view, through the layer's own focus.
|
||||
this.services.aisLiveVesselsLayer?.focusSelectedVessel?.();
|
||||
} else if (restoreTracking && satelliteSubject !== null) {
|
||||
// Back to the satellite's follow camera, through the layer's own refocus.
|
||||
this.services.satellitesLayer?.refocusTrackedById?.(satelliteSubject);
|
||||
// Back to the satellite's follow camera, through the layer's own refocus;
|
||||
// from a station, on its home entry.
|
||||
const layer = this.services.satellitesLayer;
|
||||
let subject = satelliteSubject;
|
||||
if (stationHome !== null && String(stationHome) !== String(subject)) {
|
||||
let tracked = false;
|
||||
try {
|
||||
tracked = Boolean(layer?.trackById?.(stationHome, { origin: 'user' }));
|
||||
} catch {
|
||||
tracked = false;
|
||||
}
|
||||
if (tracked) subject = stationHome;
|
||||
}
|
||||
layer?.refocusTrackedById?.(subject);
|
||||
}
|
||||
this.syncEntry();
|
||||
// Return to the card or readout control that opened Cockpit.
|
||||
|
||||
@@ -153,3 +153,21 @@ test('the nearby sites search is busy, without native disable, until it settles'
|
||||
assert.equal(button.getAttribute('aria-busy'), 'false');
|
||||
assert.equal(button.getAttribute('aria-disabled'), 'false');
|
||||
});
|
||||
|
||||
test('with Context closed, the collapsible sections are already in the page for PanelChrome', (t) => {
|
||||
// PanelChrome finds collapsible panels once, at startup, by their collapse
|
||||
// buttons; Context starts closed, so a section that mounts only while it
|
||||
// is open would never be registered and its +/- would do nothing.
|
||||
fixture(t);
|
||||
assert.equal(
|
||||
document
|
||||
.getElementById('global-context-panel')
|
||||
.classList.contains('collapsed'),
|
||||
true,
|
||||
);
|
||||
const targets = [
|
||||
...document.querySelectorAll('.panel-collapse-btn[data-collapse-target]'),
|
||||
].map((button) => button.dataset.collapseTarget);
|
||||
for (const id of ['station-panel', 'live-panel', 'radio-panel'])
|
||||
assert.ok(targets.includes(id), `${id} is there to be registered`);
|
||||
});
|
||||
@@ -98,10 +98,10 @@ test('the media cards are drawn by their view, not built in script', () => {
|
||||
const source = read('data/bhoteKoshiEmbeddedMedia.js');
|
||||
assert.doesNotMatch(source, /innerHTML|insertAdjacentHTML|createElementNS/);
|
||||
// Provider scripts and preconnects, the overlay root, and the Facebook
|
||||
// embed node and its warm host.
|
||||
// embed node and its warm host. The YouTube API's script is youtubeApi.js's.
|
||||
assert.deepEqual(
|
||||
[...source.matchAll(/createElement\('(\w+)'\)/g)].map((m) => m[1]),
|
||||
['script', 'script', 'script', 'link', 'div', 'div', 'div'],
|
||||
['script', 'script', 'link', 'div', 'div', 'div'],
|
||||
);
|
||||
assert.match(source, /renderVue\(\s*h\(BhoteKoshiMediaCards,/);
|
||||
const cards = template(CARDS);
|
||||
|
||||
@@ -28,16 +28,20 @@ const views = {
|
||||
// Display's and Radio's collapse and launcher buttons, Radio's Enable,
|
||||
// Previous, Play and Next, and the desktop rail's two items and glyphs.
|
||||
'panels/CockpitUtilityControls.vue': { buttons: 10, icons: 2 },
|
||||
// Previous, Next, Auto, the card's collapse and the three page tabs; the
|
||||
// first, second and fourth draw a glyph.
|
||||
'panels/CockpitBriefing.vue': { buttons: 7, icons: 3 },
|
||||
// Previous, Next, Auto, the card's collapse and the four page tabs (LIVE
|
||||
// shows only with a stream); the first, second and fourth draw a glyph.
|
||||
'panels/CockpitBriefing.vue': { buttons: 8, icons: 3 },
|
||||
// Previous, Next, the card's collapse and Weather; three of them draw a
|
||||
// glyph, and the nearest contact's arrow is the fourth.
|
||||
'panels/CockpitContext.vue': { buttons: 4, icons: 4 },
|
||||
// A signal row's target and its chevron.
|
||||
'panels/CockpitSignalList.vue': { buttons: 1, icons: 1 },
|
||||
// TLE, Nadir, Zoom out, Zoom in and Sensor.
|
||||
'panels/CockpitOrbital.vue': { buttons: 5, icons: 0 },
|
||||
// TLE, Nadir, Zoom out, Zoom in and Sensor, and a station's Previous and
|
||||
// Next view, which draw the two glyphs.
|
||||
'panels/CockpitOrbital.vue': { buttons: 7, icons: 2 },
|
||||
// The LIVE page's Previous, Next, Play and Try again; the first three draw
|
||||
// a glyph.
|
||||
'panels/CockpitLivePage.vue': { buttons: 4, icons: 3 },
|
||||
// The range step.
|
||||
'panels/CockpitRadar.vue': { buttons: 1, icons: 0 },
|
||||
// The flight plan's arrow.
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
import {
|
||||
LIVE_STREAMS,
|
||||
liveStreamsFor,
|
||||
youtubeWatchUrl,
|
||||
} from '../data/liveStreams.js';
|
||||
import { createYouTubeLivePlayer } from '../data/youtubeLivePlayer.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { applicationPinia } from './vueRuntime.js';
|
||||
|
||||
/** The element the LIVE section in Context keeps for the player. */
|
||||
export const LIVE_PLAYER_HOST_ID = 'live-player-host';
|
||||
|
||||
/**
|
||||
* The element the Cockpit briefing's LIVE page keeps for the player; the one
|
||||
* used while the Cockpit is on, since the right rail is hidden there.
|
||||
*/
|
||||
export const COCKPIT_LIVE_PLAYER_HOST_ID = 'cockpit-live-player-host';
|
||||
|
||||
/**
|
||||
* A layer's selected subject can be judged again as it settles (a satellite
|
||||
* is docked to the station once both orbits have been compared): the keys
|
||||
* are read again this often while something is selected.
|
||||
*/
|
||||
export const LIVE_SUBJECT_REFRESH_MS = 2000;
|
||||
|
||||
/**
|
||||
* Own the live video: which object is selected (the tracking layers'
|
||||
* `gev:awareness-subject-selected`), which streams the list attaches to it,
|
||||
* and the one player. The views (the LIVE section in Context and the Cockpit
|
||||
* briefing's LIVE page) render what this publishes, and the player is built
|
||||
* only when the viewer presses Play in one of them (`playLive`): YouTube sees
|
||||
* the viewer's IP address, so selecting a station by click, a link, a scene
|
||||
* or voice never loads it. The player is built into the view that is shown,
|
||||
* the section's outside the Cockpit and the page's inside it, and goes when
|
||||
* that view is hidden (the section collapsed, Context closed, the Cockpit
|
||||
* page left: `hideLive`), when the Cockpit is entered or left, and when the
|
||||
* selection moves to an object without that stream or clears.
|
||||
*/
|
||||
export class LiveControls {
|
||||
/**
|
||||
* @param {{store?: object, actions: {getLayer: (layerId: string) => object|null,
|
||||
* scheduleLayout?: () => void}, documentRef?: Document, globalRef?: object,
|
||||
* createPlayer?: typeof createYouTubeLivePlayer,
|
||||
* streams?: readonly object[], refreshMs?: number}} options
|
||||
*/
|
||||
constructor({
|
||||
store = useLiveStore(applicationPinia()),
|
||||
actions,
|
||||
documentRef = globalThis.document,
|
||||
globalRef = globalThis,
|
||||
createPlayer = createYouTubeLivePlayer,
|
||||
streams = LIVE_STREAMS,
|
||||
refreshMs = LIVE_SUBJECT_REFRESH_MS,
|
||||
}) {
|
||||
this.store = store;
|
||||
this.actions = actions;
|
||||
this.documentRef = documentRef;
|
||||
this.globalRef = globalRef;
|
||||
this.createPlayer = createPlayer;
|
||||
this.streams = streams;
|
||||
this.refreshMs = refreshMs;
|
||||
this.destroyed = false;
|
||||
/** The selected object: its layer, id and label; null for none. */
|
||||
this.subject = null;
|
||||
/** The streams on offer for it, and the chosen one's id. */
|
||||
this.offered = [];
|
||||
this.currentId = null;
|
||||
/** The player, the element and stream it was built for, and its state. */
|
||||
this.player = null;
|
||||
this.playerHost = null;
|
||||
this.playerStreamId = null;
|
||||
this.playback = { state: 'idle', reason: null };
|
||||
/** Whether the Cockpit is on, which decides the host the player goes in. */
|
||||
this.cockpitActive =
|
||||
documentRef?.body?.classList?.contains?.('cockpit-mode') === true;
|
||||
this.timer = null;
|
||||
/** The view last published, as text: the 2 s refresh resends nothing new. */
|
||||
this.publishedKey = undefined;
|
||||
/** The stop held back for one tick after a clear (see `_onCleared`). */
|
||||
this.clearGrace = null;
|
||||
this.listeners = new AbortController();
|
||||
const { signal } = this.listeners;
|
||||
const target = globalRef.addEventListener ? globalRef : null;
|
||||
target?.addEventListener(
|
||||
'gev:awareness-subject-selected',
|
||||
(event) => this._onSelected(event.detail),
|
||||
{ signal },
|
||||
);
|
||||
target?.addEventListener(
|
||||
'gev:awareness-subject-cleared',
|
||||
(event) => this._onCleared(event.detail),
|
||||
{ signal },
|
||||
);
|
||||
target?.addEventListener(
|
||||
'gev:cockpit-mode-changed',
|
||||
(event) => this._onCockpitMode(event.detail?.active === true),
|
||||
{ signal },
|
||||
);
|
||||
this.owner = store.connect({
|
||||
cycleLive: (direction) => this.cycle(direction),
|
||||
playLive: () => this.play(),
|
||||
stopLive: () => this.stop(),
|
||||
retryLive: () => this.play({ restart: true }),
|
||||
hideLive: (where) => this.hide(where),
|
||||
});
|
||||
store.publish(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A new selection. A player that is on keeps playing when the new subject
|
||||
* offers the same stream (another entry of the same station: a module, a
|
||||
* docked vehicle, the Cockpit stepping between views on it); otherwise it
|
||||
* goes.
|
||||
*/
|
||||
_onSelected(detail) {
|
||||
if (this.destroyed || !detail?.layerId || detail.id == null) return;
|
||||
this._cancelClearGrace();
|
||||
this.subject = {
|
||||
layerId: detail.layerId,
|
||||
id: detail.id,
|
||||
label: String(detail.label ?? detail.id),
|
||||
};
|
||||
if (this.player) {
|
||||
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
|
||||
if (offered.some((stream) => stream.id === this.playerStreamId))
|
||||
this.currentId = this.playerStreamId;
|
||||
else this.stop();
|
||||
}
|
||||
this._refresh();
|
||||
this._arm();
|
||||
}
|
||||
|
||||
/**
|
||||
* The selection cleared. With a player on, the stop waits one tick: the
|
||||
* Cockpit stepping between views on a station clears the selection and
|
||||
* selects the next entry at once, and a player for the same stream should
|
||||
* not be torn down and rebuilt between the two.
|
||||
*/
|
||||
_onCleared(detail) {
|
||||
if (this.destroyed || !this.subject) return;
|
||||
if (detail?.layerId && detail.layerId !== this.subject.layerId) return;
|
||||
this.subject = null;
|
||||
this._disarm();
|
||||
if (this.player && this.globalRef.setTimeout) {
|
||||
this._cancelClearGrace();
|
||||
this.clearGrace = this.globalRef.setTimeout(() => {
|
||||
this.clearGrace = null;
|
||||
if (this.destroyed || this.subject) return;
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
_cancelClearGrace() {
|
||||
if (this.clearGrace !== null)
|
||||
this.globalRef.clearTimeout?.(this.clearGrace);
|
||||
this.clearGrace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit went on or off: the view the player was in is hidden now,
|
||||
* so the player goes. The view now shown offers Play again.
|
||||
*/
|
||||
_onCockpitMode(active) {
|
||||
if (this.destroyed || active === this.cockpitActive) return;
|
||||
this.cockpitActive = active;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* A view was hidden (`section`: the LIVE section collapsed or Context
|
||||
* closed; `cockpit`: the briefing left its LIVE page or went): the player
|
||||
* goes if it was in that view's screen, so nothing plays unseen.
|
||||
* @param {'section'|'cockpit'} where
|
||||
* @returns {boolean} True when a player was removed.
|
||||
*/
|
||||
hide(where) {
|
||||
const id =
|
||||
where === 'cockpit' ? COCKPIT_LIVE_PLAYER_HOST_ID : LIVE_PLAYER_HOST_ID;
|
||||
if (!this.player || this.playerHost?.id !== id) return false;
|
||||
return this.stop();
|
||||
}
|
||||
|
||||
/** The element the player belongs in now: the Cockpit page's, or the section's. */
|
||||
_host() {
|
||||
const id = this.cockpitActive
|
||||
? COCKPIT_LIVE_PLAYER_HOST_ID
|
||||
: LIVE_PLAYER_HOST_ID;
|
||||
return this.documentRef?.getElementById?.(id) ?? null;
|
||||
}
|
||||
|
||||
/** Read the selected subject's keys again on a timer, while one is selected. */
|
||||
_arm() {
|
||||
this._disarm();
|
||||
if (!this.subject || !(this.refreshMs > 0)) return;
|
||||
this.timer = this.globalRef.setInterval(
|
||||
() => this._refresh(),
|
||||
this.refreshMs,
|
||||
);
|
||||
this.timer?.unref?.();
|
||||
}
|
||||
|
||||
_disarm() {
|
||||
if (this.timer !== null) this.globalRef.clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
/** The keys the selected subject is known by, from its layer. */
|
||||
_subjectKeys() {
|
||||
if (!this.subject) return [];
|
||||
const { layerId, id } = this.subject;
|
||||
const keys = [`${layerId}:${id}`];
|
||||
let layer = null;
|
||||
try {
|
||||
layer = this.actions.getLayer?.(layerId) ?? null;
|
||||
} catch {
|
||||
layer = null;
|
||||
}
|
||||
try {
|
||||
for (const key of layer?.getLiveSubjectKeys?.() ?? [])
|
||||
if (typeof key === 'string') keys.push(key);
|
||||
} catch {
|
||||
// A layer that cannot say keeps its plain key.
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/** Work out the streams on offer and publish. */
|
||||
_refresh() {
|
||||
if (this.destroyed) return;
|
||||
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
|
||||
const changed =
|
||||
offered.length !== this.offered.length ||
|
||||
offered.some((stream, index) => stream.id !== this.offered[index]?.id);
|
||||
this.offered = offered;
|
||||
if (!offered.some((stream) => stream.id === this.currentId)) {
|
||||
// The chosen stream went with the selection: nothing plays on.
|
||||
if (this.player) this.stop();
|
||||
this.currentId = offered[0]?.id ?? null;
|
||||
}
|
||||
this._publish();
|
||||
if (changed) this.actions.scheduleLayout?.();
|
||||
}
|
||||
|
||||
/** Publish `view` unless it is the one published last. */
|
||||
_send(view) {
|
||||
const key = JSON.stringify(view);
|
||||
if (key === this.publishedKey) return;
|
||||
this.publishedKey = key;
|
||||
this.store.publish(view);
|
||||
}
|
||||
|
||||
_publish() {
|
||||
if (this.destroyed) return;
|
||||
if (!this.subject || !this.offered.length) {
|
||||
this._send(null);
|
||||
return;
|
||||
}
|
||||
const index = Math.max(
|
||||
0,
|
||||
this.offered.findIndex((stream) => stream.id === this.currentId),
|
||||
);
|
||||
const current = this.offered[index];
|
||||
this._send({
|
||||
label: this.subject.label,
|
||||
streams: this.offered.map((stream) => ({
|
||||
id: stream.id,
|
||||
title: stream.title,
|
||||
owner: stream.owner,
|
||||
})),
|
||||
index,
|
||||
count: this.offered.length,
|
||||
current: {
|
||||
id: current.id,
|
||||
title: current.title,
|
||||
owner: current.owner,
|
||||
ownerUrl: current.ownerUrl,
|
||||
note: current.note,
|
||||
watchUrl: youtubeWatchUrl(current.videoId),
|
||||
},
|
||||
state: this.playback.state,
|
||||
reason: this.playback.reason,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Step to the next (+1) or previous (-1) stream on offer, wrapping. A
|
||||
* playing stream hands over to the new one.
|
||||
* @returns {boolean} True when the stream changed.
|
||||
*/
|
||||
cycle(direction = 1) {
|
||||
if (this.offered.length < 2) return false;
|
||||
const index = this.offered.findIndex((s) => s.id === this.currentId);
|
||||
const next =
|
||||
(Math.max(index, 0) + (direction < 0 ? -1 : 1) + this.offered.length) %
|
||||
this.offered.length;
|
||||
this.currentId = this.offered[next].id;
|
||||
const wasPlaying = this.player !== null;
|
||||
this.stop();
|
||||
if (wasPlaying) this.play();
|
||||
else this._publish();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the chosen stream in the host now shown: the one call that loads
|
||||
* the player, made only by the viewer's Play (or Try again). A player
|
||||
* already loading or playing that stream in that host is left alone;
|
||||
* `restart` (Try again) builds a fresh one regardless.
|
||||
* @returns {boolean} True when a player is loading or playing afterwards.
|
||||
*/
|
||||
play({ restart = false } = {}) {
|
||||
if (this.destroyed) return false;
|
||||
const stream = this.offered.find((s) => s.id === this.currentId);
|
||||
const host = this._host();
|
||||
if (!stream || !host) return false;
|
||||
const running =
|
||||
this.playback.state === 'loading' || this.playback.state === 'playing';
|
||||
if (
|
||||
!restart &&
|
||||
this.player &&
|
||||
running &&
|
||||
this.playerHost === host &&
|
||||
this.playerStreamId === stream.id
|
||||
)
|
||||
return true;
|
||||
this.stop();
|
||||
this.playback = { state: 'loading', reason: null };
|
||||
this.playerHost = host;
|
||||
this.playerStreamId = stream.id;
|
||||
this.player = this.createPlayer({
|
||||
host,
|
||||
videoId: stream.videoId,
|
||||
documentRef: this.documentRef,
|
||||
globalRef: this.globalRef,
|
||||
onChange: ({ state, reason }) => {
|
||||
if (this.destroyed) return;
|
||||
this.playback = { state, reason };
|
||||
this._publish();
|
||||
},
|
||||
});
|
||||
this._publish();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Remove the player; the screen goes dark. */
|
||||
stop() {
|
||||
const had = this.player !== null;
|
||||
this.player?.destroy();
|
||||
this.player = null;
|
||||
this.playerHost = null;
|
||||
this.playerStreamId = null;
|
||||
if (had || this.playback.state !== 'idle') {
|
||||
this.playback = { state: 'idle', reason: null };
|
||||
this._publish();
|
||||
}
|
||||
return had;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
this._cancelClearGrace();
|
||||
this.stop();
|
||||
this.destroyed = true;
|
||||
this._disarm();
|
||||
this.listeners.abort();
|
||||
this.store.detach(this.owner);
|
||||
this.store.publish(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
// src/ui/liveControls.test.mjs — LiveControls owns the live video: the
|
||||
// selected object's streams, the one player, which screen it is built into,
|
||||
// and when it goes.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
COCKPIT_LIVE_PLAYER_HOST_ID,
|
||||
LIVE_PLAYER_HOST_ID,
|
||||
LiveControls,
|
||||
} from './liveControls.js';
|
||||
import { createOwners } from './stores/owners.js';
|
||||
|
||||
const STREAMS = Object.freeze([
|
||||
{
|
||||
id: 'one',
|
||||
platform: 'youtube',
|
||||
videoId: 'AAAAAAAAAAA',
|
||||
title: 'First',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:test'],
|
||||
note: 'note',
|
||||
},
|
||||
{
|
||||
id: 'two',
|
||||
platform: 'youtube',
|
||||
videoId: 'BBBBBBBBBBB',
|
||||
title: 'Second',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:test'],
|
||||
note: 'note',
|
||||
},
|
||||
{
|
||||
id: 'other',
|
||||
platform: 'youtube',
|
||||
videoId: 'CCCCCCCCCCC',
|
||||
title: 'Elsewhere',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:other'],
|
||||
note: 'note',
|
||||
},
|
||||
]);
|
||||
|
||||
function fixture({
|
||||
withHost = true,
|
||||
withCockpitHost = true,
|
||||
cockpitMode = false,
|
||||
} = {}) {
|
||||
const globalRef = new EventTarget();
|
||||
const intervals = [];
|
||||
globalRef.setInterval = (callback, ms) => {
|
||||
const id = intervals.length + 1;
|
||||
intervals.push({ id, callback, ms, cleared: false });
|
||||
return id;
|
||||
};
|
||||
globalRef.clearInterval = (id) => {
|
||||
const timer = intervals.find((entry) => entry.id === id);
|
||||
if (timer) timer.cleared = true;
|
||||
};
|
||||
const timeouts = [];
|
||||
globalRef.setTimeout = (callback, ms) => {
|
||||
timeouts.push({ callback, ms, done: false });
|
||||
return timeouts.length;
|
||||
};
|
||||
globalRef.clearTimeout = (id) => {
|
||||
if (timeouts[id - 1]) timeouts[id - 1].done = true;
|
||||
};
|
||||
/** Run the timeouts due now, as the next tick would. */
|
||||
const tick = () => {
|
||||
for (const timeout of timeouts.splice(0))
|
||||
if (!timeout.done) timeout.callback();
|
||||
};
|
||||
const host = { id: LIVE_PLAYER_HOST_ID };
|
||||
const cockpitHost = { id: COCKPIT_LIVE_PLAYER_HOST_ID };
|
||||
const documentRef = {
|
||||
getElementById: (id) => {
|
||||
if (id === LIVE_PLAYER_HOST_ID) return withHost ? host : null;
|
||||
if (id === COCKPIT_LIVE_PLAYER_HOST_ID)
|
||||
return withCockpitHost ? cockpitHost : null;
|
||||
return null;
|
||||
},
|
||||
body: {
|
||||
classList: { contains: (name) => cockpitMode && name === 'cockpit-mode' },
|
||||
},
|
||||
};
|
||||
const published = [];
|
||||
const store = {
|
||||
...createOwners(),
|
||||
publish: (view) => published.push(view),
|
||||
};
|
||||
let keys = [];
|
||||
const layer = { getLiveSubjectKeys: () => keys };
|
||||
const layouts = [];
|
||||
const players = [];
|
||||
const createPlayer = (options) => {
|
||||
const player = {
|
||||
options,
|
||||
destroyed: 0,
|
||||
destroy: () => (player.destroyed += 1),
|
||||
};
|
||||
players.push(player);
|
||||
return player;
|
||||
};
|
||||
const controls = new LiveControls({
|
||||
store,
|
||||
actions: {
|
||||
getLayer: (layerId) => (layerId === 'satellites' ? layer : null),
|
||||
scheduleLayout: () => layouts.push(1),
|
||||
},
|
||||
documentRef,
|
||||
globalRef,
|
||||
createPlayer,
|
||||
streams: STREAMS,
|
||||
refreshMs: 2000,
|
||||
});
|
||||
const dispatch = (type, detail) =>
|
||||
globalRef.dispatchEvent(new CustomEvent(type, { detail }));
|
||||
const select = (detail) =>
|
||||
dispatch('gev:awareness-subject-selected', {
|
||||
layerId: 'satellites',
|
||||
id: 25544,
|
||||
label: 'ISS (ZARYA)',
|
||||
...detail,
|
||||
});
|
||||
const view = () => published.at(-1);
|
||||
const running = () => intervals.filter((timer) => !timer.cleared);
|
||||
return {
|
||||
controls,
|
||||
store,
|
||||
published,
|
||||
view,
|
||||
dispatch,
|
||||
select,
|
||||
setKeys: (next) => (keys = next),
|
||||
players,
|
||||
layouts,
|
||||
intervals,
|
||||
running,
|
||||
tick,
|
||||
host,
|
||||
cockpitHost,
|
||||
};
|
||||
}
|
||||
|
||||
test('nothing selected publishes no section; a selection with streams publishes them', () => {
|
||||
const f = fixture();
|
||||
assert.equal(f.view(), null);
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
const view = f.view();
|
||||
assert.equal(view.label, 'ISS (ZARYA)');
|
||||
assert.equal(view.count, 2);
|
||||
assert.equal(view.index, 0);
|
||||
assert.deepEqual(
|
||||
view.streams.map((stream) => stream.id),
|
||||
['one', 'two'],
|
||||
);
|
||||
assert.equal(view.current.id, 'one');
|
||||
assert.equal(
|
||||
view.current.watchUrl,
|
||||
'https://www.youtube.com/watch?v=AAAAAAAAAAA',
|
||||
);
|
||||
assert.equal(view.state, 'idle');
|
||||
assert.equal(
|
||||
f.layouts.length,
|
||||
1,
|
||||
'the rail is laid out once the section appears',
|
||||
);
|
||||
assert.equal(f.running().length, 1, 'the subject is re-read on a timer');
|
||||
assert.equal(f.running()[0].ms, 2000);
|
||||
});
|
||||
|
||||
test('a selection no stream names keeps the section away; the plain key counts too', () => {
|
||||
const f = fixture();
|
||||
f.select();
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.layouts.length, 0);
|
||||
// A stream attached to a layer's own `<layer>:<id>` key needs no layer help.
|
||||
const g = fixture();
|
||||
g.setKeys([]);
|
||||
g.select({ layerId: 'satellites', id: 'x' });
|
||||
assert.equal(g.view(), null);
|
||||
});
|
||||
|
||||
test('the layer is asked again on the timer: an entry that settles as docked gains the streams', () => {
|
||||
const f = fixture();
|
||||
f.select();
|
||||
assert.equal(f.view(), null);
|
||||
f.setKeys(['station:test']);
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.view()?.count, 2);
|
||||
assert.equal(f.layouts.length, 1);
|
||||
// Unchanged keys do not lay out again.
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.layouts.length, 1);
|
||||
});
|
||||
|
||||
test('playLive builds the player for the chosen stream in the section, once; Try again builds it anew', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(
|
||||
f.players.length,
|
||||
0,
|
||||
'the views ask; selection alone builds nothing',
|
||||
);
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players.length, 1);
|
||||
assert.equal(f.players[0].options.videoId, 'AAAAAAAAAAA');
|
||||
assert.equal(f.players[0].options.host, f.host);
|
||||
assert.equal(f.view().state, 'loading');
|
||||
// Asked again while loading or playing, the same player stays.
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
f.players[0].options.onChange({ state: 'playing', reason: null });
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players.length, 1, 'no second player for the same stream');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.view().state, 'playing');
|
||||
f.players[0].options.onChange({ state: 'offline', reason: 'ended' });
|
||||
assert.equal(f.view().state, 'offline');
|
||||
assert.equal(f.view().reason, 'ended');
|
||||
assert.equal(f.store.act('stopLive'), true);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
// Try again builds a fresh player.
|
||||
assert.equal(f.store.act('retryLive'), true);
|
||||
assert.equal(f.players.length, 2);
|
||||
});
|
||||
|
||||
test('Play without the host element in the page, or without a selection, does nothing', () => {
|
||||
const noHost = fixture({ withHost: false });
|
||||
noHost.setKeys(['station:test']);
|
||||
noHost.select();
|
||||
assert.equal(noHost.store.act('playLive'), false);
|
||||
assert.equal(noHost.players.length, 0);
|
||||
const idle = fixture();
|
||||
assert.equal(idle.store.act('playLive'), false);
|
||||
});
|
||||
|
||||
test('the arrows step through the streams, wrapping, and a playing stream hands over', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(f.store.act('cycleLive', 1), true);
|
||||
assert.equal(f.view().current.id, 'two');
|
||||
assert.equal(f.store.act('cycleLive', 1), true);
|
||||
assert.equal(f.view().current.id, 'one', 'wraps forward');
|
||||
assert.equal(f.store.act('cycleLive', -1), true);
|
||||
assert.equal(f.view().current.id, 'two', 'wraps backward');
|
||||
assert.equal(f.players.length, 0, 'stepping while idle loads nothing');
|
||||
f.store.act('playLive');
|
||||
f.store.act('cycleLive', 1);
|
||||
assert.equal(f.players.length, 2);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.players[1].options.videoId, 'AAAAAAAAAAA');
|
||||
assert.equal(f.view().state, 'loading');
|
||||
});
|
||||
|
||||
test('with one stream there is nothing to cycle', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:other']);
|
||||
f.select();
|
||||
assert.equal(f.view().count, 1);
|
||||
assert.equal(f.store.act('cycleLive', 1), false);
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
});
|
||||
|
||||
test('a new selection stops the stream; the same entry selected again keeps it', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.select({ origin: 'pick' });
|
||||
assert.equal(f.players[0].destroyed, 0, 'the same subject plays on');
|
||||
f.setKeys(['station:other']);
|
||||
f.select({ id: 99999, label: 'OTHER' });
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().label, 'OTHER');
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test('clearing the selection takes the section down; another layer clearing does not', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'flights' });
|
||||
assert.equal(f.view().count, 2, 'another layer clearing is not ours');
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
assert.equal(f.running().length, 0, 'the timer stops with the selection');
|
||||
// The stop waits a tick, for a selection that moves straight on.
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
f.tick();
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
});
|
||||
|
||||
test('a selection that moves straight on to an entry with the same stream keeps the player', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
// The Cockpit stepping to the next view on the station: cleared, then the
|
||||
// next entry selected, in one go.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.select({ id: 49044, label: 'ISS (NAUKA)' });
|
||||
f.tick();
|
||||
assert.equal(f.players.length, 1, 'not rebuilt');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.view().label, 'ISS (NAUKA)');
|
||||
assert.equal(f.view().current.id, 'one');
|
||||
// One without that stream stops it.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.setKeys(['station:other']);
|
||||
f.select({ id: 99999, label: 'OTHER' });
|
||||
f.tick();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
});
|
||||
|
||||
test('entering or leaving the Cockpit removes the player: the view now shown offers Play again', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.players[0].options.onChange({ state: 'playing', reason: null });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players[0].destroyed, 1, 'the rail is hidden in the Cockpit');
|
||||
assert.equal(f.players.length, 1, 'nothing is built by itself');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
// The same state again changes nothing.
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players.length, 1);
|
||||
// Play in the Cockpit's page builds it in that page's screen.
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players[1].options.host, f.cockpitHost);
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players[1].destroyed, 1);
|
||||
assert.equal(f.players.length, 2);
|
||||
});
|
||||
|
||||
test('a view that is hidden removes the player only when it is in that view', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.store.act('hideLive', 'cockpit'), false, 'not in the page');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.store.act('hideLive', 'section'), true);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
assert.equal(f.store.act('hideLive', 'section'), false, 'nothing left');
|
||||
});
|
||||
|
||||
test('selecting a station with streams builds no player until Play', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.select({ origin: 'pick' });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players.length, 0);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.players.length, 1);
|
||||
});
|
||||
|
||||
test('the Cockpit going on or off with nothing playing builds nothing', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players.length, 0);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test("entering the Cockpit without the page's screen in the page removes the player", () => {
|
||||
const f = fixture({ withCockpitHost: false });
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.players.length, 1);
|
||||
assert.equal(
|
||||
f.view().state,
|
||||
'idle',
|
||||
'the view starts it once its screen is there',
|
||||
);
|
||||
assert.equal(f.store.act('playLive'), false, 'still no screen');
|
||||
});
|
||||
|
||||
test("constructed with the Cockpit already on, playLive uses the page's screen", () => {
|
||||
const f = fixture({ cockpitMode: true });
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players[0].options.host, f.cockpitHost);
|
||||
});
|
||||
|
||||
test('the chosen stream going from the list stops it and picks the first that remains', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('cycleLive', 1);
|
||||
f.store.act('playLive');
|
||||
f.setKeys(['station:other']);
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test('destroy stops the stream, detaches the actions and publishes nothing', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.controls.destroy();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.store.act('playLive'), undefined, 'no owner answers');
|
||||
assert.equal(f.running().length, 0);
|
||||
const before = f.published.length;
|
||||
f.select();
|
||||
assert.equal(f.published.length, before, 'events after destroy are ignored');
|
||||
});
|
||||
|
||||
test('the 2 s refresh publishes nothing when nothing changed', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
const count = f.published.length;
|
||||
for (const timer of f.running()) timer.callback();
|
||||
for (const timer of f.running()) timer.callback();
|
||||
assert.equal(f.published.length, count, 'the same view is not sent again');
|
||||
f.store.act('playLive');
|
||||
assert.ok(f.published.length > count, 'a change is');
|
||||
});
|
||||
@@ -0,0 +1,261 @@
|
||||
// src/ui/livePanel.test.mjs — the LIVE panel renders what LiveControls
|
||||
// publishes, over happy-dom; it starts the stream as soon as one is chosen,
|
||||
// collapsed or not, and its controls reach the store's owner.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { usePanelChromeStore } from './stores/panelChrome.js';
|
||||
import LivePanel from './views/panels/LivePanel.vue';
|
||||
|
||||
const settle = async () => {
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(LivePanel).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useLiveStore(pinia);
|
||||
const acted = [];
|
||||
store.connect({
|
||||
cycleLive: (direction) => acted.push(['cycle', direction]),
|
||||
playLive: () => acted.push(['play']),
|
||||
stopLive: () => acted.push(['stop']),
|
||||
retryLive: () => acted.push(['retry']),
|
||||
hideLive: (where) => acted.push(['hide', where]),
|
||||
});
|
||||
const chrome = usePanelChromeStore(pinia);
|
||||
const token = chrome.connect({ toggle() {}, pin() {} });
|
||||
const setOpen = async (open) => {
|
||||
chrome.publish(token, 'live-panel', { collapsed: !open });
|
||||
await settle();
|
||||
};
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const publish = async (view) => {
|
||||
store.publish(
|
||||
view && {
|
||||
label: 'ISS (ZARYA)',
|
||||
streams: [
|
||||
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
|
||||
{
|
||||
id: 'iss-crew',
|
||||
title: 'Live video and space-to-ground audio',
|
||||
owner: 'NASA',
|
||||
},
|
||||
],
|
||||
index: 0,
|
||||
count: 2,
|
||||
current: {
|
||||
id: 'iss-exterior',
|
||||
title: 'Exterior cameras',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: 'NASA video, via YouTube',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
},
|
||||
state: 'idle',
|
||||
reason: null,
|
||||
...view,
|
||||
},
|
||||
);
|
||||
await settle();
|
||||
};
|
||||
return { $, publish, acted, setOpen, chrome, token };
|
||||
}
|
||||
|
||||
test('without a view the section is hidden and shows OFF', (t) => {
|
||||
const { $, acted } = fixture(t);
|
||||
assert.equal($('live-panel').hidden, true);
|
||||
assert.equal($('live-badge-text').textContent, 'OFF');
|
||||
assert.equal(
|
||||
$('live-player-host'),
|
||||
null,
|
||||
'no screen until a stream is offered',
|
||||
);
|
||||
assert.deepEqual(acted, [], 'nothing to start');
|
||||
});
|
||||
|
||||
test('a view shows the subject, the stream and Play under the IP notice, and loads nothing by itself', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
const panel = $('live-panel');
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal(panel.querySelector('.live-subject').textContent, 'ISS (ZARYA)');
|
||||
assert.equal($('live-stream-title').textContent, 'Exterior cameras · 1/2');
|
||||
assert.ok($('live-previous-btn'));
|
||||
assert.ok($('live-next-btn'));
|
||||
assert.ok($('live-player-host'), 'the screen is in the page for the player');
|
||||
assert.equal(
|
||||
$('live-watch-link').getAttribute('href'),
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
);
|
||||
assert.equal($('live-watch-link').getAttribute('rel'), 'noopener noreferrer');
|
||||
assert.deepEqual(acted, [], 'selecting the station loads no player');
|
||||
// The notice that YouTube sees the viewer's IP address comes before Play.
|
||||
const notice = panel.querySelector('.live-privacy');
|
||||
const play = $('live-play-btn');
|
||||
assert.ok(notice && play);
|
||||
assert.match(notice.textContent, /sees your IP address/);
|
||||
assert.equal(
|
||||
notice.compareDocumentPosition(play) & Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
'the notice is above Play',
|
||||
);
|
||||
assert.equal($('live-status').textContent, 'Click to play');
|
||||
play.click();
|
||||
assert.deepEqual(acted, [['play']], 'Play is what loads the player');
|
||||
// Loading and playing hide Play and ask for nothing more.
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-play-btn'), null);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [['play']]);
|
||||
});
|
||||
|
||||
test('a different stream chosen while idle waits for Play too', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
await publish({
|
||||
current: {
|
||||
id: 'iss-crew',
|
||||
title: 'Live video and space-to-ground audio',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: '',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=M3HKLzjvKPc',
|
||||
},
|
||||
index: 1,
|
||||
});
|
||||
assert.deepEqual(acted, []);
|
||||
assert.ok($('live-play-btn'));
|
||||
});
|
||||
|
||||
test('collapsing the section, or Context, stops the player; opening it starts nothing', async (t) => {
|
||||
const { $, publish, acted, setOpen, chrome, token } = fixture(t);
|
||||
await setOpen(true);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [], 'already playing: nothing to start');
|
||||
await setOpen(false);
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'nothing plays unseen');
|
||||
assert.ok($('live-player-host'), 'the screen keeps its element');
|
||||
await setOpen(true);
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'opening starts nothing');
|
||||
chrome.publish(token, 'global-context-panel', { collapsed: true });
|
||||
await settle();
|
||||
assert.deepEqual(acted, [
|
||||
['hide', 'section'],
|
||||
['hide', 'section'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('while playing the badge says ON AIR with the blinking dot, and there is no card', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
const panel = $('live-panel');
|
||||
assert.equal(panel.classList.contains('live-on-air'), true);
|
||||
assert.equal($('live-badge-text').textContent, 'ON AIR');
|
||||
assert.equal(
|
||||
panel.querySelector('.live-dot').classList.contains('on-air'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
panel.querySelector('.live-screen').classList.contains('active'),
|
||||
true,
|
||||
);
|
||||
assert.equal(panel.querySelector('.live-card'), null);
|
||||
assert.equal($('live-status').textContent, 'Live');
|
||||
});
|
||||
|
||||
test('starting shows the waiting dot and says LOADING', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-badge-text').textContent, 'LOADING');
|
||||
assert.equal(
|
||||
$('live-panel').querySelector('.live-dot').classList.contains('waiting'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('live-status').textContent, 'Starting…');
|
||||
});
|
||||
|
||||
test('an offline stream shows the fallback card with Try again, and is not restarted by itself', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'offline', reason: 'timeout' });
|
||||
const card = $('live-panel').querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('offline'), true);
|
||||
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
|
||||
assert.equal($('live-status').textContent, 'Stream is offline');
|
||||
assert.deepEqual(acted, [], 'offline is left to Try again');
|
||||
$('live-retry-btn').click();
|
||||
assert.deepEqual(acted, [['retry']]);
|
||||
});
|
||||
|
||||
test('a stream that cannot be embedded says so, without Try again', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'unavailable', reason: 'error-150' });
|
||||
const card = $('live-panel').querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('unavailable'), true);
|
||||
assert.equal(
|
||||
card.querySelector('strong').textContent,
|
||||
'This stream cannot play here',
|
||||
);
|
||||
assert.equal($('live-retry-btn'), null);
|
||||
assert.equal($('live-status').textContent, 'This stream cannot play here');
|
||||
assert.deepEqual(acted, []);
|
||||
});
|
||||
|
||||
test('the arrows step through the streams', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
$('live-next-btn').click();
|
||||
$('live-previous-btn').click();
|
||||
assert.deepEqual(acted, [
|
||||
['cycle', 1],
|
||||
['cycle', -1],
|
||||
]);
|
||||
});
|
||||
|
||||
test('with one stream there are no arrows and no counter', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({
|
||||
count: 1,
|
||||
streams: [{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' }],
|
||||
});
|
||||
assert.equal($('live-previous-btn'), null);
|
||||
assert.equal($('live-next-btn'), null);
|
||||
assert.equal($('live-stream-title').textContent, 'Exterior cameras');
|
||||
});
|
||||
|
||||
test('publishing null hides the section again', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({});
|
||||
await publish(null);
|
||||
assert.equal($('live-panel').hidden, true);
|
||||
});
|
||||
|
||||
test('a language change keeps the same screen element and neither stops nor restarts the stream', async (t) => {
|
||||
// The player is built into #live-player-host by LiveControls, outside Vue.
|
||||
// A locale change re-renders the panel's words; the screen must be the
|
||||
// same element afterwards, with nothing asked of the owner, or the stream
|
||||
// would be torn down and rebuilt with every language switch.
|
||||
const { getLocale, setLocale } = await import('../i18n/index.js');
|
||||
const originalLocale = getLocale();
|
||||
t.after(() => setLocale(originalLocale));
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
const screen = $('live-player-host');
|
||||
assert.ok(screen, 'the screen is in the page while a stream is offered');
|
||||
const marker = screen.appendChild(document.createElement('span'));
|
||||
const askedBefore = acted.length;
|
||||
setLocale(originalLocale === 'fr' ? 'es' : 'fr');
|
||||
await settle();
|
||||
assert.equal($('live-player-host'), screen, 'the same screen element');
|
||||
assert.equal(marker.parentNode, screen, 'what LiveControls put in it stays');
|
||||
assert.equal(acted.length, askedBefore, 'no play, stop or retry asked');
|
||||
assert.equal($('live-panel').hidden, false);
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
|
||||
/**
|
||||
* What the LIVE section in Context and the Cockpit briefing's LIVE page
|
||||
* share: the live store's view and its state read as words. Each view calls
|
||||
* this from its setup and renders the result; the controls call LiveControls
|
||||
* through `act`. Nothing here starts the stream: the views show Play while
|
||||
* it is `idle`, and the player is loaded only when the viewer presses it.
|
||||
*/
|
||||
export function useLiveScreen() {
|
||||
const store = useLiveStore();
|
||||
const { act } = store;
|
||||
const { view } = storeToRefs(store);
|
||||
const playing = computed(() => view.value?.state === 'playing');
|
||||
const loading = computed(() => view.value?.state === 'loading');
|
||||
const offline = computed(() => view.value?.state === 'offline');
|
||||
const unavailable = computed(() => view.value?.state === 'unavailable');
|
||||
const idle = computed(
|
||||
() => Boolean(view.value) && view.value.state === 'idle',
|
||||
);
|
||||
const badgeText = computed(() =>
|
||||
playing.value ? t('ON AIR') : loading.value ? t('LOADING') : t('OFF'),
|
||||
);
|
||||
const statusText = computed(() => {
|
||||
switch (view.value?.state) {
|
||||
case 'playing':
|
||||
return t('Live');
|
||||
case 'offline':
|
||||
return t('Stream is offline');
|
||||
case 'unavailable':
|
||||
return t('This stream cannot play here');
|
||||
case 'loading':
|
||||
return t('Starting…');
|
||||
default:
|
||||
return t('Click to play');
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
// src/ui/stationPanel.test.mjs — the STATION panel renders what the
|
||||
// satellites layer publishes, over happy-dom; its controls reach the owner.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { useStationStore } from './stores/station.js';
|
||||
import StationPanel from './views/panels/StationPanel.vue';
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(StationPanel).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useStationStore(pinia);
|
||||
const acted = [];
|
||||
store.connect({
|
||||
setStationMode: (mode) => acted.push(['mode', mode]),
|
||||
chooseStation: (group, choice) => acted.push(['choose', group, choice]),
|
||||
slideStation: (slider, value) => acted.push(['slide', slider, value]),
|
||||
resumeStationArm: (group) => acted.push(['resume', group]),
|
||||
zoomStation: () => acted.push(['zoom']),
|
||||
});
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const publish = async (view) => {
|
||||
store.publish(
|
||||
view && {
|
||||
key: 'iss',
|
||||
title: 'ISS',
|
||||
subject: 'ISS (ZARYA)',
|
||||
mode: 'automatic',
|
||||
telemetry: { state: 'live', poseAgeMs: 4200, liveUntilMs: null },
|
||||
sunlit: true,
|
||||
note: 'Computed, not live telemetry.',
|
||||
groups: [
|
||||
{
|
||||
id: 'sun',
|
||||
label: 'Sun position',
|
||||
note: null,
|
||||
kind: 'choices',
|
||||
choices: [
|
||||
{ id: 'follow', label: 'Follow the Sun', active: true },
|
||||
{ id: 'ahead', label: 'Ahead', active: false },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'arm',
|
||||
label: 'Canadarm2 (degrees)',
|
||||
note: null,
|
||||
kind: 'sliders',
|
||||
resume: 'Resume sway',
|
||||
sliders: [
|
||||
{
|
||||
id: 'shoulder',
|
||||
label: 'Shoulder roll',
|
||||
min: -120,
|
||||
max: 120,
|
||||
value: 15,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
zoom: { offered: false, label: 'Zoom to the ISS' },
|
||||
...view,
|
||||
},
|
||||
);
|
||||
await nextTick();
|
||||
};
|
||||
const telemetryText = () => $('station-telemetry').textContent.trim();
|
||||
return { $, publish, acted, telemetryText };
|
||||
}
|
||||
|
||||
test('without a view the section is hidden', (t) => {
|
||||
const { $ } = fixture(t);
|
||||
assert.equal($('station-panel').hidden, true);
|
||||
assert.equal($('station-badge').textContent, '');
|
||||
});
|
||||
|
||||
test('Automatic shows the subject, the live telemetry age, the Sun line and the note', async (t) => {
|
||||
const { $, publish, telemetryText } = fixture(t);
|
||||
await publish({});
|
||||
const panel = $('station-panel');
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal($('station-badge').textContent, 'ISS');
|
||||
assert.equal(
|
||||
panel.querySelector('.station-subject').textContent,
|
||||
'ISS (ZARYA)',
|
||||
);
|
||||
assert.equal($('station-automatic-btn').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(
|
||||
$('station-automatic-btn').classList.contains('is-active'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'false');
|
||||
assert.equal(telemetryText(), 'Telemetry · updated 4 s ago');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'live');
|
||||
assert.equal($('station-sun').textContent, 'Now: in sunlight');
|
||||
assert.equal(
|
||||
panel.querySelectorAll('.station-group').length,
|
||||
0,
|
||||
'no controls in Automatic',
|
||||
);
|
||||
assert.equal($('station-zoom-btn'), null);
|
||||
});
|
||||
|
||||
test('the status line words each telemetry state, with ages in seconds or minutes', async (t) => {
|
||||
const { $, publish, telemetryText } = fixture(t);
|
||||
await publish({
|
||||
telemetry: { state: 'live', poseAgeMs: 95_000, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry · updated 2 min ago');
|
||||
await publish({
|
||||
telemetry: { state: 'no-signal', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'No signal · computed values');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'waiting');
|
||||
await publish({
|
||||
telemetry: {
|
||||
state: 'no-signal',
|
||||
poseAgeMs: 30_000,
|
||||
liveUntilMs: Date.UTC(2026, 10, 13, 12, 0),
|
||||
},
|
||||
});
|
||||
assert.match(telemetryText(), /^No signal since \S.* · computed values$/);
|
||||
await publish({
|
||||
telemetry: { state: 'unavailable', poseAgeMs: 50_000, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(
|
||||
telemetryText(),
|
||||
'Telemetry unavailable · last update 50 s ago · computed values',
|
||||
);
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({
|
||||
telemetry: { state: 'unavailable', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry unavailable · computed values');
|
||||
await publish({
|
||||
telemetry: { state: 'disabled', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(
|
||||
telemetryText(),
|
||||
'Telemetry not enabled on this server · computed values',
|
||||
);
|
||||
// A station with no feed at all (Tiangong).
|
||||
await publish({
|
||||
telemetry: { state: 'none', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'No public telemetry · computed values');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({
|
||||
telemetry: { state: 'pending', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Connecting to telemetry…');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'waiting');
|
||||
await publish({
|
||||
telemetry: { state: 'idle', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry reads while the model is on screen');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({ sunlit: false });
|
||||
assert.equal($('station-sun').textContent, "Now: in the Earth's shadow");
|
||||
});
|
||||
|
||||
test('Manual shows the groups with the active choice, the sliders and the resume button', async (t) => {
|
||||
const { $, publish, telemetryText, acted } = fixture(t);
|
||||
await publish({ mode: 'manual', sunlit: null });
|
||||
const panel = $('station-panel');
|
||||
assert.equal(panel.classList.contains('station-manual'), true);
|
||||
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(telemetryText(), 'Manual · telemetry paused');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'manual');
|
||||
assert.equal($('station-sun'), null);
|
||||
assert.equal(panel.querySelectorAll('.station-group').length, 2);
|
||||
const follow = panel.querySelector('[data-station-choice="sun:follow"]');
|
||||
const ahead = panel.querySelector('[data-station-choice="sun:ahead"]');
|
||||
assert.equal(follow.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(follow.classList.contains('is-active'), true);
|
||||
assert.equal(ahead.getAttribute('aria-pressed'), 'false');
|
||||
ahead.click();
|
||||
const slider = $('station-slider-shoulder');
|
||||
assert.ok(slider, 'the slider is in the page');
|
||||
assert.equal(
|
||||
panel.querySelector('.station-slider output').textContent,
|
||||
'15°',
|
||||
);
|
||||
panel.querySelector('[data-station-resume="arm"]').click();
|
||||
assert.deepEqual(acted, [
|
||||
['choose', 'sun', 'ahead'],
|
||||
['resume', 'arm'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the mode buttons and the zoom button call the owner', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ zoom: { offered: true, label: 'Zoom to the ISS' } });
|
||||
$('station-manual-btn').click();
|
||||
$('station-automatic-btn').click();
|
||||
assert.equal($('station-zoom-btn').textContent, 'Zoom to the ISS');
|
||||
$('station-zoom-btn').click();
|
||||
assert.deepEqual(acted, [
|
||||
['mode', 'manual'],
|
||||
['mode', 'automatic'],
|
||||
['zoom'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('publishing null hides the section again', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({});
|
||||
await publish(null);
|
||||
assert.equal($('station-panel').hidden, true);
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
import { createOwners } from './owners.js';
|
||||
|
||||
/**
|
||||
* The LIVE section in Context as its view renders it: the streams on offer
|
||||
* for the selected object, the one chosen and the player's state.
|
||||
* LiveControls presents it (`gev-live` store) and answers the section's
|
||||
* controls through act(): `cycleLive`, `playLive`, `stopLive`, `retryLive`.
|
||||
*/
|
||||
export const useLiveStore = defineStore('gev-live', () => {
|
||||
/** The presented section; null while nothing selected has a stream. */
|
||||
const view = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
||||
function publish(next) {
|
||||
view.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
const { connect, detach, act } = createOwners();
|
||||
|
||||
return { view, publish, connect, detach, act };
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
import { createOwners } from './owners.js';
|
||||
|
||||
/**
|
||||
* The STATION section in Context as its view renders it: the selected
|
||||
* station's controls (Automatic or Manual, the moving parts by hand), where
|
||||
* its joint angles come from right now, and a zoom to it. The satellites
|
||||
* layer's station panel presents it (`gev-station` store) and answers its
|
||||
* controls through act(): `setStationMode`, `chooseStation`, `slideStation`,
|
||||
* `resumeStationArm`, `zoomStation`.
|
||||
*/
|
||||
export const useStationStore = defineStore('gev-station', () => {
|
||||
/** The presented section; null while no station is selected. */
|
||||
const view = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
||||
function publish(next) {
|
||||
view.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
const { connect, detach, act } = createOwners();
|
||||
|
||||
return { view, publish, connect, detach, act };
|
||||
});
|
||||
@@ -6,6 +6,33 @@ import { createPinia } from 'pinia';
|
||||
import { useStoriesStore } from './stores/stories.js';
|
||||
import { storyById } from '../stories/catalog.js';
|
||||
import StoryScreen from './views/stories/StoryScreen.vue';
|
||||
import StoriesView from './views/StoriesView.vue';
|
||||
|
||||
test('the announcement stays unread when a lazy Stories open resolves to false', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const store = useStoriesStore(pinia);
|
||||
let allowed = false;
|
||||
store.connect({ open: async () => allowed });
|
||||
const app = createApp(StoriesView).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
localStorage.removeItem('gevStoriesPopSeen');
|
||||
});
|
||||
|
||||
const entry = host.querySelector('#hStories');
|
||||
entry.click();
|
||||
await nextTick();
|
||||
assert.equal(localStorage.getItem('gevStoriesPopSeen'), null);
|
||||
assert.ok(host.querySelector('#hPop'));
|
||||
|
||||
allowed = true;
|
||||
entry.click();
|
||||
await nextTick();
|
||||
assert.equal(localStorage.getItem('gevStoriesPopSeen'), '1');
|
||||
});
|
||||
|
||||
test('the story screen previews a drag and seeks once on release', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
--cockpit-side-panel-width: min(340px, 28vw);
|
||||
/* HUD bottom offset + tallest scaled telemetry block + 20px clear border. */
|
||||
--cockpit-bottom-rail-safe: calc(clamp(84px, 11vh, 118px) + 100px);
|
||||
/* The phone Display/Radio row shares the visor inset with the roll arc. */
|
||||
--cockpit-visor-top: clamp(62px, 9vh, 90px);
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 145;
|
||||
@@ -95,7 +97,7 @@
|
||||
}
|
||||
.cockpit-visor-shell {
|
||||
position: absolute;
|
||||
inset: clamp(62px, 9vh, 90px) clamp(18px, 3vw, 48px) clamp(38px, 5vh, 56px);
|
||||
inset: var(--cockpit-visor-top) clamp(18px, 3vw, 48px) clamp(38px, 5vh, 56px);
|
||||
transform-style: preserve-3d;
|
||||
perspective: 880px;
|
||||
}
|
||||
@@ -1954,6 +1956,61 @@ html:not([lang='en']) .cockpit-brief-tabs button {
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
/* The LIVE tab is in the markup whether or not a stream is on offer. */
|
||||
.cockpit-brief-tabs button[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The briefing's LIVE page: the LIVE section's parts (live.css) in the
|
||||
card's measure. */
|
||||
.cockpit-live-subject {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
.cockpit-live-subject strong {
|
||||
overflow: hidden;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cockpit-live-subject .live-badge {
|
||||
flex: none;
|
||||
font-size: 7px;
|
||||
}
|
||||
.cockpit-live-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin: 5px 0 6px;
|
||||
}
|
||||
.cockpit-live-pick .live-stream-title {
|
||||
font-size: 8px;
|
||||
}
|
||||
.cockpit-live-pick .live-step .material-symbols-outlined {
|
||||
font-size: 14px;
|
||||
}
|
||||
.cockpit-live-status {
|
||||
margin: 5px 0 0;
|
||||
color: rgba(244, 251, 255, 0.7);
|
||||
font-size: 7px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.cockpit-live-credit {
|
||||
margin: 4px 0 0;
|
||||
color: rgba(182, 226, 241, 0.72);
|
||||
font: 600 7px/1.2 var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.cockpit-live-credit a {
|
||||
color: inherit;
|
||||
}
|
||||
.cockpit-signal-window[data-layout-mode='rail-right-constrained'] {
|
||||
gap: 5px;
|
||||
}
|
||||
@@ -2026,6 +2083,11 @@ body.cockpit-mode
|
||||
) {
|
||||
display: none !important;
|
||||
}
|
||||
/* The first-visit Stories announcement waits, unread, until Cockpit closes:
|
||||
on a phone it would cover the Display/Radio row. */
|
||||
body.cockpit-mode #gev-stories #hPop {
|
||||
display: none;
|
||||
}
|
||||
body.cockpit-mode #left-panel-stack {
|
||||
z-index: 147;
|
||||
display: flex;
|
||||
@@ -2122,10 +2184,31 @@ body.cockpit-mode #intel-hud .hud-right-edge {
|
||||
top: auto;
|
||||
right: 12px;
|
||||
bottom: 152px;
|
||||
flex-direction: row;
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
body.cockpit-mode .cockpit-utility-controls {
|
||||
flex-direction: row;
|
||||
/* Phone flight and bridge views: one row centred on the Reset/Exit axis,
|
||||
10px below the roll arc (.cockpit-roll-arc: 2px + 96px into the visor).
|
||||
Shorter screens reserve 36px around the 46% centre of .cockpit-reticle
|
||||
(about 25px tall on phones), plus an 8px gap below the 42px row.
|
||||
The row stops at 72px, below the vision controls. Windows under 240px
|
||||
tall, and narrow ones under 450px tall, keep the right-aligned row above
|
||||
Reset/Exit, clear of Reset, LOOK AHEAD and the Stories button, as do
|
||||
satellite and provider views. */
|
||||
@media (min-width: 390px) and (min-height: 240px), (min-height: 450px) {
|
||||
body.cockpit-mode.mobile-shell
|
||||
#cockpit-hud:not([data-generic]):not([data-subject='satellite'])
|
||||
.cockpit-utility-controls {
|
||||
top: clamp(
|
||||
72px,
|
||||
calc(46% - 68px),
|
||||
calc(var(--cockpit-visor-top) + 108px)
|
||||
);
|
||||
bottom: auto;
|
||||
left: 12px;
|
||||
width: max-content;
|
||||
margin-inline: auto;
|
||||
}
|
||||
}
|
||||
body.cockpit-mode .cockpit-utility-launcher {
|
||||
width: min(150px, calc((100vw - 31px) / 2));
|
||||
|
||||
@@ -482,6 +482,21 @@
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
/* A station view's arrows either side of its name. */
|
||||
.cockpit-orbital-views .cockpit-orbital-look-readout {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
.cockpit-orbital-view-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1px 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
.cockpit-orbital-view-step .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* The Cockpit HUD in orbit (#cockpit-hud[data-subject='satellite']): the
|
||||
orbital readout names the satellite, so the topline keeps only the
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/* The LIVE section inside Context: a live stream in the platform's player. */
|
||||
|
||||
#live-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* A section inside Context, laid out as the Radio section is: its +/-
|
||||
hides and shows the body, and it goes with the Context panel. */
|
||||
#live-panel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(65, 220, 231, 0.16);
|
||||
}
|
||||
.live-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(65, 220, 231, 0.18);
|
||||
border-radius: 8px;
|
||||
background: rgba(2, 15, 20, 0.42);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
#live-panel .panel-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#right-context-rail #global-context-panel:not(.collapsed) #live-panel {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#live-panel.collapsed .live-panel-inner > :not(.panel-header),
|
||||
#global-context-panel.collapsed #live-panel {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.live-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.live-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.28);
|
||||
box-shadow: none;
|
||||
flex: none;
|
||||
}
|
||||
.live-dot.waiting {
|
||||
background: #ffb547;
|
||||
}
|
||||
.live-dot.on-air {
|
||||
background: #ff3b3b;
|
||||
box-shadow: 0 0 6px rgba(255, 59, 59, 0.9);
|
||||
animation: live-blink 1.2s ease-in-out infinite;
|
||||
}
|
||||
@keyframes live-blink {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.25;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.live-dot.on-air {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
.live-subject {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.85;
|
||||
margin: 2px 0 6px;
|
||||
}
|
||||
.live-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.live-stream-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.live-stream-title small {
|
||||
font-weight: 400;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.live-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1px 4px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.6);
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
.live-step .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.live-step {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
.live-step:hover,
|
||||
.live-step:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* The screen keeps a 16:9 box whether a player is in it or not. */
|
||||
.live-screen {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: #000;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.live-player-host,
|
||||
.live-player-host iframe {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
}
|
||||
.live-screen:not(.active) .live-player-host {
|
||||
display: none;
|
||||
}
|
||||
/* The poster's Play: the only way the player is loaded. */
|
||||
.live-play {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
padding: 8px 18px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.45);
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 7, 12, 0.72);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.live-play:hover,
|
||||
.live-play:focus-visible {
|
||||
border-color: #ff3b3b;
|
||||
outline: none;
|
||||
}
|
||||
.live-play .material-symbols-outlined {
|
||||
font-size: 20px;
|
||||
}
|
||||
.live-card {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 50% 40%,
|
||||
rgba(0, 220, 255, 0.08),
|
||||
transparent 60%
|
||||
),
|
||||
#050a0f;
|
||||
}
|
||||
.live-card-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
.live-card.offline .live-card-dot {
|
||||
background: #ff3b3b;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.live-card button {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.35);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.7);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
letter-spacing: 0.12em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.live-card button:hover,
|
||||
.live-card button:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.live-status {
|
||||
margin: 6px 0 0;
|
||||
font-size: 11px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.live-credit,
|
||||
.live-privacy {
|
||||
margin: 6px 0 0;
|
||||
font-size: 10px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.live-credit a {
|
||||
color: inherit;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/* The STATION section inside Context: a space station's moving parts. */
|
||||
|
||||
#station-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* A section inside Context, laid out as the Radio section is: its +/-
|
||||
hides and shows the body, and it goes with the Context panel. */
|
||||
#station-panel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(65, 220, 231, 0.16);
|
||||
}
|
||||
.station-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(65, 220, 231, 0.18);
|
||||
border-radius: 8px;
|
||||
background: rgba(2, 15, 20, 0.42);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
#station-panel .panel-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#right-context-rail #global-context-panel:not(.collapsed) #station-panel {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#station-panel.collapsed .station-panel-inner > :not(.panel-header),
|
||||
#global-context-panel.collapsed #station-panel {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.station-badge {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.station-subject {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.85;
|
||||
margin: 2px 0 8px;
|
||||
}
|
||||
.station-modes {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.station-mode,
|
||||
.station-button {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.6);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.station-mode {
|
||||
flex: 1;
|
||||
font-weight: 700;
|
||||
}
|
||||
.station-mode.is-active,
|
||||
.station-button.is-active {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
color: var(--cockpit-accent, #00dcff);
|
||||
}
|
||||
.station-mode:focus-visible,
|
||||
.station-button:focus-visible {
|
||||
outline: 1px solid var(--cockpit-accent, #00dcff);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.station-telemetry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.station-telemetry-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
flex: none;
|
||||
}
|
||||
.station-telemetry[data-tone='live'] .station-telemetry-dot {
|
||||
background: #3bff7a;
|
||||
box-shadow: 0 0 6px rgba(59, 255, 122, 0.8);
|
||||
}
|
||||
.station-telemetry[data-tone='waiting'] .station-telemetry-dot {
|
||||
background: #ffb547;
|
||||
}
|
||||
.station-telemetry[data-tone='manual'] .station-telemetry-dot {
|
||||
background: var(--cockpit-accent, #00dcff);
|
||||
}
|
||||
.station-note {
|
||||
margin: 0 0 6px;
|
||||
font-size: 10px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.station-group {
|
||||
margin: 8px 0 0;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.station-label {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
opacity: 0.85;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.station-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
.station-sliders {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.station-slider {
|
||||
display: grid;
|
||||
grid-template-columns: 7em 1fr 3.5em;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.station-slider output {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.station-zoom {
|
||||
margin-top: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -25,8 +25,14 @@ import UiIcon from '../kit/UiIcon.vue';
|
||||
// does, they show the state they start in. The controller also publishes
|
||||
// which surfaces are shown and the utility strip's measured layout; the
|
||||
// layout pass stays with it, and the controls keep its listeners.
|
||||
const { presence, instruments, route, vision, utilityLayout } =
|
||||
storeToRefs(useCockpitStore());
|
||||
const {
|
||||
presence,
|
||||
instruments,
|
||||
route,
|
||||
vision,
|
||||
utilityLayout,
|
||||
orbital: orbitalView,
|
||||
} = storeToRefs(useCockpitStore());
|
||||
const active = computed(() => Boolean(presence.value?.active));
|
||||
// A vessel subject swaps the aviation readouts for bridge ones.
|
||||
const bridge = computed(() => presence.value?.subjectKind === 'vessel');
|
||||
@@ -36,6 +42,9 @@ const orbital = computed(() => presence.value?.subjectKind === 'satellite');
|
||||
// window view whose readouts, labels and texts the provider words.
|
||||
const generic = computed(() => presence.value?.subjectGeneric === true);
|
||||
const labels = computed(() => presence.value?.subjectLabels ?? null);
|
||||
// The station is ridden from a mount on its 3D model: the arrows look about
|
||||
// it and Home returns to it, where the nadir picture tilts and returns to nadir.
|
||||
const stationView = computed(() => (orbitalView.value?.mount ?? null) !== null);
|
||||
const subject = computed(() =>
|
||||
generic.value
|
||||
? presence.value.subjectKind
|
||||
@@ -272,7 +281,7 @@ const tickStyle = (tick) =>
|
||||
<CockpitRadar />
|
||||
</div>
|
||||
<CockpitUtilityControls />
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></div>
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <template v-if="stationView"><bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-else><bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></template></div>
|
||||
</section>
|
||||
|
||||
<nav id="view-switcher" :aria-label="t('View switcher')">
|
||||
|
||||
@@ -15,7 +15,9 @@ import BhoteKoshiPanel from './panels/BhoteKoshiPanel.vue';
|
||||
import EntityCard from './panels/EntityCard.vue';
|
||||
import ViewContext from './panels/ViewContext.vue';
|
||||
import SpaceMissionsPanel from './panels/SpaceMissionsPanel.vue';
|
||||
import LivePanel from './panels/LivePanel.vue';
|
||||
import RadioPanel from './panels/RadioPanel.vue';
|
||||
import StationPanel from './panels/StationPanel.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
import UiSearchField from '../kit/UiSearchField.vue';
|
||||
@@ -210,6 +212,11 @@ watch(
|
||||
<div :id="`context-tab-${tab.id}`" :ref="setPane(tab.id)" class="context-tab-pane"></div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- Sections PanelChrome owns sit outside the Inspector view, which mounts
|
||||
only while Context is open: PanelChrome finds collapsible panels once,
|
||||
at startup. -->
|
||||
<StationPanel />
|
||||
<LivePanel />
|
||||
<RadioPanel />
|
||||
<div class="global-context-modes" role="tablist" :aria-label="t('Context mode')">
|
||||
<UiButton id="global-context-flights-btn" class="context-mode-button" v-class-toggle="{ active: ctx?.flightsActive }" role="tab" tabindex="0" :aria-selected="String(ctx?.flightsActive ?? false)" :aria-disabled="ctx && String(ctx.busy)" :aria-busy="ctx && String(ctx.busy)" aria-controls="context-flights-view" :aria-label="t('CONTACTS')" :title="t('Cycles the nearest contacts of whatever type you select — planes, vessels, installations. Satellites track independently.')">
|
||||
|
||||
@@ -152,9 +152,9 @@ function markPopSeen() {
|
||||
/* storage off: the popup comes back next visit */
|
||||
}
|
||||
}
|
||||
function openExplore() {
|
||||
markPopSeen();
|
||||
store.controller.open();
|
||||
async function openExplore() {
|
||||
// A refused open (Cockpit) leaves the announcement unread.
|
||||
if (await store.controller.open()) markPopSeen();
|
||||
}
|
||||
|
||||
// ── Opened in GEV: a toast that leads back to the story ──
|
||||
|
||||
@@ -4,6 +4,8 @@ import { computed, useTemplateRef } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { createBriefState } from '../../cockpitBriefPages.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import { useLiveStore } from '../../stores/live.js';
|
||||
import CockpitLivePage from './CockpitLivePage.vue';
|
||||
import CockpitRoute from './CockpitRoute.vue';
|
||||
import CockpitSignalList from './CockpitSignalList.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
@@ -12,8 +14,11 @@ import UiIcon from '../../kit/UiIcon.vue';
|
||||
// The Cockpit briefing card. The Cockpit controller presents its pages,
|
||||
// cycle toggle, regional news and local conditions; until it does, the card
|
||||
// shows the state it starts in. The controls keep the controller's
|
||||
// listeners. The route card and the signal rows render themselves.
|
||||
// listeners. The route card, the signal rows and the LIVE page render
|
||||
// themselves; the LIVE page and its tab are there only while the subject has
|
||||
// a stream (the live store's view), which the controller is told of.
|
||||
const { presence, brief } = storeToRefs(useCockpitStore());
|
||||
const { view: live } = storeToRefs(useLiveStore());
|
||||
const initial = createBriefState();
|
||||
const b = computed(() => brief.value ?? initial);
|
||||
// The card's collapse, which its toggle and data-collapsed show.
|
||||
@@ -80,6 +85,9 @@ function leaveSignals() {
|
||||
</div>
|
||||
<a class="cockpit-weather-credit" href="https://open-meteo.com/" target="_blank" rel="noopener">{{ t('Weather data by Open-Meteo.com') }}</a>
|
||||
</section>
|
||||
<section data-cockpit-brief-page="live" :aria-label="t('Live video')" :hidden="b.pageId !== 'live'">
|
||||
<CockpitLivePage v-if="live" :shown="b.pageId === 'live' && !collapsed" />
|
||||
</section>
|
||||
</div>
|
||||
<footer class="cockpit-signal-footer">
|
||||
<span id="cockpit-brief-source">{{ b.source }}</span>
|
||||
@@ -87,6 +95,8 @@ function leaveSignals() {
|
||||
<UiButton data-cockpit-brief-index="0" :aria-label="t('Show Live Signals')" :aria-current="String(b.pageIndex === 0)">{{ t('SIG') }}</UiButton>
|
||||
<UiButton data-cockpit-brief-index="1" :aria-label="t('Show Regional News')" :aria-current="brief ? String(b.pageIndex === 1) : undefined">{{ t('NEWS') }}</UiButton>
|
||||
<UiButton data-cockpit-brief-index="2" :aria-label="t('Show Local Info')" :aria-current="brief ? String(b.pageIndex === 2) : undefined">{{ t('LOCAL') }}</UiButton>
|
||||
<!-- Always in the markup (the controller binds the tabs once); hidden without a stream. -->
|
||||
<UiButton data-cockpit-brief-index="3" :hidden="!live" :aria-label="t('Show Live Video')" :aria-current="brief ? String(b.pageIndex === 3) : undefined">{{ t('LIVE') }}</UiButton>
|
||||
</nav>
|
||||
</footer>
|
||||
</aside>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
|
||||
// The Cockpit briefing's LIVE page: the LIVE section of Context, in the
|
||||
// card's measure, for the ridden subject's streams. The briefing renders it
|
||||
// only while a stream is on offer. LiveControls builds the player into
|
||||
// `#cockpit-live-player-host` while the Cockpit is on (the right rail, and
|
||||
// the section's screen with it, is hidden there), only when the viewer
|
||||
// presses Play, under the notice that YouTube sees their IP address. The
|
||||
// page's controls call LiveControls through the live store, as the section's
|
||||
// do. Leaving the page, or the page going, stops the player.
|
||||
const props = defineProps({
|
||||
/** Whether the briefing shows this page now. */
|
||||
shown: { type: Boolean, default: true },
|
||||
});
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
watch(
|
||||
() => props.shown,
|
||||
(now) => {
|
||||
if (!now) act('hideLive', 'cockpit');
|
||||
},
|
||||
);
|
||||
onBeforeUnmount(() => act('hideLive', 'cockpit'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="view">
|
||||
<div class="cockpit-live-subject">
|
||||
<strong>{{ view.label }}</strong>
|
||||
<span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="cockpit-live-badge-text">{{ badgeText }}</span></span>
|
||||
</div>
|
||||
<div class="cockpit-live-pick" role="group" :aria-label="t('Stream')">
|
||||
<UiButton v-if="view.count > 1" id="cockpit-live-previous" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="cockpit-live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<UiButton v-if="view.count > 1" id="cockpit-live-next" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<p class="live-privacy cockpit-live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="cockpit-live-player-host" class="live-player-host"></div>
|
||||
<UiButton v-if="idle" id="cockpit-live-play" class="live-play" @click="act('playLive')"><UiIcon name="play_arrow" :size="null" />{{ t('Play') }}</UiButton>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
<UiButton v-if="offline" id="cockpit-live-retry" @click="act('retryLive')">{{ t('Try again') }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<p id="cockpit-live-status" class="cockpit-live-status" role="status" aria-live="polite">{{ statusText }}</p>
|
||||
<p class="cockpit-live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="cockpit-live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
|
||||
</template>
|
||||
</template>
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
} from '../../ownerFlag.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The orbital view's HUD: a nadir reticle over the picture, the satellite's
|
||||
// identity and orbit, and the optical zoom. The Cockpit controller presents
|
||||
@@ -222,6 +223,8 @@ const shownMark = computed(() =>
|
||||
const identParts = computed(() => {
|
||||
const o = orbital.value;
|
||||
if (!o) return [];
|
||||
// A module with no catalog entry (the Cupola) shows its facts instead.
|
||||
if (Array.isArray(o.facts) && o.facts.length) return [...o.facts];
|
||||
const parts = [];
|
||||
if (o.noradId !== null && o.noradId !== undefined && o.noradId !== '')
|
||||
parts.push(t('NORAD {id}', { id: String(o.noradId) }));
|
||||
@@ -252,6 +255,11 @@ watch(
|
||||
|
||||
// The off-nadir tilt; an untilted view shows no readout or reset.
|
||||
const look = computed(() => orbital.value?.look || { offset: false });
|
||||
// Riding the station from a mount on its 3D model: the view's name, or null
|
||||
// for the straight-down picture every other satellite has.
|
||||
const mount = computed(() => orbital.value?.mount ?? null);
|
||||
// The station offers several views; with two or more, the arrows step through them.
|
||||
const mountViews = computed(() => orbital.value?.mountViews ?? 0);
|
||||
// A ground focus names its target in a polite live region; the angle,
|
||||
// which changes every update, is left out of it.
|
||||
const focusText = computed(() => {
|
||||
@@ -272,7 +280,8 @@ const lensStyle = computed(() => {
|
||||
<section id="cockpit-orbital" class="cockpit-orbital" :class="{ 'cockpit-orbital-focusing': transition.active }" :style="lensStyle" :aria-label="t('Orbital view')" :hidden="!orbital">
|
||||
<template v-if="orbital">
|
||||
<div class="cockpit-orbital-lens" aria-hidden="true"></div>
|
||||
<div class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
|
||||
<!-- The nadir reticle and its north pointer; a view from the station has no ground point at its centre. -->
|
||||
<div v-if="mount === null" class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tl"></span>
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tr"></span>
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-bl"></span>
|
||||
@@ -289,7 +298,7 @@ const lensStyle = computed(() => {
|
||||
<!-- Under the vision selector: where the ground track is. -->
|
||||
<p v-if="placeText" id="cockpit-orbital-over" class="cockpit-orbital-over"><span>{{ t('CURRENTLY OVER') }}</span> <strong>{{ placeText }}</strong></p>
|
||||
<div class="cockpit-orbital-readout">
|
||||
<p class="cockpit-orbital-kicker">{{ look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
|
||||
<p class="cockpit-orbital-kicker">{{ mount !== null ? t('STATION VIEW · {name}', { name: mount }) : look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
|
||||
<div class="cockpit-orbital-title">
|
||||
<span v-if="shownMark?.kind === 'flag'" class="cockpit-orbital-flag" role="img" :aria-label="shownMark.label" :title="shownMark.label" :style="shownMark.style"></span>
|
||||
<span v-else-if="shownMark?.kind === 'badge'" class="cockpit-orbital-owner-badge" :title="shownMark.title">{{ shownMark.label }}</span>
|
||||
@@ -317,11 +326,17 @@ const lensStyle = computed(() => {
|
||||
<dd class="cockpit-orbital-subpoint">{{ subPointText }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
|
||||
<p v-if="mount === null" class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
|
||||
<!-- A station view: which one it is, and the step to the next. -->
|
||||
<div v-if="mount !== null && mountViews > 1" class="cockpit-orbital-look cockpit-orbital-views">
|
||||
<UiButton id="cockpit-orbital-view-previous" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Previous station view')" :title="t('Previous station view')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="cockpit-orbital-view-name" class="cockpit-orbital-look-readout" aria-live="polite">{{ mount }}</span>
|
||||
<UiButton id="cockpit-orbital-view-next" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Next station view')" :title="t('Next station view')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<!-- Shown only while the view is tilted off nadir: where it looks and the way back. -->
|
||||
<div v-if="look.offset" class="cockpit-orbital-look">
|
||||
<span id="cockpit-orbital-look-readout" class="cockpit-orbital-look-readout" :aria-live="look.focus ? 'off' : 'polite'">{{ look.readout }}</span>
|
||||
<UiButton id="cockpit-orbital-nadir" ref="nadirButton" class="cockpit-orbital-nadir" :aria-label="t('Return the view to nadir')" :title="t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ t('NADIR') }}</UiButton>
|
||||
<UiButton id="cockpit-orbital-nadir" ref="nadirButton" class="cockpit-orbital-nadir" :aria-label="mount !== null ? t('Return to the default view') : t('Return the view to nadir')" :title="mount !== null ? t('Return to the default view') : t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ mount !== null ? t('RESET') : t('NADIR') }}</UiButton>
|
||||
</div>
|
||||
<p id="cockpit-orbital-focus" class="cockpit-orbital-focus" aria-live="polite">{{ focusText }}</p>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
import { usePanelChromeStore } from '../../stores/panelChrome.js';
|
||||
|
||||
// The LIVE section inside Context: the live streams attached to the selected
|
||||
// object (LiveControls publishes them), one at a time in the platform's own
|
||||
// player. It is there only while the selection has a stream. The player is
|
||||
// loaded only when the viewer presses Play, under the notice that YouTube
|
||||
// sees their IP address; collapsing the section, collapsing Context, or the
|
||||
// section leaving the page stops it. Its controls call LiveControls through
|
||||
// the store.
|
||||
const PANEL_ID = 'live-panel';
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
// Nothing plays unseen: a hidden section gives up its player.
|
||||
const { panels } = storeToRefs(usePanelChromeStore());
|
||||
const hidden = computed(
|
||||
() =>
|
||||
(panels.value[PANEL_ID]?.collapsed ?? true) ||
|
||||
panels.value['global-context-panel']?.collapsed === true,
|
||||
);
|
||||
watch(hidden, (now) => {
|
||||
if (now) act('hideLive', 'section');
|
||||
});
|
||||
onBeforeUnmount(() => act('hideLive', 'section'));
|
||||
const liveWords = computed(() => ({
|
||||
expandLabel: t('Expand Live section'),
|
||||
collapseLabel: t('Collapse Live section'),
|
||||
expandTitle: t('Expand Live'),
|
||||
collapseTitle: t('Collapse Live'),
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RailPanel :id="PANEL_ID" tag="section" start-collapsed :hidden="!view" v-class-toggle="{ 'live-on-air': playing }" :aria-label="t('Live streams for the selected object')" :title="t('LIVE')" :toggle-words="liveWords" :glow="false" scroll>
|
||||
<template #badge><span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="live-badge-text">{{ badgeText }}</span></span></template>
|
||||
<template v-if="view">
|
||||
<div class="live-subject">{{ view.label }}</div>
|
||||
<div class="live-pick" role="group" :aria-label="t('Stream')">
|
||||
<UiButton v-if="view.count > 1" id="live-previous-btn" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<UiButton v-if="view.count > 1" id="live-next-btn" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<p class="live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="live-player-host" class="live-player-host"></div>
|
||||
<UiButton v-if="idle" id="live-play-btn" class="live-play" @click="act('playLive')"><UiIcon name="play_arrow" :size="null" />{{ t('Play') }}</UiButton>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
<UiButton v-if="offline" id="live-retry-btn" @click="act('retryLive')">{{ t('Try again') }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<p id="live-status" class="live-status" role="status" aria-live="polite">{{ statusText }}</p>
|
||||
<p class="live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
|
||||
</template>
|
||||
</RailPanel>
|
||||
</template>
|
||||
@@ -0,0 +1,118 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { formatDate, formatNumber, t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import { useStationStore } from '../../stores/station.js';
|
||||
|
||||
// The STATION section inside Context: the selected space station's moving
|
||||
// parts. Automatic leaves them to their rules (NASA's telemetry where the
|
||||
// server relays it, computed from the Sun otherwise); Manual hands them to
|
||||
// the person. The satellites layer publishes the view; its controls call
|
||||
// the layer through the store. It is there only while a station is selected.
|
||||
const store = useStationStore();
|
||||
const { act } = store;
|
||||
const { view } = storeToRefs(store);
|
||||
const manual = computed(() => view.value?.mode === 'manual');
|
||||
|
||||
/** A duration as the status line words it. */
|
||||
const ago = (ms) => {
|
||||
if (!Number.isFinite(ms)) return '';
|
||||
const seconds = Math.max(0, Math.round(ms / 1000));
|
||||
return seconds < 90
|
||||
? t('{seconds} s', { seconds: formatNumber(seconds) })
|
||||
: t('{minutes} min', { minutes: formatNumber(Math.round(seconds / 60)) });
|
||||
};
|
||||
const clock = (ms) =>
|
||||
Number.isFinite(ms)
|
||||
? formatDate(ms, { hour: '2-digit', minute: '2-digit' })
|
||||
: '';
|
||||
const telemetry = computed(() => view.value?.telemetry ?? null);
|
||||
const telemetryText = computed(() => {
|
||||
const status = telemetry.value;
|
||||
if (!status) return '';
|
||||
if (manual.value) return t('Manual · telemetry paused');
|
||||
switch (status.state) {
|
||||
case 'live':
|
||||
return t('Telemetry · updated {ago} ago', { ago: ago(status.poseAgeMs) });
|
||||
case 'no-signal':
|
||||
return Number.isFinite(status.liveUntilMs)
|
||||
? t('No signal since {time} · computed values', { time: clock(status.liveUntilMs) })
|
||||
: t('No signal · computed values');
|
||||
case 'unavailable':
|
||||
return Number.isFinite(status.poseAgeMs)
|
||||
? t('Telemetry unavailable · last update {ago} ago · computed values', { ago: ago(status.poseAgeMs) })
|
||||
: t('Telemetry unavailable · computed values');
|
||||
case 'disabled':
|
||||
return t('Telemetry not enabled on this server · computed values');
|
||||
case 'none':
|
||||
return t('No public telemetry · computed values');
|
||||
case 'idle':
|
||||
return t('Telemetry reads while the model is on screen');
|
||||
default:
|
||||
return t('Connecting to telemetry…');
|
||||
}
|
||||
});
|
||||
const telemetryTone = computed(() => {
|
||||
if (manual.value) return 'manual';
|
||||
const state = telemetry.value?.state;
|
||||
return state === 'live' ? 'live' : state === 'no-signal' ? 'waiting' : state === 'pending' ? 'waiting' : 'off';
|
||||
});
|
||||
const sunText = computed(() => {
|
||||
const sunlit = view.value?.sunlit;
|
||||
if (sunlit === null || sunlit === undefined) return '';
|
||||
return sunlit ? t('Now: in sunlight') : t("Now: in the Earth's shadow");
|
||||
});
|
||||
// The mode radios: arrow keys move the choice and the focus, as a radio
|
||||
// group's do, and only the checked one is in the tab order.
|
||||
function stepMode(event) {
|
||||
const next = manual.value ? 'automatic' : 'manual';
|
||||
act('setStationMode', next);
|
||||
event.currentTarget
|
||||
?.querySelector(`#station-${next}-btn`)
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
const stationWords = computed(() => ({
|
||||
expandLabel: t('Expand Station section'),
|
||||
collapseLabel: t('Collapse Station section'),
|
||||
expandTitle: t('Expand Station'),
|
||||
collapseTitle: t('Collapse Station'),
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RailPanel id="station-panel" tag="section" start-collapsed :hidden="!view" v-class-toggle="{ 'station-manual': manual }" :aria-label="t('Controls for the selected space station')" :title="t('STATION')" :toggle-words="stationWords" :glow="false" scroll>
|
||||
<template #badge><span id="station-badge" class="station-badge">{{ view ? view.title : '' }}</span></template>
|
||||
<template v-if="view">
|
||||
<div class="station-subject">{{ view.subject }}</div>
|
||||
<div class="station-modes" role="radiogroup" :aria-label="t('Mode')" @keydown.left.prevent="stepMode" @keydown.right.prevent="stepMode" @keydown.up.prevent="stepMode" @keydown.down.prevent="stepMode">
|
||||
<UiButton id="station-automatic-btn" role="radio" class="station-mode" :tabindex="manual ? -1 : 0" :aria-checked="String(!manual)" v-class-toggle="{ 'is-active': !manual }" @click="act('setStationMode', 'automatic')">{{ t('Automatic') }}</UiButton>
|
||||
<UiButton id="station-manual-btn" role="radio" class="station-mode" :tabindex="manual ? 0 : -1" :aria-checked="String(manual)" v-class-toggle="{ 'is-active': manual }" @click="act('setStationMode', 'manual')">{{ t('Manual') }}</UiButton>
|
||||
</div>
|
||||
<p id="station-telemetry" class="station-telemetry" :data-tone="telemetryTone" role="status" aria-live="polite"><span class="station-telemetry-dot" aria-hidden="true"></span>{{ telemetryText }}</p>
|
||||
<p v-if="!manual && sunText" id="station-sun" class="station-note">{{ sunText }}</p>
|
||||
<p v-if="!manual && view.note" class="station-note">{{ t(view.note) }}</p>
|
||||
<template v-if="manual">
|
||||
<div v-for="group in view.groups" :key="group.id" class="station-group">
|
||||
<div class="station-label">{{ t(group.label) }}</div>
|
||||
<div v-if="group.kind === 'choices'" class="station-row" role="group" :aria-label="t(group.label)">
|
||||
<UiButton v-for="choice in group.choices" :key="choice.id" class="station-button" :data-station-choice="`${group.id}:${choice.id}`" :pressed="Boolean(choice.active)" pressed-class="is-active" @click="act('chooseStation', group.id, choice.id)">{{ t(choice.label) }}</UiButton>
|
||||
</div>
|
||||
<div v-else class="station-sliders">
|
||||
<label v-for="slider in group.sliders" :key="slider.id" class="station-slider">
|
||||
<span>{{ t(slider.label) }}</span>
|
||||
<UiSlider :id="`station-slider-${slider.id}`" :min="slider.min" :max="slider.max" :model-value="slider.value" :aria-label="t(slider.label)" @update:model-value="act('slideStation', slider.id, $event)" />
|
||||
<output class="gev-slider-value">{{ formatNumber(slider.value) }}°</output>
|
||||
</label>
|
||||
<UiButton v-if="group.resume" class="station-button" :data-station-resume="group.id" @click="act('resumeStationArm', group.id)">{{ t(group.resume) }}</UiButton>
|
||||
</div>
|
||||
<p v-if="group.note" class="station-note">{{ t(group.note) }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<UiButton v-if="view.zoom.offered" id="station-zoom-btn" class="station-button station-zoom" @click="act('zoomStation')">{{ t(view.zoom.label) }}</UiButton>
|
||||
</template>
|
||||
</RailPanel>
|
||||
</template>
|
||||
Reference in new issue
Block a user