mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Both panels landed after the original string extraction, so they rendered English in every locale. Mark their markup and runtime text (status, SINCE stops, provider tooltips, coverage meta, viewer captions, draw hints and colours), the layer-list names kept in PANEL_LABELS, and add 90 es and ru entries. Street Level is «Уличные снимки» / «A pie de calle». Co-Authored-By: Claude Opus 5.5 <[email protected]>
85 lines
2.5 KiB
JavaScript
85 lines
2.5 KiB
JavaScript
import { COLORS } from './policy.js';
|
|
|
|
import { msg, t } from '../../i18n/index.js';
|
|
/**
|
|
* @typedef {object} ProviderSnapshot
|
|
* @property {string} id
|
|
* @property {string} name
|
|
* @property {string} label
|
|
* @property {boolean} on
|
|
* @property {boolean|null} configured null until the status call answers
|
|
* @property {boolean} keyRequired no usable key: missing or rejected
|
|
* @property {boolean} [keyRejected] the provider refused the configured key
|
|
* @property {string|null} requiresKeyId
|
|
* @property {boolean} loading
|
|
* @property {number} count
|
|
* @property {string} hint
|
|
* @property {string|null} error
|
|
* @property {string} color The source's one colour.
|
|
*/
|
|
|
|
/**
|
|
* Totals over switched-on providers. Key-gated only when every one lacks its
|
|
* key; `keyRejected` when that is because a key was refused.
|
|
* @param {Array<ProviderSnapshot>} providers
|
|
*/
|
|
export function summarizeCoverage(providers) {
|
|
const active = providers.filter((p) => p.on);
|
|
return {
|
|
count: active.reduce((sum, p) => sum + (p.count || 0), 0),
|
|
loading: active.some((p) => p.loading),
|
|
hint:
|
|
providers.length === 0
|
|
? msg('No street-level imagery providers configured')
|
|
: active.find((p) => p.hint)?.hint || '',
|
|
error: active.find((p) => p.error)?.error || null,
|
|
keyRequired:
|
|
active.length > 0 && active.every((p) => p.keyRequired === true),
|
|
keyRejected:
|
|
active.length > 0 &&
|
|
active.every((p) => p.keyRequired === true) &&
|
|
active.some((p) => p.keyRejected === true),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* The panel snapshot from core state and provider snapshots. The legend has
|
|
* one swatch per active source, then the shared selection colour.
|
|
* @param {{enabled: boolean, filter: object, providers: Array<ProviderSnapshot>, street: object, sequence: object}} input
|
|
*/
|
|
export function composeUIState({
|
|
enabled,
|
|
filter,
|
|
providers,
|
|
street,
|
|
sequence,
|
|
surface = 'draped',
|
|
}) {
|
|
const active = providers.filter((p) => p.on);
|
|
const { keyRequired, keyRejected, ...coverage } =
|
|
summarizeCoverage(providers);
|
|
const legend = active.map((provider) => ({
|
|
key: provider.id,
|
|
label: provider.name,
|
|
color: provider.color,
|
|
}));
|
|
if (active.length)
|
|
legend.push({
|
|
key: 'selected',
|
|
label: t('Selected'),
|
|
color: COLORS.selected,
|
|
});
|
|
return {
|
|
enabled,
|
|
keyRequired,
|
|
keyRejected,
|
|
filter: { ...filter },
|
|
providers: providers.map((p) => ({ ...p })),
|
|
coverage,
|
|
legend,
|
|
sequence: { ...sequence },
|
|
street: { ...street },
|
|
surface,
|
|
};
|
|
}
|