mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge branch 'main' into sameh/photo-without-credit
This commit is contained in:
110 files changed
+18169
-237
No files matched your search
@@ -1,9 +1,29 @@
|
||||
/**
|
||||
* The Cockpit briefing's pages and the state it starts in. It needs only the
|
||||
* i18n module, so the controller and the view can both read it.
|
||||
* i18n module and the regional-news window, so the controller and the view
|
||||
* can both read it.
|
||||
*/
|
||||
import { REGIONAL_NEWS_WINDOW_HOURS } from '../data/regionalNewsWindow.js';
|
||||
import { msg, t } from '../i18n/index.js';
|
||||
|
||||
// i18n-ignore: provider name
|
||||
/** The news feed named before any briefing has answered. */
|
||||
export const DEFAULT_NEWS_SOURCE = 'GOOGLE NEWS RSS';
|
||||
|
||||
/**
|
||||
* The Regional News footer for a fresh, empty or unavailable list: the feed
|
||||
* and the window its articles are held to.
|
||||
* @param {string} [source]
|
||||
* @param {number} [hours]
|
||||
* @returns {string}
|
||||
*/
|
||||
export function newsWindowFooter(
|
||||
source = DEFAULT_NEWS_SOURCE,
|
||||
hours = REGIONAL_NEWS_WINDOW_HOURS,
|
||||
) {
|
||||
return t('{source} · LAST {hours} H', { source, hours });
|
||||
}
|
||||
|
||||
export const COCKPIT_BRIEF_PAGES = [
|
||||
{
|
||||
id: 'signals',
|
||||
@@ -15,8 +35,7 @@ export const COCKPIT_BRIEF_PAGES = [
|
||||
id: 'news',
|
||||
kickerKey: msg('REGIONAL NEWS'),
|
||||
subtitleKey: msg('LATEST LOCATION-MATCHED REPORTING'),
|
||||
sourceKey: msg('{source} · LOCATION QUERY · RECENT'),
|
||||
sourceName: 'GOOGLE NEWS RSS', // i18n-ignore: provider name
|
||||
// The news footer comes from the news state (`news.footer`), not here.
|
||||
},
|
||||
{
|
||||
id: 'local',
|
||||
@@ -60,6 +79,7 @@ export function createBriefState() {
|
||||
statusHidden: false,
|
||||
state: null,
|
||||
status: t('ACQUIRING REGIONAL NEWS'),
|
||||
footer: newsWindowFooter(),
|
||||
articles: [],
|
||||
},
|
||||
local: {
|
||||
|
||||
+112
-20
@@ -12,7 +12,14 @@ import {
|
||||
COCKPIT_BRIEF_PAGES,
|
||||
CYCLE_HELP_KEYS,
|
||||
createBriefState,
|
||||
newsWindowFooter,
|
||||
} from './cockpitBriefPages.js';
|
||||
import {
|
||||
recentRegionalArticles,
|
||||
regionalNewsWindowHours,
|
||||
} from '../data/regionalNewsWindow.js';
|
||||
|
||||
const NEWS_ROWS = 4;
|
||||
|
||||
// regionalModel.weatherCodeLabel is shared with node code and returns
|
||||
// English; translate it here.
|
||||
@@ -52,9 +59,13 @@ export function showBriefPage(index, { manual = false } = {}) {
|
||||
kicker: t(page.kickerKey),
|
||||
subtitle: t(page.subtitleKey),
|
||||
position: `${this.briefPageIndex + 1} / ${count}`,
|
||||
source: page.sourceKey
|
||||
? t(page.sourceKey, { source: page.sourceName })
|
||||
: page.source,
|
||||
// The news footer follows the news state, so it survives page changes.
|
||||
source:
|
||||
page.id === 'news'
|
||||
? this.brief.news.footer
|
||||
: page.sourceKey
|
||||
? t(page.sourceKey)
|
||||
: page.source,
|
||||
});
|
||||
this.publishBriefView();
|
||||
if (manual && this.briefAutoRotateEnabled)
|
||||
@@ -176,6 +187,13 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
)
|
||||
return;
|
||||
|
||||
// The brief held stands in after a failed refresh only near where its news
|
||||
// was read; past the refresh distance it is another place's.
|
||||
const previous =
|
||||
this.services.regionalDistanceM(this.regionalBriefPoint, point) <
|
||||
COCKPIT_REGIONAL_REFRESH_DISTANCE_M
|
||||
? this.regionalBrief
|
||||
: null;
|
||||
this.regionalBriefAnchor = point;
|
||||
this.regionalBriefFetchedAt = Date.now();
|
||||
const controller = new AbortController();
|
||||
@@ -193,8 +211,9 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
subjectId !== this.regionalBriefSubjectId
|
||||
)
|
||||
return;
|
||||
this.regionalBrief = payload;
|
||||
this.renderRegionalBrief(payload, info);
|
||||
this.regionalBrief = withCachedNews(payload, previous);
|
||||
if (this.regionalBrief === payload) this.regionalBriefPoint = point;
|
||||
this.renderRegionalBrief(this.regionalBrief, info);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (
|
||||
@@ -203,7 +222,14 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
requestToken === this.regionalBriefRequestToken &&
|
||||
subjectId === this.regionalBriefSubjectId
|
||||
) {
|
||||
this.renderRegionalBriefStatus('unavailable', info);
|
||||
if (previous) {
|
||||
this.regionalBrief = cachedNews(previous, previous);
|
||||
this.renderRegionalBrief(this.regionalBrief, info);
|
||||
} else {
|
||||
// Another place's brief: not to come back with a language change.
|
||||
this.regionalBrief = null;
|
||||
this.renderRegionalBriefStatus('unavailable', info);
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -212,6 +238,75 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A brief whose news comes from `previous` after a refresh that brought none:
|
||||
* the earlier articles stay, marked `cached` so they are labelled as such.
|
||||
* @param {object} payload The brief to keep everything else from.
|
||||
* @param {object} previous The last brief rendered for this subject.
|
||||
*/
|
||||
function cachedNews(payload, previous) {
|
||||
return {
|
||||
...payload,
|
||||
newsStatus: 'cached',
|
||||
newsSource: previous.newsSource,
|
||||
newsWindowHours: previous.newsWindowHours,
|
||||
newsFetchedAt: previous.newsFetchedAt ?? previous.retrievedAt ?? null,
|
||||
articles: previous.articles,
|
||||
};
|
||||
}
|
||||
|
||||
// A refresh whose news read failed keeps the articles from before it.
|
||||
function withCachedNews(payload, previous) {
|
||||
return previous && payload?.newsStatus === 'unavailable'
|
||||
? cachedNews(payload, previous)
|
||||
: payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Regional News state a brief presents. `ready` and `cached` have rows
|
||||
* inside the window; `cached` is a refresh that failed (a client-side failure,
|
||||
* or the local proxy's `stale` answer). `empty` is a source that answered with
|
||||
* nothing in the window; anything else is `unavailable`.
|
||||
* @returns {{state: string, status: string, footer: string, articles: object[]}}
|
||||
*/
|
||||
function regionalNewsView(payload) {
|
||||
const hours = regionalNewsWindowHours(payload?.newsWindowHours);
|
||||
// Old caches and the local path are held to the window here too.
|
||||
const articles = recentRegionalArticles(payload?.articles, {
|
||||
windowHours: hours,
|
||||
limit: NEWS_ROWS,
|
||||
});
|
||||
const source = String(
|
||||
payload?.newsSource || t('REGIONAL NEWS'),
|
||||
).toUpperCase();
|
||||
const refreshFailed =
|
||||
payload?.newsStatus === 'cached' || payload?.status === 'stale';
|
||||
if (articles.length && refreshFailed)
|
||||
return {
|
||||
state: 'cached',
|
||||
status: t('CACHED · REFRESH FAILED'),
|
||||
footer: t('{source} · CACHED {age}', {
|
||||
source,
|
||||
age: formatCockpitBriefAge(
|
||||
payload?.newsFetchedAt ?? payload?.retrievedAt,
|
||||
),
|
||||
}),
|
||||
articles,
|
||||
};
|
||||
const answered =
|
||||
!refreshFailed && ['ready', 'empty'].includes(payload?.newsStatus);
|
||||
return {
|
||||
state: articles.length ? 'ready' : answered ? 'empty' : 'unavailable',
|
||||
status: articles.length
|
||||
? ''
|
||||
: answered
|
||||
? t('NO NEWS IN THE LAST {hours} H', { hours })
|
||||
: t('REGIONAL NEWS UNAVAILABLE'),
|
||||
footer: newsWindowFooter(source, hours),
|
||||
articles,
|
||||
};
|
||||
}
|
||||
|
||||
export function renderRegionalBriefStatus(status, info) {
|
||||
const { news, local } = this.brief;
|
||||
news.statusHidden = false;
|
||||
@@ -220,7 +315,10 @@ export function renderRegionalBriefStatus(status, info) {
|
||||
status === 'loading'
|
||||
? t('ACQUIRING REGIONAL NEWS')
|
||||
: t('REGIONAL NEWS UNAVAILABLE');
|
||||
if (status === 'unavailable') news.articles = [];
|
||||
news.footer = newsWindowFooter();
|
||||
// Only called with no brief for this subject: any rows are another's.
|
||||
news.articles = [];
|
||||
if (this.briefPageIndex === 1) this.brief.source = news.footer;
|
||||
if (status === 'loading') local.place = t('RESOLVING REGION');
|
||||
if (status === 'unavailable') local.place = t('REGION UNAVAILABLE');
|
||||
local.coordinates = localCoordinates(info);
|
||||
@@ -228,7 +326,7 @@ export function renderRegionalBriefStatus(status, info) {
|
||||
}
|
||||
|
||||
export function renderRegionalBrief(payload, info) {
|
||||
const articles = Array.isArray(payload?.articles) ? payload.articles : [];
|
||||
const { state, status, footer, articles } = regionalNewsView(payload);
|
||||
const seen = new Map();
|
||||
const storyKey = (url) => {
|
||||
const count = seen.get(url) ?? 0;
|
||||
@@ -241,13 +339,11 @@ export function renderRegionalBrief(payload, info) {
|
||||
const placeLabel =
|
||||
payload?.place?.label || payload?.place?.country || t('REGION UNAVAILABLE');
|
||||
this.brief.news = {
|
||||
statusHidden: articles.length > 0,
|
||||
state: payload?.newsStatus || 'unavailable',
|
||||
status:
|
||||
payload?.newsStatus === 'empty'
|
||||
? t('NO RECENT LOCATION MATCHES')
|
||||
: t('REGIONAL NEWS UNAVAILABLE'),
|
||||
articles: articles.slice(0, 4).map((article) => ({
|
||||
statusHidden: state === 'ready',
|
||||
state,
|
||||
status,
|
||||
footer,
|
||||
articles: articles.map((article) => ({
|
||||
// A row keeps its node, and so its focus, only for the same story.
|
||||
key: storyKey(article.url),
|
||||
url: article.url,
|
||||
@@ -281,11 +377,7 @@ export function renderRegionalBrief(payload, info) {
|
||||
: '—',
|
||||
};
|
||||
this.brief.regionalStatus = payload?.status || 'partial';
|
||||
if (this.briefPageIndex === 1) {
|
||||
this.brief.source = t('{source} · LOCATION QUERY', {
|
||||
source: String(payload?.newsSource || t('REGIONAL NEWS')).toUpperCase(),
|
||||
});
|
||||
}
|
||||
if (this.briefPageIndex === 1) this.brief.source = footer;
|
||||
this.publishBriefView();
|
||||
this.scheduleContextLayout();
|
||||
}
|
||||
+360
-17
@@ -3,11 +3,14 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
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 {
|
||||
maybeRefreshRegionalBrief,
|
||||
publishBriefView,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
@@ -88,10 +91,7 @@ test('pages, the cycle toggle and the source follow the controller', async (t) =
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-kicker'), 'REGIONAL NEWS');
|
||||
assert.equal(text('#cockpit-brief-position'), '2 / 3');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · LOCATION QUERY · RECENT',
|
||||
);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
assert.deepEqual(visiblePages(), ['news']);
|
||||
assert.deepEqual(current(), ['false', 'true', 'false']);
|
||||
assert.equal($('#cockpit-signal-stream').dataset.briefPage, 'news');
|
||||
@@ -129,7 +129,8 @@ test('regional news and local conditions render what the region returned', async
|
||||
url: `https://example.com/${index}`,
|
||||
title: `Story ${index}`,
|
||||
domain: 'example.com',
|
||||
publishedAt: new Date().toISOString(),
|
||||
// Newest first is the shown order, so Story 0 is the newest.
|
||||
publishedAt: new Date(Date.now() - index * 60_000).toISOString(),
|
||||
})),
|
||||
weather: {
|
||||
temperatureC: 21.6,
|
||||
@@ -159,7 +160,7 @@ test('regional news and local conditions render what the region returned', async
|
||||
assert.equal(text('#cockpit-local-condition'), 'RAIN');
|
||||
assert.equal(text('#cockpit-local-cloud'), 'CLOUD 40%');
|
||||
assert.equal(text('#cockpit-local-precipitation'), '1.3');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LOCATION QUERY');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
assert.equal($('#cockpit-signal-stream').dataset.regionalStatus, 'ok');
|
||||
renderRegionalBriefStatus.call(owner, 'unavailable', {});
|
||||
await nextTick();
|
||||
@@ -210,26 +211,293 @@ test('a refreshed news list keeps a focused story on its own link', async (t) =>
|
||||
assert.equal($('#cockpit-news-list').textContent.includes('Story y'), true);
|
||||
});
|
||||
|
||||
test('the news source names the feed only while it is current on page 2', async (t) => {
|
||||
// This contract changed on purpose: the footer used to fall back to a
|
||||
// static "· RECENT" on every page change, which promised nothing. It now
|
||||
// follows the news state and names the window it holds articles to.
|
||||
test('the news footer follows the news state across page changes, not a static RECENT', async (t) => {
|
||||
const { text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
renderRegionalBrief.call(owner, { newsSource: 'wire', articles: [] }, INFO);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'wire',
|
||||
newsWindowHours: 24,
|
||||
articles: [story('a')],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LOCATION QUERY');
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 24 H');
|
||||
showBriefPage.call(owner, 0);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'wire',
|
||||
newsWindowHours: 12,
|
||||
articles: [story('a')],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
// Off page 2 the footer is the current page's.
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'SOURCE-BACKED EVENTS · NO SYNTHETIC NEWS',
|
||||
);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(text('#cockpit-brief-source'), 'WIRE · LAST 12 H');
|
||||
});
|
||||
|
||||
test('the news banner is hidden by the stylesheet, not only by the attribute', async (t) => {
|
||||
// happy-dom applies no author CSS by itself, so `hidden` alone proves
|
||||
// nothing: `.cockpit-brief-status { display: grid }` used to beat it.
|
||||
const css = readFileSync(
|
||||
fileURLToPath(new URL('./styles/cockpit.css', import.meta.url)),
|
||||
'utf8',
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/\.cockpit-brief-status\[hidden\]\s*\{\s*display:\s*none;?\s*\}/,
|
||||
);
|
||||
const { $, owner } = fixture(t);
|
||||
const style = document.head.appendChild(document.createElement('style'));
|
||||
t.after(() => style.remove());
|
||||
style.textContent = css;
|
||||
showBriefPage.call(owner, 1);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ newsStatus: 'ready', articles: [story('a')] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
const banner = $('#cockpit-news-status');
|
||||
assert.equal(banner.hidden, true);
|
||||
assert.equal(getComputedStyle(banner).display, 'none');
|
||||
renderRegionalBrief.call(owner, { newsStatus: 'empty', articles: [] }, INFO);
|
||||
await nextTick();
|
||||
assert.equal(getComputedStyle(banner).display, 'grid');
|
||||
});
|
||||
|
||||
const hoursAgo = (hours) =>
|
||||
new Date(Date.now() - hours * 3_600_000).toISOString();
|
||||
|
||||
test('ready, cached, empty and unavailable each label the news differently', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
const rows = () =>
|
||||
[...document.querySelectorAll('#cockpit-news-list strong')].map(
|
||||
(row) => row.textContent,
|
||||
);
|
||||
const banner = () => ({
|
||||
hidden: $('#cockpit-news-status').hidden,
|
||||
state: $('#cockpit-news-status').dataset.state,
|
||||
text: text('#cockpit-news-status'),
|
||||
});
|
||||
const ready = {
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: hoursAgo(0.5),
|
||||
articles: [story('a'), story('b')],
|
||||
};
|
||||
renderRegionalBrief.call(owner, ready, INFO);
|
||||
await nextTick();
|
||||
assert.equal(banner().hidden, true);
|
||||
assert.equal(banner().state, 'ready');
|
||||
assert.deepEqual(rows(), ['Story a', 'Story b']);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
|
||||
// The local proxy's stale answer is a refresh that failed.
|
||||
renderRegionalBrief.call(owner, { ...ready, status: 'stale' }, INFO);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'cached',
|
||||
text: 'CACHED · REFRESH FAILED',
|
||||
});
|
||||
assert.deepEqual(rows(), ['Story a', 'Story b']);
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · CACHED 30M AGO',
|
||||
);
|
||||
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
...ready,
|
||||
newsStatus: 'empty',
|
||||
newsSource: 'Google News RSS',
|
||||
articles: [],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'empty',
|
||||
text: 'NO NEWS IN THE LAST 24 H',
|
||||
});
|
||||
assert.deepEqual(rows(), []);
|
||||
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ ...ready, newsStatus: 'unavailable', newsSource: null, articles: [] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(banner(), {
|
||||
hidden: false,
|
||||
state: 'unavailable',
|
||||
text: 'REGIONAL NEWS UNAVAILABLE',
|
||||
});
|
||||
assert.deepEqual(rows(), []);
|
||||
});
|
||||
|
||||
test('articles outside the window are dropped even when a server sends them', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
showBriefPage.call(owner, 1);
|
||||
const dated = (id, publishedAt) => ({ ...story(id), publishedAt });
|
||||
// The reported case: 4, 104, 215 and 165 days old under "RECENT".
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{
|
||||
newsStatus: 'ready',
|
||||
articles: [
|
||||
dated('old', hoursAgo(4 * 24)),
|
||||
dated('older', hoursAgo(104 * 24)),
|
||||
dated('undated', null),
|
||||
dated('one', hoursAgo(20)),
|
||||
dated('two', hoursAgo(2)),
|
||||
],
|
||||
},
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.deepEqual(
|
||||
[...document.querySelectorAll('#cockpit-news-list strong')].map(
|
||||
(row) => row.textContent,
|
||||
),
|
||||
['Story two', 'Story one'],
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').hidden, true);
|
||||
renderRegionalBrief.call(
|
||||
owner,
|
||||
{ newsStatus: 'ready', articles: [dated('old', hoursAgo(25))] },
|
||||
INFO,
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(document.querySelectorAll('#cockpit-news-list li').length, 0);
|
||||
assert.equal(text('#cockpit-news-status'), 'NO NEWS IN THE LAST 24 H');
|
||||
});
|
||||
|
||||
test('a failed refresh keeps the earlier articles as cached, and clears only when there are none', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
const answers = [];
|
||||
Object.assign(owner, {
|
||||
active: true,
|
||||
regionalBriefSubjectId: null,
|
||||
regionalBriefAbort: null,
|
||||
regionalBriefRequestToken: 0,
|
||||
regionalBriefFetchedAt: 0,
|
||||
regionalBrief: null,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
});
|
||||
owner.services = {
|
||||
...owner.services,
|
||||
regionalDistanceM: () => 0,
|
||||
fetchRegionalBrief: () => answers.shift()(),
|
||||
};
|
||||
const refresh = async (answer, info = { ...INFO, icao24: 'abc123' }) => {
|
||||
answers.push(answer);
|
||||
owner.regionalBriefFetchedAt = 0;
|
||||
maybeRefreshRegionalBrief.call(owner, info);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
};
|
||||
const rows = () => document.querySelectorAll('#cockpit-news-list li').length;
|
||||
showBriefPage.call(owner, 1);
|
||||
|
||||
// No earlier brief: an error clears and says unavailable.
|
||||
await refresh(() => Promise.reject(new Error('503')));
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(text('#cockpit-news-status'), 'REGIONAL NEWS UNAVAILABLE');
|
||||
assert.equal(rows(), 0);
|
||||
|
||||
const fetchedAt = hoursAgo(1);
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: fetchedAt,
|
||||
articles: [story('a'), story('b')],
|
||||
}),
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').hidden, true);
|
||||
assert.equal(rows(), 2);
|
||||
|
||||
// A network failure keeps the rows and says so, with their age.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')));
|
||||
assert.equal($('#cockpit-news-status').hidden, false);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · CACHED 1H AGO',
|
||||
);
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, 1);
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'GOOGLE NEWS RSS · LOCATION QUERY · RECENT',
|
||||
'GOOGLE NEWS RSS · CACHED 1H AGO',
|
||||
);
|
||||
showBriefPage.call(owner, 0);
|
||||
renderRegionalBrief.call(owner, { newsSource: 'wire', articles: [] }, INFO);
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'SOURCE-BACKED EVENTS · NO SYNTHETIC NEWS',
|
||||
|
||||
// So does a brief whose news read failed while weather answered.
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'partial',
|
||||
newsStatus: 'unavailable',
|
||||
articles: [],
|
||||
}),
|
||||
);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
|
||||
// A successful refresh clears the cached label; a true empty clears rows.
|
||||
await refresh(() =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'empty',
|
||||
newsSource: 'Google News RSS',
|
||||
articles: [],
|
||||
}),
|
||||
);
|
||||
assert.equal(text('#cockpit-news-status'), 'NO NEWS IN THE LAST 24 H');
|
||||
assert.equal(rows(), 0);
|
||||
assert.equal(text('#cockpit-brief-source'), 'GOOGLE NEWS RSS · LAST 24 H');
|
||||
|
||||
// Another aircraft never inherits the last one's rows.
|
||||
await refresh(() =>
|
||||
Promise.resolve({ newsStatus: 'ready', articles: [story('c')] }),
|
||||
);
|
||||
assert.equal(rows(), 1);
|
||||
await refresh(() => Promise.reject(new Error('503')), {
|
||||
...INFO,
|
||||
icao24: 'def456',
|
||||
});
|
||||
assert.equal(text('#cockpit-news-status'), 'REGIONAL NEWS UNAVAILABLE');
|
||||
assert.equal(rows(), 0);
|
||||
});
|
||||
|
||||
test('an unchanged position publishes nothing new', (t) => {
|
||||
@@ -278,7 +546,10 @@ test('the card and its toggle render the collapse the controller presents', asyn
|
||||
await nextTick();
|
||||
assert.equal(card.dataset.collapsed, 'true');
|
||||
assert.equal(toggle.getAttribute('aria-expanded'), 'false');
|
||||
assert.equal(toggle.getAttribute('aria-label'), 'Expand cockpit briefing panel');
|
||||
assert.equal(
|
||||
toggle.getAttribute('aria-label'),
|
||||
'Expand cockpit briefing panel',
|
||||
);
|
||||
assert.equal(toggle.title, 'Expand briefing panel');
|
||||
assert.equal(toggle.textContent.trim(), 'right_panel_open');
|
||||
assert.equal(owner.signalUserCollapsed, true);
|
||||
@@ -287,3 +558,75 @@ test('the card and its toggle render the collapse the controller presents', asyn
|
||||
assert.equal(card.dataset.collapsed, 'false');
|
||||
assert.equal(toggle.textContent.trim(), 'right_panel_close');
|
||||
});
|
||||
|
||||
test("a refresh that fails after a move never shows the last location's brief as current", async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
const answers = [];
|
||||
Object.assign(owner, {
|
||||
active: true,
|
||||
regionalBriefSubjectId: null,
|
||||
regionalBriefAbort: null,
|
||||
regionalBriefRequestToken: 0,
|
||||
regionalBriefFetchedAt: 0,
|
||||
regionalBrief: null,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
});
|
||||
owner.services = {
|
||||
...owner.services,
|
||||
// One degree of latitude stands for a move past the refresh distance.
|
||||
regionalDistanceM: (from, to) =>
|
||||
from ? Math.abs(from.latitude - to.latitude) * 111_000 : Infinity,
|
||||
fetchRegionalBrief: () => answers.shift()(),
|
||||
};
|
||||
const refresh = async (answer, latitude) => {
|
||||
answers.push(answer);
|
||||
owner.regionalBriefFetchedAt = 0;
|
||||
maybeRefreshRegionalBrief.call(owner, {
|
||||
...INFO,
|
||||
icao24: 'abc123',
|
||||
latitude,
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
};
|
||||
const rows = () => document.querySelectorAll('#cockpit-news-list li').length;
|
||||
const here = () =>
|
||||
Promise.resolve({
|
||||
status: 'ready',
|
||||
newsStatus: 'ready',
|
||||
newsSource: 'Google News RSS',
|
||||
newsWindowHours: 24,
|
||||
newsFetchedAt: hoursAgo(1),
|
||||
articles: [story('a'), story('b')],
|
||||
});
|
||||
showBriefPage.call(owner, 1);
|
||||
|
||||
await refresh(here, 40);
|
||||
assert.equal(rows(), 2);
|
||||
// The same place: a failed refresh keeps the rows as cached.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')), 40);
|
||||
assert.equal(text('#cockpit-news-status'), 'CACHED · REFRESH FAILED');
|
||||
assert.equal(rows(), 2);
|
||||
// Elsewhere: the brief is unavailable, as it was before there was a cache.
|
||||
await refresh(() => Promise.reject(new TypeError('Failed to fetch')), 45);
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(rows(), 0);
|
||||
// Nor is it held, for a language change to show again.
|
||||
assert.equal(owner.regionalBrief, null);
|
||||
|
||||
// Nor does a brief there whose news read failed borrow the last place's rows.
|
||||
await refresh(here, 40);
|
||||
assert.equal(rows(), 2);
|
||||
await refresh(
|
||||
() =>
|
||||
Promise.resolve({
|
||||
status: 'partial',
|
||||
newsStatus: 'unavailable',
|
||||
articles: [],
|
||||
}),
|
||||
45,
|
||||
);
|
||||
assert.equal($('#cockpit-news-status').dataset.state, 'unavailable');
|
||||
assert.equal(rows(), 0);
|
||||
});
|
||||
@@ -147,6 +147,15 @@ export class LayerBindings {
|
||||
fires.attachShellServices({ imageryHost: this.services.imageryHost });
|
||||
this._weatherShellModules.push(fires);
|
||||
}
|
||||
// News flies to a chosen report or hotspot through the same release.
|
||||
const news = this._dataManager?.layers?.get('news')?.module;
|
||||
if (typeof news?.attachShellServices === 'function') {
|
||||
news.attachShellServices({
|
||||
runNavigation: (navigate) =>
|
||||
this.runImmediateNavigation('news', navigate),
|
||||
});
|
||||
this._weatherShellModules.push(news);
|
||||
}
|
||||
}
|
||||
|
||||
_persistAwarenessSelection(event, cleared = false) {
|
||||
|
||||
@@ -38,6 +38,8 @@ export const LAYER_NAME_KEYS = Object.freeze({
|
||||
'drone-airspace': msg('Prohibited & Restricted Airspace'),
|
||||
'wildlife-sightings': msg('Wildlife Sightings'),
|
||||
's2-ghostmaps': msg('S2 GhostMaps'),
|
||||
news: msg('News'),
|
||||
shipwrecks: msg('Shipwrecks'),
|
||||
wind: msg('Wind'),
|
||||
'weather-radar': msg('Rain radar'),
|
||||
'weather-satellite': msg('Satellite clouds'),
|
||||
|
||||
+42
-2
@@ -11,6 +11,7 @@ import {
|
||||
} from './layerNames.js';
|
||||
export { localizeLayerName } from './layerNames.js';
|
||||
import { createWeatherPanel } from './weatherPanel.js';
|
||||
import { createNewsPanel } from './newsPanel.js';
|
||||
import {
|
||||
translateFeedError,
|
||||
translateStatusLine,
|
||||
@@ -81,6 +82,8 @@ const PANEL_GROUPS = [
|
||||
'fire-perimeters',
|
||||
'gnss-integrity',
|
||||
's2-ghostmaps',
|
||||
'shipwrecks',
|
||||
'news',
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -317,6 +320,11 @@ export class LayerPanel {
|
||||
container?.ownerDocument?.getElementById?.('weather-panel-body'),
|
||||
setLayerParams: this.setLayerParams,
|
||||
});
|
||||
this._newsPanel?.destroy();
|
||||
this._newsPanel = createNewsPanel({
|
||||
container: container?.ownerDocument?.getElementById?.('news-panel-body'),
|
||||
setLayerParams: this.setLayerParams,
|
||||
});
|
||||
this._mountRecentImagery();
|
||||
this._renderToggles();
|
||||
}
|
||||
@@ -352,6 +360,8 @@ export class LayerPanel {
|
||||
this._releaseBindings();
|
||||
this._weatherPanel?.destroy();
|
||||
this._weatherPanel = null;
|
||||
this._newsPanel?.destroy();
|
||||
this._newsPanel = null;
|
||||
this._recentImageryPanel?.destroy();
|
||||
this._recentImageryPanel = null;
|
||||
this._recentImageryFactory = null;
|
||||
@@ -416,10 +426,12 @@ export class LayerPanel {
|
||||
onLocaleChange(() => {
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}),
|
||||
);
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}
|
||||
|
||||
/** Present every row from the layers' current state and render them. */
|
||||
@@ -451,6 +463,8 @@ export class LayerPanel {
|
||||
this._selectListItem(layerId, itemId, generation),
|
||||
onSlider: (layerId, sliderId, value) =>
|
||||
this._moveSlider(layerId, sliderId, value, generation),
|
||||
onRange: (layerId, rangeId, end, value) =>
|
||||
this._pickRangeEnd(layerId, rangeId, end, value, generation),
|
||||
}),
|
||||
id === null ? this._toggleContainer : this._groupContainers.get(id),
|
||||
);
|
||||
@@ -480,7 +494,7 @@ export class LayerPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* A layer's row chips, one-of-many switch, slider, color legend, info line
|
||||
* A layer's row chips, one-of-many switch, slider, start/end pickers, color legend, info line
|
||||
* and ordered list. The block
|
||||
* is hidden while the layer is off (or while a dependency owner has
|
||||
* surrendered it), so a quiet row stays quiet. Chips and list items are
|
||||
@@ -507,6 +521,7 @@ export class LayerPanel {
|
||||
const infoText = controls?.info ? String(controls.info) : '';
|
||||
const segmented = controls?.segmented || null;
|
||||
const slider = controls?.slider || null;
|
||||
const range = controls?.range || null;
|
||||
// The info line, once shown, stays in place and hides when empty.
|
||||
if (infoText) row.info = true;
|
||||
return {
|
||||
@@ -515,10 +530,12 @@ export class LayerPanel {
|
||||
legend.length === 0 &&
|
||||
!infoText &&
|
||||
!segmented &&
|
||||
!slider,
|
||||
!slider &&
|
||||
!range,
|
||||
chips,
|
||||
segmented,
|
||||
slider,
|
||||
range,
|
||||
legend,
|
||||
info: row.info
|
||||
? { text: infoText, title: controls?.infoTitle || '' }
|
||||
@@ -583,6 +600,20 @@ export class LayerPanel {
|
||||
this.setLayerParams(id, slider.params(value), { origin: 'user' });
|
||||
}
|
||||
|
||||
_pickRangeEnd(id, rangeId, end, value, generation = this._generation) {
|
||||
if (this._destroyed || this._generation !== generation) return;
|
||||
const range = this._rowControlsFor(id)?.range;
|
||||
if (
|
||||
!range ||
|
||||
range.id !== rangeId ||
|
||||
(end !== 'from' && end !== 'to') ||
|
||||
typeof range.params !== 'function' ||
|
||||
!this.isEnabled(id)
|
||||
)
|
||||
return;
|
||||
this.setLayerParams(id, range.params(end, value), { origin: 'user' });
|
||||
}
|
||||
|
||||
_selectListItem(id, itemId, generation = this._generation) {
|
||||
if (this._destroyed || this._generation !== generation) return;
|
||||
const item = this._rowControlsFor(id)?.list?.items?.find(
|
||||
@@ -648,6 +679,15 @@ export class LayerPanel {
|
||||
}
|
||||
this._paint();
|
||||
this._refreshWeatherPanel();
|
||||
this._refreshNewsPanel();
|
||||
}
|
||||
|
||||
/** Feed the News rail panel the view the news layer publishes while on. */
|
||||
_refreshNewsPanel() {
|
||||
const layer = this.getAll().find(({ id }) => id === 'news');
|
||||
this._newsPanel?.update(
|
||||
layer?.enabled ? this._rowControlsFor(layer.id)?.feed || null : null,
|
||||
);
|
||||
}
|
||||
|
||||
_buildMetaText(layer) {
|
||||
|
||||
@@ -50,7 +50,8 @@ test('Wildlife follows Events and precedes Weather', () => {
|
||||
);
|
||||
const wildlife = order.findIndex(({ id }) => id === 'wildlife-sightings');
|
||||
assert.equal(order[wildlife].label, 'Wildlife');
|
||||
assert.equal(order[wildlife - 1].id, 's2-ghostmaps');
|
||||
// News is the last of Events.
|
||||
assert.equal(order[wildlife - 1].id, 'news');
|
||||
assert.equal(order[wildlife + 1].id, 'air-quality');
|
||||
assert.equal(order.filter(({ id }) => id === 'wildlife-sightings').length, 1);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import RailChips from '../rail/RailChips.vue';
|
||||
import RailRowList from '../rail/RailRowList.vue';
|
||||
import RowRange from './RowRange.vue';
|
||||
import RowSlider from './RowSlider.vue';
|
||||
import RowSwitch from './RowSwitch.vue';
|
||||
import RowText from './RowText.vue';
|
||||
@@ -15,6 +16,7 @@ defineProps({
|
||||
onChip: { type: Function, default: () => {} },
|
||||
onListItem: { type: Function, default: () => {} },
|
||||
onSlider: { type: Function, default: () => {} },
|
||||
onRange: { type: Function, default: () => {} },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -68,6 +70,13 @@ defineProps({
|
||||
:on-input="
|
||||
(value) => onSlider(item.id, item.controls.slider.id, value)
|
||||
"
|
||||
/><RowRange
|
||||
v-if="item.controls.range"
|
||||
:range="item.controls.range"
|
||||
:on-select="
|
||||
(end, value) =>
|
||||
onRange(item.id, item.controls.range.id, end, value)
|
||||
"
|
||||
/><span
|
||||
v-for="(entry, index) in item.controls.legend"
|
||||
:key="index"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup>
|
||||
// A row's start and end pickers on one line (e.g. the Shipwrecks period).
|
||||
// Both ends share one option list; `onSelect` reports which end moved
|
||||
// ('from' or 'to') and the chosen option value.
|
||||
defineProps({
|
||||
range: { type: Object, required: true },
|
||||
onSelect: { type: Function, default: () => {} },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="data-toggle-range" :data-range-id="range.id"
|
||||
><div class="data-toggle-slider-head"
|
||||
><span class="data-toggle-slider-label">{{ range.label }}</span
|
||||
><span class="data-toggle-slider-value gev-slider-value">{{
|
||||
range.valueText
|
||||
}}</span></div
|
||||
><div class="data-toggle-range-ends"
|
||||
><label
|
||||
v-for="end in ['from', 'to']"
|
||||
:key="end"
|
||||
class="data-toggle-range-end"
|
||||
><span class="data-toggle-range-caption">{{ range[end].label }}</span
|
||||
><select
|
||||
class="data-toggle-range-select"
|
||||
:data-range-end="end"
|
||||
:aria-label="range[end].ariaLabel || undefined"
|
||||
:value="String(range[end].value)"
|
||||
@change="onSelect(end, $event.target.value)"
|
||||
><option
|
||||
v-for="option in range.options"
|
||||
:key="option.value"
|
||||
:value="String(option.value)"
|
||||
>{{ option.label }}</option
|
||||
></select
|
||||
></label
|
||||
></div
|
||||
></div
|
||||
>
|
||||
</template>
|
||||
@@ -159,3 +159,62 @@ test('a row switch and slider render their markup and report choices', () => {
|
||||
assert.equal(segments[1].classList.contains('active'), true);
|
||||
render(null, container);
|
||||
});
|
||||
|
||||
test('a row range renders start and end pickers and reports which end moved', () => {
|
||||
document.body.replaceChildren();
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
const picks = [];
|
||||
const item = {
|
||||
...row(false),
|
||||
key: 'shipwrecks',
|
||||
id: 'shipwrecks',
|
||||
controls: {
|
||||
hidden: false,
|
||||
chips: [],
|
||||
segmented: null,
|
||||
slider: null,
|
||||
range: {
|
||||
id: 'period',
|
||||
label: 'Period',
|
||||
valueText: '2010–2024',
|
||||
from: { label: 'From', ariaLabel: 'First year', value: 2010 },
|
||||
to: { label: 'To', ariaLabel: 'Last year', value: 2024 },
|
||||
options: [2024, 2010, 2007].map((year) => ({
|
||||
value: year,
|
||||
label: String(year),
|
||||
})),
|
||||
},
|
||||
legend: [],
|
||||
info: null,
|
||||
list: null,
|
||||
},
|
||||
};
|
||||
render(
|
||||
h(LayerRows, {
|
||||
items: [item],
|
||||
onRange: (id, rangeId, end, value) =>
|
||||
picks.push([id, rangeId, end, value]),
|
||||
}),
|
||||
container,
|
||||
);
|
||||
const block = container.querySelector('.data-toggle-range');
|
||||
assert.equal(block.dataset.rangeId, 'period');
|
||||
assert.equal(
|
||||
block.querySelector('.data-toggle-slider-value').textContent,
|
||||
'2010–2024',
|
||||
);
|
||||
const [from, to] = block.querySelectorAll('select.data-toggle-range-select');
|
||||
assert.equal(from.getAttribute('aria-label'), 'First year');
|
||||
assert.equal(from.value, '2010');
|
||||
assert.equal(to.value, '2024');
|
||||
assert.deepEqual(
|
||||
[...block.querySelectorAll('.data-toggle-range-caption')].map(
|
||||
(caption) => caption.textContent,
|
||||
),
|
||||
['From', 'To'],
|
||||
);
|
||||
to.value = '2007';
|
||||
to.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
assert.deepEqual(picks, [['shipwrecks', 'period', 'to', '2007']]);
|
||||
render(null, container);
|
||||
});
|
||||
@@ -977,3 +977,20 @@ test('a slow downward pull is claimed before Android native scroll takes ownersh
|
||||
assert.equal(shell.getSheet(), null);
|
||||
shell.destroy();
|
||||
});
|
||||
|
||||
test('on phones the News panel shows in the Context sheet only, like Weather', () => {
|
||||
const css = readFileSync(
|
||||
new URL('./styles/mobile-shell.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
// Hidden by id: the rail's own `#news-panel:not(.collapsed)` rule outranks
|
||||
// the generic `#right-context-rail > *` hiding rule.
|
||||
assert.match(
|
||||
css,
|
||||
/body\.mobile-shell #right-context-rail > #news-panel,\n[^{}]*\{\s*display: none;/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/body\.mobile-shell\[data-mobile-sheet='context'\]\s+#right-context-rail\s+> #news-panel:not\(\[hidden\]\),/,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,159 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// One event in the News panel: the publisher's
|
||||
// picture when the event has one, the headline, a mono meta line (severity
|
||||
// marker, category, place, sources, age), who reported it, its attestation
|
||||
// and media chips, and the service it came through ("via …"), which some ask
|
||||
// to be credited wherever their reports show. A click chooses it (the layer
|
||||
// flies there and opens its card on the globe); open, it plays the post's
|
||||
// clip when it has one (on request, with sound and controls), and shows the
|
||||
// summary, the other sides' reports and the link to the original article.
|
||||
// The layer computes every value shown (feedCardView in
|
||||
// src/layers/news/model.js).
|
||||
const props = defineProps({
|
||||
item: { type: Object, required: true },
|
||||
open: { type: Boolean, default: false },
|
||||
onChoose: { type: Function, default: () => {} },
|
||||
onClear: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
// A picture the publisher no longer serves leaves the card without one.
|
||||
const pictureFailed = ref(false);
|
||||
const dropPicture = () => {
|
||||
pictureFailed.value = true;
|
||||
};
|
||||
// So does a clip whose signed link has expired.
|
||||
const clipFailed = ref(false);
|
||||
const dropClip = () => {
|
||||
clipFailed.value = true;
|
||||
};
|
||||
watch(
|
||||
() => props.item.picture?.url,
|
||||
() => {
|
||||
pictureFailed.value = false;
|
||||
clipFailed.value = false;
|
||||
},
|
||||
);
|
||||
const meta = () =>
|
||||
[
|
||||
props.item.category,
|
||||
props.item.place &&
|
||||
(props.item.placedByModel
|
||||
? t('{place} (placed by model)', { place: props.item.place })
|
||||
: props.item.place),
|
||||
props.item.sources,
|
||||
props.item.age,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
class="news-card"
|
||||
:class="{ 'is-open': open, 'is-unmapped': !item.mappable }"
|
||||
:data-report-id="item.id"
|
||||
:style="{ '--news-color': item.color }"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="news-card__main ui-focus"
|
||||
:aria-expanded="open ? 'true' : 'false'"
|
||||
@click="onChoose(item)"
|
||||
>
|
||||
<span v-if="item.picture && !pictureFailed" class="news-card__thumb"
|
||||
><img
|
||||
:src="item.picture.url"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropPicture }"
|
||||
/><span
|
||||
v-if="item.picture.video && !clipFailed"
|
||||
class="news-card__play"
|
||||
role="img"
|
||||
:aria-label="t('Video')"
|
||||
>▶</span
|
||||
><span v-if="item.picture.credit" class="news-card__credit">{{
|
||||
item.picture.credit
|
||||
}}</span></span
|
||||
>
|
||||
<span class="news-card__title">{{ item.title }}</span>
|
||||
<span v-if="item.original" class="news-card__note">{{
|
||||
t('English headline by the model')
|
||||
}}</span>
|
||||
<span class="news-card__meta ui-mono"
|
||||
><span
|
||||
class="news-card__marker"
|
||||
:class="{ solid: item.solid }"
|
||||
role="img"
|
||||
:aria-label="item.severityLabel"
|
||||
:title="item.severityLabel"
|
||||
><svg viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path :d="item.icon" /></svg></span
|
||||
><span v-if="item.severity >= 2" class="news-card__severity">{{
|
||||
item.severityLabel
|
||||
}}</span
|
||||
>{{ item.severity >= 2 ? ` · ${meta()}` : meta() }}</span
|
||||
>
|
||||
<span v-if="item.sides" class="news-card__sides">{{ item.sides }}</span>
|
||||
<span v-if="item.chips.length" class="news-card__chips"
|
||||
><span
|
||||
v-for="chip in item.chips"
|
||||
:key="`${chip.kind}:${chip.label}`"
|
||||
class="news-chip"
|
||||
:class="`news-chip--${chip.kind}`"
|
||||
>{{ chip.label }}</span
|
||||
></span
|
||||
>
|
||||
<span v-if="item.via" class="news-card__via ui-mono">{{ item.via }}</span>
|
||||
</button>
|
||||
<div v-if="open" class="news-card__open">
|
||||
<video
|
||||
v-if="item.picture?.video && !clipFailed"
|
||||
class="news-card__clip"
|
||||
:src="item.picture.video"
|
||||
:poster="pictureFailed ? undefined : item.picture.url"
|
||||
controls
|
||||
playsinline
|
||||
preload="none"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropClip }"
|
||||
></video>
|
||||
<p v-if="item.original" class="news-card__original">{{
|
||||
item.original
|
||||
}}</p>
|
||||
<p v-if="item.snippet" class="news-card__snippet">{{ item.snippet }}</p>
|
||||
<p v-if="!item.mappable" class="news-card__note">
|
||||
{{ t('Not placed on the map') }}
|
||||
</p>
|
||||
<ul v-if="item.others.length" class="news-card__others">
|
||||
<li v-for="other in item.others" :key="other.url">
|
||||
<span class="news-card__side ui-mono">{{ other.side }}</span
|
||||
><a :href="other.url" target="_blank" rel="noopener noreferrer"
|
||||
>{{ other.publisher }}: {{ other.title }}</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="news-card__actions">
|
||||
<a
|
||||
class="news-card__link"
|
||||
:href="item.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>{{ item.sourceLink }}</a
|
||||
>
|
||||
<UiButton
|
||||
class="data-toggle-chip news-card__clear"
|
||||
type="button"
|
||||
@click="onClear()"
|
||||
>{{ t('Close') }}</UiButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
@@ -0,0 +1,294 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiEmpty from '../kit/UiEmpty.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
import RailChips from '../rail/RailChips.vue';
|
||||
import NewsCard from './NewsCard.vue';
|
||||
|
||||
// The News panel: the window the server serves only (the last 24 hours, or
|
||||
// fewer where the host serves less), or a shorter one chosen at the
|
||||
// top (24/12/6/3/1 h), and two sections. Conflicts: hotspot chips, the
|
||||
// severity floor, the chosen event and a continuous feed, newest first.
|
||||
// Local: every report in the area at the view centre (its country, a large
|
||||
// country's state; within a radius at sea) while the camera is low, named at
|
||||
// the top, which the map then shows, outlined, instead of the hotspots' news.
|
||||
// A section read from a key the server lacks (or whose allowance for the day
|
||||
// is spent) says which key instead. It
|
||||
// renders the `feed` view the news layer publishes and acts only through
|
||||
// `onParams`.
|
||||
const props = defineProps({
|
||||
view: { type: Object, default: null },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
const filters = computed(() => props.view?.filters ?? {});
|
||||
const local = computed(() => filters.value.section === 'local');
|
||||
const sections = computed(() =>
|
||||
[
|
||||
{ id: 'conflicts', label: t('Conflicts') },
|
||||
{ id: 'local', label: t('Local') },
|
||||
].map((chip) => ({
|
||||
...chip,
|
||||
active: (filters.value.section ?? 'conflicts') === chip.id,
|
||||
})),
|
||||
);
|
||||
const chips = computed(() =>
|
||||
(props.view?.hotspots ?? []).map((chip) => ({
|
||||
id: chip.id,
|
||||
label: `${chip.label} ${chip.count}`,
|
||||
active: chip.active,
|
||||
title: chip.label,
|
||||
})),
|
||||
);
|
||||
const severityOptions = computed(() => {
|
||||
const levels = props.view?.severities ?? [];
|
||||
return [
|
||||
{ value: '0', label: t('Any severity') },
|
||||
...levels.slice(1, 3).map((level) => ({
|
||||
value: String(level.value),
|
||||
label: t('{severity} and above', { severity: level.label }),
|
||||
})),
|
||||
...levels.slice(3).map((level) => ({
|
||||
value: String(level.value),
|
||||
label: t('{severity} only', { severity: level.label }),
|
||||
})),
|
||||
];
|
||||
});
|
||||
const categoryOptions = computed(() => [
|
||||
{ value: 'all', label: t('All categories') },
|
||||
...(props.view?.categories ?? []),
|
||||
]);
|
||||
const windowOptions = computed(() =>
|
||||
(props.view?.windowChoices ?? []).map((hours) => ({
|
||||
value: String(hours),
|
||||
label: t('Last {hours} h', { hours }),
|
||||
})),
|
||||
);
|
||||
// The longest choice is the server's whole window, kept as no choice.
|
||||
const chooseWindow = (hours) =>
|
||||
setFilter('hours', hours === props.view?.windowChoices?.[0] ? null : hours);
|
||||
const selectedId = computed(() => props.view?.selected?.id ?? null);
|
||||
// The chosen event leads the panel unless the feed already shows it open.
|
||||
const selectedApart = computed(() => {
|
||||
const chosen = props.view?.selected;
|
||||
if (!chosen) return null;
|
||||
const listed = local.value
|
||||
? props.view.inView.items.some((item) => item.id === chosen.id)
|
||||
: props.view.items.some((item) => item.id === chosen.id);
|
||||
return listed ? null : chosen;
|
||||
});
|
||||
// What Local reads: the area named, else the radius; neither while the
|
||||
// first area is being named, so the radius does not flash before it.
|
||||
const areaHead = computed(() => {
|
||||
const inView = props.view?.inView;
|
||||
if (!inView?.active) return '';
|
||||
if (inView.area) return t('News from {area}', { area: inView.area });
|
||||
if (inView.areaLoading) return '';
|
||||
return t('Within {km} km of the view centre', { km: inView.radiusKm });
|
||||
});
|
||||
const status = computed(() => {
|
||||
const view = props.view;
|
||||
if (!view) return '';
|
||||
if (view.error) return view.error;
|
||||
if (view.loading && !view.items.length) return t('Reading the news…');
|
||||
return '';
|
||||
});
|
||||
|
||||
const setFilter = (name, value) =>
|
||||
props.onParams({ filters: { [name]: value } });
|
||||
function choose(item) {
|
||||
if (item.id === selectedId.value) props.onParams({ clear: true });
|
||||
else props.onParams({ reportId: item.id, focus: true });
|
||||
}
|
||||
const clear = () => props.onParams({ clear: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
v-if="view"
|
||||
class="news-readout"
|
||||
:aria-label="t('News, last {hours} hours', { hours: view.windowHours })"
|
||||
>
|
||||
<UiSelect
|
||||
v-if="windowOptions.length > 1"
|
||||
class="gev-field news-filter news-readout__window-choice"
|
||||
:aria-label="t('Time window')"
|
||||
:model-value="String(view.windowHours)"
|
||||
:options="windowOptions"
|
||||
@update:model-value="chooseWindow(Number($event))"
|
||||
/>
|
||||
<p v-else class="news-readout__window ui-mono">{{
|
||||
t('Last {hours} h', { hours: view.windowHours })
|
||||
}}</p>
|
||||
<div
|
||||
class="news-readout__sections"
|
||||
role="group"
|
||||
:aria-label="t('News sections')"
|
||||
>
|
||||
<RailChips
|
||||
:chips="sections"
|
||||
:on-select="(chip) => setFilter('section', chip.id)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="!local"
|
||||
class="news-readout__chips"
|
||||
role="group"
|
||||
:aria-label="t('Hotspots')"
|
||||
>
|
||||
<RailChips
|
||||
:chips="chips"
|
||||
:on-select="(chip) => setFilter('hotspot', chip.id)"
|
||||
/>
|
||||
</div>
|
||||
<div class="news-readout__filters">
|
||||
<UiSelect
|
||||
v-if="!local"
|
||||
class="gev-field news-filter"
|
||||
:aria-label="t('Severity')"
|
||||
:model-value="String(filters.minSeverity ?? 2)"
|
||||
:options="severityOptions"
|
||||
@update:model-value="setFilter('minSeverity', Number($event))"
|
||||
/>
|
||||
<UiSelect
|
||||
class="gev-field news-filter"
|
||||
:aria-label="t('Category')"
|
||||
:model-value="filters.category ?? 'all'"
|
||||
:options="categoryOptions"
|
||||
@update:model-value="setFilter('category', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<NewsCard
|
||||
v-if="selectedApart"
|
||||
class="news-readout__selected"
|
||||
:item="selectedApart"
|
||||
open
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
|
||||
<section
|
||||
v-if="local"
|
||||
class="news-readout__section"
|
||||
:aria-label="t('Local')"
|
||||
>
|
||||
<p v-if="areaHead" class="news-readout__head news-readout__area ui-mono">
|
||||
{{ areaHead }}
|
||||
</p>
|
||||
<UiEmpty
|
||||
v-if="!view.inView.active"
|
||||
class="news-readout__empty"
|
||||
:title="t('Zoom in to see local news')"
|
||||
/>
|
||||
<UiEmpty
|
||||
v-else-if="view.inView.key"
|
||||
class="news-readout__empty"
|
||||
:title="view.inView.key.title"
|
||||
:hint="view.inView.key.hint"
|
||||
/>
|
||||
<p v-else-if="view.inView.error" class="news-readout__status">
|
||||
{{ view.inView.error }}
|
||||
</p>
|
||||
<UiEmpty
|
||||
v-else-if="!view.inView.items.length && !view.inView.loading"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('Nothing reported near here in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
"
|
||||
/>
|
||||
<ol
|
||||
v-else
|
||||
class="news-readout__list"
|
||||
:class="{ 'is-stale': view.inView.loading }"
|
||||
:aria-busy="view.inView.loading ? 'true' : 'false'"
|
||||
>
|
||||
<li v-for="item in view.inView.items" :key="item.id">
|
||||
<NewsCard
|
||||
:item="item"
|
||||
:open="item.id === selectedId"
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-else
|
||||
class="news-readout__section"
|
||||
:aria-label="t('Latest news')"
|
||||
>
|
||||
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
|
||||
<UiEmpty
|
||||
v-if="view.key"
|
||||
class="news-readout__empty"
|
||||
:title="view.key.title"
|
||||
:hint="view.key.hint"
|
||||
/>
|
||||
<ol
|
||||
v-else-if="view.items.length"
|
||||
class="news-readout__list news-readout__feed"
|
||||
>
|
||||
<li v-for="item in view.items" :key="item.id">
|
||||
<NewsCard
|
||||
:item="item"
|
||||
:open="item.id === selectedId"
|
||||
:on-choose="choose"
|
||||
:on-clear="clear"
|
||||
/>
|
||||
</li>
|
||||
</ol>
|
||||
<UiEmpty
|
||||
v-else-if="!view.loading && !view.error"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('No news matches these filters in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
"
|
||||
/>
|
||||
<div class="news-readout__footer">
|
||||
<span class="news-readout__status" role="status">{{ status }}</span>
|
||||
<UiButton
|
||||
v-if="view.hasMore && !view.loading"
|
||||
class="data-toggle-chip"
|
||||
type="button"
|
||||
@click="onParams({ loadMore: true })"
|
||||
>{{ t('Load older news') }}</UiButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<details class="news-legend">
|
||||
<summary>{{ t('How to read the map') }}</summary>
|
||||
<p>{{ t('Colour: severity · icon: type of event') }}</p>
|
||||
<ul class="news-legend__severity">
|
||||
<li
|
||||
v-for="level in view.severities"
|
||||
:key="level.value"
|
||||
:style="{ '--news-color': level.color }"
|
||||
>
|
||||
{{ level.label }}
|
||||
</li>
|
||||
</ul>
|
||||
<p>{{
|
||||
t(
|
||||
'Solid rim: reported by both sides or independently. Dashed rim: a claim. Thin rim: one source, or one side’s own press.',
|
||||
)
|
||||
}}</p>
|
||||
<p>{{
|
||||
t(
|
||||
'Larger: more sources · fainter: older. Picture card: a major or fast-growing event with two or more sources.',
|
||||
)
|
||||
}}</p>
|
||||
<p>{{
|
||||
t('Side labels describe the source, not whether a report is true.')
|
||||
}}</p>
|
||||
</details>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,89 @@
|
||||
import { h, render as renderVue } from 'vue';
|
||||
import NewsFeed from './news/NewsFeed.vue';
|
||||
|
||||
const LAYER_ID = 'news';
|
||||
const LOAD_MORE_MARGIN_PX = 160;
|
||||
// Remounting must not reopen a panel the reader already collapsed.
|
||||
const appearedPanels = new WeakSet();
|
||||
const set = (node, key, value) => {
|
||||
if (node[key] !== value) node[key] = value;
|
||||
};
|
||||
|
||||
/**
|
||||
* The News rail panel (`#news-panel`): it renders the `feed` view the news
|
||||
* layer publishes through its row controls, shows itself only while the
|
||||
* layer is on, and acts only through setLayerParams. Near the bottom of its
|
||||
* scroller it asks for the next older page, once per page; other filters or a
|
||||
* failed read let it ask again.
|
||||
*/
|
||||
export function createNewsPanel({ container, setLayerParams = () => {} } = {}) {
|
||||
const document = container?.ownerDocument;
|
||||
if (!document?.createElement) return null;
|
||||
const panel = container.closest?.('#news-panel');
|
||||
const count = panel?.querySelector('#news-panel-count');
|
||||
const onParams = (params) =>
|
||||
setLayerParams(LAYER_ID, params, { origin: 'user' });
|
||||
let view = null;
|
||||
let destroyed = false;
|
||||
let requestedAt = -1;
|
||||
let shownFilters = '';
|
||||
|
||||
function render() {
|
||||
if (destroyed) return;
|
||||
renderVue(h(NewsFeed, { view, onParams }), container);
|
||||
const hidden = !view;
|
||||
if (panel) set(panel, 'hidden', hidden);
|
||||
// The count is the shown section's: Local's list, else the feed.
|
||||
const shown =
|
||||
view?.filters?.section === 'local' ? view.inView?.items : view?.items;
|
||||
if (count) set(count, 'textContent', String(shown?.length ?? 0));
|
||||
if (!hidden && panel && !appearedPanels.has(panel)) {
|
||||
appearedPanels.add(panel);
|
||||
// First appearance opens the panel unless a stored or shared collapse
|
||||
// choice exists (marked by the panel chrome when it restored the state).
|
||||
const preference = panel.dataset?.collapsedPreference;
|
||||
if (
|
||||
panel.classList?.contains('collapsed') &&
|
||||
(preference === undefined || preference === 'default')
|
||||
)
|
||||
panel.querySelector('[data-collapse-target="news-panel"]')?.click();
|
||||
}
|
||||
}
|
||||
|
||||
const onScroll = () => {
|
||||
if (!view?.hasMore || view.loading) return;
|
||||
const remaining =
|
||||
container.scrollHeight - container.scrollTop - container.clientHeight;
|
||||
if (remaining > LOAD_MORE_MARGIN_PX) return;
|
||||
if (requestedAt === view.items.length) return;
|
||||
requestedAt = view.items.length;
|
||||
onParams({ loadMore: true });
|
||||
};
|
||||
container.addEventListener?.('scroll', onScroll, { passive: true });
|
||||
|
||||
return {
|
||||
/** Show the layer's feed view, or hide the panel with null. */
|
||||
update(next) {
|
||||
const filters = JSON.stringify(next?.filters ?? null);
|
||||
// A new list (other filters or hotspot), or a read that failed, may stop
|
||||
// at the same length as the last request: let the next scroll ask.
|
||||
// A list started over is shorter than the one the last request saw.
|
||||
if (
|
||||
filters !== shownFilters ||
|
||||
(next?.error && !view?.error) ||
|
||||
(next?.items?.length ?? 0) < requestedAt
|
||||
)
|
||||
requestedAt = -1;
|
||||
shownFilters = filters;
|
||||
view = next || null;
|
||||
render();
|
||||
},
|
||||
destroy() {
|
||||
destroyed = true;
|
||||
container.removeEventListener?.('scroll', onScroll);
|
||||
renderVue(null, container);
|
||||
if (panel) set(panel, 'hidden', true);
|
||||
if (count) set(count, 'textContent', '0');
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createNewsPanel } from './newsPanel.js';
|
||||
import {
|
||||
NEWS_CATEGORIES,
|
||||
NEWS_SEVERITY,
|
||||
categoryLabel,
|
||||
feedCardView,
|
||||
normalizeFilters,
|
||||
} from '../layers/news/model.js';
|
||||
|
||||
const NOW = Date.parse('2026-10-28T10:00:00Z');
|
||||
const report = (id, extra = {}) => ({
|
||||
id,
|
||||
title: `Report ${id}`,
|
||||
url: `https://www.example.com/${id}`,
|
||||
publishedAt: '2026-10-28T09:00:00.000Z',
|
||||
publisher: 'Example',
|
||||
side: 'UA',
|
||||
category: 'strike',
|
||||
severity: 2,
|
||||
geo: { lat: 50, lon: 36, place: 'Kharkiv', mappable: true },
|
||||
pins: [{ lat: 50, lon: 36, place: 'Kharkiv', mappable: true }],
|
||||
event: null,
|
||||
media: [],
|
||||
...extra,
|
||||
});
|
||||
const big = report('big', {
|
||||
severity: 3,
|
||||
titleEn: 'Strike on Kharkiv',
|
||||
title: 'Удар по Харкову',
|
||||
media: ['video'],
|
||||
event: {
|
||||
size: 4,
|
||||
severity: 3,
|
||||
status: 'both-sides',
|
||||
lastAt: '2026-10-28T09:50:00.000Z',
|
||||
sides: [
|
||||
{
|
||||
side: 'UA',
|
||||
title: 'a',
|
||||
url: 'https://a.test/',
|
||||
publisher: 'A',
|
||||
publishedAt: '2026-10-28T09:00:00.000Z',
|
||||
},
|
||||
{
|
||||
side: 'RU',
|
||||
title: 'b',
|
||||
url: 'https://b.test/',
|
||||
publisher: 'B',
|
||||
publishedAt: '2026-10-28T09:40:00.000Z',
|
||||
},
|
||||
],
|
||||
image: { url: 'https://a.test/p.jpg', publisher: 'A' },
|
||||
},
|
||||
});
|
||||
|
||||
function view(extra = {}) {
|
||||
return {
|
||||
filters: normalizeFilters(),
|
||||
hotspots: [
|
||||
{ id: 'all', label: 'All', count: 7, active: true },
|
||||
{ id: 'ua-ru-war', label: 'Ukraine–Russia', count: 7, active: false },
|
||||
],
|
||||
categories: Object.keys(NEWS_CATEGORIES).map((id) => ({
|
||||
value: id,
|
||||
label: categoryLabel(id),
|
||||
})),
|
||||
severities: NEWS_SEVERITY.map((level, index) => ({
|
||||
value: index,
|
||||
label: level.label,
|
||||
color: level.color,
|
||||
})),
|
||||
items: [feedCardView(big, NOW), feedCardView(report('lone'), NOW)],
|
||||
inView: { active: false, loading: false, error: null, items: [] },
|
||||
selected: null,
|
||||
hasMore: true,
|
||||
windowHours: 24,
|
||||
loading: false,
|
||||
error: null,
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
||||
function fixture() {
|
||||
document.body.innerHTML = `
|
||||
<div id="news-panel" class="collapsed" hidden>
|
||||
<span id="news-panel-count">0</span>
|
||||
<button data-collapse-target="news-panel"></button>
|
||||
<div id="news-panel-body"></div>
|
||||
</div>`;
|
||||
const panel = document.getElementById('news-panel');
|
||||
let opened = 0;
|
||||
panel
|
||||
.querySelector('[data-collapse-target]')
|
||||
.addEventListener('click', () => {
|
||||
opened++;
|
||||
panel.classList.remove('collapsed');
|
||||
});
|
||||
const calls = [];
|
||||
const news = createNewsPanel({
|
||||
container: document.getElementById('news-panel-body'),
|
||||
setLayerParams: (id, params, options) => calls.push([id, params, options]),
|
||||
});
|
||||
return { news, panel, calls, opened: () => opened };
|
||||
}
|
||||
|
||||
test('the panel shows the last 24 h as event cards and opens once', () => {
|
||||
const { news, panel, opened } = fixture();
|
||||
news.update(null);
|
||||
assert.equal(panel.hidden, true);
|
||||
news.update(view());
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal(opened(), 1);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '2');
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__window').textContent,
|
||||
'Last 24 h',
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...panel.querySelectorAll('.news-readout__chips [data-chip-id]')].map(
|
||||
(chip) => chip.textContent,
|
||||
),
|
||||
['All 7', 'Ukraine–Russia 7'],
|
||||
);
|
||||
const [first, second] = panel.querySelectorAll(
|
||||
'.news-readout__feed .news-card',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__title').textContent,
|
||||
'Strike on Kharkiv',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__note').textContent,
|
||||
'English headline by the model',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__meta').textContent,
|
||||
'Major · Strike · Kharkiv · 4 sources · 10 min',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__marker').getAttribute('aria-label'),
|
||||
'Major',
|
||||
);
|
||||
assert.equal(
|
||||
first.querySelector('.news-card__sides').textContent,
|
||||
'Reported by UA sources · RU sources',
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...first.querySelectorAll('.news-chip')].map((c) => c.textContent),
|
||||
['Reported by both sides', 'Video'],
|
||||
);
|
||||
const img = first.querySelector('.news-card__thumb img');
|
||||
assert.equal(img.getAttribute('src'), 'https://a.test/p.jpg');
|
||||
assert.equal(img.getAttribute('referrerpolicy'), 'no-referrer');
|
||||
assert.equal(first.querySelector('.news-card__credit').textContent, 'A');
|
||||
// A lone report has no picture.
|
||||
assert.equal(second.querySelector('.news-card__thumb'), null);
|
||||
// A later update does not reopen a panel the reader collapsed.
|
||||
panel.classList.add('collapsed');
|
||||
news.update(view());
|
||||
assert.equal(opened(), 1);
|
||||
news.destroy();
|
||||
assert.equal(panel.hidden, true);
|
||||
});
|
||||
|
||||
test('a card click flies there; open, it links the source and closes', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view());
|
||||
panel.querySelector('.news-card__main').click();
|
||||
assert.deepEqual(calls.at(-1), [
|
||||
'news',
|
||||
{ reportId: 'big', focus: true },
|
||||
{ origin: 'user' },
|
||||
]);
|
||||
news.update(view({ selected: feedCardView(big, NOW) }));
|
||||
const open = panel.querySelector('.news-card.is-open');
|
||||
const link = open.querySelector('.news-card__link');
|
||||
assert.equal(link.textContent, 'Source: example.com ↗');
|
||||
assert.equal(link.getAttribute('href'), 'https://www.example.com/big');
|
||||
assert.equal(link.getAttribute('rel'), 'noopener noreferrer');
|
||||
assert.equal(
|
||||
open.querySelector('.news-card__original').textContent,
|
||||
'Удар по Харкову',
|
||||
);
|
||||
open.querySelector('.news-card__main').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { clear: true });
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('filters, the Local section and empty or failed reads', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view());
|
||||
assert.equal(panel.querySelector('[aria-label="Local"]'), null);
|
||||
assert.equal(panel.querySelector('.news-toggle'), null);
|
||||
const severity = panel.querySelector('select[aria-label="Severity"]');
|
||||
assert.equal(severity.value, '2');
|
||||
severity.value = '3';
|
||||
severity.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { minSeverity: 3 } });
|
||||
panel.querySelector('[data-chip-id="ua-ru-war"]').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hotspot: 'ua-ru-war' } });
|
||||
panel.querySelector('[data-chip-id="local"]').click();
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { section: 'local' } });
|
||||
|
||||
news.update(
|
||||
view({
|
||||
items: [],
|
||||
hasMore: false,
|
||||
}),
|
||||
);
|
||||
assert.match(
|
||||
panel.textContent,
|
||||
/No news matches these filters in the last 24 h/,
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-readout__footer button'), null);
|
||||
|
||||
// Local: no hotspot chips or severity floor, and its own empty states.
|
||||
const localView = (inView) =>
|
||||
view({
|
||||
filters: normalizeFilters({ section: 'local' }),
|
||||
inView: { loading: false, error: null, items: [], ...inView },
|
||||
});
|
||||
news.update(localView({ active: false }));
|
||||
const section = panel.querySelector('[aria-label="Local"]');
|
||||
assert.match(section.textContent, /Zoom in to see local news/);
|
||||
assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]'), null);
|
||||
assert.equal(panel.querySelector('select[aria-label="Severity"]'), null);
|
||||
assert.equal(panel.querySelector('[aria-label="Latest news"]'), null);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '0');
|
||||
news.update(
|
||||
localView({ active: true, items: [feedCardView(report('near'), NOW)] }),
|
||||
);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '1');
|
||||
news.update(localView({ active: true }));
|
||||
assert.match(
|
||||
panel.querySelector('[aria-label="Local"]').textContent,
|
||||
/Nothing reported near here in the last 24 h/,
|
||||
);
|
||||
news.update(view());
|
||||
|
||||
news.update(
|
||||
view({ items: [], error: 'News feed unavailable', hasMore: false }),
|
||||
);
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__status').textContent,
|
||||
'News feed unavailable',
|
||||
);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('each section says which key it lacks; Local names the area it reads', () => {
|
||||
const { news, panel } = fixture();
|
||||
const key = {
|
||||
title: 'Liveuamap key required',
|
||||
hint: 'Needs LIVEUAMAP_API_KEY — add it in Provider Settings',
|
||||
};
|
||||
news.update(view({ key, items: [], hasMore: false }));
|
||||
const latest = panel.querySelector('[aria-label="Latest news"]');
|
||||
assert.match(latest.textContent, /Liveuamap key required/);
|
||||
assert.match(latest.textContent, /Needs LIVEUAMAP_API_KEY/);
|
||||
assert.doesNotMatch(latest.textContent, /No news matches/);
|
||||
|
||||
const localView = (inView) =>
|
||||
view({
|
||||
filters: normalizeFilters({ section: 'local' }),
|
||||
inView: {
|
||||
active: true,
|
||||
loading: false,
|
||||
error: null,
|
||||
items: [],
|
||||
radiusKm: 500,
|
||||
...inView,
|
||||
},
|
||||
});
|
||||
const section = () => panel.querySelector('[aria-label="Local"]');
|
||||
const heading = () => section().querySelector('.news-readout__area');
|
||||
news.update(
|
||||
localView({
|
||||
key: {
|
||||
title: 'World News API limit reached for today',
|
||||
hint: 'News resumes tomorrow, or with a paid plan',
|
||||
},
|
||||
}),
|
||||
);
|
||||
assert.match(section().textContent, /World News API limit reached for today/);
|
||||
assert.match(section().textContent, /News resumes tomorrow/);
|
||||
assert.doesNotMatch(section().textContent, /Nothing reported near here/);
|
||||
|
||||
// The area named, else the radius at sea.
|
||||
news.update(localView({ area: 'Ukraine' }));
|
||||
assert.equal(heading().textContent.trim(), 'News from Ukraine');
|
||||
news.update(localView({ area: null }));
|
||||
assert.equal(
|
||||
heading().textContent.trim(),
|
||||
'Within 500 km of the view centre',
|
||||
);
|
||||
// While the first area is named, neither: the radius does not flash.
|
||||
news.update(localView({ area: null, areaLoading: true, loading: true }));
|
||||
assert.equal(heading(), null);
|
||||
// A new area on the way keeps the one shown.
|
||||
news.update(localView({ area: 'Ukraine', areaLoading: true, loading: true }));
|
||||
assert.equal(heading().textContent.trim(), 'News from Ukraine');
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('a card credits the service its report came through', () => {
|
||||
const { news, panel } = fixture();
|
||||
news.update(
|
||||
view({
|
||||
items: [
|
||||
feedCardView(report('gdelt', { attribution: 'GDELT Project' }), NOW),
|
||||
feedCardView(report('own'), NOW),
|
||||
],
|
||||
}),
|
||||
);
|
||||
const [credited, own] = panel.querySelectorAll('.news-card');
|
||||
assert.equal(
|
||||
credited.querySelector('.news-card__via').textContent,
|
||||
'via GDELT Project',
|
||||
);
|
||||
assert.equal(own.querySelector('.news-card__via'), null);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('scrolling to the end asks once per page, again after a filter change or a failed read', () => {
|
||||
const { news, calls } = fixture();
|
||||
const body = document.getElementById('news-panel-body');
|
||||
// A scroller at its bottom.
|
||||
Object.defineProperty(body, 'scrollHeight', {
|
||||
value: 1000,
|
||||
configurable: true,
|
||||
});
|
||||
Object.defineProperty(body, 'clientHeight', {
|
||||
value: 400,
|
||||
configurable: true,
|
||||
});
|
||||
body.scrollTop = 600;
|
||||
const loadMores = () => calls.filter(([, p]) => p.loadMore === true).length;
|
||||
const scroll = () => body.dispatchEvent(new Event('scroll'));
|
||||
news.update(view());
|
||||
scroll();
|
||||
scroll();
|
||||
assert.equal(loadMores(), 1);
|
||||
// The page came back with nothing new (as many items): no second request.
|
||||
news.update(view());
|
||||
scroll();
|
||||
assert.equal(loadMores(), 1);
|
||||
// Another hotspot, the same number of rows: the new list can be read on.
|
||||
const hotspot = normalizeFilters({ hotspot: 'ua-ru-war' }, [
|
||||
{ id: 'ua-ru-war' },
|
||||
]);
|
||||
news.update(view({ filters: hotspot }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 2);
|
||||
// The read fails: the next scroll tries again.
|
||||
news.update(view({ filters: hotspot, error: 'News feed unavailable' }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 3);
|
||||
// While loading, or with no older page, nothing is asked.
|
||||
news.update(view({ filters: hotspot, loading: true }));
|
||||
scroll();
|
||||
news.update(view({ filters: hotspot, hasMore: false }));
|
||||
scroll();
|
||||
assert.equal(loadMores(), 3);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('the window choice offers shorter windows; the longest is the server window', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view({ windowHours: 12, windowChoices: [12, 6, 3, 1] }));
|
||||
assert.equal(panel.querySelector('.news-readout__window'), null);
|
||||
const choice = panel.querySelector('select[aria-label="Time window"]');
|
||||
assert.deepEqual(
|
||||
[...choice.options].map((option) => option.textContent),
|
||||
['Last 12 h', 'Last 6 h', 'Last 3 h', 'Last 1 h'],
|
||||
);
|
||||
assert.equal(choice.value, '12');
|
||||
choice.value = '3';
|
||||
choice.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hours: 3 } });
|
||||
choice.value = '12';
|
||||
choice.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hours: null } });
|
||||
});
|
||||
|
||||
test('the panel names the window the server serves', () => {
|
||||
const { news, panel } = fixture();
|
||||
news.update(view({ windowHours: 12 }));
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__window').textContent,
|
||||
'Last 12 h',
|
||||
);
|
||||
});
|
||||
|
||||
test('a clip waits behind its picture and plays, on request, in the open card', () => {
|
||||
const { news, panel } = fixture();
|
||||
const clipped = report('clip', {
|
||||
event: {
|
||||
size: 1,
|
||||
sides: [],
|
||||
image: {
|
||||
url: 'https://cdn4.telesco.pe/file/v.jpg',
|
||||
publisher: 'Channel',
|
||||
video: 'https://cdn4.telesco.pe/file/v.mp4?token=x',
|
||||
},
|
||||
},
|
||||
});
|
||||
news.update(view({ items: [feedCardView(clipped, NOW)] }));
|
||||
const card = panel.querySelector('.news-card');
|
||||
assert.equal(card.querySelector('.news-card__play').textContent, '▶');
|
||||
assert.equal(card.querySelector('video'), null);
|
||||
news.update(
|
||||
view({
|
||||
items: [feedCardView(clipped, NOW)],
|
||||
selected: feedCardView(clipped, NOW),
|
||||
}),
|
||||
);
|
||||
const video = panel.querySelector('.news-card.is-open video');
|
||||
assert.equal(
|
||||
video.getAttribute('src'),
|
||||
'https://cdn4.telesco.pe/file/v.mp4?token=x',
|
||||
);
|
||||
assert.equal(
|
||||
video.getAttribute('poster'),
|
||||
'https://cdn4.telesco.pe/file/v.jpg',
|
||||
);
|
||||
assert.equal(video.getAttribute('preload'), 'none');
|
||||
assert.ok(video.hasAttribute('controls'));
|
||||
// An expired link leaves the card without the clip.
|
||||
video.dispatchEvent(new Event('error'));
|
||||
news.update(
|
||||
view({
|
||||
items: [feedCardView(clipped, NOW)],
|
||||
selected: feedCardView(clipped, NOW),
|
||||
}),
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-card.is-open video'), null);
|
||||
news.destroy();
|
||||
});
|
||||
@@ -17,6 +17,7 @@ const SHARE_PANEL_STATE_SPECS = Object.freeze([
|
||||
{ id: 'data-panel' },
|
||||
{ id: 'cctv-panel' },
|
||||
{ id: 'weather-panel' },
|
||||
{ id: 'news-panel' },
|
||||
{ id: 'recent-imagery-panel' },
|
||||
{ id: 'street-level-panel' },
|
||||
{ id: 'radio-panel' },
|
||||
@@ -41,6 +42,7 @@ const COCKPIT_ENTRY_COLLAPSE_PANEL_IDS = Object.freeze([
|
||||
'data-panel',
|
||||
'cctv-panel',
|
||||
'weather-panel',
|
||||
'news-panel',
|
||||
'recent-imagery-panel',
|
||||
'street-level-panel',
|
||||
'scene-panel',
|
||||
|
||||
@@ -97,6 +97,7 @@ export class PanelLayoutController {
|
||||
this._ppToggles = document.getElementById('pp-toggles');
|
||||
this._cctvPanel = document.getElementById('cctv-panel');
|
||||
this._weatherPanel = document.getElementById('weather-panel');
|
||||
this._newsPanel = document.getElementById('news-panel');
|
||||
this._recentImageryPanel = document.getElementById('recent-imagery-panel');
|
||||
this._streetLevelPanel = document.getElementById('street-level-panel');
|
||||
}
|
||||
@@ -193,6 +194,7 @@ export class PanelLayoutController {
|
||||
for (const panel of [
|
||||
this._cctvPanel,
|
||||
this._weatherPanel,
|
||||
this._newsPanel,
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
]) {
|
||||
@@ -208,6 +210,7 @@ export class PanelLayoutController {
|
||||
this._ppToggles,
|
||||
this._cctvPanel,
|
||||
this._weatherPanel,
|
||||
this._newsPanel,
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
globalContextPanel,
|
||||
|
||||
@@ -22,6 +22,7 @@ export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
'pp-toggles': { icon: 'tune', label: msg('DISPLAY') },
|
||||
'cctv-panel': { icon: 'videocam', label: msg('CCTV') },
|
||||
'weather-panel': { icon: 'partly_cloudy_day', label: msg('WEATHER') },
|
||||
'news-panel': { icon: 'public', label: msg('NEWS') },
|
||||
'recent-imagery-panel': {
|
||||
icon: 'satellite_alt',
|
||||
label: msg('RECENT IMAGERY'),
|
||||
|
||||
@@ -1822,7 +1822,13 @@ html:not([lang='en']) #cockpit-brief-auto {
|
||||
letter-spacing: 0.13em;
|
||||
text-align: center;
|
||||
}
|
||||
.cockpit-brief-status[data-state='unavailable'] {
|
||||
/* `display: grid` above would otherwise beat the UA [hidden] rule and keep a
|
||||
stale banner over a populated list. */
|
||||
.cockpit-brief-status[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.cockpit-brief-status[data-state='unavailable'],
|
||||
.cockpit-brief-status[data-state='cached'] {
|
||||
color: #d5a863;
|
||||
}
|
||||
.cockpit-local-place {
|
||||
|
||||
@@ -156,9 +156,10 @@ body.mobile-shell[data-mobile-sheet='more'] #right-context-rail {
|
||||
|
||||
body.mobile-shell #left-panel-stack > *,
|
||||
body.mobile-shell #right-context-rail > *,
|
||||
/* Rail rules show expanded Weather and Recent Imagery by id; on phones they
|
||||
belong to the Context sheet only. */
|
||||
/* Rail rules show expanded Weather, News and Recent Imagery by id; on phones
|
||||
they belong to the Context sheet only. */
|
||||
body.mobile-shell #right-context-rail > #weather-panel,
|
||||
body.mobile-shell #right-context-rail > #news-panel,
|
||||
body.mobile-shell #right-context-rail > #recent-imagery-panel {
|
||||
display: none;
|
||||
}
|
||||
@@ -182,6 +183,9 @@ body.mobile-shell[data-mobile-sheet='context']
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #weather-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #news-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #recent-imagery-panel:not([hidden]),
|
||||
@@ -195,6 +199,12 @@ body.mobile-shell[data-mobile-sheet='more'] #right-context-rail > #pp-toggles {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* The sheet scrolls: News keeps its height instead of shrinking under the
|
||||
panel below it, as the rail makes it do on a desktop. */
|
||||
body.mobile-shell #right-context-rail > #news-panel:not(.collapsed) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Dock: voice floats above the tab bar; search and presets are sheets ─ */
|
||||
body.mobile-shell #command-dock {
|
||||
/* The dock's tray rules size voice by this basis; a column makes it a height. */
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
/* News rail panel (#news-panel): the last 24 hours as a doom-scroll of event
|
||||
cards drawn with GEV's own tokens. Colour is
|
||||
severity only (the layer sets --news-color per card); never a side. The
|
||||
rail owns placement and height; only the body scrolls. */
|
||||
.news-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--panel-radius);
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(24px) saturate(1.4);
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
box-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.5),
|
||||
0 0 0 1px rgba(255, 255, 255, 0.03) inset,
|
||||
0 1px 0 rgba(255, 255, 255, 0.06) inset;
|
||||
}
|
||||
#news-panel .panel-glow {
|
||||
position: absolute;
|
||||
inset: -18px;
|
||||
background: radial-gradient(
|
||||
ellipse at center,
|
||||
rgba(0, 212, 255, 0.16) 0%,
|
||||
transparent 65%
|
||||
);
|
||||
filter: blur(16px);
|
||||
opacity: 0.25;
|
||||
pointer-events: none;
|
||||
}
|
||||
#news-panel .panel-header {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#news-panel-count {
|
||||
color: var(--text-secondary);
|
||||
font: 9px var(--font-mono);
|
||||
}
|
||||
#news-panel-body {
|
||||
min-height: 0;
|
||||
max-height: calc(var(--right-stack-max-height, 50svh) - 64px);
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
#news-panel.collapsed #news-panel-body,
|
||||
#news-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
#right-context-rail > #news-panel {
|
||||
position: relative;
|
||||
inset: auto;
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
max-height: 100%;
|
||||
pointer-events: auto;
|
||||
}
|
||||
#right-context-rail > #news-panel:not(.collapsed) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
#right-context-rail.layout-focus > #news-panel:not(.collapsed) {
|
||||
flex: 0 1 var(--right-panel-allocated-height);
|
||||
height: var(--right-panel-allocated-height);
|
||||
min-height: 0;
|
||||
max-height: var(--right-panel-allocated-height);
|
||||
}
|
||||
#right-context-rail.layout-focus
|
||||
> #news-panel:not(.collapsed)
|
||||
.news-panel-inner {
|
||||
height: 100%;
|
||||
}
|
||||
#right-context-rail[data-rail-measuring]
|
||||
> #news-panel:not(.collapsed)
|
||||
> .news-panel-inner {
|
||||
height: auto !important;
|
||||
}
|
||||
#right-context-rail #news-panel.collapsed {
|
||||
width: var(--right-display-collapsed-width);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
#right-context-rail #news-panel.collapsed .news-panel-inner {
|
||||
height: 50px;
|
||||
min-height: 50px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
#right-context-rail #news-panel.collapsed {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
:root[data-ui-theme='cyber'] .news-panel-inner {
|
||||
border-radius: 0;
|
||||
clip-path: var(--cyber-panel-frame);
|
||||
box-shadow: var(--cyber-panel-shadow);
|
||||
}
|
||||
|
||||
.news-readout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
color: var(--text-primary);
|
||||
font: 11px/1.4 var(--font-sans);
|
||||
}
|
||||
.news-readout__window,
|
||||
.news-readout__head {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font: 600 9px var(--font-mono);
|
||||
letter-spacing: 0.12em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
/* What Local reads, in the primary colour so it reads before the list. */
|
||||
.news-readout__area {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.news-readout__sections,
|
||||
.news-readout__chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
/* One select per row: at the rail's width two side by side cut off
|
||||
"Significant and above" (and longer translations). */
|
||||
.news-readout__filters {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
}
|
||||
.news-filter {
|
||||
min-width: 0;
|
||||
}
|
||||
/* The window choice sits where the window label does, as narrow as its text. */
|
||||
.news-readout__window-choice {
|
||||
align-self: flex-start;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.news-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-toggle input {
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
.news-readout__section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.news-readout__list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.news-readout__list.is-stale {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.news-readout__status,
|
||||
.news-readout__empty {
|
||||
color: var(--text-dim);
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
/* A missing key's next step, under what it holds back. */
|
||||
.news-readout__empty .ui-empty__hint {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.news-readout__footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.news-card {
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.news-card:hover,
|
||||
.news-card.is-open {
|
||||
border-color: var(--glass-border-hover);
|
||||
background: rgba(0, 212, 255, 0.06);
|
||||
}
|
||||
.news-card.is-open {
|
||||
border-color: rgba(0, 212, 255, 0.45);
|
||||
}
|
||||
.news-card.is-unmapped .news-card__title {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__main {
|
||||
display: grid;
|
||||
grid-template-columns: 96px 1fr;
|
||||
column-gap: 8px;
|
||||
row-gap: 3px;
|
||||
width: 100%;
|
||||
padding: 6px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-card__main > :not(.news-card__thumb) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.news-card__thumb ~ * {
|
||||
grid-column: 2 !important;
|
||||
}
|
||||
.news-card__thumb {
|
||||
position: relative;
|
||||
grid-row: 1 / span 5;
|
||||
width: 96px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-dark);
|
||||
}
|
||||
.news-card__thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
/* A clip waits behind its picture; the open card plays it. */
|
||||
.news-card__play {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
|
||||
pointer-events: none;
|
||||
}
|
||||
.news-card__clip {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 220px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 4px;
|
||||
background: #000;
|
||||
}
|
||||
.news-card__credit {
|
||||
position: absolute;
|
||||
inset-inline-end: 0;
|
||||
bottom: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0 4px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
color: var(--text-primary);
|
||||
font-size: 8px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.news-card__title {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.news-card__note,
|
||||
.news-card__sides {
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-card__meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
color: var(--text-secondary);
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
/* The globe's marker in small: a dark disc, rim and icon in the severity
|
||||
colour (sprites.js). */
|
||||
.news-card__marker {
|
||||
flex: none;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
box-sizing: border-box;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 1.5px solid var(--news-color);
|
||||
border-radius: 50%;
|
||||
background: var(--bg-dark);
|
||||
}
|
||||
.news-card__marker svg {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
fill: none;
|
||||
stroke: var(--news-color);
|
||||
stroke-width: 1.8;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.news-card__marker.solid svg {
|
||||
fill: var(--news-color);
|
||||
stroke: none;
|
||||
}
|
||||
/* The service a report came through: credited, and kept quiet. */
|
||||
.news-card__via {
|
||||
color: var(--text-dim);
|
||||
font: 9px var(--font-mono);
|
||||
}
|
||||
.news-card__severity {
|
||||
flex: none;
|
||||
color: var(--news-color);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.news-card__chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
/* GEV's read-only badge (status-badge.css), neutral unless attested. */
|
||||
.news-chip {
|
||||
padding: 2px 7px;
|
||||
border: 1px solid var(--glass-border-hover);
|
||||
border-radius: 999px;
|
||||
color: var(--text-secondary);
|
||||
font: 8px var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.news-chip--official,
|
||||
.news-chip--confirmed {
|
||||
border-color: rgba(0, 212, 255, 0.32);
|
||||
background: rgba(0, 212, 255, 0.09);
|
||||
color: #9defff;
|
||||
}
|
||||
.news-chip--claimed {
|
||||
border-style: dashed;
|
||||
}
|
||||
.news-card__open {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 0 8px 8px;
|
||||
}
|
||||
.news-card__original,
|
||||
.news-card__snippet {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 11px;
|
||||
}
|
||||
.news-card__original {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__others {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-card__others a,
|
||||
.news-card__link {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.news-card__others a:hover,
|
||||
.news-card__link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.news-card__side {
|
||||
margin-inline-end: 6px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.news-card__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font: 10px var(--font-mono);
|
||||
}
|
||||
.news-legend {
|
||||
color: var(--text-secondary);
|
||||
font-size: 10px;
|
||||
}
|
||||
.news-legend summary {
|
||||
cursor: pointer;
|
||||
}
|
||||
.news-legend p {
|
||||
margin: 4px 0;
|
||||
}
|
||||
.news-legend__severity {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
margin: 4px 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.news-legend__severity li::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-inline-end: 4px;
|
||||
border-radius: 50%;
|
||||
background: var(--news-color);
|
||||
}
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.news-card,
|
||||
.news-readout__list {
|
||||
transition:
|
||||
background var(--transition-fast),
|
||||
border-color var(--transition-fast),
|
||||
opacity var(--transition-fast);
|
||||
}
|
||||
}
|
||||
@@ -1092,6 +1092,43 @@ html:not([lang='en']) .data-row-list-text {
|
||||
letter-spacing: 0.8px;
|
||||
}
|
||||
|
||||
/* Optional start and end pickers on one line (e.g. a layer's period). The
|
||||
shared field style paints each select. */
|
||||
.data-toggle-range {
|
||||
flex-basis: 100%;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.data-toggle-range-ends {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.data-toggle-range-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.data-toggle-range-caption {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 8px;
|
||||
letter-spacing: 1.2px;
|
||||
color: var(--text-dim);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.data-toggle-range-select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 24px;
|
||||
font: 10px/1 var(--font-mono);
|
||||
}
|
||||
|
||||
/* Optional per-layer quantitative slider (Active Fires minimum FRP). The
|
||||
track is painted by the layer (`--slider-track`, a stepped color ramp), so
|
||||
the slider doubles as the marker legend; ticks sit under their thresholds. */
|
||||
|
||||
@@ -36,6 +36,10 @@ const sceneRuntime = computed(() => scenePanel.value?.runtime ?? '');
|
||||
<template #badge><span id="weather-panel-count" :aria-label="t('Active weather products')">0</span></template>
|
||||
<div id="weather-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
</RailPanel>
|
||||
<RailPanel id="news-panel" hidden :title="t('NEWS')" sideways rail-scroller>
|
||||
<template #badge><span id="news-panel-count" :aria-label="t('News items in the feed')">0</span></template>
|
||||
<div id="news-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
</RailPanel>
|
||||
<RailPanel id="recent-imagery-panel" hidden :title="t('RECENT IMAGERY')" sideways rail-scroller>
|
||||
<template #badge><span id="recent-imagery-panel-count" :aria-label="t('Imagery days in the box')"></span></template>
|
||||
<div id="recent-imagery-panel-body" class="ui-scroll" data-rail-scroller></div>
|
||||
|
||||
Reference in new issue
Block a user