mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Add the Data Library: live regional datasets, tiles and packs
DATA LAYERS keeps its curated core layers; regional and niche sources live in the Data Library, opened from Browse data library at the foot of the panel. Each entry is a JSON manifest in src/library/entries/ pointing at a live upstream (query API, provider-hosted file or tile endpoint), so nothing is bundled and a self-hosted instance hosts no data. Sources without CORS go through one allowlisted /api/library route. Kinds: dataset (GeoJSON, CSV, JSON records, ArcGIS, partitioned GeoParquet), tiles (XYZ, WMS/ArcGIS bbox export, terrarium relief) and pack. Selections persist and travel in share links as lib=, separate from the core layer tokens. Library rows get Zoom and Remove icon chips that work while the layer is off, rendered through RailChips. Strings are translated in every locale.
This commit is contained in:
1 parent
10a788db78
commit
db80d82b8d
182 files changed
+15805
-44
No files matched your search
+26
-10
@@ -120,6 +120,17 @@ const PANEL_ORDER = PANEL_GROUPS.flatMap(({ label, ids, containerId }) =>
|
||||
const PANEL_POSITIONS = new Map(
|
||||
PANEL_ORDER.map(({ id }, index) => [id, index]),
|
||||
);
|
||||
// Data Library layers follow every core group, in the order they were added.
|
||||
const LIBRARY_GROUP = msg('Library');
|
||||
const panelPosition = (layer) =>
|
||||
layer.libraryEntryId
|
||||
? PANEL_ORDER.length + 1
|
||||
: (PANEL_POSITIONS.get(layer.id) ?? PANEL_ORDER.length);
|
||||
const panelGroup = (layer) =>
|
||||
layer.libraryEntryId
|
||||
? LIBRARY_GROUP
|
||||
: (PANEL_ORDER[PANEL_POSITIONS.get(layer.id)]?.label ??
|
||||
msg('Other layers'));
|
||||
|
||||
function englishPanelLabel(layer) {
|
||||
return PANEL_LABELS[layer.id] || LAYER_NAME_KEYS[layer.id] || layer.name;
|
||||
@@ -372,6 +383,10 @@ export class LayerPanel {
|
||||
this._groupContainers = new Map();
|
||||
this._toggleContainer = null;
|
||||
}
|
||||
/** Rebuild the rows after the layer set changed (a Data Library add/remove). */
|
||||
rerender() {
|
||||
this._renderToggles();
|
||||
}
|
||||
_renderToggles() {
|
||||
if (this._destroyed || !this._toggleContainer) return;
|
||||
this._releaseBindings();
|
||||
@@ -380,19 +395,13 @@ export class LayerPanel {
|
||||
// its toggle and metadata.
|
||||
const layers = this.getAll()
|
||||
.slice()
|
||||
.sort(
|
||||
(a, b) =>
|
||||
(PANEL_POSITIONS.get(a.id) ?? PANEL_ORDER.length) -
|
||||
(PANEL_POSITIONS.get(b.id) ?? PANEL_ORDER.length),
|
||||
);
|
||||
.sort((a, b) => panelPosition(a) - panelPosition(b));
|
||||
this._rows = [];
|
||||
this._rowViews = new Map();
|
||||
let previousGroup = '';
|
||||
for (const layer of layers) {
|
||||
if (!layer.showInTogglePanel) continue;
|
||||
const group =
|
||||
PANEL_ORDER[PANEL_POSITIONS.get(layer.id)]?.label ??
|
||||
msg('Other layers');
|
||||
const group = panelGroup(layer);
|
||||
const containerId =
|
||||
PANEL_ORDER[PANEL_POSITIONS.get(layer.id)]?.containerId;
|
||||
const container = this._groupContainers.has(containerId)
|
||||
@@ -485,6 +494,7 @@ export class LayerPanel {
|
||||
id: layer.id,
|
||||
// English name for voice tools, which must not receive translated text.
|
||||
englishName: englishPanelLabel(layer),
|
||||
libraryEntry: layer.libraryEntryId || null,
|
||||
icon: layer.icon,
|
||||
name: panelLabel(layer),
|
||||
count: row.count ? presentLayerCount(layer.stats) : null,
|
||||
@@ -504,7 +514,12 @@ export class LayerPanel {
|
||||
* controls for good, and a shown info line stays.
|
||||
*/
|
||||
_presentControls(row, layer) {
|
||||
const controls = layer.enabled ? this._rowControlsFor(layer.id) : null;
|
||||
// A quiet row stays quiet while off, except Data Library rows, whose
|
||||
// actions (zoom, remove) work on a layer that is off.
|
||||
const controls =
|
||||
layer.enabled || layer.libraryEntryId
|
||||
? this._rowControlsFor(layer.id)
|
||||
: null;
|
||||
if (controls?.readout) {
|
||||
// The row became a rail readout: its controls go for good.
|
||||
row.controls = false;
|
||||
@@ -580,7 +595,8 @@ export class LayerPanel {
|
||||
...(live?.chips || []),
|
||||
...(live?.segmented?.options || []),
|
||||
].find((entry) => entry.id === chipId);
|
||||
if (!chip || chip.disabled || !this.isEnabled(id)) return;
|
||||
if (!chip || chip.disabled || (!this.isEnabled(id) && !chip.whileOff))
|
||||
return;
|
||||
if (typeof chip.onClick === 'function') chip.onClick();
|
||||
else if (chip.params)
|
||||
this.setLayerParams(id, chip.params, { origin: 'user' });
|
||||
|
||||
@@ -33,6 +33,7 @@ defineProps({
|
||||
}"
|
||||
:data-layer-id="item.id"
|
||||
:data-layer-name="item.englishName"
|
||||
:data-library-entry="item.libraryEntry || undefined"
|
||||
><div class="data-toggle-top"
|
||||
><div class="data-toggle-left"
|
||||
><span class="data-icon" aria-hidden="true">{{ item.icon }}</span
|
||||
|
||||
@@ -218,3 +218,57 @@ test('a row range renders start and end pickers and reports which end moved', ()
|
||||
assert.deepEqual(picks, [['shipwrecks', 'period', 'to', '2007']]);
|
||||
render(null, container);
|
||||
});
|
||||
|
||||
const libraryRow = (chips) => ({
|
||||
...row(false),
|
||||
key: 'lib-night-lights',
|
||||
id: 'lib-night-lights',
|
||||
libraryEntry: 'nasa-black-marble',
|
||||
controls: { hidden: false, chips, legend: [], list: null },
|
||||
});
|
||||
|
||||
test('a Data Library row names its entry and draws icon action chips', () => {
|
||||
document.body.replaceChildren();
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
const zoom = {
|
||||
id: 'zoom',
|
||||
icon: 'zoom_in_map',
|
||||
action: true,
|
||||
label: 'Zoom to layer',
|
||||
};
|
||||
render(h(LayerRows, { items: [libraryRow([zoom])] }), container);
|
||||
const element = container.querySelector('[data-layer-id="lib-night-lights"]');
|
||||
assert.equal(element.dataset.libraryEntry, 'nasa-black-marble');
|
||||
const button = element.querySelector('[data-chip-id="zoom"]');
|
||||
const glyph = button.children[0];
|
||||
assert.equal(glyph.className, 'material-symbols-outlined');
|
||||
assert.equal(glyph.textContent, 'zoom_in_map');
|
||||
assert.equal(glyph.getAttribute('aria-hidden'), 'true');
|
||||
assert.equal(button.getAttribute('aria-label'), 'Zoom to layer');
|
||||
assert.equal(button.title, 'Zoom to layer');
|
||||
assert.equal(button.getAttribute('aria-pressed'), null);
|
||||
assert.ok(button.classList.contains('chip-icon'));
|
||||
|
||||
// The same id as a text toggle drops the icon semantics.
|
||||
render(
|
||||
h(LayerRows, {
|
||||
items: [libraryRow([{ id: 'zoom', label: 'ZOOM', active: true }])],
|
||||
}),
|
||||
container,
|
||||
);
|
||||
const toggle = element.querySelector('[data-chip-id="zoom"]');
|
||||
assert.equal(toggle.textContent, 'ZOOM');
|
||||
assert.equal(toggle.getAttribute('aria-label'), null);
|
||||
assert.equal(toggle.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(toggle.classList.contains('chip-icon'), false);
|
||||
render(null, container);
|
||||
});
|
||||
|
||||
test('a core row carries no library entry attribute', () => {
|
||||
document.body.replaceChildren();
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
render(h(LayerRows, { items: [row(false)] }), container);
|
||||
const element = container.querySelector('[data-layer-id="flights"]');
|
||||
assert.equal(element.hasAttribute('data-library-entry'), false);
|
||||
render(null, container);
|
||||
});
|
||||
@@ -0,0 +1,604 @@
|
||||
/**
|
||||
* DATA LAYERS ▸ Browse data library: the dialog that lists every Data Library
|
||||
* entry this build knows, with its licence, coverage and what this instance
|
||||
* needs to serve it, and adds or removes it from the panel.
|
||||
*
|
||||
* A `dialog[data-panel-surface]` per docs/panel-surfaces.md: this module owns
|
||||
* width, height, labels, initial and return focus, Escape and dismissal, and
|
||||
* closes itself when clean view, recording or Cockpit hides the panels.
|
||||
*/
|
||||
import { formatNumber, msg, t, tn } from '../i18n/index.js';
|
||||
|
||||
const PANEL_HIDING_MODES = ['ui-clean-view', 'recording-mode', 'cockpit-mode'];
|
||||
/** How long Remove all stays armed after its first press. */
|
||||
const RESET_CONFIRM_MS = 4000;
|
||||
/** How often the open dialog rereads its stat tiles (the panel's own pace). */
|
||||
const STATS_REFRESH_MS = 1000;
|
||||
|
||||
const FAMILY_LABELS = Object.freeze({
|
||||
movement: msg('Movement'),
|
||||
cameras: msg('Cameras'),
|
||||
infrastructure: msg('Infrastructure'),
|
||||
events: msg('Events'),
|
||||
weather: msg('Weather'),
|
||||
environment: msg('Environment'),
|
||||
imagery: msg('Imagery'),
|
||||
demographics: msg('Demographics'),
|
||||
});
|
||||
|
||||
const KIND_LABELS = Object.freeze({
|
||||
dataset: msg('DATASET'),
|
||||
tiles: msg('TILES'),
|
||||
pack: msg('PACK'),
|
||||
});
|
||||
|
||||
const STATUS_LABELS = Object.freeze({
|
||||
incubating: msg('INCUBATING'),
|
||||
community: msg('COMMUNITY'),
|
||||
verified: msg('VERIFIED'),
|
||||
stale: msg('STALE'),
|
||||
archived: msg('ARCHIVED'),
|
||||
});
|
||||
|
||||
function element(tag, className, text) {
|
||||
const node = document.createElement(tag);
|
||||
if (className) node.className = className;
|
||||
if (text !== undefined) node.textContent = text;
|
||||
return node;
|
||||
}
|
||||
|
||||
function badge(text, tone = '') {
|
||||
const node = element(
|
||||
'span',
|
||||
`data-library-badge${tone ? ` data-library-badge--${tone}` : ''}`,
|
||||
text,
|
||||
);
|
||||
return node;
|
||||
}
|
||||
|
||||
const compact = (value) =>
|
||||
formatNumber(value, { notation: 'compact', maximumFractionDigits: 1 });
|
||||
|
||||
/**
|
||||
* The four stat tiles at the top of Browse: label, value and one line of
|
||||
* breakdown each. Text only; nothing here is a data colour.
|
||||
* @param {ReturnType<ReturnType<typeof import('../library/controller.js').createDataLibrary>['summary']>} summary
|
||||
* @returns {Array<{ id: string, label: string, value: string, detail: string }>}
|
||||
*/
|
||||
export function libraryStatTiles(summary) {
|
||||
const { kinds } = summary;
|
||||
return [
|
||||
{
|
||||
id: 'entries',
|
||||
label: t('Datasets'),
|
||||
value: compact(summary.entries),
|
||||
detail: t('{datasets} · {tiles} · {packs}', {
|
||||
datasets: tn(kinds.dataset, '{count} dataset', '{count} datasets'),
|
||||
tiles: tn(kinds.tiles, '{count} tile layer', '{count} tile layers'),
|
||||
packs: tn(kinds.pack, '{count} pack', '{count} packs'),
|
||||
}),
|
||||
},
|
||||
{
|
||||
id: 'themes',
|
||||
label: t('Themes'),
|
||||
value: compact(summary.themes.length),
|
||||
// The count alone: the theme names are the Theme filter below.
|
||||
detail: '',
|
||||
},
|
||||
{
|
||||
id: 'added',
|
||||
label: t('Added'),
|
||||
value: compact(summary.added),
|
||||
detail: summary.added
|
||||
? tn(summary.on, '{count} on the map', '{count} on the map')
|
||||
: t('none yet'),
|
||||
},
|
||||
{
|
||||
id: 'features',
|
||||
label: t('Map features'),
|
||||
value: summary.featureLayers ? compact(summary.features) : '—',
|
||||
detail: summary.featureLayers
|
||||
? tn(
|
||||
summary.featureLayers,
|
||||
'from {count} dataset',
|
||||
'from {count} datasets',
|
||||
)
|
||||
: t('switch on a dataset to load features'),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** The sentence explaining what this instance needs to serve an entry. */
|
||||
export function libraryReasonText({ entry, available, reason }) {
|
||||
if (entry.kind === 'pack')
|
||||
return available
|
||||
? t('Switched on by this instance · part of the CCTV layer')
|
||||
: t('Operator opt-in: set {env}=1 on the server', {
|
||||
env: entry.pack.env,
|
||||
});
|
||||
if (available) return '';
|
||||
if (reason === 'operator-opt-in')
|
||||
return t('Operator opt-in: add {id} to GEV_LIBRARY_ENABLE on the server', {
|
||||
id: entry.id,
|
||||
});
|
||||
if (reason === 'operator-disabled')
|
||||
return t("Turned off by this instance's operator");
|
||||
if (reason === 'key-missing') return t('Needs a provider key on the server');
|
||||
if (reason === 'server-unavailable')
|
||||
return t("Needs this app's server · not available in a static build");
|
||||
return t('Checking what this instance serves…');
|
||||
}
|
||||
|
||||
function coverageText(entry) {
|
||||
const { coverage } = entry;
|
||||
if (coverage.global) return t('Global');
|
||||
if (coverage.countries?.length) return coverage.countries.join(' · ');
|
||||
return t('Regional');
|
||||
}
|
||||
|
||||
const IMAGERY_TYPE_LABELS = Object.freeze({
|
||||
ortho: msg('Orthophoto'),
|
||||
'satellite-mosaic': msg('Satellite mosaic'),
|
||||
oblique: msg('Oblique'),
|
||||
historic: msg('Historic imagery'),
|
||||
});
|
||||
|
||||
/**
|
||||
* An imagery entry's specs as label/value pairs for its card: what it is,
|
||||
* how sharp, when it was flown and how often it is refreshed.
|
||||
* @param {object} entry
|
||||
* @returns {Array<{ label: string, value: string }>}
|
||||
*/
|
||||
export function imagerySpecs(entry) {
|
||||
const imagery = entry?.imagery;
|
||||
if (!imagery) return [];
|
||||
const type =
|
||||
imagery.type === 'ortho' && imagery.trueOrtho
|
||||
? t('True orthophoto')
|
||||
: t(IMAGERY_TYPE_LABELS[imagery.type]);
|
||||
return [
|
||||
{ label: t('Type'), value: type },
|
||||
{ label: t('Resolution'), value: imagery.resolution },
|
||||
imagery.vintage && { label: t('Flown'), value: imagery.vintage },
|
||||
imagery.updateCycle && { label: t('Updates'), value: imagery.updateCycle },
|
||||
imagery.orthoQuality && {
|
||||
label: t('Ortho quality'),
|
||||
value: imagery.orthoQuality,
|
||||
},
|
||||
].filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a row matches the current filters.
|
||||
* @param {{ entry: object, available: boolean, added: boolean }} row
|
||||
* @param {{ query: string, family: string, availableOnly: boolean }} filter
|
||||
*/
|
||||
export function libraryRowMatches(row, { query, family, availableOnly }) {
|
||||
const { entry } = row;
|
||||
if (entry.status === 'archived' && !row.added) return false;
|
||||
if (family && entry.family !== family) return false;
|
||||
if (availableOnly && !row.available) return false;
|
||||
const needle = String(query || '')
|
||||
.trim()
|
||||
.toLocaleLowerCase();
|
||||
if (!needle) return true;
|
||||
return [
|
||||
entry.title,
|
||||
entry.provider,
|
||||
entry.description,
|
||||
entry.id,
|
||||
entry.imagery?.resolution,
|
||||
...(entry.coverage.countries || []),
|
||||
]
|
||||
.join(' ')
|
||||
.toLocaleLowerCase()
|
||||
.includes(needle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse order: what a viewer can add first, then what this instance would
|
||||
* need to switch on, then packs (which a host layer owns), each by title.
|
||||
* @param {Array<{ entry: object, available: boolean }>} rows
|
||||
*/
|
||||
export function sortLibraryRows(rows) {
|
||||
const rank = ({ entry, available }) =>
|
||||
entry.kind === 'pack' ? 2 : available ? 0 : 1;
|
||||
return [...rows].sort(
|
||||
(a, b) =>
|
||||
rank(a) - rank(b) || a.entry.title.localeCompare(b.entry.title, 'en'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ library: ReturnType<import('../library/controller.js').createDataLibrary>, trigger: HTMLElement|null }} options
|
||||
* @returns {{ open: () => void, close: () => void, destroy: () => void }}
|
||||
*/
|
||||
export function mountLibraryBrowser({ library, trigger }) {
|
||||
const removers = [];
|
||||
const listen = (node, type, listener) => {
|
||||
node.addEventListener(type, listener);
|
||||
removers.push(() => node.removeEventListener(type, listener));
|
||||
};
|
||||
const filter = { query: '', family: '', availableOnly: false };
|
||||
let dialog = null;
|
||||
let list = null;
|
||||
let status = null;
|
||||
let stats = null;
|
||||
let statsTimer = null;
|
||||
let resetButton = null;
|
||||
// Remove all asks twice: the first press arms it for a few seconds.
|
||||
let resetArmed = false;
|
||||
let resetTimer = null;
|
||||
let resetting = false;
|
||||
|
||||
function disarmReset() {
|
||||
clearTimeout(resetTimer);
|
||||
resetTimer = null;
|
||||
resetArmed = false;
|
||||
}
|
||||
|
||||
function build() {
|
||||
dialog = element('dialog', 'data-library-dialog');
|
||||
dialog.id = 'data-library';
|
||||
dialog.setAttribute('data-panel-surface', '');
|
||||
dialog.setAttribute('aria-labelledby', 'data-library-title');
|
||||
dialog.setAttribute('aria-describedby', 'data-library-intro');
|
||||
|
||||
const header = element('header', 'data-library-header');
|
||||
header.setAttribute('data-panel-header', '');
|
||||
const title = element(
|
||||
'h2',
|
||||
'panel-title panel-surface-title',
|
||||
t('DATA LIBRARY'),
|
||||
);
|
||||
title.id = 'data-library-title';
|
||||
const close = element(
|
||||
'button',
|
||||
'panel-surface-control data-library-close',
|
||||
'×',
|
||||
);
|
||||
close.type = 'button';
|
||||
close.setAttribute('aria-label', t('Close data library'));
|
||||
listen(close, 'click', () => api.close());
|
||||
header.append(title, close);
|
||||
|
||||
const body = element('div', 'data-library-body');
|
||||
body.setAttribute('data-panel-body', '');
|
||||
stats = element('dl', 'data-library-stats');
|
||||
stats.setAttribute('aria-label', t('Data Library at a glance'));
|
||||
const intro = element(
|
||||
'p',
|
||||
'data-library-intro',
|
||||
t(
|
||||
'Live sources beyond the core layers. Each one is fetched from its provider while it is on; nothing is stored in this app. Add one and it appears in Data Layers under Library.',
|
||||
),
|
||||
);
|
||||
intro.id = 'data-library-intro';
|
||||
|
||||
const filters = element('div', 'data-library-filters');
|
||||
const searchLabel = element('label', 'data-library-field');
|
||||
searchLabel.append(element('span', '', t('Search')));
|
||||
const search = element('input', 'panel-surface-control');
|
||||
search.type = 'search';
|
||||
search.autocomplete = 'off';
|
||||
search.placeholder = t('Name, provider or country');
|
||||
listen(search, 'input', () => {
|
||||
filter.query = search.value;
|
||||
render();
|
||||
});
|
||||
searchLabel.append(search);
|
||||
|
||||
const familyLabel = element('label', 'data-library-field');
|
||||
familyLabel.append(element('span', '', t('Theme')));
|
||||
const family = element('select', 'panel-surface-control');
|
||||
family.append(new Option(t('All themes'), ''));
|
||||
for (const [value, label] of Object.entries(FAMILY_LABELS))
|
||||
family.append(new Option(t(label), value));
|
||||
listen(family, 'change', () => {
|
||||
filter.family = family.value;
|
||||
render();
|
||||
});
|
||||
familyLabel.append(family);
|
||||
|
||||
const availableLabel = element('label', 'data-library-check');
|
||||
const available = element('input');
|
||||
available.type = 'checkbox';
|
||||
listen(available, 'change', () => {
|
||||
filter.availableOnly = available.checked;
|
||||
render();
|
||||
});
|
||||
availableLabel.append(
|
||||
available,
|
||||
element('span', '', t('Only what this instance serves')),
|
||||
);
|
||||
filters.append(searchLabel, familyLabel, availableLabel);
|
||||
|
||||
const toolbar = element('div', 'data-library-toolbar');
|
||||
status = element('p', 'data-library-status');
|
||||
status.setAttribute('role', 'status');
|
||||
status.setAttribute('aria-live', 'polite');
|
||||
resetButton = element('button', 'panel-surface-control data-library-reset');
|
||||
resetButton.type = 'button';
|
||||
listen(resetButton, 'click', () => {
|
||||
if (resetting) return;
|
||||
if (!resetArmed) {
|
||||
resetArmed = true;
|
||||
resetTimer = setTimeout(() => {
|
||||
disarmReset();
|
||||
render();
|
||||
}, RESET_CONFIRM_MS);
|
||||
render();
|
||||
return;
|
||||
}
|
||||
disarmReset();
|
||||
resetting = true;
|
||||
render();
|
||||
Promise.resolve(library.reset())
|
||||
.catch((error) => console.warn('[Library] reset failed:', error))
|
||||
.finally(() => {
|
||||
resetting = false;
|
||||
render();
|
||||
dialog?.querySelector('input[type="search"]')?.focus();
|
||||
});
|
||||
});
|
||||
toolbar.append(status, resetButton);
|
||||
|
||||
list = element('ul', 'data-library-list');
|
||||
listen(list, 'click', (event) => {
|
||||
const button = event.target?.closest?.('button[data-library-action]');
|
||||
if (!button || button.disabled) return;
|
||||
const id = button.dataset.libraryId;
|
||||
const kind = button.dataset.libraryAction;
|
||||
if (kind === 'zoom') {
|
||||
// Close first so the flight is visible; focus returns to Browse.
|
||||
// An entry that is off is switched on first.
|
||||
api.close();
|
||||
Promise.resolve(library.zoom(id)).catch((error) =>
|
||||
console.warn(`[Library] ${id} zoom failed:`, error),
|
||||
);
|
||||
return;
|
||||
}
|
||||
const action = kind === 'add' ? library.add(id) : library.remove(id);
|
||||
Promise.resolve(action).catch((error) =>
|
||||
console.warn(`[Library] ${id} failed:`, error),
|
||||
);
|
||||
});
|
||||
|
||||
body.append(stats, intro, filters, toolbar, list);
|
||||
dialog.append(header, body);
|
||||
listen(dialog, 'cancel', (event) => {
|
||||
event.preventDefault();
|
||||
api.close();
|
||||
});
|
||||
// A click on the backdrop (the dialog box itself, outside its content)
|
||||
// dismisses, like Escape.
|
||||
listen(dialog, 'click', (event) => {
|
||||
if (event.target === dialog) api.close();
|
||||
});
|
||||
document.body.append(dialog);
|
||||
return search;
|
||||
}
|
||||
|
||||
function renderRow({ entry, available, reason, added, on, busy, canZoom }) {
|
||||
const item = element('li', 'data-library-item');
|
||||
item.dataset.libraryId = entry.id;
|
||||
item.classList.toggle('is-unavailable', !available);
|
||||
|
||||
const head = element('div', 'data-library-item-head');
|
||||
const icon = element('span', 'data-library-icon', entry.icon);
|
||||
icon.setAttribute('aria-hidden', 'true');
|
||||
const name = element('span', 'data-library-name', entry.title);
|
||||
const badges = element('span', 'data-library-badges');
|
||||
badges.append(badge(t(KIND_LABELS[entry.kind])));
|
||||
badges.append(
|
||||
badge(
|
||||
t(STATUS_LABELS[entry.status]),
|
||||
entry.status === 'verified'
|
||||
? 'good'
|
||||
: entry.status === 'stale'
|
||||
? 'warn'
|
||||
: '',
|
||||
),
|
||||
);
|
||||
if (entry.licence.operatorOptIn) badges.append(badge(t('OPT-IN'), 'warn'));
|
||||
else if (entry.kind !== 'pack' && entry.source.key)
|
||||
badges.append(badge(t('KEY'), 'warn'));
|
||||
else if (entry.kind !== 'pack') badges.append(badge(t('KEYLESS')));
|
||||
head.append(icon, name, badges);
|
||||
|
||||
const description = element('p', 'data-library-description');
|
||||
description.textContent = entry.description;
|
||||
|
||||
const meta = element('p', 'data-library-meta');
|
||||
const provider = element('span', '', entry.provider);
|
||||
provider.setAttribute('translate', 'no');
|
||||
const licence = element('a', '', entry.licence.name);
|
||||
licence.href = entry.licence.url;
|
||||
licence.target = '_blank';
|
||||
licence.rel = 'noopener noreferrer';
|
||||
meta.append(
|
||||
provider,
|
||||
document.createTextNode(' · '),
|
||||
element('span', '', coverageText(entry)),
|
||||
document.createTextNode(' · '),
|
||||
licence,
|
||||
);
|
||||
|
||||
item.append(head, description);
|
||||
const specs = imagerySpecs(entry);
|
||||
if (specs.length) {
|
||||
const list = element('dl', 'data-library-specs');
|
||||
for (const { label, value } of specs) {
|
||||
const row = element('div', 'data-library-spec');
|
||||
row.append(element('dt', '', label), element('dd', '', value));
|
||||
list.append(row);
|
||||
}
|
||||
item.append(list);
|
||||
}
|
||||
item.append(meta);
|
||||
const note = libraryReasonText({ entry, available, reason });
|
||||
if (note) item.append(element('p', 'data-library-reason', note));
|
||||
|
||||
if (entry.kind !== 'pack') {
|
||||
const actions = element('div', 'data-library-actions');
|
||||
if (added && canZoom) {
|
||||
const zoom = element(
|
||||
'button',
|
||||
'panel-surface-control data-library-action',
|
||||
t('ZOOM'),
|
||||
);
|
||||
zoom.type = 'button';
|
||||
zoom.dataset.libraryId = entry.id;
|
||||
zoom.dataset.libraryAction = 'zoom';
|
||||
zoom.disabled = busy;
|
||||
zoom.setAttribute(
|
||||
'aria-label',
|
||||
t('Zoom to {name}', { name: entry.title }),
|
||||
);
|
||||
actions.append(zoom);
|
||||
}
|
||||
const action = element(
|
||||
'button',
|
||||
'panel-surface-control data-library-action',
|
||||
);
|
||||
action.type = 'button';
|
||||
action.dataset.libraryId = entry.id;
|
||||
action.dataset.libraryAction = added ? 'remove' : 'add';
|
||||
action.textContent = busy
|
||||
? t('WORKING…')
|
||||
: added
|
||||
? t('REMOVE')
|
||||
: t('ADD');
|
||||
action.disabled = busy || (!added && !available);
|
||||
action.setAttribute(
|
||||
'aria-label',
|
||||
added
|
||||
? t('Remove {name} from Data Layers', { name: entry.title })
|
||||
: t('Add {name} to Data Layers', { name: entry.title }),
|
||||
);
|
||||
if (added && on) item.classList.add('is-on');
|
||||
actions.append(action);
|
||||
item.append(actions);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/** Rewrite the stat tiles in place; unchanged text is not touched. */
|
||||
function renderStats() {
|
||||
if (!dialog?.open || !stats) return;
|
||||
for (const tile of libraryStatTiles(library.summary())) {
|
||||
let node = stats.querySelector(`[data-stat="${tile.id}"]`);
|
||||
if (!node) {
|
||||
node = element('div', 'data-library-stat');
|
||||
node.dataset.stat = tile.id;
|
||||
node.append(
|
||||
element('dt', 'data-library-stat-label'),
|
||||
element('dd', 'data-library-stat-value'),
|
||||
element('dd', 'data-library-stat-detail'),
|
||||
);
|
||||
stats.append(node);
|
||||
}
|
||||
const [label, value, detail] = node.children;
|
||||
if (label.textContent !== tile.label) label.textContent = tile.label;
|
||||
if (value.textContent !== tile.value) value.textContent = tile.value;
|
||||
if (detail.textContent !== tile.detail) detail.textContent = tile.detail;
|
||||
detail.hidden = !tile.detail;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
if (!dialog?.open) return;
|
||||
renderStats();
|
||||
const rows = library.list();
|
||||
const shown = sortLibraryRows(
|
||||
rows.filter((row) => libraryRowMatches(row, filter)),
|
||||
);
|
||||
const focusedId = document.activeElement?.dataset?.libraryId;
|
||||
const focusedAction = document.activeElement?.dataset?.libraryAction;
|
||||
list.replaceChildren(...shown.map(renderRow));
|
||||
if (focusedId) {
|
||||
const row = `button[data-library-id="${CSS.escape(focusedId)}"]`;
|
||||
// The same control when it survived the render (Add becomes Remove).
|
||||
(
|
||||
list.querySelector(
|
||||
`${row}[data-library-action="${CSS.escape(focusedAction || '')}"]`,
|
||||
) ||
|
||||
list.querySelector(`${row}:not([data-library-action="zoom"])`) ||
|
||||
list.querySelector(row)
|
||||
)?.focus();
|
||||
}
|
||||
const added = rows.filter((row) => row.added).length;
|
||||
if (!added && !resetting) disarmReset();
|
||||
resetButton.hidden = added === 0 && !resetting;
|
||||
resetButton.disabled = resetting;
|
||||
resetButton.classList.toggle('is-armed', resetArmed);
|
||||
resetButton.textContent = resetting
|
||||
? t('WORKING…')
|
||||
: resetArmed
|
||||
? tn(added, 'CONFIRM · REMOVE {count}', 'CONFIRM · REMOVE ALL {count}')
|
||||
: t('REMOVE ALL');
|
||||
resetButton.setAttribute(
|
||||
'aria-label',
|
||||
resetArmed
|
||||
? t('Confirm: remove every added entry from Data Layers')
|
||||
: t('Remove every added entry from Data Layers'),
|
||||
);
|
||||
// The stat tiles carry the totals; this line answers the filter.
|
||||
status.textContent = !library.ready
|
||||
? t('Checking what this instance serves…')
|
||||
: t('Showing {shown} of {total}', {
|
||||
shown: shown.length,
|
||||
total: rows.length,
|
||||
});
|
||||
}
|
||||
|
||||
const api = {
|
||||
open() {
|
||||
const search = dialog ? null : build();
|
||||
if (dialog.open) return;
|
||||
render();
|
||||
dialog.showModal();
|
||||
render();
|
||||
// Feature counts arrive as datasets finish loading, outside the
|
||||
// library's own notifications; refresh the tiles while open.
|
||||
clearInterval(statsTimer);
|
||||
statsTimer = setInterval(renderStats, STATS_REFRESH_MS);
|
||||
(search || dialog.querySelector('input[type="search"]'))?.focus();
|
||||
},
|
||||
close() {
|
||||
disarmReset();
|
||||
clearInterval(statsTimer);
|
||||
statsTimer = null;
|
||||
if (!dialog?.open) return;
|
||||
dialog.close();
|
||||
trigger?.focus?.();
|
||||
},
|
||||
destroy() {
|
||||
api.close();
|
||||
unsubscribe();
|
||||
observer?.disconnect();
|
||||
for (const remove of removers.splice(0)) remove();
|
||||
dialog?.remove();
|
||||
dialog = null;
|
||||
},
|
||||
};
|
||||
|
||||
const unsubscribe = library.subscribe(render);
|
||||
if (trigger) listen(trigger, 'click', () => api.open());
|
||||
const observer =
|
||||
typeof MutationObserver === 'function'
|
||||
? new MutationObserver(() => {
|
||||
if (
|
||||
PANEL_HIDING_MODES.some((mode) =>
|
||||
document.body.classList.contains(mode),
|
||||
)
|
||||
)
|
||||
api.close();
|
||||
})
|
||||
: null;
|
||||
observer?.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
});
|
||||
return api;
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
libraryReasonText,
|
||||
libraryRowMatches,
|
||||
libraryStatTiles,
|
||||
sortLibraryRows,
|
||||
} from './libraryBrowser.js';
|
||||
import { libraryEntry } from '../library/catalog.js';
|
||||
import { localInfrastructureOverlayCopy } from '../data/localGeojsonCore.js';
|
||||
|
||||
const row = (id, extra = {}) => ({
|
||||
entry: libraryEntry(id),
|
||||
available: true,
|
||||
added: false,
|
||||
...extra,
|
||||
});
|
||||
const all = { query: '', family: '', availableOnly: false };
|
||||
|
||||
test('Browse filters by text, theme and what this instance serves', () => {
|
||||
assert.ok(
|
||||
libraryRowMatches(row('eia-power-plants'), { ...all, query: 'eia' }),
|
||||
);
|
||||
assert.ok(
|
||||
libraryRowMatches(row('eia-power-plants'), { ...all, query: 'us' }),
|
||||
);
|
||||
assert.equal(
|
||||
libraryRowMatches(row('eia-power-plants'), { ...all, query: 'volcano' }),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
libraryRowMatches(row('eia-power-plants'), { ...all, family: 'events' }),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
libraryRowMatches(row('cctv-nyc-dot', { available: false }), {
|
||||
...all,
|
||||
availableOnly: true,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('the guidance names the exact operator switch', () => {
|
||||
assert.match(
|
||||
libraryReasonText({ ...row('cctv-nyc-dot'), available: false }),
|
||||
/CCTV_NYC_ENABLED=1/,
|
||||
);
|
||||
assert.match(
|
||||
libraryReasonText({ ...row('cctv-nyc-dot'), available: true }),
|
||||
/part of the CCTV layer/,
|
||||
);
|
||||
assert.match(
|
||||
libraryReasonText({
|
||||
...row('gvp-holocene-volcanoes'),
|
||||
available: false,
|
||||
reason: 'server-unavailable',
|
||||
}),
|
||||
/static build/,
|
||||
);
|
||||
assert.equal(libraryReasonText(row('nasa-eonet-events')), '');
|
||||
});
|
||||
|
||||
test('library features show their manifest card lines on the map', () => {
|
||||
const copy = localInfrastructureOverlayCopy(
|
||||
{
|
||||
name: 'Grand Coulee',
|
||||
__gevDetails: ['PrimSource: hydroelectric', 'Total_MW: 6809', 'extra'],
|
||||
},
|
||||
'lib-eia-power-plants',
|
||||
);
|
||||
assert.deepEqual(copy, {
|
||||
title: 'Grand Coulee',
|
||||
details: ['PrimSource: hydroelectric', 'Total_MW: 6809'],
|
||||
});
|
||||
});
|
||||
|
||||
test('Browse lists what a viewer can add first and packs last', () => {
|
||||
const order = sortLibraryRows([
|
||||
row('cctv-nyc-dot', { available: false }),
|
||||
row('nasa-eonet-events'),
|
||||
row('gvp-holocene-volcanoes', { available: false }),
|
||||
row('eia-power-plants'),
|
||||
]).map(({ entry }) => entry.id);
|
||||
assert.deepEqual(order, [
|
||||
'nasa-eonet-events',
|
||||
'eia-power-plants',
|
||||
'gvp-holocene-volcanoes',
|
||||
'cctv-nyc-dot',
|
||||
]);
|
||||
});
|
||||
|
||||
test('the stat tiles summarise the library in words and compact numbers', () => {
|
||||
const tiles = libraryStatTiles({
|
||||
entries: 8,
|
||||
kinds: { dataset: 3, tiles: 2, pack: 3 },
|
||||
themes: ['cameras', 'environment', 'events', 'imagery', 'infrastructure'],
|
||||
available: 5,
|
||||
unavailable: 3,
|
||||
added: 2,
|
||||
on: 1,
|
||||
features: 3712,
|
||||
featureLayers: 2,
|
||||
});
|
||||
assert.deepEqual(
|
||||
tiles.map(({ id, value, detail }) => [id, value, detail]),
|
||||
[
|
||||
['entries', '8', '3 datasets · 2 tile layers · 3 packs'],
|
||||
['themes', '5', ''],
|
||||
['added', '2', '1 on the map'],
|
||||
['features', '3.7K', 'from 2 datasets'],
|
||||
],
|
||||
);
|
||||
const empty = libraryStatTiles({
|
||||
entries: 1,
|
||||
kinds: { dataset: 1, tiles: 0, pack: 0 },
|
||||
themes: ['events'],
|
||||
available: 1,
|
||||
unavailable: 0,
|
||||
added: 0,
|
||||
on: 0,
|
||||
features: 0,
|
||||
featureLayers: 0,
|
||||
});
|
||||
assert.deepEqual(
|
||||
empty.map(({ value, detail }) => [value, detail]),
|
||||
[
|
||||
['1', '1 dataset · 0 tile layers · 0 packs'],
|
||||
['1', ''],
|
||||
['0', 'none yet'],
|
||||
['—', 'switch on a dataset to load features'],
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('an imagery card lists type, resolution, years flown and refresh', async () => {
|
||||
const { imagerySpecs } = await import('./libraryBrowser.js');
|
||||
const specs = imagerySpecs(libraryEntry('geneva-sitg-ortho'));
|
||||
assert.deepEqual(
|
||||
specs.map(({ label }) => label),
|
||||
['Type', 'Resolution', 'Flown', 'Updates'],
|
||||
);
|
||||
assert.equal(specs[0].value, 'True orthophoto');
|
||||
assert.equal(specs[1].value, '5 cm');
|
||||
assert.deepEqual(imagerySpecs(libraryEntry('eia-power-plants')), []);
|
||||
});
|
||||
@@ -2,13 +2,16 @@
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// Keyed chips shared by rail cards; the owner decides what a click does.
|
||||
// An `icon` chip shows a Material Symbol (named in index.html's `icon_names`
|
||||
// subset) with its label as the accessible name and tip; an `action` chip
|
||||
// (Zoom, Remove) is a plain button, not an on/off toggle.
|
||||
defineProps({
|
||||
chips: { type: Array, default: () => [] },
|
||||
onSelect: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
const chipClass = (chip) =>
|
||||
`data-toggle-chip chip-${chip.state || (chip.active ? 'active' : 'idle')}`;
|
||||
`data-toggle-chip chip-${chip.state || (chip.active ? 'active' : 'idle')}${chip.icon ? ' chip-icon' : ''}`;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -17,14 +20,20 @@ const chipClass = (chip) =>
|
||||
:key="chip.id"
|
||||
:data-chip-id="chip.id"
|
||||
:class="chipClass(chip)"
|
||||
:pressed="Boolean(chip.active)"
|
||||
:pressed="chip.action ? undefined : Boolean(chip.active)"
|
||||
pressed-class="active"
|
||||
:style="chip.color ? `--chip-color: ${chip.color}` : undefined"
|
||||
:data-chip-color="chip.color || undefined"
|
||||
:title="chip.title || undefined"
|
||||
:label="chip.icon ? chip.label : undefined"
|
||||
:title="chip.title || (chip.icon ? chip.label : undefined)"
|
||||
:disabled="Boolean(chip.disabled)"
|
||||
:aria-busy="String(Boolean(chip.busy))"
|
||||
@click="onSelect(chip)"
|
||||
>{{ chip.label }}</UiButton
|
||||
><span
|
||||
v-if="chip.icon"
|
||||
class="material-symbols-outlined"
|
||||
aria-hidden="true"
|
||||
>{{ chip.icon }}</span
|
||||
><template v-else>{{ chip.label }}</template></UiButton
|
||||
>
|
||||
</template>
|
||||
@@ -26,6 +26,10 @@ export function railFixture(onWrite = () => {}) {
|
||||
getAttribute(key) {
|
||||
return this.attributes.get(key) ?? null;
|
||||
},
|
||||
removeAttribute(key) {
|
||||
onWrite('attribute');
|
||||
this.attributes.delete(key);
|
||||
},
|
||||
appendChild(child) {
|
||||
return this.insertBefore(child, null);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
/* Data Library: the Browse button under DATA LAYERS and its dialog.
|
||||
The dialog is a dialog[data-panel-surface] (docs/panel-surfaces.md): the
|
||||
shared skin draws the surface; this file owns geometry and the list. */
|
||||
|
||||
.data-library-footer {
|
||||
padding: 8px 10px 4px;
|
||||
border-top: 1px solid var(--glass-border);
|
||||
}
|
||||
|
||||
.data-library-browse {
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
padding: 6px 10px;
|
||||
border: 1px dashed var(--glass-border-hover);
|
||||
border-radius: var(--btn-radius);
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
font: 600 10px/1.4 var(--font-mono);
|
||||
letter-spacing: 1.2px;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
color var(--transition-fast),
|
||||
border-color var(--transition-fast),
|
||||
background var(--transition-fast);
|
||||
}
|
||||
|
||||
.data-library-browse:hover,
|
||||
.data-library-browse:focus-visible {
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent);
|
||||
background: var(--accent-dim);
|
||||
}
|
||||
|
||||
.data-library-browse:focus-visible {
|
||||
outline: 2px solid var(--text-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.data-library-dialog {
|
||||
/* Frosted rather than opaque: a lighter surface than the rail panels
|
||||
(0.72) keeps the globe's colour visible, and the blur stops the HUD text
|
||||
behind the dialog from competing with the dialog's own. */
|
||||
--glass-bg: rgba(12, 12, 20, 0.55);
|
||||
width: min(560px, calc(100vw - 32px));
|
||||
max-height: min(720px, calc(100dvh - 48px));
|
||||
margin: auto;
|
||||
color: var(--text-primary);
|
||||
-webkit-backdrop-filter: blur(22px) saturate(1.3);
|
||||
backdrop-filter: blur(22px) saturate(1.3);
|
||||
/* The blur follows the surface's shape (Cyber's cut corners). The dialog
|
||||
has no outward popups for a clip to hide. */
|
||||
clip-path: var(--panel-surface-frame);
|
||||
}
|
||||
|
||||
.data-library-dialog::backdrop {
|
||||
background: rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.data-library-close {
|
||||
min-width: 30px;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* At a glance: four stat tiles above the intro. Text tokens only. */
|
||||
.data-library-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.data-library-stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 8px;
|
||||
background: rgba(8, 10, 16, 0.38);
|
||||
}
|
||||
|
||||
.data-library-stat-label {
|
||||
color: var(--text-secondary);
|
||||
font: 600 9px/1.3 var(--font-mono);
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.data-library-stat-value {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font: 600 20px/1.15 var(--font-sans);
|
||||
}
|
||||
|
||||
.data-library-stat-detail {
|
||||
margin: 0;
|
||||
color: rgba(232, 234, 237, 0.68);
|
||||
font-size: 10px;
|
||||
line-height: 1.35;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-stat {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-stat-value {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.data-library-intro {
|
||||
margin: 0 0 10px;
|
||||
color: rgba(232, 234, 237, 0.72);
|
||||
}
|
||||
|
||||
.data-library-filters {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.data-library-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.data-library-field .panel-surface-control {
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.data-library-check {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.data-library-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin: 4px 0 8px;
|
||||
}
|
||||
|
||||
.data-library-status {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font: 10px/1.4 var(--font-mono);
|
||||
}
|
||||
|
||||
.data-library-reset {
|
||||
min-height: 26px;
|
||||
padding: 3px 10px;
|
||||
font: 600 10px/1.4 var(--font-mono);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.data-library-reset.is-armed {
|
||||
border-color: var(--panel-surface-error);
|
||||
color: var(--panel-surface-error);
|
||||
}
|
||||
|
||||
.data-library-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.data-library-item {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
column-gap: 10px;
|
||||
row-gap: 4px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 10px;
|
||||
background: rgba(8, 10, 16, 0.38);
|
||||
}
|
||||
|
||||
.data-library-item.is-on {
|
||||
border-color: var(--accent-glow);
|
||||
}
|
||||
|
||||
.data-library-item.is-unavailable .data-library-name,
|
||||
.data-library-item.is-unavailable .data-library-description {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.data-library-item > :not(.data-library-actions) {
|
||||
grid-column: 1;
|
||||
}
|
||||
|
||||
.data-library-actions {
|
||||
grid-column: 2;
|
||||
grid-row: 1 / span 3;
|
||||
align-self: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.data-library-action {
|
||||
min-width: 82px;
|
||||
font: 600 10px/1.4 var(--font-mono);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.data-library-item-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.data-library-icon {
|
||||
width: 14px;
|
||||
color: var(--accent);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.data-library-name {
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.data-library-badges {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.data-library-badge {
|
||||
padding: 0 5px;
|
||||
border: 1px solid var(--glass-border-hover);
|
||||
border-radius: 4px;
|
||||
color: var(--text-secondary);
|
||||
font: 600 9px/1.6 var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.data-library-badge--good {
|
||||
border-color: var(--accent-glow);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.data-library-badge--warn {
|
||||
border-color: rgba(255, 194, 61, 0.45);
|
||||
color: #ffc23d;
|
||||
}
|
||||
|
||||
.data-library-description,
|
||||
.data-library-meta,
|
||||
.data-library-reason {
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.data-library-meta {
|
||||
color: rgba(232, 234, 237, 0.68);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.data-library-meta a {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
.data-library-meta a:hover,
|
||||
.data-library-meta a:focus-visible {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Imagery specs: label over value, wrapping into as many columns as fit. */
|
||||
.data-library-specs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.data-library-spec {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.data-library-spec dt {
|
||||
color: rgba(232, 234, 237, 0.56);
|
||||
font: 9px/1.4 var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.data-library-spec dd {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 11px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.data-library-reason {
|
||||
color: #ffc23d;
|
||||
font: 10px/1.5 var(--font-mono);
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-dialog {
|
||||
--glass-bg: rgba(18, 24, 27, 0.62);
|
||||
width: min(600px, calc(100vw - 32px));
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-item {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber']
|
||||
:is(.data-library-icon, .data-library-badge--good) {
|
||||
color: var(--cyber-red-bright);
|
||||
border-color: var(--cyber-red-bright);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.data-library-stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.data-library-filters {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.data-library-item {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.data-library-actions {
|
||||
grid-column: 1;
|
||||
grid-row: auto;
|
||||
flex-direction: row;
|
||||
justify-self: start;
|
||||
}
|
||||
}
|
||||
|
||||
body:is(.ui-clean-view, .recording-mode) .data-library-dialog {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Library rows list their legend one item per line, as Fire Perimeters'
|
||||
longer labels do, with the zoom and remove icons on their own line. */
|
||||
.data-toggle-row[data-library-entry] .data-toggle-legend-item {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
@@ -905,6 +905,30 @@ html:not([lang='en'])
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* An icon action chip (RailChips.vue `icon`): a square button sized to the
|
||||
text chips beside it. */
|
||||
.data-toggle-chip.chip-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 24px;
|
||||
height: 20px;
|
||||
padding: 0 4px;
|
||||
letter-spacing: 0;
|
||||
/* A glyph alone needs more contrast than a text chip to read. */
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.data-toggle-chip.chip-icon:hover,
|
||||
.data-toggle-chip.chip-icon:focus-visible {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.data-toggle-chip.chip-icon .material-symbols-outlined {
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.data-toggle-chip:hover,
|
||||
.data-toggle-chip:focus-visible {
|
||||
border-color: var(--glass-border-hover);
|
||||
|
||||
@@ -437,6 +437,7 @@ html:not([lang='en']) #scene-panel .scene-controls .scene-btn {
|
||||
|
||||
#control-panel.collapsed .button-grid,
|
||||
#data-panel.collapsed .data-toggle-list,
|
||||
#data-panel.collapsed .data-library-footer,
|
||||
#global-context-panel.collapsed #radio-panel,
|
||||
#global-context-panel.collapsed #military-awareness-panel,
|
||||
#global-context-panel.collapsed .global-context-actions,
|
||||
|
||||
@@ -43,6 +43,11 @@ async function importChosen(event) {
|
||||
<!-- Data Layer Toggle Panel -->
|
||||
<RailPanel id="data-panel" start-collapsed class="active" :title="t('DATA LAYERS')">
|
||||
<div id="data-toggles" class="data-toggle-list ui-scroll"></div>
|
||||
<!-- Data Library: src/ui/libraryBrowser.js owns the dialog; the button
|
||||
shows once the library controller is mounted (src/app/tools.js). -->
|
||||
<div class="data-library-footer">
|
||||
<button id="data-library-browse" type="button" class="data-library-browse" aria-haspopup="dialog" aria-controls="data-library" hidden>{{ t('BROWSE DATA LIBRARY') }}</button>
|
||||
</div>
|
||||
</RailPanel>
|
||||
|
||||
<!-- Utilities: Directions (LayerPanel renders its row here), Draw, Import -->
|
||||
|
||||
Reference in new issue
Block a user