mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge branch 'sameh/world-clock' into sameh/world-timeline-launches
This commit is contained in:
commit
137639dd38
572 files changed
+111206
-2700
No files matched your search
@@ -14,11 +14,14 @@ import MissionDetail from './panels/MissionDetail.vue';
|
||||
import MissionRoster from './panels/MissionRoster.vue';
|
||||
import RadioPanel from './panels/RadioPanel.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
|
||||
// ContextControls presents the mode switch and the nearby sites search and
|
||||
// publishes them; until it does, the panel shows its initial markup.
|
||||
const { view: ctx } = storeToRefs(useContextStore());
|
||||
const { presence: cockpit } = storeToRefs(useCockpitStore());
|
||||
// The entry rides the tracked aircraft (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace('aircraft'));
|
||||
// While the Bhote Koshi event is on, its panel is the rail's only content.
|
||||
const { panel: bhotePanel } = storeToRefs(useBhoteKoshiPanelStore());
|
||||
// The Scene runtime chip SceneControls presents while a scene plays.
|
||||
@@ -56,8 +59,8 @@ const sceneRuntime = computed(() => scenePanel.value?.runtime ?? '');
|
||||
<section id="context-flights-view" class="context-mode-view" role="tabpanel" aria-labelledby="global-context-flights-btn" :hidden="!ctx?.flightsActive">
|
||||
<div class="global-context-actions" :aria-label="t('Contact Context actions')">
|
||||
<button id="cockpit-entry" type="button" :hidden="!cockpit?.entryAvailable">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">flight</span>
|
||||
<span>{{ t('COCKPIT') }}</span>
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ entry.icon }}</span>
|
||||
<span>{{ entry.label }}</span>
|
||||
</button>
|
||||
<button id="installations-search-btn" class="panel-layer-toggle" type="button" :aria-disabled="ctx && String(ctx.installationsBusy)" :aria-busy="ctx && String(ctx.installationsBusy)">{{ t('SEARCH NEARBY SITES') }}</button>
|
||||
<UiButton id="tr3b-toggle" class="tr3b-toggle" :pressed="!!cockpit?.tr3b?.converted" :hidden="!cockpit?.tr3b" :aria-label="t('Reclassify tracked contact as TR-3B')" :title="cockpit?.tr3b?.converted ? t('Restore real aircraft') : t('Reclassify as TR-3B')">🛸</UiButton>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useHudStore } from '../stores/hud.js';
|
||||
import { useCockpitStore } from '../stores/cockpit.js';
|
||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
|
||||
// The readouts, visibility, layout variant and colors IntelHUD publishes.
|
||||
const { hud } = storeToRefs(useHudStore());
|
||||
@@ -10,6 +12,12 @@ const { hud } = storeToRefs(useHudStore());
|
||||
// right after IntelHUD is built.
|
||||
const EMPTY = Object.freeze({ vessel: {}, sensor: [], recShown: null });
|
||||
const view = computed(() => hud.value ?? EMPTY);
|
||||
// The selected vehicle's readout offers the same entry as the Contacts
|
||||
// button, so first person needs no Contacts panel. The Cockpit controller
|
||||
// answers its clicks.
|
||||
const { presence: cockpit } = storeToRefs(useCockpitStore());
|
||||
// The entry rides the tracked aircraft (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace('aircraft'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -46,6 +54,10 @@ const view = computed(() => hud.value ?? EMPTY);
|
||||
<div class="hud-readout"><div id="hud-gsd">{{ view.gsd }}</div></div>
|
||||
<div class="hud-readout"><div id="hud-alt">{{ view.alt }}</div></div>
|
||||
<div class="hud-readout"><div id="hud-ais-vessel" :class="['hud-ais-vessel', { active: view.vessel.active }]">{{ view.vessel.text }}</div></div>
|
||||
<button id="cockpit-entry-readout" type="button" :hidden="!cockpit?.entryAvailable">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ entry.icon }}</span>
|
||||
<span>{{ entry.label }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="hud-bracket">┘</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<script setup>
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useVoiceStore } from '../../stores/voice.js';
|
||||
import { ASSISTANT_NAME } from '../../../voice/control.js';
|
||||
import PanelLayoutButtons from './PanelLayoutButtons.vue';
|
||||
|
||||
// The typed chat in the command dock, as its owner (src/voice/chatControl.js)
|
||||
// writes the voice control presenter. Messages arrive apart from the view, so
|
||||
// a reply revealed frame by frame renders only this list.
|
||||
const props = defineProps({ view: { type: Object, required: true } });
|
||||
const store = useVoiceStore();
|
||||
const { controls, chat: messages } = storeToRefs(store);
|
||||
const emit = (name, ...args) => controls.value?.emit(name, ...args);
|
||||
const list = ref(null);
|
||||
const layerSelect = ref(null);
|
||||
const layerChoice = ref('');
|
||||
|
||||
// The input holds what the person types until its owner writes it (history
|
||||
// recall, a suggestion, clearing after send): only then is it replaced.
|
||||
const vOwnedDraft = {
|
||||
mounted(el, { value }) {
|
||||
el.value = value.text;
|
||||
},
|
||||
updated(el, { value, oldValue }) {
|
||||
if (value.revision !== oldValue?.revision && el.value !== value.text)
|
||||
el.value = value.text;
|
||||
},
|
||||
};
|
||||
|
||||
// Keep the newest message in view as the conversation grows, while the
|
||||
// reader is at the bottom: one who scrolled up to read stays there until
|
||||
// they send. The position is read on scroll, not on every reveal frame.
|
||||
let stuck = true;
|
||||
const onListScroll = () => {
|
||||
const el = list.value;
|
||||
if (el) stuck = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
|
||||
};
|
||||
// A send is a new newest user message. The log is capped, so a full one
|
||||
// does not grow as it takes a message: compare ids, not lengths.
|
||||
const lastSent = (list) => list?.findLast((entry) => entry.role === 'user')?.id;
|
||||
watch(messages, (next, previous) => {
|
||||
const sent =
|
||||
next.at(-1)?.role === 'user' && lastSent(next) !== lastSent(previous);
|
||||
if (!stuck && !sent) return;
|
||||
void nextTick(() => {
|
||||
if (list.value) list.value.scrollTop = list.value.scrollHeight;
|
||||
});
|
||||
});
|
||||
|
||||
// Arrow keys only move the layer choice (a closed select changes on each
|
||||
// press on Windows and Linux); the Attach button or Enter attaches it.
|
||||
function attachLayer() {
|
||||
const value = layerChoice.value;
|
||||
layerChoice.value = '';
|
||||
if (layerSelect.value) layerSelect.value.value = '';
|
||||
if (value) emit('chat-layer', value);
|
||||
}
|
||||
|
||||
const quickPrompts = () => [t('Fly to Tokyo'), t('Show live flights')];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="gev-chat-panel" :hidden="!props.view.chat.open" :data-minimized="props.view.chat.minimized ? 'true' : undefined" :aria-label="t('AI chat')">
|
||||
<header class="gev-chat-header">
|
||||
<div><strong>{{ t('GEV CHAT') }}</strong><p>{{ t('Ask about the map. Tell it where to go.') }}</p></div>
|
||||
<div id="gev-chat-header-actions">
|
||||
<PanelLayoutButtons :docked="props.view.layout.docked" :minimized="props.view.chat.minimized" @dock="emit('layout-dock')" @minimize="emit('chat-minimize')" />
|
||||
<button v-if="props.view.panel" id="gev-voice-settings-button" class="gev-voice-settings-button" type="button" :aria-label="t('Settings')" :title="t('Settings')" aria-controls="gev-voice-panel" :aria-expanded="String(props.view.voicePanel.settingsExpanded)" @click="emit('settings-button')"><span class="material-symbols-outlined gev-voice-settings-icon" aria-hidden="true">settings</span></button>
|
||||
<button id="gev-chat-close" type="button" :aria-label="t('Close chat')" @click="emit('chat-close')">×</button>
|
||||
</div>
|
||||
</header>
|
||||
<div id="gev-chat-messages" ref="list" role="log" :aria-label="t('Conversation')" aria-live="polite" :aria-busy="props.view.chat.busy || props.view.chat.revealing ? 'true' : undefined" @scroll.passive="onListScroll">
|
||||
<div id="gev-chat-empty" :hidden="!props.view.chat.empty">
|
||||
<svg viewBox="0 0 24 24" width="32" height="32" fill="none" stroke="currentColor" stroke-width="1" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><ellipse cx="12" cy="12" rx="4" ry="10"></ellipse><path d="M2 12h20"></path></svg>
|
||||
<h3>{{ t('Explore with a question') }}</h3>
|
||||
<p>{{ t('Find a place, explore live data, or change your view.') }}</p>
|
||||
<button v-for="prompt in quickPrompts()" :key="prompt" type="button" :hidden="!props.view.chat.quickChecked" @click="emit('chat-prompt', prompt)">{{ prompt }}</button>
|
||||
</div>
|
||||
<div v-for="message in messages" :key="message.id" class="gev-chat-message" :data-role="message.role">
|
||||
<small>{{ message.role === 'user' ? t('YOU') : ASSISTANT_NAME }}</small><span>{{ message.text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p id="gev-chat-status" role="status">{{ props.view.chat.status }}</p>
|
||||
<!-- Stays under the status for the whole conversation. -->
|
||||
<p v-if="props.view.chat.authNote" id="gev-chat-auth-note">{{ props.view.chat.authNote }}</p>
|
||||
<div id="gev-chat-attachments" :aria-label="t('Attachments')" :hidden="!props.view.chat.attachments.length">
|
||||
<button v-for="item in props.view.chat.attachments" :key="item.key" type="button" :disabled="props.view.chat.locked" :aria-label="`${t('Remove attachment')}: ${item.name}`" @click="emit('chat-attachment-remove', item.key)">{{ item.name }} ×</button>
|
||||
</div>
|
||||
<div id="gev-chat-attach-menu" :hidden="!props.view.chat.attachMenuOpen" @keydown="emit('chat-attach-keydown', $event)">
|
||||
<label for="gev-chat-layer">{{ t('Attach a map layer') }}</label>
|
||||
<div id="gev-chat-layer-row">
|
||||
<select id="gev-chat-layer" ref="layerSelect" :disabled="props.view.chat.locked" @change="layerChoice = $event.target.value" @keydown.enter.prevent="attachLayer()">
|
||||
<option value="">{{ t('Choose a layer…') }}</option>
|
||||
<option v-for="layer in props.view.chat.layers" :key="layer.value" :value="layer.value">{{ layer.label }}</option>
|
||||
</select>
|
||||
<button id="gev-chat-layer-attach" type="button" :disabled="props.view.chat.locked || !layerChoice" @click="attachLayer()">{{ t('Attach layer') }}</button>
|
||||
</div>
|
||||
<button id="gev-chat-file-button" type="button" :disabled="props.view.chat.locked" @click="emit('chat-file-button')">{{ t('Attach a file') }}</button>
|
||||
<p>{{ t('TXT, Markdown, CSV, JSON or GeoJSON · up to 10 KB in total. Attachments are sent to your AI provider with your message.') }}</p>
|
||||
<input id="gev-chat-file" type="file" accept=".txt,.md,.csv,.json,.geojson" multiple hidden @change="emit('chat-files', $event.target)" />
|
||||
</div>
|
||||
<aside id="gev-chat-mini-reply" :hidden="!props.view.chat.miniReply" :aria-label="t('Latest AI response')">
|
||||
<header><span translate="no">{{ ASSISTANT_NAME }}</span><button id="gev-chat-expand-reply" type="button" :aria-label="t('Expand conversation')" :title="t('Expand conversation')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M14 4h6v6m0-6-7 7M10 20H4v-6m0 6 7-7"></path></svg></button></header>
|
||||
<p id="gev-chat-mini-text" aria-live="polite">{{ props.view.chat.miniReply }}</p>
|
||||
</aside>
|
||||
<div id="gev-chat-suggestions" :aria-label="t('Command suggestions')" :hidden="!props.view.chat.suggestions.length">
|
||||
<div v-for="group in props.view.chat.suggestions" :key="group.label">
|
||||
<small>{{ group.label }}</small>
|
||||
<button v-for="command in group.items" :key="command" type="button" :title="command" @click="emit('chat-suggestion', command)">{{ command }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="gev-chat-form" @submit.prevent="emit('chat-submit')">
|
||||
<button id="gev-chat-restore" type="button" :aria-label="t('Expand chat')" :title="t('Expand chat')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-6 4V6a2 2 0 0 1 2-2Z"></path></svg></button>
|
||||
<button id="gev-chat-attach" type="button" :disabled="props.view.chat.busy" :aria-label="t('Add attachment')" :aria-expanded="String(props.view.chat.attachMenuOpen)" aria-controls="gev-chat-attach-menu" @click="emit('chat-attach-toggle')" @keydown="emit('chat-attach-keydown', $event)"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m8 12 6-6a3 3 0 0 1 4 4l-8 8a5 5 0 0 1-7-7l9-9"></path></svg></button>
|
||||
<textarea id="gev-chat-input" v-owned-draft="{ text: props.view.chat.draft, revision: props.view.chat.draftRevision }" :rows="props.view.chat.rows" maxlength="4000" :aria-label="t('Message GEV')" :placeholder="t('Ask GEV anything about the map…')" @input="emit('chat-input', $event.target.value)" @keydown="emit('chat-keydown', $event)"></textarea>
|
||||
<button id="gev-chat-send" :type="props.view.chat.busy ? 'button' : 'submit'" :disabled="props.view.chat.sendDisabled" :data-busy="String(props.view.chat.busy)" :aria-label="props.view.chat.busy ? t('Stop reply') : t('Send message')" :title="props.view.chat.busy ? t('Stop reply') : t('Send message')" @click="props.view.chat.busy && emit('chat-stop')"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path class="gev-chat-enter-icon" d="M19 5v8H5m5-5-5 5 5 5"></path><rect class="gev-chat-stop-icon" x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none"></rect></svg></button>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
@@ -49,10 +49,10 @@ const weatherLabel = computed(() =>
|
||||
<span class="cockpit-context-qualifier">{{ t('CONTEXT ONLY') }}</span>
|
||||
</header>
|
||||
<div class="cockpit-context-cohorts" role="list" :aria-label="t('Nearby cohort counts')">
|
||||
<div v-class-toggle="{ unknown: c.cohorts.flights.unknown }" role="listitem" data-context-cohort="flights"><span>{{ t('FLT') }}</span><strong>{{ c.cohorts.flights.count }}</strong><small translate="no">OpenSky</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts.military.unknown }" role="listitem" data-context-cohort="military"><span>{{ t('MIL') }}</span><strong>{{ c.cohorts.military.count }}</strong><small translate="no">adsb.lol</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts['ais-live-vessels'].unknown }" role="listitem" data-context-cohort="ais-live-vessels"><span translate="no">AIS</span><strong>{{ c.cohorts['ais-live-vessels'].count }}</strong><small translate="no">AISStream</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts['military-installations'].unknown }" role="listitem" data-context-cohort="military-installations"><span>{{ t('SITE') }}</span><strong>{{ c.cohorts['military-installations'].count }}</strong><small translate="no">OpenStreetMap</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts.flights.unknown }" role="listitem" data-context-cohort="flights"><span>{{ t('FLT') }}</span><strong>{{ c.cohorts.flights.count }}</strong><small translate="no" :title="c.cohorts.flights.source">{{ c.cohorts.flights.source }}</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts.military.unknown }" role="listitem" data-context-cohort="military"><span>{{ t('MIL') }}</span><strong>{{ c.cohorts.military.count }}</strong><small translate="no" :title="c.cohorts.military.source">{{ c.cohorts.military.source }}</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts['ais-live-vessels'].unknown }" role="listitem" data-context-cohort="ais-live-vessels"><span translate="no">AIS</span><strong>{{ c.cohorts['ais-live-vessels'].count }}</strong><small translate="no" :title="c.cohorts['ais-live-vessels'].source">{{ c.cohorts['ais-live-vessels'].source }}</small></div>
|
||||
<div v-class-toggle="{ unknown: c.cohorts['military-installations'].unknown }" role="listitem" data-context-cohort="military-installations"><span>{{ t('SITE') }}</span><strong>{{ c.cohorts['military-installations'].count }}</strong><small translate="no" :title="c.cohorts['military-installations'].source">{{ c.cohorts['military-installations'].source }}</small></div>
|
||||
</div>
|
||||
<div class="cockpit-context-nearest">
|
||||
<span id="cockpit-context-direction" v-class-toggle="{ unknown: c.direction.unknown }" class="material-symbols-outlined" :style="directionStyle" aria-hidden="true">navigation</span>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup>
|
||||
import { t } from '../../../i18n/index.js';
|
||||
|
||||
// Dock and minimize for an assistant panel (chat or voice). The owner
|
||||
// (src/voice/panelLayout.js) places the panel; this reports the choice.
|
||||
const props = defineProps({
|
||||
docked: { type: Boolean, default: false },
|
||||
minimized: { type: Boolean, default: false },
|
||||
});
|
||||
defineEmits(['dock', 'minimize']);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="gev-panel-layout" role="group" :aria-label="t('Panel position')">
|
||||
<button type="button" data-layout-dock :aria-pressed="String(props.docked)" :aria-label="props.docked ? t('Move above the dock') : t('Dock to the right')" :title="props.docked ? t('Move above the dock') : t('Dock to the right')" @click="$emit('dock')"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path :d="props.docked ? 'M4 5h16v14H4ZM4 14h16' : 'M4 5h16v14H4ZM14 5v14'"></path></svg></button>
|
||||
<button type="button" data-layout-minimize :aria-label="props.minimized ? t('Expand panel') : t('Minimize panel')" :title="props.minimized ? t('Expand panel') : t('Minimize panel')" @click="$emit('minimize')"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path :d="props.minimized ? 'M6 6h12v12H6Z' : 'M6 12h12'"></path></svg></button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -67,7 +67,7 @@ const radioWords = computed(() => ({
|
||||
<a id="radio-station-homepage" :href="radio ? radio.station.homepage || undefined : '#'" target="_blank" rel="noopener noreferrer" :hidden="radio ? !radio.station.homepage : true">{{ t('STATION SITE') }}</a>
|
||||
<a href="https://www.radio-browser.info/" target="_blank" rel="noopener noreferrer">{{ t('DIRECTORY: RADIO BROWSER') }}</a>
|
||||
</div>
|
||||
<p class="radio-privacy">{{ t('Audio connects directly to the broadcaster after you press play. Your IP is visible to that broadcaster.') }}</p>
|
||||
<p class="radio-privacy">{{ t('Audio connects directly to the broadcaster when you press play, choose a station on the globe or ask voice to play. Your IP is visible to that broadcaster.') }}</p>
|
||||
<SdrCard />
|
||||
</RailPanel>
|
||||
</template>
|
||||
@@ -3,8 +3,11 @@ import { storeToRefs } from 'pinia';
|
||||
import { formatNumber, t } from '../../../i18n/index.js';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import { useVoiceStore } from '../../stores/voice.js';
|
||||
import { ASSISTANT_NAME } from '../../../voice/control.js';
|
||||
import VoiceCard from './VoiceCard.vue';
|
||||
import VoiceVisualizer from './VoiceVisualizer.vue';
|
||||
import ChatPanel from './ChatPanel.vue';
|
||||
import PanelLayoutButtons from './PanelLayoutButtons.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
|
||||
@@ -49,16 +52,25 @@ const rootData = (root) => ({
|
||||
'data-push-to-talk': optional(root.pushToTalk),
|
||||
'data-microphone': optional(root.microphone),
|
||||
'data-row-grace': root.rowGrace ? 'true' : undefined,
|
||||
'data-assistant-mode': root.assistantMode,
|
||||
'data-chat-open': String(root.chatOpen),
|
||||
'data-chat-busy': String(root.chatBusy),
|
||||
'data-voice-exchange': root.voiceExchange ? 'true' : undefined,
|
||||
});
|
||||
// Settings opened from chat take chat's frame, so the switch does not jump.
|
||||
const frameStyle = (panel) => ({
|
||||
'--chat-frame-width': panel.frameWidth ? `${panel.frameWidth}px` : undefined,
|
||||
'--chat-frame-height': panel.frameHeight ? `${panel.frameHeight}px` : undefined,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="gev-voice-control" v-bind="rootData(view.root)" v-class-toggle="{ 'error-dismissed': view.root.errorDismissed }" @pointerleave="emit('pointerleave', $event)" @pointerenter="emit('pointerenter', $event)">
|
||||
<label id="gev-voice-provider-field" class="gev-voice-provider-field" :hidden="view.provider.hidden">
|
||||
<span class="gev-active-border" aria-hidden="true"></span>
|
||||
<label v-if="!view.panel" id="gev-voice-provider-field" class="gev-voice-provider-field" :hidden="view.provider.hidden">
|
||||
<span>{{ t('Voice provider') }}</span>
|
||||
<UiSelect id="gev-voice-provider" class="gev-field" :aria-label="t('Voice provider')" :title="view.provider.title" :model-value="view.provider.value" @update:model-value="emit('provider-change', $event)"><option v-for="option in view.provider.options" :key="option.value" :value="option.value">{{ option.label }}</option></UiSelect>
|
||||
</label>
|
||||
<button v-if="view.panel" id="gev-voice-settings-button" class="gev-voice-settings-button" type="button" :aria-label="t('Voice Settings')" aria-controls="gev-voice-panel" :aria-expanded="String(view.voicePanel.settingsExpanded)" @click="emit('settings-button')"><span class="material-symbols-outlined gev-voice-settings-icon" aria-hidden="true">settings</span></button>
|
||||
<div class="gev-voice-heading">
|
||||
<div class="gev-voice-kicker">{{ t('AI AGENT') }}</div>
|
||||
<div id="gev-voice-status">{{ view.status.text }}</div>
|
||||
@@ -72,7 +84,12 @@ const rootData = (root) => ({
|
||||
<span class="gev-mic-orbit"><img src="/mic.svg" alt="" /></span>
|
||||
<span class="gev-mic-label">{{ view.mic.text }}</span>
|
||||
</UiButton>
|
||||
<button v-if="view.panel" id="gev-chat-button" type="button" :aria-label="t('Open AI chat')" aria-controls="gev-chat-panel" :aria-expanded="String(view.chat.open && !view.chat.minimized)" @click="emit('chat-button')"><svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-6 4V6a2 2 0 0 1 2-2Z"></path></svg><span class="gev-chat-label">{{ t('CHAT') }}</span></button>
|
||||
<ChatPanel v-if="view.panel" :view="view" />
|
||||
<VoiceVisualizer />
|
||||
<div class="gev-chat-thinking" aria-hidden="true"><span></span><span></span><span></span></div>
|
||||
<!-- Chat announces its phase in its own status line (#gev-chat-status); in chat mode this one stays silent. -->
|
||||
<div id="gev-assistant-phase" role="status" :aria-live="view.root.assistantMode === 'chat' ? 'off' : 'polite'" :aria-hidden="view.root.assistantMode === 'chat' ? 'true' : undefined">{{ view.phase.text }}</div>
|
||||
<div class="gev-voice-readout">
|
||||
<div id="gev-voice-detail" :title="optional(view.detail.title)">{{ view.detail.text }}</div>
|
||||
</div>
|
||||
@@ -80,21 +97,39 @@ const rootData = (root) => ({
|
||||
<span class="gev-voice-help-kicker">{{ t('VOICE CONTROL') }}</span>
|
||||
<span class="gev-voice-help-detail">{{ view.help.text }}</span>
|
||||
</div>
|
||||
<section v-if="view.panel" id="gev-voice-panel" class="gev-voice-panel" :hidden="view.voicePanel.hidden" :data-view="optional(view.voicePanel.view)" :aria-label="t('Voice Settings')" @keydown="emit('panel-keydown', $event)">
|
||||
<section v-if="view.panel" id="gev-voice-panel" class="gev-voice-panel" :hidden="view.voicePanel.hidden" :data-view="optional(view.voicePanel.view)" :data-minimized="view.voicePanel.minimized ? 'true' : undefined" :data-context="optional(view.voicePanel.context)" :style="frameStyle(view.voicePanel)" :aria-label="t('Voice Settings')" @keydown="emit('panel-keydown', $event)">
|
||||
<div class="gev-voice-panel-header">
|
||||
<button id="gev-chat-back" type="button" :hidden="!view.chat.backVisible" @click="emit('chat-back')"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M15 5l-7 7 7 7"></path></svg><span>{{ t('Back to chat') }}</span></button>
|
||||
<button id="gev-voice-back" type="button" @click="emit('voice-back')"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true"><path d="M15 5l-7 7 7 7"></path></svg><span>{{ t('Back to voice') }}</span></button>
|
||||
<span class="gev-voice-panel-title">{{ t('VOICE') }}</span>
|
||||
<div class="gev-voice-panel-tabs" role="tablist" :aria-label="t('Voice Settings')">
|
||||
<button id="gev-voice-preview-tab" class="gev-voice-panel-tab" type="button" role="tab" :aria-label="t('Preview')" :title="t('Preview')" :aria-selected="String(view.voicePanel.selected === 'preview')" :tabindex="view.voicePanel.selected === 'preview' ? 0 : -1" aria-controls="gev-voice-preview-panel" @click="emit('tab', 0)" @keydown="emit('tab-keydown', 0, $event)"><span class="material-symbols-outlined gev-voice-panel-tab-icon" aria-hidden="true">visibility</span></button>
|
||||
<button id="gev-voice-settings-tab" class="gev-voice-panel-tab" type="button" role="tab" :aria-label="t('Settings')" :title="t('Settings')" :aria-selected="String(view.voicePanel.selected === 'settings')" :tabindex="view.voicePanel.selected === 'settings' ? 0 : -1" aria-controls="gev-voice-settings-panel" @click="emit('tab', 1)" @keydown="emit('tab-keydown', 1, $event)"><span class="material-symbols-outlined gev-voice-panel-tab-icon" aria-hidden="true">settings</span></button>
|
||||
</div>
|
||||
<PanelLayoutButtons :docked="view.layout.docked" :minimized="view.voicePanel.minimized" @dock="emit('layout-dock')" @minimize="emit('voice-minimize')" />
|
||||
<button id="gev-voice-settings-close" type="button" :aria-label="t('Close voice panel')" @click="emit('settings-close')">×</button>
|
||||
</div>
|
||||
<div class="gev-voice-mini" role="group" :aria-label="t('Latest voice exchange')">
|
||||
<p :hidden="!view.mini.user"><span class="gev-voice-mini-who">{{ t('YOU') }}</span><span id="gev-voice-mini-user">{{ view.mini.user }}</span></p>
|
||||
<p :hidden="!view.mini.assistant"><span class="gev-voice-mini-who" translate="no">{{ ASSISTANT_NAME }}</span><span id="gev-voice-mini-assistant">{{ view.mini.assistant }}</span></p>
|
||||
</div>
|
||||
<div class="gev-voice-panel-body ui-scroll">
|
||||
<section id="gev-voice-preview-panel" role="tabpanel" aria-labelledby="gev-voice-preview-tab" :hidden="view.voicePanel.previewHidden">
|
||||
<p id="gev-voice-preview-empty" :hidden="view.previewEmpty.hidden">{{ view.previewEmpty.text }}</p>
|
||||
<div class="gev-voice-hints" role="group" :aria-label="t('Try saying')"><small>{{ t('Try saying') }}</small><q>{{ t('What am I looking at?') }}</q><q>{{ t('Fly to Tokyo') }}</q><q>{{ t('Show live flights') }}</q></div>
|
||||
<VoiceCard :card="view.card" @dismiss="emit('card-dismiss')" />
|
||||
</section>
|
||||
<section id="gev-voice-settings-panel" role="tabpanel" aria-labelledby="gev-voice-settings-tab" :hidden="view.voicePanel.settingsHidden">
|
||||
<label id="gev-voice-provider-field" class="gev-voice-provider-field" :hidden="view.provider.hidden">
|
||||
<span>{{ t('AI Provider') }}</span>
|
||||
<UiSelect id="gev-voice-provider" class="gev-field" :aria-label="t('AI Provider')" :title="view.provider.title" :model-value="view.provider.value" @update:model-value="emit('provider-change', $event)"><option v-for="option in view.provider.options" :key="option.value" :value="option.value">{{ option.label }}</option></UiSelect>
|
||||
</label>
|
||||
<p class="gev-voice-settings-note">{{ t('The selected AI provider is shared by voice and chat.') }}</p>
|
||||
<div id="gev-settings-chat">
|
||||
<label class="gev-voice-preference gev-voice-preference-toggle"><input id="gev-chat-quick" type="checkbox" v-checked="view.chat.quickChecked" @change="emit('chat-quick-change', $event.target.checked)" /><span>{{ t('Show quick commands') }}</span></label>
|
||||
<p>{{ t('Chat replies are silent. No microphone access is needed.') }}</p>
|
||||
</div>
|
||||
<div id="gev-settings-voice">
|
||||
<label class="gev-voice-preference gev-voice-preference-toggle"><input id="gev-voice-preview-enabled" type="checkbox" aria-describedby="gev-voice-preview-note" v-checked="view.preferences.previewChecked" @change="emit('preview-change', $event.target.checked)" /><span>{{ t('Show Voice Preview') }}</span></label>
|
||||
<p id="gev-voice-preview-note" class="gev-voice-settings-note">{{ view.preferences.previewNote }}</p>
|
||||
<div class="gev-voice-timeout-group">
|
||||
@@ -120,17 +155,18 @@ const rootData = (root) => ({
|
||||
<span id="gev-voice-cost-value" class="gev-voice-cost-value" :hidden="view.cost.hidden" :data-level="view.cost.level" :title="view.cost.title">{{ view.cost.text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
<VoiceCard v-else :card="view.card" @dismiss="emit('card-dismiss')" />
|
||||
<div class="gev-voice-error-tray" role="alert" aria-live="assertive">
|
||||
<div class="gev-voice-error-header">
|
||||
<span>{{ t('VOICE SYSTEM ERROR') }}</span>
|
||||
<span>{{ view.error.typed ? `${t('Chat')} · ${t('ERROR', { context: 'voice' })}` : t('VOICE SYSTEM ERROR') }}</span>
|
||||
<button class="gev-voice-error-dismiss" type="button" @click="controls?.dismissError()">{{ t('DISMISS') }}</button>
|
||||
</div>
|
||||
<div id="gev-voice-error-detail">{{ view.error.text }}</div>
|
||||
<div class="gev-voice-error-hint">{{ t('Check microphone permission and network access, then try again.') }}</div>
|
||||
<div class="gev-voice-error-hint" :hidden="view.error.typed">{{ t('Check microphone permission and network access, then try again.') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,132 @@
|
||||
<script setup>
|
||||
import { computed, shallowRef, useTemplateRef, watch } from 'vue';
|
||||
import { formatDate, t, translateKnown } from '../../../i18n/index.js';
|
||||
import { photoCreator, formatAge } from '../../../layers/wildlifeSightings/photoText.js';
|
||||
import { ACARTIA_SITE, inatLicenceLabel, inatPhotoUrl, isOpenPhoto } from '../../../layers/wildlifeSightings/records.js';
|
||||
|
||||
const props = defineProps({
|
||||
sighting: { type: Object, required: true },
|
||||
nowMs: { type: Number, required: true },
|
||||
taxa: { type: String, default: 'all' },
|
||||
});
|
||||
const emit = defineEmits(['close', 'resize']);
|
||||
const acartia = computed(() => props.sighting.origin === 'acartia');
|
||||
const name = computed(() => translateKnown(props.sighting.commonName || props.sighting.scientificName) || t('SIGHTING'));
|
||||
const scientificName = computed(() => translateKnown(props.sighting.scientificName || ''));
|
||||
const photo = computed(() => {
|
||||
const row = props.sighting;
|
||||
if (row.obscured || acartia.value || !isOpenPhoto(row.photo)) return null;
|
||||
const src = inatPhotoUrl(row.photo.square ?? row.photo.url, 'medium');
|
||||
const creator = photoCreator(row.photo);
|
||||
return src && creator ? { src, creator, licence: inatLicenceLabel(row.photo.license_code ?? row.photo.licence) } : null;
|
||||
});
|
||||
const observedDay = computed(() => {
|
||||
const row = props.sighting;
|
||||
const day = row.observedOn || (!row.obscured && Number.isFinite(row.observedAt) ? new Date(row.observedAt).toISOString().slice(0, 10) : '');
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(day)) return '';
|
||||
const date = new Date(`${day}T00:00:00Z`);
|
||||
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === day ? day : '';
|
||||
});
|
||||
const age = computed(() => {
|
||||
const row = props.sighting;
|
||||
const delta = props.nowMs - row.observedAt;
|
||||
if (row.obscured || !Number.isFinite(row.observedAt) || delta >= 30 * 86_400_000) return '';
|
||||
const compact = formatAge(Math.max(0, delta));
|
||||
return acartia.value ? t('seen {age} ago', { age: compact }) : t('observed {age} ago', { age: compact });
|
||||
});
|
||||
const observedDate = computed(() => observedDay.value ? formatDate(Date.parse(`${observedDay.value}T00:00:00Z`), { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' }) : '');
|
||||
const link = computed(() => {
|
||||
// The "Acartia" label only ever points at the Acartia site, never a row URL.
|
||||
if (acartia.value) return ACARTIA_SITE;
|
||||
try {
|
||||
const url = new URL(props.sighting.link);
|
||||
return url.protocol === 'https:' && !url.username && !url.password ? url.href : null;
|
||||
} catch { return null; }
|
||||
});
|
||||
const providerCredit = computed(() => {
|
||||
if (!acartia.value) return '';
|
||||
const { name = '', entity = '' } = props.sighting.provider || {};
|
||||
return entity ? t('Reported by {name} ({entity})', { name, entity }) : t('Reported by {name}', { name });
|
||||
});
|
||||
const actionLabel = computed(() => acartia.value ? t('Open {name} on Acartia', { name: name.value }) : t('Open {name} on iNaturalist', { name: name.value }));
|
||||
const photoImage = useTemplateRef('photoImage');
|
||||
const loaded = shallowRef(false);
|
||||
const failed = shallowRef(false);
|
||||
const currentImage = (image) => image === photoImage.value && image?.dataset.sightingId === props.sighting.stableId && image?.getAttribute('src') === photo.value?.src;
|
||||
async function onPhotoLoad(event) {
|
||||
const image = event.currentTarget;
|
||||
// Ignore late decodes after a different observation replaces this photo.
|
||||
try { await image.decode?.(); } catch { /* onload is sufficient on older engines */ }
|
||||
if (!currentImage(image)) return;
|
||||
loaded.value = true;
|
||||
emit('resize');
|
||||
}
|
||||
function fail(event) {
|
||||
if (!currentImage(event.currentTarget)) return;
|
||||
failed.value = true;
|
||||
emit('resize');
|
||||
}
|
||||
watch([() => props.sighting.stableId, () => photo.value?.src], () => { loaded.value = false; failed.value = false; }, { flush: 'sync' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="wildlife-sighting-card" data-wildlife-sighting-card tabindex="-1" :aria-label="name" @keydown.stop @keyup.stop>
|
||||
<button type="button" class="wildlife-sighting-card-close" :aria-label="t('Close sighting')" @click="emit('close')">×</button>
|
||||
<component :is="link ? 'a' : 'div'" class="wildlife-sighting-card-content" :href="link || undefined" :target="link ? '_blank' : undefined" :rel="link ? 'noopener noreferrer' : undefined" :aria-label="link ? actionLabel : undefined">
|
||||
<div v-if="photo" class="wildlife-sighting-card-photo" :aria-busy="!loaded && !failed">
|
||||
<p v-if="!loaded && !failed" role="status">{{ t('Loading photo...') }}</p>
|
||||
<p v-if="failed" role="status">{{ t('Photo unavailable') }}</p>
|
||||
<img v-show="!failed" ref="photoImage" :key="sighting.stableId + photo.src" :data-sighting-id="sighting.stableId" :src="photo.src" :alt="t('Photo of {name}', { name })" referrerpolicy="no-referrer" :class="{ loaded }" @load="onPhotoLoad" @error="fail" />
|
||||
</div>
|
||||
<div class="wildlife-sighting-card-caption">
|
||||
<h2>{{ name }}</h2>
|
||||
<p v-if="scientificName && scientificName !== name"><i>{{ scientificName }}</i></p>
|
||||
<p v-if="age || observedDay"><time :datetime="observedDay || undefined">{{ age || observedDate }}</time></p>
|
||||
<p v-if="sighting.obscured">{{ t('Location obscured to a 0.2° cell') }}</p>
|
||||
<!-- i18n-ignore: creator and licence are provider attribution, copied verbatim -->
|
||||
<p v-if="photo" class="wildlife-sighting-card-credit">© {{ photo.creator }} · {{ photo.licence }}</p>
|
||||
<p v-if="providerCredit" class="wildlife-sighting-card-credit">{{ providerCredit }}</p>
|
||||
<p v-if="acartia" class="wildlife-sighting-card-credit">{{ t('Acartia') }} · {{ t('CC BY 4.0') }} · {{ t('Salish Sea') }}</p>
|
||||
<p v-if="link" class="wildlife-sighting-card-source">{{ acartia ? t('Acartia') : t('iNaturalist') }} ↗</p>
|
||||
</div>
|
||||
</component>
|
||||
<p v-if="acartia || taxa === 'whales'" class="wildlife-sighting-card-guidance">
|
||||
<a href="https://www.bewhalewise.org" target="_blank" rel="noopener noreferrer">{{ t('Be Whale Wise') }}</a>
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wildlife-sighting-card {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-height: inherit;
|
||||
overflow: auto;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--glass-border-hover);
|
||||
border-radius: var(--btn-radius);
|
||||
background: var(--menu-bg);
|
||||
color: var(--text-primary);
|
||||
font: 11px/1.4 var(--font-mono);
|
||||
box-shadow: 0 3px 16px rgb(0 0 0 / 30%);
|
||||
}
|
||||
.wildlife-sighting-card-content { display: block; color: inherit; text-decoration: none; }
|
||||
.wildlife-sighting-card-content:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; }
|
||||
/* Script focus starts inside the card; tab focus still outlines its controls. */
|
||||
.wildlife-sighting-card:focus-visible { outline: none !important; }
|
||||
.wildlife-sighting-card-close { position: absolute; z-index: 1; inset-block-start: 4px; inset-inline-end: 4px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--btn-radius); background: transparent; color: inherit; font: 20px/1 var(--font-sans); cursor: pointer; }
|
||||
.wildlife-sighting-card-close:hover { background: var(--menu-bg); }
|
||||
.wildlife-sighting-card-close:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 2px; }
|
||||
.wildlife-sighting-card-photo { position: relative; width: 100%; height: 180px; }
|
||||
.wildlife-sighting-card-photo > p { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }
|
||||
.wildlife-sighting-card-photo > img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
|
||||
.wildlife-sighting-card-photo > img.loaded { opacity: 1; }
|
||||
.wildlife-sighting-card-caption { padding-top: 6px; overflow-wrap: anywhere; }
|
||||
.wildlife-sighting-card-caption h2, .wildlife-sighting-card-caption p { margin: 0 0 3px; }
|
||||
.wildlife-sighting-card-caption h2 { padding-inline-end: 20px; font: inherit; font-weight: 700; }
|
||||
.wildlife-sighting-card-credit { color: var(--text-secondary); }
|
||||
.wildlife-sighting-card-guidance { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 0; color: var(--text-secondary); }
|
||||
.wildlife-sighting-card-guidance a { color: inherit; }
|
||||
.wildlife-sighting-card-source { text-decoration: underline; text-underline-offset: 2px; }
|
||||
</style>
|
||||
Reference in new issue
Block a user