feat(receiver): 持久化接收机发现端点并支持位置备注信息
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 2.5 MiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256"/>
|
||||
|
After Width: | Height: | Size: 89 B |
@@ -0,0 +1,89 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const MAX_LINK_GAP_MS = 30000;
|
||||
const BASE_JUMP_M = 260;
|
||||
const MAX_SPEED_MPS = 120;
|
||||
const TO_RAD = Math.PI / 180;
|
||||
|
||||
function registrationColors(registered) {
|
||||
if (registered === true) return {fill:'#26ad72', glow:'rgba(38,210,133,.82)'};
|
||||
if (registered === false) return {fill:'#ec4361', glow:'rgba(255,64,96,.86)'};
|
||||
return {fill:'#637c91', glow:'rgba(128,158,180,.45)'};
|
||||
}
|
||||
|
||||
function createMarker({heading = 0, fill = 'rgba(255,211,90,.96)', glow = 'rgba(255,211,90,.86)', opacity = 1} = {}) {
|
||||
const badge = document.createElement('div');
|
||||
badge.className = 'rid-drone-marker';
|
||||
badge.setAttribute('aria-hidden', 'true');
|
||||
badge.style.setProperty('--rid-drone-fill', fill);
|
||||
badge.style.setProperty('--rid-drone-glow', glow);
|
||||
badge.style.opacity = opacity;
|
||||
const plane = document.createElement('span');
|
||||
plane.className = 'rid-drone-plane';
|
||||
plane.style.transform = 'rotate(' + heading + 'deg)';
|
||||
badge.append(plane);
|
||||
return badge;
|
||||
}
|
||||
|
||||
function validPosition(point) {
|
||||
return Number.isFinite(point?.longitude) && Math.abs(point.longitude) <= 180
|
||||
&& Number.isFinite(point?.latitude) && Math.abs(point.latitude) <= 90
|
||||
&& Number.isFinite(point?.timeMs);
|
||||
}
|
||||
|
||||
function jumping(from, to) {
|
||||
const dy = Math.sin((to.latitude - from.latitude) * TO_RAD / 2);
|
||||
const dx = Math.sin((to.longitude - from.longitude) * TO_RAD / 2);
|
||||
const latitude = Math.cos(from.latitude * TO_RAD) * Math.cos(to.latitude * TO_RAD);
|
||||
const metres = 12742000 * Math.asin(Math.sqrt(Math.min(1, dy * dy + latitude * dx * dx)));
|
||||
const seconds = Math.max(0.5, (to.timeMs - from.timeMs) / 1000);
|
||||
return metres > BASE_JUMP_M + MAX_SPEED_MPS * seconds;
|
||||
}
|
||||
|
||||
function shortInterval(from, to) {
|
||||
const elapsed = to.timeMs - from.timeMs;
|
||||
return elapsed >= 0 && elapsed < MAX_LINK_GAP_MS;
|
||||
}
|
||||
|
||||
function trackHeading(fromLat, fromLng, toLat, toLng) {
|
||||
const east = (((toLng - fromLng + 540) % 360) - 180) * Math.cos((fromLat + toLat) * TO_RAD / 2);
|
||||
const north = toLat - fromLat;
|
||||
return east || north ? (Math.atan2(east, north) / TO_RAD + 360) % 360 : null;
|
||||
}
|
||||
|
||||
function prepareTrack(samples) {
|
||||
const points = [];
|
||||
let pendingBreak = false;
|
||||
let skipped = 0;
|
||||
let newSegments = 0;
|
||||
for (let index = 0; index < samples.length; index += 1) {
|
||||
const point = samples[index];
|
||||
if (!validPosition(point)) {
|
||||
pendingBreak = true;
|
||||
skipped += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
const previous = points.at(-1);
|
||||
const next = samples[index + 1];
|
||||
const connectedBefore = previous && !point.segmentStart && !pendingBreak && shortInterval(previous, point);
|
||||
// Discard an isolated out-and-back spike only when the adjacent run is still continuous.
|
||||
if (connectedBefore && validPosition(next) && !next.segmentStart && shortInterval(previous, next)
|
||||
&& shortInterval(point, next) && jumping(previous, point) && jumping(point, next) && !jumping(previous, next)) {
|
||||
skipped += 1;
|
||||
continue;
|
||||
}
|
||||
if (previous && !point.segmentStart && (!connectedBefore || jumping(previous, point))) {
|
||||
points.push({...point, segmentStart: true});
|
||||
newSegments += 1;
|
||||
} else {
|
||||
points.push(point);
|
||||
}
|
||||
pendingBreak = false;
|
||||
}
|
||||
return {points, skipped, newSegments};
|
||||
}
|
||||
|
||||
window.ridDroneMap = Object.freeze({createMarker, prepareTrack, trackHeading, registrationColors, MAX_LINK_GAP_MS});
|
||||
})();
|
||||
@@ -0,0 +1,61 @@
|
||||
.rid-drone-marker {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid rgb(255 255 255 / 92%);
|
||||
border-radius: 50%;
|
||||
background: var(--rid-drone-fill);
|
||||
box-shadow: 0 0 18px var(--rid-drone-glow);
|
||||
}
|
||||
|
||||
.rid-drone-plane {
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
background: #fff;
|
||||
clip-path: polygon(50% 2%, 57% 9%, 58% 34%, 95% 59%, 95% 68%, 58% 57%,
|
||||
57% 79%, 72% 91%, 72% 98%, 50% 90%, 28% 98%, 28% 91%,
|
||||
43% 79%, 42% 57%, 5% 68%, 5% 59%, 42% 34%, 43% 9%);
|
||||
}
|
||||
|
||||
.rid-pilot-marker {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 2px solid #fff1c5;
|
||||
border-radius: 9px;
|
||||
background: #ffd35a;
|
||||
box-shadow: 0 2px 7px #081726bb;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.rid-pair-label {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 5px);
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
box-sizing: border-box;
|
||||
width: max-content;
|
||||
max-width: 240px;
|
||||
padding: 3px 7px;
|
||||
border: 1px solid #80b5d8;
|
||||
border-radius: 6px;
|
||||
background: #0b2034f2;
|
||||
color: #eff8ff;
|
||||
font: 600 12px/1.25 "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
box-shadow: 0 2px 5px #06101b9c;
|
||||
}
|
||||
|
||||
.rid-pilot-marker .rid-pair-label {
|
||||
top: calc(100% + 5px + var(--rid-pilot-label-offset));
|
||||
bottom: auto;
|
||||
border-color: #dcaf4b;
|
||||
}
|
||||
|
||||
.mapWrap[data-hide-models] .rid-pair-label { display: none; }
|
||||
@@ -0,0 +1,62 @@
|
||||
@import url('/workbench/pagination.css');
|
||||
|
||||
body.rid-embedded {
|
||||
--work-text: #e6f5ff;
|
||||
--work-muted: #b2cada;
|
||||
--work-line: #36536a;
|
||||
--work-panel: #102438;
|
||||
--work-input: #091a2c;
|
||||
--glass-surface: #102438;
|
||||
--glass-solid: #102438;
|
||||
--mc-accent: #69ccff;
|
||||
--mc-accent-blue: #1e88ff;
|
||||
background: #0b1d2e;
|
||||
}
|
||||
body.rid-embedded > .workspace-pane {
|
||||
inset: 0;
|
||||
background: transparent;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
body.rid-embedded .registry-workspace {
|
||||
height: 100dvh;
|
||||
}
|
||||
body.rid-embedded .rt-list-manager-head button[aria-label="返回工作区"] {
|
||||
display: none;
|
||||
}
|
||||
body.rid-embedded :is(.history-panel, .track-playback-controls, .rx-surface, .registry-group) {
|
||||
border-color: var(--work-line);
|
||||
}
|
||||
body.rid-embedded :is(button, input, select, textarea, summary):focus-visible {
|
||||
outline: 2px solid #7ddcff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
/* Archive lists fill the workspace; cards retain their responsive grid width. */
|
||||
body.rid-embedded[data-screen=archives]:not([data-archive-detail=open]) .registry-workspace {
|
||||
width:100%; max-width:none; margin-inline:0; box-sizing:border-box;
|
||||
}
|
||||
body.rid-embedded[data-screen=archives]:not([data-archive-detail=open]) .registry-workspace .history-panel {
|
||||
height:100%; min-height:0; border-radius:8px; box-shadow:none;
|
||||
}
|
||||
body.rid-embedded[data-screen=archives] .archiveTools { flex-flow:row wrap; align-items:center; gap:10px 12px; margin-bottom:18px; }
|
||||
body.rid-embedded[data-screen=archives] .archiveTools .history-search { flex:1 1 240px; max-width:520px; margin:0; }
|
||||
body.rid-embedded[data-screen=archives] .archiveTools #new-registration { width:auto; min-height:40px; }
|
||||
body.rid-embedded[data-screen=archives] .archiveTools .history-toolbar { margin:0 0 0 auto; gap:8px; }
|
||||
body.rid-embedded[data-screen=archives] .archiveTools :is(#selection-toggle,#export-toggle) { min-height:40px; }
|
||||
body.rid-embedded[data-screen=archives] .archive-card { border-radius:8px; padding:16px; }
|
||||
body.rid-embedded[data-screen=archives] .archive-card .archive-more { flex:none; min-width:28px; }
|
||||
body.rid-embedded[data-screen=archives][data-archive-detail=open] .archiveTools { flex-direction:column; align-items:stretch; }
|
||||
body.rid-embedded[data-screen=archives][data-archive-detail=open] .archiveTools .history-search { flex:none; }
|
||||
body.rid-embedded[data-screen=archives][data-archive-detail=open] .archiveTools .history-toolbar { margin:0; }
|
||||
@media (max-width: 760px) {
|
||||
body.rid-embedded .registry-workspace {
|
||||
height: auto;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
body.rid-embedded .rx-cards {
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
|
||||
}
|
||||
body.rid-embedded .rt-list-manager-head {
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
const modulePath = '/workbench/module.html';
|
||||
|
||||
if (location.pathname === modulePath) {
|
||||
if (window.parent === window) {
|
||||
location.replace('/workbench/platform.html');
|
||||
} else {
|
||||
const available = new Set(['home', 'register', 'archives', 'target-lists', 'maps', 'history', 'receivers']);
|
||||
let navigating = false;
|
||||
|
||||
function send(type, view) {
|
||||
window.parent.postMessage({ type, view }, location.origin);
|
||||
}
|
||||
|
||||
function ready() {
|
||||
send('rid-embedded-ready');
|
||||
}
|
||||
|
||||
window.addEventListener('rid-embedded-ready', ready);
|
||||
if (document.body?.className === 'rid-embedded') ready();
|
||||
|
||||
window.addEventListener('message', event => {
|
||||
if (event.origin !== location.origin || event.source !== window.parent ||
|
||||
event.data?.type !== 'rid-embedded-navigate' || !available.has(event.data.view)) return;
|
||||
navigating = true;
|
||||
try {
|
||||
const { view, record, mapOptions } = event.data;
|
||||
if (view === 'history') window.ridHistory?.setMapOptions(mapOptions);
|
||||
if (document.body.dataset.screen !== view) {
|
||||
window.dispatchEvent(new CustomEvent('rid-embedded-navigate', { detail: view }));
|
||||
}
|
||||
if (view === 'history') {
|
||||
window.dispatchEvent(new CustomEvent('rid-history-record', {
|
||||
detail: record ? JSON.stringify(record) : null
|
||||
}));
|
||||
}
|
||||
} finally {
|
||||
navigating = false;
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('rid-history-return-records', () => send('rid-embedded-return-records'));
|
||||
|
||||
window.addEventListener('rid-workspace-view', () => {
|
||||
const view = document.body.dataset.screen;
|
||||
if (!navigating && available.has(view)) send('rid-embedded-view', view);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// The reference markup uses data attributes for both static and generated controls.
|
||||
// Only these named actions are callable. Arguments are data, never JavaScript.
|
||||
const actions = Object.freeze(Object.fromEntries(`
|
||||
cancelDrawZone clearAllTrackLayers clearCurrentAlerts copyDroneRid deleteZone deleteCenterAlarm finishDrawZone
|
||||
fitAll focusAlertOnMap focusStationByKey focusZoneByKey logout
|
||||
mapSetViewWgs84 markAlarmHandled openModule renameZone setBaseMap
|
||||
shareDroneLocation shareStationLocation startDrawZone testAlarm
|
||||
toggleMapLabels toggleSidePanel toggleZone trackDrone unlockDroneTracking
|
||||
`.trim().split(/\s+/).map(name => [name, window[name]])));
|
||||
|
||||
function argument(element, value) {
|
||||
if (value === '@value') return element.value;
|
||||
if (value === '@checked') return element.checked;
|
||||
if (value === '@number') return Number(element.value);
|
||||
if (value === '@true') return true;
|
||||
if (value.startsWith('@n:')) return Number(value.slice(3));
|
||||
return value;
|
||||
}
|
||||
|
||||
function run(event, element, kind) {
|
||||
const name = element.getAttribute(`data-rid-${kind}`);
|
||||
const args = [];
|
||||
for (let index = 0; index < 3; index++) {
|
||||
const value = element.getAttribute(`data-rid-arg${index}`);
|
||||
if (value !== null) args.push(argument(element, value));
|
||||
}
|
||||
if (name === 'stop') {
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (Object.hasOwn(actions, name)) return actions[name](...args);
|
||||
}
|
||||
|
||||
for (const kind of ['click', 'change', 'input']) {
|
||||
document.addEventListener(kind, event => {
|
||||
const control = event.target.closest?.(`[data-rid-${kind}]`);
|
||||
if (control) Promise.resolve().then(() => run(event, control, kind)).catch(error => {
|
||||
const feedback = document.getElementById('rid-workbench-status');
|
||||
feedback.textContent = error.message || '操作失败,请重试';
|
||||
feedback.hidden = false;
|
||||
clearTimeout(feedback.hideTimer);
|
||||
feedback.hideTimer = setTimeout(() => { feedback.hidden = true; }, 4500);
|
||||
});
|
||||
});
|
||||
}
|
||||
for (const control of document.querySelectorAll('.tool[data-rid-click]')) {
|
||||
control.setAttribute('role', 'button');
|
||||
control.tabIndex = 0;
|
||||
}
|
||||
document.addEventListener('keydown', event => {
|
||||
const control = event.target.closest?.('div[role="button"][data-rid-click]');
|
||||
if (control && (event.key === ' ' || event.key === 'Enter')) {
|
||||
event.preventDefault();
|
||||
control.click();
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,16 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
const types = Object.freeze({
|
||||
whitelist: {label:'白名单',tone:'ok',fill:'#27b888',rank:4},
|
||||
authorized: {label:'已报备',tone:'ok',fill:'#27b888',rank:5},
|
||||
unregistered: {label:'未登记告警',tone:'danger',fill:'#cc3c48',rank:2},
|
||||
unfiled: {label:'未报备告警',tone:'warning',fill:'#ca921e',rank:3},
|
||||
geofence_enter: {label:'防控区告警',tone:'danger',fill:'#cc3c48',rank:0},
|
||||
blacklist: {label:'黑名单告警',tone:'danger',fill:'#cc3c48',rank:1},
|
||||
unknown: {label:'待核验',tone:'muted',fill:'#929eaa',rank:6}
|
||||
});
|
||||
const meta = code => types[code] || types.unknown;
|
||||
const tag = code => {const value=meta(code);return `<span class="flightTag ${value.tone}">${value.label}</span>`;};
|
||||
const tags = values => (values?.length ? [...new Set(values)] : ['unknown']).sort((a,b)=>meta(a).rank-meta(b).rank).map(tag).join(' ');
|
||||
window.ridFlightStatus=Object.freeze({types,meta,tag,tags,colors:code=>({fill:meta(code).fill,glow:meta(code).fill+'88'})});
|
||||
})();
|
||||
@@ -0,0 +1,704 @@
|
||||
.nav button:focus-visible,
|
||||
.moduleNav button:focus-visible,
|
||||
.tool[role="button"]:focus-visible {
|
||||
outline: 2px solid #65d8ff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
#app .top { z-index: 2300; }
|
||||
body { color-scheme: dark; }
|
||||
#app .top .nav { align-items: center; flex-wrap: nowrap; }
|
||||
#app .top .nav .btn { margin: 0; flex: 0 0 auto; }
|
||||
.overview-totals { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
|
||||
.overview-totals span { color: #b9d6e8; font-size: 12px; padding: 4px 8px; border: 1px solid #294a60; border-radius: 5px; background: #102639; }
|
||||
.overview-totals strong { margin-inline-start: 3px; color: #f0f9ff; font-variant-numeric: tabular-nums; }
|
||||
.mapDisplayOptions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 12px;
|
||||
padding-top: 5px;
|
||||
border-top: 1px solid #36546a;
|
||||
color: #e1f2ff;
|
||||
}
|
||||
.mapDisplayOptions label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-height: 22px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mapDisplayOptions input {
|
||||
flex: none;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
margin: 0;
|
||||
accent-color: #74bfff;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mapDisplayOptions input:focus-visible {
|
||||
outline: 2px solid #7ddcff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.nav-account {
|
||||
flex: 0 0 auto;
|
||||
max-width: 130px;
|
||||
margin-inline: 4px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
color: #a5c9de;
|
||||
}
|
||||
#workbenchNav button[aria-current="page"] {
|
||||
border-color: #67bdff;
|
||||
background: #123c60;
|
||||
color: #e7f7ff;
|
||||
}
|
||||
.moduleNav {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px 12px;
|
||||
padding: 6px 14px 0;
|
||||
border-bottom: 1px solid #28455b;
|
||||
background: #0a1b2d;
|
||||
}
|
||||
.moduleNav[hidden] { display: none; }
|
||||
.moduleNav button {
|
||||
margin: 0;
|
||||
padding: 7px 8px;
|
||||
min-height: 34px;
|
||||
border: 0;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
color: #b2cbdd;
|
||||
font-size: 13px;
|
||||
}
|
||||
.moduleNav button:hover { color: #e9f6ff; }
|
||||
.moduleNav button[aria-current="page"] { color: #e9f6ff; border-bottom-color: #69c2ff; }
|
||||
@media (max-width: 2240px) {
|
||||
#app .top .nav { gap: 5px !important; }
|
||||
#app .top .nav .btn { padding-inline: 7px !important; font-size: 12px !important; }
|
||||
.nav-account { max-width: 110px; }
|
||||
}
|
||||
|
||||
@media (max-width: 1700px) {
|
||||
#app .top { height: 102px; align-items: flex-start; padding-top: 13px !important; }
|
||||
#app .top .titleBox {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 31px;
|
||||
margin: 0;
|
||||
transform: translate(-50%, -50%);
|
||||
max-width: calc(100% - 32px);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
#app .top .title { overflow: hidden; text-overflow: ellipsis; }
|
||||
#app .top .nav {
|
||||
position: absolute;
|
||||
inset: auto 14px 8px;
|
||||
max-width: none;
|
||||
justify-content: safe center;
|
||||
overflow-x: auto;
|
||||
padding: 3px;
|
||||
}
|
||||
#app .main { top: 102px; }
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
#app .top { height: 122px; }
|
||||
#app .top .brand { display: flex; position: absolute; left: 50%; top: 49px; transform: translateX(-50%); }
|
||||
#app .top .brandLogo { display: none; }
|
||||
#app .main { top: 122px; }
|
||||
}
|
||||
|
||||
#rid-workbench-status {
|
||||
position: fixed;
|
||||
z-index: 4000;
|
||||
inset: auto 1rem 1rem auto;
|
||||
max-width: min(420px, calc(100vw - 2rem));
|
||||
margin: 0;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid #2b6894;
|
||||
border-radius: 10px;
|
||||
background: #0b2035;
|
||||
color: #e6f6ff;
|
||||
}
|
||||
|
||||
.rid-module-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
margin-bottom: 14px;
|
||||
color: #b2cada;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.rid-module-editor:empty { display: none; }
|
||||
.rid-module-feedback { padding: 9px 12px; margin-bottom: 10px; color: #9ff3d9; border: 1px solid #266977; border-radius: 8px; }
|
||||
.rid-module-feedback.dangerText { color: #ffc4cb; border-color: #864555; }
|
||||
.moduleBody :focus-visible,
|
||||
.mapWrap :is(button, select):focus-visible,
|
||||
.centerLoginPanel button:focus-visible { outline: 2px solid #7ddcff; outline-offset: 2px; }
|
||||
.rid-admin-form, .rid-admin-form fieldset, .rid-admin-fields {
|
||||
display: flex; flex-wrap: wrap; align-items: end; gap: 10px;
|
||||
}
|
||||
.rid-admin-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.rid-admin-form label, .rid-period label { display: grid; gap: 5px; color: #c7e5f6; font-size: 13px; }
|
||||
.rid-admin-form .rid-check { display: flex; flex-direction: row; align-items: center; min-height: 34px; }
|
||||
.rid-module-page [hidden] { display: none !important; }
|
||||
.rid-module-page button:disabled { opacity: .55; cursor: default; }
|
||||
|
||||
.moduleBody {
|
||||
padding: clamp(12px, 1.5vw, 24px);
|
||||
background: #0b1d2e;
|
||||
}
|
||||
.moduleBody .rid-period {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: end;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border-color: #29465c;
|
||||
background: #102438;
|
||||
}
|
||||
.rid-period label { min-width: 0; flex: 0 1 190px; }
|
||||
.rid-period label:first-child:has(input:not([type])) { flex: 1 1 220px; max-width: 380px; }
|
||||
#alarmFilters label:has(select) { flex-basis: 135px; }
|
||||
.moduleBody :is(input:not([type=checkbox]), select) { min-width: 0; min-height: 36px; }
|
||||
.moduleBody input::placeholder { color: #8ea9bd; }
|
||||
.moduleBody button:not(.red):not(:disabled) { background: #1b63a6; }
|
||||
.moduleBody button:not(.red):not(:disabled):hover { background: #2376be; }
|
||||
.moduleBody :is(.rid-period, .rid-module-toolbar, .rid-admin-form) button { min-height: 36px; padding-inline: 14px; }
|
||||
.moduleBody .rid-module-toolbar button[data-action="refresh-rx"],
|
||||
.moduleBody .rid-admin-form button[data-action="cancel-edit"],
|
||||
.moduleBody .dataTable button:not(.red):not(:disabled) {
|
||||
box-shadow: inset 0 0 0 1px #365973;
|
||||
background: #18324a;
|
||||
}
|
||||
.moduleBody .dataTable :is(th, td) { vertical-align: middle; }
|
||||
.moduleBody .dataTable td { overflow-wrap: anywhere; }
|
||||
.moduleBody .dataTable th { background: #132d43; }
|
||||
.moduleBody .dataTable tbody tr:last-child td { border-bottom: 0; }
|
||||
.moduleBody .dataTable td .smallBtn { margin: 2px; padding: 5px 8px; }
|
||||
.moduleBody .resultCount { font-size: 13px; color: #bed3e1; font-variant-numeric: tabular-nums; }
|
||||
.moduleBody .moduleEmpty {
|
||||
min-height: 116px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #aac2d4;
|
||||
}
|
||||
.moduleBody .moduleSplit {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
.moduleBody .moduleSplit .dataTable { min-width: 0; }
|
||||
.moduleBody .moduleSplit .dataTable :is(th, td) { white-space: normal; }
|
||||
.moduleBody .moduleSplit .dataTable :is(th, td):last-child {
|
||||
text-align: end;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.moduleBody .stateTag.neutral { background: #223b51; color: #c1d4e3; }
|
||||
.moduleBody .stateTag { white-space: normal; max-width: 240px; }
|
||||
.moduleBody .dataTableWrap { max-height: max(180px, calc(100dvh - 350px)); }
|
||||
.moduleBody:not([hidden]):has(#alarmResult), #alarmResult {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
#alarmResult { flex: 1 1 auto; }
|
||||
#alarmFilters, #alarmResult > :is(.resultCount, .rid-pager) { flex: none; }
|
||||
#alarmResult > .dataTableWrap { min-height: 0; }
|
||||
@media (max-width: 560px), (max-height: 620px) {
|
||||
#alarmResult { flex: none; }
|
||||
#alarmResult > .dataTableWrap { max-height: 52dvh; }
|
||||
}
|
||||
.moduleBody .rid-pager .rid-pager-actions button:not(:disabled) { background: #18344c; }
|
||||
.moduleBody .rid-pager .rid-pager-actions button:hover:not(:disabled) { background: #254f70; }
|
||||
[data-module="configs"] { max-width: 780px; }
|
||||
.rid-config-form fieldset { display: grid; width: 100%; gap: 14px; }
|
||||
.rid-config-form input[name="name"] { max-width: 410px; }
|
||||
.rid-config-form button { justify-self: start; }
|
||||
.rid-config-options { display: flex; flex-wrap: wrap; column-gap: 20px; }
|
||||
.rid-admin-form :is(label, .rid-admin-fields) { max-width: 100%; }
|
||||
.rid-admin-form input[type="checkbox"] { width: 16px; height: 16px; accent-color: #489be5; }
|
||||
.rid-admin-form .btnrow { flex-wrap: wrap; }
|
||||
@media (max-width: 760px) {
|
||||
.moduleBody .moduleSplit { grid-template-columns: 1fr; }
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
#app .top .nav { inset-inline: 8px; }
|
||||
.nav-account { max-width: 64px; }
|
||||
#app .moduleBody .rid-period {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
|
||||
}
|
||||
.rid-period label:has(input:not([type])),
|
||||
.rid-period label:has(select),
|
||||
.rid-period button { grid-column: 1 / -1; }
|
||||
.rid-period label:has(input:not([type])) { max-width: none; }
|
||||
.rid-period button { justify-self: end; }
|
||||
}
|
||||
@media (max-width: 410px) {
|
||||
.nav-account { display: none; }
|
||||
#app .moduleBody .rid-period { grid-template-columns: 1fr !important; }
|
||||
}
|
||||
|
||||
.loginCenterMountain .centerLoginScene {
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
gap: 24px;
|
||||
min-height: 100dvh;
|
||||
padding: clamp(18px, 3vw, 42px);
|
||||
}
|
||||
.loginCenterMountain .centerLoginHeader,
|
||||
.loginCenterMountain .centerLoginPanel,
|
||||
.loginCenterMountain .centerLoginFooter { position: relative; inset: auto; }
|
||||
.loginCenterMountain .centerLoginBg { animation: none; }
|
||||
.loginCenterMountain .centerLoginPanel {
|
||||
place-self: center;
|
||||
transform: none;
|
||||
width: min(100%, 410px);
|
||||
padding: clamp(20px, 3vw, 36px);
|
||||
border-radius: 14px;
|
||||
border-color: #365976;
|
||||
box-shadow: 0 16px 50px #0006;
|
||||
background: #0b2035f2;
|
||||
}
|
||||
.centerLoginPanel::before,
|
||||
.centerLoginSubmit::before { display: none; }
|
||||
.centerPanelHeading h1 { margin: 0 0 24px; font-size: 24px; color: #f4f9ff; }
|
||||
.centerLoginPanel .centerField input { padding-inline: 13px; }
|
||||
.centerLoginPanel .centerLoginSubmit {
|
||||
height: 44px;
|
||||
letter-spacing: 0;
|
||||
font-size: 15px;
|
||||
background: #1a69ad;
|
||||
border: 1px solid #3d8ac8;
|
||||
box-shadow: none;
|
||||
}
|
||||
.centerLoginPanel .centerLoginSubmit:hover { transform: none; }
|
||||
.centerLoginPanel .centerLoginState { text-align: center; color: #b0c9dc; }
|
||||
.centerLoginFooter { color: #b0c5d7; }
|
||||
|
||||
#moduleTitle {
|
||||
position: absolute;
|
||||
inset: 0 auto auto 0;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
#moduleBody[hidden], #moduleEmbed [hidden], #moduleEmbed[hidden] { display: none; }
|
||||
.moduleEmbed { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
||||
.moduleEmbed iframe { flex: 1; min-height: 0; width: 100%; border: 0; }
|
||||
#moduleEmbedStatus { margin: 18px 20px; color: #bfddf2; }
|
||||
#moduleEmbedRetry { align-self: start; margin: 0 20px; }
|
||||
|
||||
#app .left { overflow: hidden; }
|
||||
#app .left .deviceListPanel,
|
||||
#app .left .targetListPanel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#app .left .p-title { flex: 0 0 auto; }
|
||||
#app .left #stationList,
|
||||
#app .left #droneList {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
overflow: auto;
|
||||
padding-inline-end: 3px;
|
||||
}
|
||||
#app .right { overflow: hidden; }
|
||||
#app .right > :is(.zonePanel, .alertPanel) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
#app .right .p-title { flex: 0 0 auto; }
|
||||
#app .right :is(.zonePanelContent, #alertList) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
overflow: auto;
|
||||
padding-inline-end: 3px;
|
||||
}
|
||||
#app .main > :is(.left, .right) { max-width: 100%; }
|
||||
@media (max-width: 1100px) {
|
||||
#app .main { grid-template-columns: minmax(0, 1fr) !important; }
|
||||
#app .main > :is(.left, .right) { top: 62px; bottom: 12px; max-height: none; }
|
||||
#app .sideToggle { top: 12px; transform: none; height: 36px; border-radius: 7px; }
|
||||
#app .main .sideToggle.leftToggle { left: 9px; }
|
||||
#app .main .sideToggle.rightToggle { right: 9px; }
|
||||
}
|
||||
.zonePanelContent [hidden] { display: none; }
|
||||
.zoneCoordinateEntry {
|
||||
border: 1px solid #284a61;
|
||||
border-radius: 6px;
|
||||
background: #0c2136;
|
||||
}
|
||||
.zoneCoordinateEntry > summary {
|
||||
padding: 8px 10px;
|
||||
color: #cae7f6;
|
||||
cursor: pointer;
|
||||
}
|
||||
.zoneCoordinateEntry > summary:hover { background: #132c42; }
|
||||
.zoneCoordinateEntry form,
|
||||
.zoneCoordinateEntry form label { display: grid; gap: 5px; min-width: 0; }
|
||||
.zoneCoordinateEntry form { gap: 8px; border-top: 1px solid #284a61; padding: 9px; font-size: 12px; }
|
||||
.zoneFormFields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(86px, .64fr); gap: 7px; }
|
||||
.zoneCoordinateEntry :is(input, select, textarea) { width: 100%; min-width: 0; }
|
||||
.zoneCoordinateEntry textarea {
|
||||
border: 1px solid #325671;
|
||||
border-radius: 5px;
|
||||
padding: 7px 8px;
|
||||
background: #091a2d;
|
||||
color: #dcecf6;
|
||||
resize: vertical;
|
||||
font: 12px/1.5 ui-monospace, monospace;
|
||||
}
|
||||
.zoneCoordinateEntry form button { justify-self: end; }
|
||||
#zoneCoordinateHelp, .zoneDrawEditor p { margin: 0; color: #a8c7dc; font-size: 12px; }
|
||||
.zoneDrawEditor {
|
||||
margin-top: 8px;
|
||||
padding: 8px;
|
||||
border: 1px solid #284a61;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.zoneDrawActions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 7px; }
|
||||
.zoneDrawActions input { width: 100%; }
|
||||
.zoneDrawActions button { white-space: nowrap; }
|
||||
.zoneFeedback { flex: 0 0 auto; margin: 0 0 8px; color: #a3dfca; font-size: 12px; }
|
||||
.zoneFeedback.error { color: #ffadb7; }
|
||||
.zoneList { list-style: none; margin: 10px 0 0; padding: 0; }
|
||||
.zoneListItem, .workbenchAlert { padding: 9px 10px; border: 1px solid #244359; border-radius: 6px; background: #0c2032; }
|
||||
.zoneListItem + .zoneListItem, .workbenchAlert + .workbenchAlert { margin-top: 7px; }
|
||||
.zoneListHead, .workbenchAlertHead, .workbenchAlertTarget {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px 8px;
|
||||
}
|
||||
.zoneListHead b, .workbenchAlertHead b, .workbenchAlertId { overflow-wrap: anywhere; }
|
||||
.zoneListMeta { margin: 4px 0; color: #a8c7dc; font-size: 12px; }
|
||||
.zoneListItem .zoneActions { margin-top: 7px; }
|
||||
#zoneList .zoneFocus {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
color: inherit;
|
||||
text-align: start;
|
||||
}
|
||||
#zoneList .zoneFocus:hover b { text-decoration: underline; color: #98d7ff; }
|
||||
#zoneList .zoneFocus:focus-visible { outline: 2px solid #65d8ff; outline-offset: 3px; }
|
||||
#zoneList .zoneFocus .zoneListMeta { display: block; font-weight: 400; }
|
||||
.workbenchAlert { border-width: 2px; }
|
||||
.workbenchAlertHead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; }
|
||||
.workbenchAlertHead b { font-size: 14px; }
|
||||
.workbenchAlertMeta { position: relative; display: inline-flex; align-items: center; padding-inline-end: 13px; }
|
||||
.workbenchAlertHead time { color: #a8c7dc; font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.workbenchAlertId { display: block; margin-top: 5px; color: #cfe5f3; font-size: 12px; }
|
||||
.workbenchAlertTarget { margin-top: 5px; }
|
||||
.workbenchAlertPosition { color: #a8c7dc; font-size: 12px; font-variant-numeric: tabular-nums; }
|
||||
.panel .panelCount { margin-inline-start: auto; color: #b5d4e5; font-size: 12px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
||||
.alert-unread-dot { position: absolute; inset-inline-end: 0; top: 50%; transform: translateY(-50%); width: 7px; height: 7px; border-radius: 50%; background: #ff5b74; }
|
||||
.rid-station-marker { position: relative; box-sizing: border-box; display: grid; place-items: center; width: 31px; height: 31px; border: 2px solid #bcdfff; border-radius: 7px; background: #28639f; color: white; box-shadow: 0 1px 6px #081725b0; }
|
||||
.rid-station-marker.waiting { background: #6b4b26; border-color: #f4cc8c; }
|
||||
.rid-station-marker.offline { background: #344453; border-color: #acbcc8; }
|
||||
.alertPanel .alarmSettingRow {
|
||||
flex: 0 0 auto;
|
||||
margin-top: 8px;
|
||||
padding: 8px 0 0;
|
||||
border-top: 1px solid #244359;
|
||||
}
|
||||
|
||||
#stationList .stationCard {
|
||||
margin: 0 0 8px;
|
||||
border: 1px solid #22435d;
|
||||
border-radius: 8px;
|
||||
background: #0c2136;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
#stationList .stationCard.offline { background: #0a1b2d; }
|
||||
.stationCardHead {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 2px 9px;
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
}
|
||||
.stationCardHead::-webkit-details-marker { display: none; }
|
||||
.stationCardHead::before {
|
||||
content: "";
|
||||
grid-column: 1;
|
||||
grid-row: 1 / 3;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-right: 1px solid #a8c7dc;
|
||||
border-bottom: 1px solid #a8c7dc;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
.stationCard[open] .stationCardHead::before { transform: rotate(45deg); }
|
||||
.stationCardHead:hover { background: #142c41; }
|
||||
.stationCardHead:focus-visible { outline: 2px solid #65d8ff; outline-offset: -2px; }
|
||||
.stationName { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; font-size: 13px; }
|
||||
.stationTransport { grid-column: 2; grid-row: 2; color: #a8c7dc; }
|
||||
.stationCardHead .tag { grid-column: 3; grid-row: 1 / 3; white-space: nowrap; }
|
||||
.stationCardBody { padding: 6px 10px 9px; border-top: 1px solid #22435d; }
|
||||
.stationAddress {
|
||||
overflow-wrap: anywhere;
|
||||
margin-top: 3px;
|
||||
color: #9dc1d9;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.stationFix, .stationExtra { margin: 5px 0 0; color: #a8c7dc; }
|
||||
.stationFix.fixed { color: #92e6be; }
|
||||
.stationMetrics {
|
||||
display: grid;
|
||||
grid-template-columns: 1.3fr 1fr 1fr;
|
||||
gap: 5px;
|
||||
margin: 6px 0 0;
|
||||
}
|
||||
.stationMetrics div {
|
||||
min-width: 0;
|
||||
background: #102942;
|
||||
border-radius: 5px;
|
||||
padding: 4px 6px;
|
||||
}
|
||||
.stationMetrics dt { font-size: 11px; color: #a8c7dc; }
|
||||
.stationMetrics dd { color: #e4f5ff; font-variant-numeric: tabular-nums; margin: 1px 0 0; }
|
||||
.stationPosition { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
|
||||
.stationPosition span { flex-basis: 100%; font-variant-numeric: tabular-nums; }
|
||||
.stationPosition .smallBtn:focus-visible { outline: 2px solid #65d8ff; outline-offset: 2px; }
|
||||
|
||||
.targetCard button:focus-visible { outline: 2px solid #65d8ff; outline-offset: 2px; }
|
||||
.targetCard {
|
||||
background: #0c2136; border: 1px solid #22435d; border-left: 3px solid var(--target-accent);
|
||||
border-radius: 8px; padding: 9px 10px; margin: 0 0 8px; font-size: 12px; line-height: 1.4;
|
||||
}
|
||||
.targetCard.active { border-color: #5ecbff; border-left-color: var(--target-accent); }
|
||||
.targetCardHead, .targetIdentity, .targetTelemetry {
|
||||
display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px;
|
||||
}
|
||||
.targetCardHead strong { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
|
||||
.targetIdentity { color: #b4d4e9; margin-top: 3px; }
|
||||
.targetIdentity code { min-width: 0; overflow-wrap: anywhere; }
|
||||
.targetIdentity .tag, .targetCardHead .tag { flex: none; }
|
||||
.targetTelemetry { margin-top: 8px; padding: 5px 7px; border-radius: 5px; background: #102942; }
|
||||
.targetSecondary { margin: 4px 0 0; color: #a8c7dc; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
|
||||
.targetActions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
|
||||
|
||||
/* Shared flight classification across live cards, records and filings. */
|
||||
.flightTag { display:inline-flex; align-items:center; gap:5px; padding:2px 7px; border:1px solid; border-radius:4px; font-size:12px; line-height:1.5; font-weight:600; white-space:nowrap; }
|
||||
.flightTag.warning { color:#ffe29a; background:#554016; border-color:#b88624; }
|
||||
.flightTag.danger { color:#ffd0d4; background:#531f2a; border-color:#b83d4b; }
|
||||
.flightTag.ok { color:#9ce9c7; background:#153e32; border-color:#287757; }
|
||||
.flightTag.white { color:#a6e4fa; background:#163a4c; border-color:#3085a3; }
|
||||
.flightTag.muted { color:#c3ccd5; background:#263540; border-color:#536575; }
|
||||
.workbenchAlert.warning { border-color:#a67720; background:#2d291c; }
|
||||
.workbenchAlert.danger { border-color:#ab3948; background:#311e28; }
|
||||
.workbenchAlert.warning .alert-unread-dot { background:#efbd49; }
|
||||
.workbenchAlert.danger .alert-unread-dot { background:#ff6172; }
|
||||
.alertClassification { margin:6px 0 2px; }
|
||||
.workbenchAlertTarget { flex-wrap:wrap; gap:6px; }
|
||||
.workbenchAlertPosition { flex:1 1 100%; }
|
||||
.panelCount { display:inline-flex; flex-wrap:wrap; justify-content:flex-end; gap:8px; font-size:11px; }
|
||||
.countOk { color:#6bd5a5; } .countWarning { color:#ecc66a; } .countMuted { color:#a2b2bf; }
|
||||
.dot.flightWarning { background:#ca921e; } .dot.flightDanger { background:#cc3c48; }
|
||||
/* Reserve the Leaflet zoom column and attribution strip. The remaining controls share one grid. */
|
||||
.mapWrap { container: live-map / size; }
|
||||
.mapDock {
|
||||
position: absolute;
|
||||
inset: auto 14px 24px 60px;
|
||||
z-index: 4;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
align-items: end;
|
||||
gap: 8px;
|
||||
pointer-events: none;
|
||||
}
|
||||
.mapDock > :is(.legend, .toolbar, .mapSourceBox) {
|
||||
position: static;
|
||||
inset: auto !important;
|
||||
transform: none !important;
|
||||
min-width: 0;
|
||||
max-width: 100% !important;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.mapDock > .legend {
|
||||
justify-self: start;
|
||||
display: block !important;
|
||||
width: min(328px, 100%) !important;
|
||||
}
|
||||
.mapLegendToggle { display: none; }
|
||||
.mapLegendContent { display: grid; gap: 8px; }
|
||||
.mapDock > .toolbar {
|
||||
justify-self: center;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 4px !important;
|
||||
padding: 5px 7px !important;
|
||||
width: min(292px, 100%);
|
||||
}
|
||||
.mapDock .toolbar .tool {
|
||||
flex: 1 1 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
min-width: 0 !important;
|
||||
min-height: 32px;
|
||||
padding: 2px !important;
|
||||
}
|
||||
.mapDock > .mapSourceBox {
|
||||
justify-self: end;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.mapWrap .leaflet-bottom.leaflet-left {
|
||||
left: 12px !important;
|
||||
bottom: 24px !important;
|
||||
}
|
||||
|
||||
@container live-map (max-width: 1060px) or (max-height: 370px) {
|
||||
.mapDock > .legend {
|
||||
width: fit-content !important;
|
||||
padding: 4px 7px !important;
|
||||
}
|
||||
.mapDock > .legend:has(> .mapLegendToggle[aria-expanded="true"]) {
|
||||
width: min(328px, 100%) !important;
|
||||
}
|
||||
.mapLegendToggle {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
padding: 3px 6px;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
line-height: 1.35;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mapLegendArrow {
|
||||
flex: 0 0 auto;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border: solid currentColor;
|
||||
border-width: 0 1px 1px 0;
|
||||
transform: translateY(1px) rotate(225deg);
|
||||
}
|
||||
.mapLegendToggle[aria-expanded="true"] .mapLegendArrow { transform: translateY(-2px) rotate(45deg); }
|
||||
.mapLegendToggle[aria-expanded="false"] + .mapLegendContent { display: none; }
|
||||
.mapLegendContent {
|
||||
max-height: clamp(58px, 32cqh, 180px);
|
||||
overflow: auto;
|
||||
padding: 6px 4px 3px;
|
||||
}
|
||||
}
|
||||
@container live-map (max-width: 810px) {
|
||||
.mapDock { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.mapDock > .legend { grid-column: 1 / -1; }
|
||||
.mapDock > .toolbar { justify-self: start; }
|
||||
.mapLegendContent { max-height: clamp(36px, calc(100cqh - 148px), 180px); }
|
||||
}
|
||||
@container live-map (max-width: 430px) {
|
||||
.mapDock { grid-template-columns: minmax(0, 1fr); inset-inline: 52px 10px; }
|
||||
.mapLegendContent { max-height: clamp(24px, calc(100cqh - 168px), 180px); }
|
||||
.mapDock > :is(.toolbar, .mapSourceBox) { justify-self: start; }
|
||||
.mapDock > .legend { max-width: calc(100% - 40px) !important; }
|
||||
}
|
||||
@container live-map (max-height: 320px) {
|
||||
#app .main .mapWrap > .sideToggle {
|
||||
top: 12px;
|
||||
transform: none;
|
||||
height: 36px;
|
||||
}
|
||||
}
|
||||
.legendStatus { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px 12px; }
|
||||
.legend .legendStatus span { min-width:0; align-items:flex-start !important; white-space:normal !important; line-height:1.5 !important; }
|
||||
.legend .legendStatus .dot { margin-top:4px; }
|
||||
.legendStatus em { min-width:0; overflow-wrap:anywhere; }
|
||||
.legendSymbols { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; }
|
||||
.legend .mapDisplayOptions { gap:6px 12px; padding-top:8px; }
|
||||
.legend .mapDisplayOptions label { white-space:nowrap; min-height:24px; }
|
||||
/* Fill the workspace; keep pagination below the independently scrolling list. */
|
||||
.moduleBody:has(> [data-module="flight-plans"]) { display:flex; flex-direction:column; overflow:hidden; }
|
||||
[data-module="flight-plans"] { width:100%; max-width:none; flex:1; min-height:0; display:flex; flex-direction:column; }
|
||||
[data-module="flight-plans"] > .rid-module-feedback { flex:none; }
|
||||
[data-module="flight-plans"] > .rid-module-content { flex:1; min-height:0; display:flex; flex-direction:column; gap:12px; }
|
||||
[data-module="flight-plans"] .rid-module-toolbar { flex:none; margin:0; }
|
||||
[data-module="flight-plans"] .rid-module-editor:empty { display:none; }
|
||||
[data-module="flight-plans"] .rid-module-editor { flex:0 1 auto; min-height:0; max-height:65%; overflow:auto; }
|
||||
[data-module="flight-plans"] .rid-module-editor > :last-child { margin-bottom:0; }
|
||||
[data-module="flight-plans"] .planResults { flex:1; min-height:120px; display:flex; flex-direction:column; gap:10px; }
|
||||
.moduleBody [data-module="flight-plans"] .planResults > .dataTableWrap { flex:1; min-height:0; max-height:none; overflow:auto; }
|
||||
.moduleBody [data-module="flight-plans"] .planResults > .moduleEmpty { flex:1; min-height:0; display:grid; place-items:center; margin:0; }
|
||||
[data-module="flight-plans"] .planResults > .rid-pager { flex:none; margin:0; }
|
||||
[data-module="flight-plans"] .dataTable th { position:sticky; top:0; z-index:1; }
|
||||
@media (max-height:540px) {
|
||||
.moduleBody:has(> [data-module="flight-plans"]) { overflow:auto; }
|
||||
[data-module="flight-plans"] { flex:none; min-height:100%; }
|
||||
[data-module="flight-plans"] .rid-module-editor { flex:none; max-height:none; overflow:visible; }
|
||||
[data-module="flight-plans"] .planResults { flex:none; min-height:220px; }
|
||||
.moduleBody [data-module="flight-plans"] .planResults > .dataTableWrap { flex:none; max-height:50dvh; }
|
||||
}
|
||||
[data-module="flight-plans"] .rid-module-toolbar { padding:12px 14px; border:1px solid #29465c; border-radius:8px; background:#102438; }
|
||||
.flightPlanForm { width:100%; max-width:none; box-sizing:border-box; }
|
||||
[data-module="flight-plans"] .planSearch { flex:1 1 260px; width:auto; max-width:520px; }
|
||||
[data-module="flight-plans"] .rid-module-toolbar > label { display:flex; align-items:center; gap:8px; }
|
||||
[data-module="flight-plans"] .rid-module-toolbar select { width:auto; min-width:150px; }
|
||||
.planFormHeader { margin-bottom:18px; border-bottom:1px solid #29465c; padding-bottom:14px; }
|
||||
.planFormHeader h3 { margin:0 0 6px; font-size:16px; }
|
||||
.planFormHeader p,.planFieldGroup p { margin:0; font-size:12px; line-height:1.7; }
|
||||
.planEditorColumns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; }
|
||||
.planFieldGroup { min-width:0; }
|
||||
.planFieldGroup h4 { margin:0 0 14px; font-size:13px; font-weight:600; color:#c7e5f6; }
|
||||
.planFormGrid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 14px; }
|
||||
.flightPlanForm label,.planReviewForm label { display:flex; min-width:0; flex-direction:column; gap:6px; margin-bottom:12px; font-size:13px; line-height:1.5; }
|
||||
.flightPlanForm :is(input,select),.planReviewForm select { width:100%; box-sizing:border-box; min-width:0; }
|
||||
.flightPlanForm textarea,.planReviewForm textarea { width:100%; box-sizing:border-box; padding:10px; border:1px solid #35566c; border-radius:6px; color:#d9e9f3; background:#091b2a; font:inherit; resize:vertical; }
|
||||
.flightPlanForm .btnrow,.planReviewForm .btnrow { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; padding-top:14px; border-top:1px solid #29465c; }
|
||||
.moduleBody [data-module="flight-plans"] button[data-action="cancel-edit"],.moduleBody [data-module="flight-plans"] button[data-action="refresh-plans"] { background:#18324a; border:1px solid #365973; }
|
||||
.planDetails { display:grid; grid-template-columns:100px minmax(0,1fr); gap:12px; }
|
||||
.planDetails dd { margin:0; } .planDetails pre,[data-module="flight-plans"] pre { white-space:pre-wrap; overflow-wrap:anywhere; }
|
||||
[data-module="flight-plans"] .dataTable td:last-child { min-width:170px; }
|
||||
[data-module="flight-plans"] .smallBtn { margin:2px; }
|
||||
@media(max-width:1000px) { .planEditorColumns {grid-template-columns:1fr; gap:8px;} }
|
||||
@media(max-width:600px) { .planFormGrid {grid-template-columns:1fr; gap:0;} .planDetails {grid-template-columns:1fr;} [data-module="flight-plans"] .planSearch {max-width:none; flex-basis:100%; order:1;} }
|
||||
|
||||
/* The create/edit form lives in the browser top layer, without resizing the list. */
|
||||
.flightPlanDialog { width:min(1040px,calc(100vw - 40px)); max-width:none; max-height:calc(100dvh - 40px); box-sizing:border-box; margin:auto; padding:0; border:1px solid #365973; border-radius:12px; background:#0b1d2e; color:#d9e9f3; box-shadow:0 20px 70px #0008; overflow:auto; color-scheme:dark; }
|
||||
.flightPlanDialog::backdrop { background:rgba(2,10,18,.7); }
|
||||
.flightPlanDialog .flightPlanForm { margin:0; padding:24px; border:0; border-radius:0; background:none; }
|
||||
.flightPlanDialog .planFormHeader { position:relative; padding-right:42px; }
|
||||
.flightPlanDialog .planFormHeader h3 { font-size:18px; }
|
||||
.moduleBody .flightPlanDialog .planDialogClose { position:absolute; top:-6px; right:-6px; display:grid; place-items:center; width:32px; height:32px; padding:0; border:1px solid transparent; border-radius:6px; background:transparent; color:#bcd1e0; font-size:24px; font-weight:400; line-height:1; }
|
||||
.moduleBody .flightPlanDialog .planDialogClose:hover { background:#1a344a; color:#fff; }
|
||||
.flightPlanDialog .planDialogFeedback { margin-bottom:16px; }
|
||||
.flightPlanDialog:has(button[type="submit"]:disabled) :is(.planDialogClose,[data-action="cancel-edit"]) { opacity:.5; cursor:wait; }
|
||||
@media(max-width:600px) { .flightPlanDialog { width:calc(100vw - 24px); max-height:calc(100dvh - 24px); } .flightPlanDialog .flightPlanForm { padding:18px; } }
|
||||
@@ -0,0 +1,26 @@
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2010-2023, Volodymyr Agafonkin
|
||||
Copyright (c) 2010-2011, CloudMade
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 696 B |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 618 B |
@@ -0,0 +1,661 @@
|
||||
/* required styles */
|
||||
|
||||
.leaflet-pane,
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-tile-container,
|
||||
.leaflet-pane > svg,
|
||||
.leaflet-pane > canvas,
|
||||
.leaflet-zoom-box,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-layer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-container {
|
||||
overflow: hidden;
|
||||
}
|
||||
.leaflet-tile,
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
}
|
||||
/* Prevents IE11 from highlighting tiles in blue */
|
||||
.leaflet-tile::selection {
|
||||
background: transparent;
|
||||
}
|
||||
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
|
||||
.leaflet-safari .leaflet-tile {
|
||||
image-rendering: -webkit-optimize-contrast;
|
||||
}
|
||||
/* hack that prevents hw layers "stretching" when loading new tiles */
|
||||
.leaflet-safari .leaflet-tile-container {
|
||||
width: 1600px;
|
||||
height: 1600px;
|
||||
-webkit-transform-origin: 0 0;
|
||||
}
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow {
|
||||
display: block;
|
||||
}
|
||||
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
|
||||
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
|
||||
.leaflet-container .leaflet-overlay-pane svg {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
.leaflet-container .leaflet-marker-pane img,
|
||||
.leaflet-container .leaflet-shadow-pane img,
|
||||
.leaflet-container .leaflet-tile-pane img,
|
||||
.leaflet-container img.leaflet-image-layer,
|
||||
.leaflet-container .leaflet-tile {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
width: auto;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.leaflet-container img.leaflet-tile {
|
||||
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
|
||||
mix-blend-mode: plus-lighter;
|
||||
}
|
||||
|
||||
.leaflet-container.leaflet-touch-zoom {
|
||||
-ms-touch-action: pan-x pan-y;
|
||||
touch-action: pan-x pan-y;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag {
|
||||
-ms-touch-action: pinch-zoom;
|
||||
/* Fallback for FF which doesn't support pinch-zoom */
|
||||
touch-action: none;
|
||||
touch-action: pinch-zoom;
|
||||
}
|
||||
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
|
||||
-ms-touch-action: none;
|
||||
touch-action: none;
|
||||
}
|
||||
.leaflet-container {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.leaflet-container a {
|
||||
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
|
||||
}
|
||||
.leaflet-tile {
|
||||
filter: inherit;
|
||||
visibility: hidden;
|
||||
}
|
||||
.leaflet-tile-loaded {
|
||||
visibility: inherit;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
width: 0;
|
||||
height: 0;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
z-index: 800;
|
||||
}
|
||||
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
|
||||
.leaflet-overlay-pane svg {
|
||||
-moz-user-select: none;
|
||||
}
|
||||
|
||||
.leaflet-pane { z-index: 400; }
|
||||
|
||||
.leaflet-tile-pane { z-index: 200; }
|
||||
.leaflet-overlay-pane { z-index: 400; }
|
||||
.leaflet-shadow-pane { z-index: 500; }
|
||||
.leaflet-marker-pane { z-index: 600; }
|
||||
.leaflet-tooltip-pane { z-index: 650; }
|
||||
.leaflet-popup-pane { z-index: 700; }
|
||||
|
||||
.leaflet-map-pane canvas { z-index: 100; }
|
||||
.leaflet-map-pane svg { z-index: 200; }
|
||||
|
||||
.leaflet-vml-shape {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
.lvml {
|
||||
behavior: url(#default#VML);
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
/* control positioning */
|
||||
|
||||
.leaflet-control {
|
||||
position: relative;
|
||||
z-index: 800;
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-top,
|
||||
.leaflet-bottom {
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-top {
|
||||
top: 0;
|
||||
}
|
||||
.leaflet-right {
|
||||
right: 0;
|
||||
}
|
||||
.leaflet-bottom {
|
||||
bottom: 0;
|
||||
}
|
||||
.leaflet-left {
|
||||
left: 0;
|
||||
}
|
||||
.leaflet-control {
|
||||
float: left;
|
||||
clear: both;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
float: right;
|
||||
}
|
||||
.leaflet-top .leaflet-control {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.leaflet-left .leaflet-control {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.leaflet-right .leaflet-control {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
/* zoom and fade animations */
|
||||
|
||||
.leaflet-fade-anim .leaflet-popup {
|
||||
opacity: 0;
|
||||
-webkit-transition: opacity 0.2s linear;
|
||||
-moz-transition: opacity 0.2s linear;
|
||||
transition: opacity 0.2s linear;
|
||||
}
|
||||
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
|
||||
opacity: 1;
|
||||
}
|
||||
.leaflet-zoom-animated {
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
svg.leaflet-zoom-animated {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-animated {
|
||||
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
|
||||
}
|
||||
.leaflet-zoom-anim .leaflet-tile,
|
||||
.leaflet-pan-anim .leaflet-tile {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.leaflet-zoom-anim .leaflet-zoom-hide {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* cursors */
|
||||
|
||||
.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
}
|
||||
.leaflet-grab {
|
||||
cursor: -webkit-grab;
|
||||
cursor: -moz-grab;
|
||||
cursor: grab;
|
||||
}
|
||||
.leaflet-crosshair,
|
||||
.leaflet-crosshair .leaflet-interactive {
|
||||
cursor: crosshair;
|
||||
}
|
||||
.leaflet-popup-pane,
|
||||
.leaflet-control {
|
||||
cursor: auto;
|
||||
}
|
||||
.leaflet-dragging .leaflet-grab,
|
||||
.leaflet-dragging .leaflet-grab .leaflet-interactive,
|
||||
.leaflet-dragging .leaflet-marker-draggable {
|
||||
cursor: move;
|
||||
cursor: -webkit-grabbing;
|
||||
cursor: -moz-grabbing;
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* marker & overlays interactivity */
|
||||
.leaflet-marker-icon,
|
||||
.leaflet-marker-shadow,
|
||||
.leaflet-image-layer,
|
||||
.leaflet-pane > svg path,
|
||||
.leaflet-tile-container {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.leaflet-interactive,
|
||||
.leaflet-image-layer.leaflet-interactive,
|
||||
.leaflet-pane > svg path.leaflet-interactive,
|
||||
svg.leaflet-image-layer.leaflet-interactive path {
|
||||
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* visual tweaks */
|
||||
|
||||
.leaflet-container {
|
||||
background: #ddd;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
.leaflet-container a {
|
||||
color: #0078A8;
|
||||
}
|
||||
.leaflet-zoom-box {
|
||||
border: 2px dotted #38f;
|
||||
background: rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
|
||||
/* general typography */
|
||||
.leaflet-container {
|
||||
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
||||
font-size: 12px;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
/* general toolbar styles */
|
||||
|
||||
.leaflet-bar {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a {
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #ccc;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
}
|
||||
.leaflet-bar a,
|
||||
.leaflet-control-layers-toggle {
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
.leaflet-bar a:hover,
|
||||
.leaflet-bar a:focus {
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
.leaflet-bar a:first-child {
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-bottom: none;
|
||||
}
|
||||
.leaflet-bar a.leaflet-disabled {
|
||||
cursor: default;
|
||||
background-color: #f4f4f4;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-bar a {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:first-child {
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
.leaflet-touch .leaflet-bar a:last-child {
|
||||
border-bottom-left-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
}
|
||||
|
||||
/* zoom control */
|
||||
|
||||
.leaflet-control-zoom-in,
|
||||
.leaflet-control-zoom-out {
|
||||
font: bold 18px 'Lucida Console', Monaco, monospace;
|
||||
text-indent: 1px;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
|
||||
/* layers control */
|
||||
|
||||
.leaflet-control-layers {
|
||||
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
|
||||
background: #fff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
.leaflet-retina .leaflet-control-layers-toggle {
|
||||
background-image: url(images/layers-2x.png);
|
||||
background-size: 26px 26px;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers-toggle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
}
|
||||
.leaflet-control-layers .leaflet-control-layers-list,
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
|
||||
display: none;
|
||||
}
|
||||
.leaflet-control-layers-expanded .leaflet-control-layers-list {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
.leaflet-control-layers-expanded {
|
||||
padding: 6px 10px 6px 6px;
|
||||
color: #333;
|
||||
background: #fff;
|
||||
}
|
||||
.leaflet-control-layers-scrollbar {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
padding-right: 5px;
|
||||
}
|
||||
.leaflet-control-layers-selector {
|
||||
margin-top: 2px;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
.leaflet-control-layers label {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
}
|
||||
.leaflet-control-layers-separator {
|
||||
height: 0;
|
||||
border-top: 1px solid #ddd;
|
||||
margin: 5px -10px 5px -6px;
|
||||
}
|
||||
|
||||
/* Default icon URLs */
|
||||
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
|
||||
background-image: url(images/marker-icon.png);
|
||||
}
|
||||
|
||||
|
||||
/* attribution and scale controls */
|
||||
|
||||
.leaflet-container .leaflet-control-attribution {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
margin: 0;
|
||||
}
|
||||
.leaflet-control-attribution,
|
||||
.leaflet-control-scale-line {
|
||||
padding: 0 5px;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.leaflet-control-attribution a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.leaflet-control-attribution a:hover,
|
||||
.leaflet-control-attribution a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.leaflet-attribution-flag {
|
||||
display: inline !important;
|
||||
vertical-align: baseline !important;
|
||||
width: 1em;
|
||||
height: 0.6669em;
|
||||
}
|
||||
.leaflet-left .leaflet-control-scale {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.leaflet-bottom .leaflet-control-scale {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.leaflet-control-scale-line {
|
||||
border: 2px solid #777;
|
||||
border-top: none;
|
||||
line-height: 1.1;
|
||||
padding: 2px 5px 1px;
|
||||
white-space: nowrap;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
text-shadow: 1px 1px #fff;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child) {
|
||||
border-top: 2px solid #777;
|
||||
border-bottom: none;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
|
||||
border-bottom: 2px solid #777;
|
||||
}
|
||||
|
||||
.leaflet-touch .leaflet-control-attribution,
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
box-shadow: none;
|
||||
}
|
||||
.leaflet-touch .leaflet-control-layers,
|
||||
.leaflet-touch .leaflet-bar {
|
||||
border: 2px solid rgba(0,0,0,0.2);
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
|
||||
/* popup */
|
||||
|
||||
.leaflet-popup {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.leaflet-popup-content-wrapper {
|
||||
padding: 1px;
|
||||
text-align: left;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.leaflet-popup-content {
|
||||
margin: 13px 24px 13px 20px;
|
||||
line-height: 1.3;
|
||||
font-size: 13px;
|
||||
font-size: 1.08333em;
|
||||
min-height: 1px;
|
||||
}
|
||||
.leaflet-popup-content p {
|
||||
margin: 17px 0;
|
||||
margin: 1.3em 0;
|
||||
}
|
||||
.leaflet-popup-tip-container {
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
margin-top: -1px;
|
||||
margin-left: -20px;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.leaflet-popup-tip {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
padding: 1px;
|
||||
|
||||
margin: -10px auto 0;
|
||||
pointer-events: auto;
|
||||
|
||||
-webkit-transform: rotate(45deg);
|
||||
-moz-transform: rotate(45deg);
|
||||
-ms-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.leaflet-popup-content-wrapper,
|
||||
.leaflet-popup-tip {
|
||||
background: white;
|
||||
color: #333;
|
||||
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border: none;
|
||||
text-align: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font: 16px/24px Tahoma, Verdana, sans-serif;
|
||||
color: #757575;
|
||||
text-decoration: none;
|
||||
background: transparent;
|
||||
}
|
||||
.leaflet-container a.leaflet-popup-close-button:hover,
|
||||
.leaflet-container a.leaflet-popup-close-button:focus {
|
||||
color: #585858;
|
||||
}
|
||||
.leaflet-popup-scrolled {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper {
|
||||
-ms-zoom: 1;
|
||||
}
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
width: 24px;
|
||||
margin: 0 auto;
|
||||
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
|
||||
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
|
||||
}
|
||||
|
||||
.leaflet-oldie .leaflet-control-zoom,
|
||||
.leaflet-oldie .leaflet-control-layers,
|
||||
.leaflet-oldie .leaflet-popup-content-wrapper,
|
||||
.leaflet-oldie .leaflet-popup-tip {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
|
||||
/* div icon */
|
||||
|
||||
.leaflet-div-icon {
|
||||
background: #fff;
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
|
||||
/* Tooltip */
|
||||
/* Base styles for the element that has a tooltip */
|
||||
.leaflet-tooltip {
|
||||
position: absolute;
|
||||
padding: 6px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #fff;
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
white-space: nowrap;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
||||
}
|
||||
.leaflet-tooltip.leaflet-interactive {
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.leaflet-tooltip-top:before,
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
border: 6px solid transparent;
|
||||
background: transparent;
|
||||
content: "";
|
||||
}
|
||||
|
||||
/* Directions */
|
||||
|
||||
.leaflet-tooltip-bottom {
|
||||
margin-top: 6px;
|
||||
}
|
||||
.leaflet-tooltip-top {
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before,
|
||||
.leaflet-tooltip-top:before {
|
||||
left: 50%;
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-top:before {
|
||||
bottom: 0;
|
||||
margin-bottom: -12px;
|
||||
border-top-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-bottom:before {
|
||||
top: 0;
|
||||
margin-top: -12px;
|
||||
margin-left: -6px;
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-left {
|
||||
margin-left: -6px;
|
||||
}
|
||||
.leaflet-tooltip-right {
|
||||
margin-left: 6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before,
|
||||
.leaflet-tooltip-right:before {
|
||||
top: 50%;
|
||||
margin-top: -6px;
|
||||
}
|
||||
.leaflet-tooltip-left:before {
|
||||
right: 0;
|
||||
margin-right: -12px;
|
||||
border-left-color: #fff;
|
||||
}
|
||||
.leaflet-tooltip-right:before {
|
||||
left: 0;
|
||||
margin-left: -12px;
|
||||
border-right-color: #fff;
|
||||
}
|
||||
|
||||
/* Printing */
|
||||
|
||||
@media print {
|
||||
/* Prevent printers from removing background-images of controls. */
|
||||
.leaflet-control {
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
#liveMap3D {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
#liveMap3D[hidden],
|
||||
.rid-live-3d-marker[hidden],
|
||||
.rid-live-3d-height[hidden],
|
||||
.rid-live-3d-popup[hidden] { display: none; }
|
||||
.mapWrap[data-map-mode="3d"] #map { visibility: hidden; }
|
||||
.rid-live-3d-trails,
|
||||
.rid-live-3d-markers {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
}
|
||||
.rid-live-3d-marker {
|
||||
position: absolute;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
transform: translate(-50%, -50%);
|
||||
outline-offset: 3px;
|
||||
pointer-events: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rid-live-3d-height {
|
||||
position: absolute;
|
||||
left: calc(100% + 5px);
|
||||
top: 2px;
|
||||
padding: 3px 6px;
|
||||
border: 1px solid #74c4f484;
|
||||
border-radius: 5px;
|
||||
background: #071e32ed;
|
||||
color: #e5f8ff;
|
||||
font: 600 11px/1.4 system-ui, sans-serif;
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.rid-live-3d-popup {
|
||||
position: absolute;
|
||||
transform: translate(-50%, calc(-100% - 20px));
|
||||
z-index: 2;
|
||||
padding: 12px 22px 12px 14px;
|
||||
width: max-content;
|
||||
max-width: min(310px, 100%);
|
||||
overflow-wrap: anywhere;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
color: #152537;
|
||||
box-shadow: 0 3px 15px #10202b75;
|
||||
font: 13px/1.4 system-ui, sans-serif;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.rid-live-3d-popup.below { transform: translate(-50%, 20px); }
|
||||
.rid-live-3d-popup button {
|
||||
position: absolute;
|
||||
right: 6px;
|
||||
top: 4px;
|
||||
padding: 0 4px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #516476;
|
||||
box-shadow: none;
|
||||
}
|
||||
.mapWrap .zonePopupCard {
|
||||
min-width: 100px;
|
||||
color: #192e42;
|
||||
overflow-wrap: anywhere;
|
||||
font: 13px/1.5 system-ui, sans-serif;
|
||||
}
|
||||
.mapWrap .zonePopupCard strong { display: block; font-size: 14px; font-weight: 650; }
|
||||
.mapWrap .zonePopupMeta { margin-top: 3px; color: #4b6072; }
|
||||
.mapWrap .zoneMapPopup .maplibregl-popup-content {
|
||||
padding: 10px 29px 10px 12px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.mapWrap .zoneMapPopup .leaflet-popup-content { margin: 10px 29px 10px 12px; }
|
||||
.mapWrap .zoneMapPopup :is(.maplibregl-popup-close-button, .leaflet-popup-close-button) {
|
||||
padding: 0;
|
||||
color: #4b6072;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
font-size: 16px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
.mapWrap .zoneMapPopup :is(.maplibregl-popup-close-button, .leaflet-popup-close-button):hover {
|
||||
color: #192e42;
|
||||
background: #e7edf2;
|
||||
}
|
||||
#mapViewToggle[aria-pressed="true"] {
|
||||
border-color: #6bccff;
|
||||
background: #166b97;
|
||||
color: white;
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
|
||||
import * as ml from '/vendor/maplibre-gl.mjs';
|
||||
ml.setWorkerUrl('/vendor/maplibre-gl-worker.mjs');
|
||||
|
||||
const COLLECTION = 'FeatureCollection';
|
||||
|
||||
function project(matrix, coordinate, width, height) {
|
||||
const {x, y, z} = coordinate;
|
||||
const w = matrix[3] * x + matrix[7] * y + matrix[11] * z + matrix[15];
|
||||
if (w <= 0) return null;
|
||||
return [
|
||||
(1 + (matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12]) / w) * width / 2,
|
||||
(1 - (matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13]) / w) * height / 2
|
||||
];
|
||||
}
|
||||
|
||||
export function openLiveMap(container, options) {
|
||||
const {center, zoom, basemap, onCamera, onError} = options;
|
||||
const map = new ml.Map({
|
||||
container, center, zoom: zoom - 1, pitch: options.pitch ?? 52, bearing: options.bearing ?? 0, maxPitch: 70, maxZoom: 17,
|
||||
renderWorldCopies: false, attributionControl: false,
|
||||
style: {
|
||||
version: 8,
|
||||
sources: {
|
||||
base: {type:'raster', tiles:[basemap.tiles], tileSize:256, maxzoom:18, attribution:'天地图 © 自然资源部'},
|
||||
labels: {type:'raster', tiles:[basemap.labels || basemap.tiles], tileSize:256, maxzoom:18},
|
||||
fences: {type:'geojson', data:{type:COLLECTION, features:[]}}
|
||||
},
|
||||
layers: [
|
||||
{id:'background', type:'background', paint:{'background-color':'#0a1827'}},
|
||||
{id:'base', type:'raster', source:'base'},
|
||||
{id:'labels', type:'raster', source:'labels', layout:{visibility:basemap.labels ? 'visible' : 'none'}},
|
||||
{id:'fences', type:'fill', source:'fences', paint:{'fill-color':'#ff536e','fill-opacity':0.18}},
|
||||
{id:'fence-outline', type:'line', source:'fences', paint:{'line-color':'#ff637a','line-width':2}}
|
||||
]
|
||||
}
|
||||
});
|
||||
map.addControl(new ml.NavigationControl(), 'bottom-left');
|
||||
map.addControl(new ml.AttributionControl({compact:true}), 'bottom-right');
|
||||
|
||||
const lines = document.createElement('canvas');
|
||||
lines.className = 'rid-live-3d-trails';
|
||||
lines.setAttribute('aria-hidden', 'true');
|
||||
const context = lines.getContext('2d');
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'rid-live-3d-markers';
|
||||
const popup = document.createElement('div');
|
||||
popup.className = 'rid-live-3d-popup';
|
||||
popup.hidden = true;
|
||||
const close = document.createElement('button');
|
||||
close.type = 'button';
|
||||
close.setAttribute('aria-label', '关闭地图详情');
|
||||
close.textContent = '×';
|
||||
const popupBody = document.createElement('div');
|
||||
popup.append(close, popupBody);
|
||||
overlay.append(popup);
|
||||
map.getCanvasContainer().append(lines, overlay);
|
||||
|
||||
let active = true;
|
||||
let updatingCamera = false;
|
||||
let selected = null;
|
||||
let projection;
|
||||
const zonePopup = new ml.Popup({closeButton:true, className:'zoneMapPopup', maxWidth:'260px'});
|
||||
let config = basemap;
|
||||
let fences = [];
|
||||
let entries = new Map();
|
||||
const elements = new Map();
|
||||
let trailPoints = new WeakMap();
|
||||
let trackCoords = options.trackCoords;
|
||||
|
||||
function closePopup() {
|
||||
selected = null;
|
||||
popup.hidden = true;
|
||||
map.triggerRepaint();
|
||||
}
|
||||
close.addEventListener('click', () => {
|
||||
const button = elements.get(selected)?.button;
|
||||
closePopup();
|
||||
button?.focus();
|
||||
});
|
||||
|
||||
function showTarget(id) {
|
||||
selected = id;
|
||||
map.triggerRepaint();
|
||||
}
|
||||
|
||||
function toGround(point) {
|
||||
return ml.MercatorCoordinate.fromLngLat(point);
|
||||
}
|
||||
|
||||
function toAir(point, height) {
|
||||
return ml.MercatorCoordinate.fromLngLat(point, Math.max(0, height ?? 0));
|
||||
}
|
||||
|
||||
function trailPoint(raw) {
|
||||
let point = trailPoints.get(raw);
|
||||
if (!point) {
|
||||
point = toAir(trackCoords(raw[0], raw[1]), raw[2]);
|
||||
trailPoints.set(raw, point);
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
function markerFor(entry) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'rid-live-3d-marker';
|
||||
const visual = document.createElement('span');
|
||||
const height = document.createElement('span');
|
||||
height.className = 'rid-live-3d-height';
|
||||
button.append(visual, height);
|
||||
button.addEventListener('pointerdown', event => event.stopPropagation());
|
||||
button.addEventListener('click', event => {
|
||||
event.stopPropagation();
|
||||
if (selected === entry.id) closePopup();
|
||||
else showTarget(entry.id);
|
||||
});
|
||||
overlay.append(button);
|
||||
return {button, visual, height, icon: null};
|
||||
}
|
||||
|
||||
function updateEntries(next) {
|
||||
entries = new Map();
|
||||
for (const entry of next) {
|
||||
entries.set(entry.id, {...entry, ground:toGround(entry.position), air:toAir(entry.position, entry.height),
|
||||
pilotGround:entry.pilot ? toGround(entry.pilot) : null});
|
||||
let element = elements.get(entry.id);
|
||||
if (!element) elements.set(entry.id, element = markerFor(entry));
|
||||
if (element.icon !== entry.icon) {
|
||||
element.visual.replaceChildren(entry.icon?.cloneNode(true) || document.createTextNode(entry.label[0]));
|
||||
element.icon = entry.icon;
|
||||
element.plane = element.visual.querySelector('.rid-drone-plane');
|
||||
}
|
||||
element.button.setAttribute('aria-label', entry.label);
|
||||
const value = entry.heightLabel || '';
|
||||
if (element.height.textContent !== value) element.height.textContent = value;
|
||||
element.height.hidden = !value;
|
||||
}
|
||||
for (const [id, element] of elements) {
|
||||
if (entries.has(id)) continue;
|
||||
element.button.remove();
|
||||
elements.delete(id);
|
||||
if (selected === id) closePopup();
|
||||
}
|
||||
map.triggerRepaint();
|
||||
}
|
||||
|
||||
function paint(matrix) {
|
||||
if (!active || !context || !matrix) return;
|
||||
const width = container.clientWidth;
|
||||
const height = container.clientHeight;
|
||||
if (!width || !height) return;
|
||||
projection = {matrix:matrix.slice(),width,height};
|
||||
const scale = Math.min(window.devicePixelRatio || 1, 2);
|
||||
const pixelsWide = Math.round(width * scale);
|
||||
const pixelsHigh = Math.round(height * scale);
|
||||
if (lines.width !== pixelsWide || lines.height !== pixelsHigh) {
|
||||
lines.width = pixelsWide;
|
||||
lines.height = pixelsHigh;
|
||||
}
|
||||
context.setTransform(scale, 0, 0, scale, 0, 0);
|
||||
context.clearRect(0, 0, width, height);
|
||||
context.lineJoin = context.lineCap = 'round';
|
||||
let popupAnchor;
|
||||
const screen = coordinate => project(matrix, coordinate, width, height);
|
||||
for (const [id, entry] of entries) {
|
||||
const element = elements.get(id);
|
||||
const position = screen(entry.air);
|
||||
const visible = position && position[0] >= -32 && position[0] <= width + 32
|
||||
&& position[1] >= -30 && position[1] <= height + 30;
|
||||
element.button.hidden = !visible;
|
||||
if (visible) {
|
||||
element.button.style.left = position[0] + 'px';
|
||||
element.button.style.top = position[1] + 'px';
|
||||
if (element.plane && Number.isFinite(entry.heading)) {
|
||||
const angle = entry.heading * Math.PI / 180;
|
||||
const distance = 20 * entry.air.meterInMercatorCoordinateUnits();
|
||||
const ahead = screen({x:entry.air.x + Math.sin(angle) * distance,
|
||||
y:entry.air.y - Math.cos(angle) * distance, z:entry.air.z});
|
||||
if (ahead) {
|
||||
const screenAngle = Math.atan2(ahead[0] - position[0], position[1] - ahead[1]) * 180 / Math.PI;
|
||||
element.plane.style.transform = `rotate(${screenAngle}deg)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entry.trail) {
|
||||
context.beginPath();
|
||||
context.setLineDash([]);
|
||||
context.strokeStyle = entry.trailColor || '#43efa0';
|
||||
context.lineWidth = 2.5;
|
||||
let previous;
|
||||
for (const raw of entry.trail) {
|
||||
const point = screen(trailPoint(raw));
|
||||
if (!point) { previous = undefined; continue; }
|
||||
if (previous && !raw[3]) {
|
||||
context.lineTo(...point);
|
||||
} else {
|
||||
context.moveTo(...point);
|
||||
}
|
||||
previous = raw;
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
if (entry.pilotGround && visible) {
|
||||
const pilot = screen(entry.pilotGround);
|
||||
if (pilot) {
|
||||
context.beginPath();
|
||||
context.strokeStyle = '#55d5ef';
|
||||
context.lineWidth = 1.5;
|
||||
context.setLineDash([5, 5]);
|
||||
context.moveTo(...pilot);
|
||||
context.lineTo(...position);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
if (entry.height > 0 && visible) {
|
||||
const ground = screen(entry.ground);
|
||||
if (ground) {
|
||||
context.beginPath();
|
||||
context.setLineDash([4, 4]);
|
||||
context.strokeStyle = '#a6e5ff';
|
||||
context.lineWidth = 1.5;
|
||||
context.moveTo(...ground);
|
||||
context.lineTo(...position);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
element.button.setAttribute('aria-expanded', String(selected === id));
|
||||
if (selected === id && visible) popupAnchor = [position, entry.popup];
|
||||
}
|
||||
popup.hidden = !popupAnchor;
|
||||
if (popupAnchor) {
|
||||
const [position, content] = popupAnchor;
|
||||
if (popupBody.dataset.content !== content) {
|
||||
popupBody.innerHTML = content;
|
||||
popupBody.dataset.content = content;
|
||||
}
|
||||
const half = Math.min(popup.offsetWidth / 2, width / 2);
|
||||
popup.style.left = Math.max(half, Math.min(width - half, position[0])) + 'px';
|
||||
popup.style.top = position[1] + 'px';
|
||||
popup.classList.toggle('below', position[1] < popup.offsetHeight + 30);
|
||||
}
|
||||
}
|
||||
|
||||
function applyStyle() {
|
||||
map.getSource('base')?.setTiles([config.tiles]);
|
||||
if (config.labels) map.getSource('labels')?.setTiles([config.labels]);
|
||||
if (map.getLayer('labels')) map.setLayoutProperty('labels','visibility', config.labels ? 'visible' : 'none');
|
||||
map.getSource('fences')?.setData({type:COLLECTION, features:fences});
|
||||
}
|
||||
|
||||
map.on('style.load', () => {
|
||||
applyStyle();
|
||||
map.addLayer({id:'rid-airspace', type:'custom', renderingMode:'3d', render(_gl, args) {
|
||||
paint(args.defaultProjectionData?.mainMatrix || args.modelViewProjectionMatrix);
|
||||
}});
|
||||
});
|
||||
map.on('moveend', () => {
|
||||
if (active && !updatingCamera) onCamera(map.getCenter(), map.getZoom() + 1);
|
||||
});
|
||||
map.on('click', event => {
|
||||
closePopup();
|
||||
if (!map.getLayer('fences')) return;
|
||||
const [zone] = map.queryRenderedFeatures(event.point, {layers:['fences']});
|
||||
if (zone) {
|
||||
zonePopup.setLngLat(event.lngLat)
|
||||
.setDOMContent(options.createZonePopupContent(zone.properties))
|
||||
.addTo(map);
|
||||
}
|
||||
});
|
||||
map.on('webglcontextlost', onError);
|
||||
|
||||
function resize() {
|
||||
if (!active) return;
|
||||
updatingCamera = true;
|
||||
try {
|
||||
map.resize();
|
||||
} finally {
|
||||
updatingCamera = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getCamera: () => ({pitch:map.getPitch(), bearing:map.getBearing()}),
|
||||
showTarget,
|
||||
setActive(value) {
|
||||
active = value;
|
||||
if (!active) zonePopup.remove();
|
||||
resize();
|
||||
},
|
||||
resize,
|
||||
destroy: () => map.remove(),
|
||||
setView(center, zoom) {
|
||||
const current = map.getCenter();
|
||||
if (Math.abs(current.lng - center[0]) < 1e-8 && Math.abs(current.lat - center[1]) < 1e-8
|
||||
&& Math.abs(map.getZoom() - zoom + 1) < 1e-6) return;
|
||||
updatingCamera = true;
|
||||
try { map.jumpTo({center, zoom:zoom - 1}); } finally { updatingCamera = false; }
|
||||
},
|
||||
setBasemap(value) {
|
||||
if (config.tiles === value.tiles && config.labels === value.labels) return;
|
||||
if (config.tiles !== value.tiles) trailPoints = new WeakMap();
|
||||
config = value;
|
||||
applyStyle();
|
||||
},
|
||||
setFences(value) {
|
||||
fences = value;
|
||||
zonePopup.remove();
|
||||
map.getSource('fences')?.setData({type:COLLECTION, features:fences});
|
||||
},
|
||||
updateEntries,
|
||||
metrics() {
|
||||
const screen = coordinate => projection && project(projection.matrix, coordinate, projection.width, projection.height);
|
||||
return {camera:{pitch:map.getPitch(), bearing:map.getBearing(), zoom:map.getZoom()+1}, size:[lines.width,lines.height],
|
||||
positions:[...entries.values()].map(entry => ({
|
||||
id:entry.id, heading:entry.heading, height:entry.height, altitude:entry.air.toAltitude(),
|
||||
air:screen(entry.air), ground:screen(entry.ground),
|
||||
tail:entry.trail?.length ? screen(trailPoint(entry.trail.at(-1))) : null
|
||||
}))};
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>登录 - RID侦测平台</title>
|
||||
<link rel="icon" href="/workbench/assets/rid-app.ico" type="image/x-icon">
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<link rel="stylesheet" href="/workbench/platform.css">
|
||||
<link rel="stylesheet" href="/workbench/integration.css">
|
||||
</head>
|
||||
<body class="loginPage loginCenterMountain">
|
||||
<main class="centerLoginScene">
|
||||
<div class="centerLoginBg" aria-hidden="true"></div>
|
||||
<div class="centerLoginShade" aria-hidden="true"></div>
|
||||
<header class="centerLoginHeader">
|
||||
<div class="centerBrand">
|
||||
<img class="centerBrandMark" src="/workbench/assets/bsrid_logo_icon_light.png" alt="" width="46" height="46">
|
||||
<strong id="loginPlatformName">RID侦测平台</strong>
|
||||
</div>
|
||||
</header>
|
||||
<form class="centerLoginPanel">
|
||||
<div class="centerPanelHeading"><h1>平台登录</h1></div>
|
||||
<label class="centerField"><span>用户名</span><input id="username" autocomplete="username" placeholder="请输入用户名" required></label>
|
||||
<label class="centerField"><span>密码</span><input id="password" type="password" autocomplete="current-password" placeholder="请输入密码" required></label>
|
||||
<button type="submit" class="centerLoginSubmit"><span>登录</span></button>
|
||||
<div id="loginMsg" class="centerLoginMsg" role="alert"></div>
|
||||
<div class="centerLoginState" id="loginStatusText" aria-live="polite">正在检查本地账号</div>
|
||||
</form>
|
||||
<footer class="centerLoginFooter">© 2026 <span id="loginFooterName">RID侦测平台</span></footer>
|
||||
</main>
|
||||
<script src="/workbench/login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,61 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
const status = document.getElementById('loginStatusText');
|
||||
|
||||
const form = document.querySelector('.centerLoginPanel');
|
||||
const button = form.querySelector('button');
|
||||
const buttonLabel = button.querySelector('span');
|
||||
const message = document.getElementById('loginMsg');
|
||||
const username = document.getElementById('username');
|
||||
const password = document.getElementById('password');
|
||||
let needsSetup = false;
|
||||
button.disabled = true;
|
||||
|
||||
async function prepare() {
|
||||
const response = await fetch('/api/auth/status', { cache: 'no-store' });
|
||||
if (!response.ok) throw new Error('无法读取本地服务状态');
|
||||
const account = await response.json();
|
||||
if (account.authenticated) return location.replace('/workbench/platform.html');
|
||||
needsSetup = !account.configured;
|
||||
buttonLabel.textContent = needsSetup ? '创建管理员' : '登录';
|
||||
password.autocomplete = needsSetup ? 'new-password' : 'current-password';
|
||||
password.minLength = needsSetup ? 10 : 0;
|
||||
status.textContent = needsSetup ? '首次运行,请设置管理员账号和至少 10 字符的密码' : '本地账号验证';
|
||||
button.disabled = false;
|
||||
}
|
||||
|
||||
form.addEventListener('submit', async event => {
|
||||
event.preventDefault();
|
||||
button.disabled = true;
|
||||
message.textContent = '';
|
||||
status.textContent = needsSetup ? '正在创建管理员' : '正在验证本地账号';
|
||||
try {
|
||||
const response = await fetch(`/api/auth/${needsSetup ? 'setup' : 'login'}`, {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username: username.value.trim(), password: password.value })
|
||||
});
|
||||
password.value = '';
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
if (response.status === 409) await prepare();
|
||||
throw new Error(data.error || '本地账号验证失败');
|
||||
}
|
||||
status.textContent = '认证通过,正在进入平台';
|
||||
location.replace('/workbench/platform.html');
|
||||
} catch (error) {
|
||||
message.textContent = error.message;
|
||||
status.textContent = '请检查后重试';
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
prepare().catch(error => { message.textContent = error.message; });
|
||||
fetch('/api/workbench/branding', { cache: 'no-store' })
|
||||
.then(response => response.ok ? response.json() : null)
|
||||
.then(branding => {
|
||||
if (!branding?.name) return;
|
||||
document.getElementById('loginPlatformName').textContent = branding.name;
|
||||
document.getElementById('loginFooterName').textContent = branding.name;
|
||||
document.title = `登录 - ${branding.name}`;
|
||||
})
|
||||
.catch(() => {});
|
||||
})();
|
||||
@@ -0,0 +1,127 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const nativeViews = Object.freeze({
|
||||
register: 'register', archives: 'archives', drones: 'target-lists',
|
||||
maps: 'maps', history: 'history', receivers: 'receivers'
|
||||
});
|
||||
const workbenchViews = new Map(Object.entries(nativeViews).map(([key, view]) => [view, key]));
|
||||
const container = document.getElementById('moduleEmbed');
|
||||
const content = document.getElementById('moduleBody');
|
||||
const status = document.getElementById('moduleEmbedStatus');
|
||||
const retry = document.getElementById('moduleEmbedRetry');
|
||||
|
||||
let frame;
|
||||
let pendingView = 'home';
|
||||
let pendingRecord;
|
||||
let ready = false;
|
||||
let timer;
|
||||
|
||||
function navigate(view) {
|
||||
if (ready) frame.contentWindow.postMessage({
|
||||
type: 'rid-embedded-navigate', view, record: view === 'history' ? pendingRecord : undefined,
|
||||
mapOptions: view === 'history' ? {
|
||||
basemap: document.getElementById('mapSourceSelect').value === 'tdt-vector' ? 'road' : 'imagery',
|
||||
labels: document.getElementById('labelToggle').checked
|
||||
} : undefined
|
||||
}, location.origin);
|
||||
}
|
||||
|
||||
function mount() {
|
||||
frame = document.createElement('iframe');
|
||||
frame.title = 'RID 业务模块';
|
||||
frame.hidden = true;
|
||||
frame.src = '/workbench/module.html';
|
||||
container.append(frame);
|
||||
}
|
||||
|
||||
function waiting() {
|
||||
status.textContent = '正在打开业务模块…';
|
||||
status.hidden = false;
|
||||
retry.hidden = true;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(async () => {
|
||||
if (ready || container.hidden) return;
|
||||
const account = await window.ridWorkbenchApi.request('/api/auth/status').catch(() => null);
|
||||
if (ready || container.hidden) return;
|
||||
if (account && !account.authenticated) return location.replace('/workbench/');
|
||||
status.textContent = '业务模块加载失败,请重试。';
|
||||
retry.hidden = false;
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
function hide() {
|
||||
pendingView = 'home';
|
||||
pendingRecord = undefined;
|
||||
container.hidden = true;
|
||||
content.hidden = false;
|
||||
clearTimeout(timer);
|
||||
navigate(pendingView);
|
||||
}
|
||||
|
||||
function show(name, record) {
|
||||
if (!Object.hasOwn(nativeViews, name)) {
|
||||
hide();
|
||||
return false;
|
||||
}
|
||||
pendingView = nativeViews[name];
|
||||
pendingRecord = name === 'history' && record ? {
|
||||
flightKey: record.flightKey, targetId: record.targetId, timeMs: record.timeMs, endMs: record.endMs
|
||||
} : undefined;
|
||||
content.hidden = true;
|
||||
container.hidden = false;
|
||||
if (!frame) mount();
|
||||
frame.title = document.getElementById('moduleTitle').textContent;
|
||||
if (ready) navigate(pendingView);
|
||||
else waiting();
|
||||
return true;
|
||||
}
|
||||
|
||||
retry.addEventListener('click', () => {
|
||||
frame.remove();
|
||||
ready = false;
|
||||
mount();
|
||||
frame.title = document.getElementById('moduleTitle').textContent;
|
||||
waiting();
|
||||
});
|
||||
|
||||
function returnToRecords() {
|
||||
if (pendingView !== 'history' || !pendingRecord) return false;
|
||||
const records = content.querySelector('[data-module="records"]');
|
||||
if (!records) return false;
|
||||
const key = pendingRecord.flightKey;
|
||||
window.showModuleHeading('records');
|
||||
hide();
|
||||
records.onRecordsReturn?.();
|
||||
records.querySelector('[data-action="record-play"][data-id="' + CSS.escape(key) + '"]')?.focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
window.addEventListener('message', event => {
|
||||
if (event.origin !== location.origin || !frame || event.source !== frame.contentWindow) return;
|
||||
if (event.data?.type === 'rid-embedded-ready') {
|
||||
ready = true;
|
||||
clearTimeout(timer);
|
||||
status.hidden = retry.hidden = true;
|
||||
frame.hidden = false;
|
||||
navigate(pendingView);
|
||||
return;
|
||||
}
|
||||
if (!ready || container.hidden) return;
|
||||
if (event.data?.type === 'rid-embedded-return-records' && pendingView === 'history' && pendingRecord) {
|
||||
if (!returnToRecords()) window.openModule('records');
|
||||
return;
|
||||
}
|
||||
if (event.data?.type !== 'rid-embedded-view') return;
|
||||
const view = event.data.view;
|
||||
if (view === 'home') {
|
||||
window.closeModule();
|
||||
} else if (workbenchViews.has(view)) {
|
||||
pendingView = view;
|
||||
window.showModuleHeading(workbenchViews.get(view));
|
||||
frame.title = document.getElementById('moduleTitle').textContent;
|
||||
}
|
||||
});
|
||||
|
||||
window.ridModuleHost = Object.freeze({ show, hide, returnToRecords });
|
||||
})();
|
||||
@@ -0,0 +1,716 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
const { request, modelRules, resolveModel, roleLabel } = window.ridWorkbenchApi;
|
||||
const workbench = '/api/workbench';
|
||||
const receiverPath = '/api/receivers';
|
||||
const userPath = '/api/auth/users';
|
||||
const limit = 50;
|
||||
const transportNames = { serial: 'USB 串口', udp: 'UDP 监听', 'tcp-listen': 'TCP 监听' };
|
||||
const receiverFormat = format => !format || format === 'raw' ? 'rid-device-json' : format;
|
||||
const stateNames = {
|
||||
stopped: '已停用', 'serial-open': '串口已打开', 'udp-listening': 'UDP 监听中',
|
||||
'tcp-listening': 'TCP 监听中', connecting: '正在连接', disconnected: '连接中断'
|
||||
};
|
||||
function receiverState(row) {
|
||||
const status = row.status;
|
||||
if (!row.config.enabled) return '已停用';
|
||||
if (status.lastError) return status.lastError;
|
||||
if (status.state === 'tcp-listening') {
|
||||
if (!status.lastDataMs || Date.now() - status.lastDataMs > 15000) return '监听中 · 等待数据';
|
||||
return '接收中';
|
||||
}
|
||||
return stateNames[status.state] || '待机';
|
||||
}
|
||||
function receiverTone(row) {
|
||||
const { state, lastError, lastDataMs } = row.status;
|
||||
if (!row.config.enabled) return 'neutral';
|
||||
if (lastError || state === 'disconnected') return 'danger';
|
||||
if (/^(serial-open|udp-listening|tcp-listening)$/.test(state) &&
|
||||
lastDataMs && Date.now() - lastDataMs <= 15000) return 'ok';
|
||||
return 'neutral';
|
||||
}
|
||||
function receiverSource(row) {
|
||||
return row.status.lastPeerIp || (row.config.peerIp ? '未收到 · 已配置 ' + row.config.peerIp : '—');
|
||||
}
|
||||
const alertNames = Object.fromEntries(Object.entries(window.ridFlightStatus.types).map(([key,value])=>[key,value.label]));
|
||||
|
||||
const column = (label, key) => ({ label, key });
|
||||
const cell = (label, render) => ({ label, render });
|
||||
const time = value => value ? new Date(value).toLocaleString('zh-CN', { hour12: false }) : '—';
|
||||
const fixed = (value, digits) => Number.isFinite(value) ? value.toFixed(digits) : '—';
|
||||
const editorField = (label, control) => `<label>${label}${control}</label>`;
|
||||
const input = (name, value, props = '') =>
|
||||
`<input name="${name}" value="${escAttr(value)}" ${props}>`;
|
||||
const select = (name, entries, selected) => `<select name="${name}">${entries.map(([value, label]) =>
|
||||
`<option value="${escAttr(value)}" ${selected === value ? 'selected' : ''}>${esc(label)}</option>`
|
||||
).join('')}</select>`;
|
||||
const enabled = (name, value, label) =>
|
||||
`<label class="rid-check"><input type="checkbox" name="${name}" ${value ? 'checked' : ''}>${label}</label>`;
|
||||
const button = (label, action, id, danger = false) =>
|
||||
`<button type="button" class="smallBtn ${danger ? 'red' : ''}" data-action="${action}" data-id="${escAttr(id)}">${label}</button>`;
|
||||
const editorFooter = label => `<div class="btnrow"><button type="submit">${label}</button><button type="button" data-action="cancel-edit">取消</button></div>`;
|
||||
const toolbar = (left, right = '') => `<div class="rid-module-toolbar">${left}${right}</div>`;
|
||||
const section = (title, body) => `<section class="configGroup"><h3>${title}</h3>${body}</section>`;
|
||||
|
||||
const live = root => root.isConnected && activeModuleName === root.dataset.module;
|
||||
function feedback(root, message, error = false) {
|
||||
const el = root.querySelector('.flightPlanDialog[open] .planDialogFeedback') || root.querySelector('.rid-module-feedback');
|
||||
el.textContent = message;
|
||||
el.hidden = !message;
|
||||
el.classList.toggle('dangerText', error);
|
||||
}
|
||||
function run(root, control, operation) {
|
||||
if (!live(root) || control.disabled) return;
|
||||
control.disabled = true;
|
||||
feedback(root, '');
|
||||
Promise.resolve().then(operation).catch(error => {
|
||||
if (live(root)) feedback(root, error.message || '操作失败,请重试', true);
|
||||
}).finally(() => { control.disabled = false; });
|
||||
}
|
||||
function onForm(root, form, operation) {
|
||||
form.addEventListener('submit', event => {
|
||||
event.preventDefault();
|
||||
run(root, event.submitter || form.querySelector('button[type="submit"]'),
|
||||
() => operation(new FormData(form)));
|
||||
});
|
||||
}
|
||||
function onAction(root, action, operation) {
|
||||
for (const control of root.querySelectorAll(`[data-action="${action}"]`)) {
|
||||
control.onclick = () => run(root, control, () => operation(control.dataset.id, control));
|
||||
}
|
||||
}
|
||||
function editArea(root, body) {
|
||||
const pane = root.querySelector('.rid-module-editor');
|
||||
pane.innerHTML = body;
|
||||
if (body) pane.querySelector('input,select')?.focus();
|
||||
onAction(root, 'cancel-edit', () => editArea(root, ''));
|
||||
return pane.querySelector('form');
|
||||
}
|
||||
function body(root, html) {
|
||||
if (live(root)) root.querySelector('.rid-module-content').innerHTML = html;
|
||||
}
|
||||
|
||||
function managedTable(root, label, columns, rows, empty, pageSize = 20) {
|
||||
const offset = Math.min(root.pageOffset ?? 0, lastPageOffset(rows.length, pageSize));
|
||||
root.pageOffset = offset;
|
||||
return renderTable(columns, rows.slice(offset, offset + pageSize), empty)
|
||||
+ renderPager(label, offset, rows.length, pageSize);
|
||||
}
|
||||
|
||||
function bindManagedTable(root, reload) {
|
||||
bindPager(root, async (offset, direction) => {
|
||||
const previousOffset = root.pageOffset;
|
||||
root.pageOffset = offset;
|
||||
try {
|
||||
await reload();
|
||||
if (live(root)) {
|
||||
(root.querySelector(`[data-page-direction="${direction}"]:enabled`) || root.querySelector('.rid-page-number'))?.focus();
|
||||
}
|
||||
} catch (error) {
|
||||
root.pageOffset = previousOffset;
|
||||
if (live(root)) feedback(root, error.message || '换页失败,请重试', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function dates(withKeyword, right = '') {
|
||||
return `<form class="filterBar rid-period">
|
||||
${withKeyword ? editorField('关键字', input('q', '', 'maxlength="80" placeholder="UAS ID / 上报机型 / BSSID / 接收器"')) : ''}
|
||||
${editorField('开始时间', input('from', '', 'type="datetime-local" required'))}
|
||||
${editorField('结束时间', input('to', '', 'type="datetime-local" required'))}
|
||||
<button type="submit">查询</button>${right}
|
||||
</form><div class="moduleResult" aria-live="polite"></div>`;
|
||||
}
|
||||
|
||||
function dateForm(root, name) {
|
||||
const form = root.querySelector('.rid-period');
|
||||
const from = form.elements.from, to = form.elements.to;
|
||||
from.id = `${name}From`;
|
||||
to.id = `${name}To`;
|
||||
setDefaultModuleDates(from.id, to.id);
|
||||
return form;
|
||||
}
|
||||
|
||||
function period(values, offset = 0) {
|
||||
const fromMs = new Date(values.get('from')).getTime();
|
||||
const toMs = new Date(values.get('to')).getTime() + 59999;
|
||||
if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || fromMs > toMs) {
|
||||
throw new Error('请选择有效的开始和结束时间');
|
||||
}
|
||||
return new URLSearchParams({ fromMs, toMs, offset, limit, q: (values.get('q') || '').trim() });
|
||||
}
|
||||
|
||||
async function records(root) {
|
||||
body(root, dates(true));
|
||||
const form = dateForm(root, 'record');
|
||||
const result = root.querySelector('.moduleResult');
|
||||
let values = new FormData(form);
|
||||
let generation = 0;
|
||||
let refreshTimer;
|
||||
const query = (offset, activeRows) => {
|
||||
const params = period(values, offset);
|
||||
if (activeRows) {
|
||||
params.delete('q');
|
||||
params.set('flightKeys', activeRows.map(row => row.flightKey).join(','));
|
||||
}
|
||||
return request(`${workbench}/observations?${params}`);
|
||||
};
|
||||
const details = rules => [
|
||||
['UAS ID', row => row.targetId],
|
||||
['机型', row => resolveModel(row.targetId, row.model, rules) || '—'],
|
||||
['飞行状态', row => (row.flightStatuses?.length ? row.flightStatuses : ['unknown']).map(code=>window.ridFlightStatus.meta(code).label).join(' · ')],
|
||||
['开始时间', row => time(row.timeMs)],
|
||||
['结束时间', row => row.endMs == null ? '接收中' : time(row.endMs)],
|
||||
['BSSID', row => row.bssid || '—'],
|
||||
['RSSI / dBm', row => fixed(row.rssi, 1)],
|
||||
['高度 / m', row => fixed(row.altitudeM, 1)],
|
||||
['速度 / m/s', row => fixed(row.speedMps, 1)],
|
||||
['坐标', row => Number.isFinite(row.latitude) && Number.isFinite(row.longitude)
|
||||
? fixed(row.latitude, 6) + ', ' + fixed(row.longitude, 6) : '—'],
|
||||
['接收器', row => row.receiverId || '—']
|
||||
];
|
||||
|
||||
function refreshActiveRows(current, activeRows, columns) {
|
||||
clearTimeout(refreshTimer);
|
||||
if (!activeRows.size) return;
|
||||
refreshTimer = setTimeout(async () => {
|
||||
if (!live(root) || current !== generation) return;
|
||||
try {
|
||||
const data = await query(0, [...activeRows.values()].map(entry => entry.row));
|
||||
if (!live(root) || current !== generation) return;
|
||||
for (const row of data.entries) {
|
||||
const entry = activeRows.get(row.flightKey);
|
||||
if (!entry) continue;
|
||||
columns.forEach(([label, read], index) => {
|
||||
if (label === '飞行状态') {
|
||||
entry.cells[index].innerHTML = window.ridFlightStatus.tags(row.flightStatuses);
|
||||
return;
|
||||
}
|
||||
const value = read(row);
|
||||
if (entry.cells[index].textContent !== value) entry.cells[index].textContent = value;
|
||||
});
|
||||
Object.assign(entry.row, row);
|
||||
if (row.endMs != null) activeRows.delete(row.flightKey);
|
||||
}
|
||||
} catch {
|
||||
if (!live(root) || current !== generation) return;
|
||||
}
|
||||
refreshActiveRows(current, activeRows, columns);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
async function load(offset, focusAction) {
|
||||
clearTimeout(refreshTimer);
|
||||
const current = ++generation;
|
||||
result.innerHTML = '<div class="moduleEmpty">正在查询接收记录…</div>';
|
||||
try {
|
||||
const [page, rules] = await Promise.all([query(offset), modelRules().catch(() => [])]);
|
||||
if (!live(root) || current !== generation) return;
|
||||
const rows = page.entries;
|
||||
const columns = details(rules);
|
||||
const cols = [...columns.map(([label, read]) => cell(label, row => label==='飞行状态'?window.ridFlightStatus.tags(row.flightStatuses):esc(read(row)))),
|
||||
cell('操作', row => button('回放轨迹', 'record-play', row.flightKey))];
|
||||
const lastOffset = lastPageOffset(page.total, limit);
|
||||
if (offset > lastOffset) return load(lastOffset, focusAction);
|
||||
result.innerHTML = `<div class="resultCount">共 ${page.total} 条记录</div>
|
||||
${renderTable(cols, rows, '该时段无接收记录')}
|
||||
${renderPager('记录分页', offset, page.total, limit)}`;
|
||||
const activeRows = new Map();
|
||||
const recordsByKey = new Map();
|
||||
const visibleRows = result.querySelectorAll('tbody tr');
|
||||
rows.forEach((row, index) => {
|
||||
const tr = visibleRows[index];
|
||||
tr.querySelector('[data-action="record-play"]').setAttribute('aria-label', row.targetId + ' 的轨迹回放');
|
||||
recordsByKey.set(row.flightKey, row);
|
||||
if (row.endMs == null) activeRows.set(row.flightKey, {row, cells: tr.cells});
|
||||
});
|
||||
onAction(root, 'record-play', key => openModule('history', recordsByKey.get(key)));
|
||||
root.onRecordsReturn = () => refreshActiveRows(current, activeRows, columns);
|
||||
refreshActiveRows(current, activeRows, columns);
|
||||
bindPager(result, (next, direction) => load(next, direction).catch(error => {
|
||||
if (live(root)) feedback(root, error.message || '换页失败,请重试', true);
|
||||
}), focusAction);
|
||||
} catch (error) {
|
||||
if (live(root) && current === generation) result.innerHTML = '<div class="moduleEmpty">查询未完成,可调整条件后重试。</div>';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
onForm(root, form, async data => { values = data; await load(0); });
|
||||
await load(0);
|
||||
}
|
||||
|
||||
async function rankings(root) {
|
||||
body(root, dates(false));
|
||||
const form = dateForm(root, 'rank');
|
||||
const result = root.querySelector('.moduleResult');
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const trackStats = request('/api/history/summary?fromMs=' + today.getTime()).catch(() => null);
|
||||
async function load(values) {
|
||||
const params = period(values);
|
||||
result.innerHTML = '<div class="moduleEmpty">正在统计…</div>';
|
||||
try {
|
||||
const [targets, models, receivers, alarms, devices, tracks, flightStates] = await Promise.all([
|
||||
...['target', 'model', 'receiver'].map(dim => request(`${workbench}/rankings?${params}&dimension=${dim}`)),
|
||||
request(`/api/monitoring/rankings?${params}`),
|
||||
request(receiverPath),
|
||||
trackStats,
|
||||
request(`${workbench}/rankings?${params}&dimension=flight_status`)
|
||||
]);
|
||||
if (!live(root)) return;
|
||||
const names = new Map(devices.receivers.map(item => [item.id, item.name]));
|
||||
const rows = (data, labels) => data.entries.map((row, index) => ({
|
||||
...row, rank: index + 1, name: labels?.get(row.name) || row.name
|
||||
}));
|
||||
const groups = [
|
||||
['目标排行', rows(targets)], ['上报机型排行', rows(models)],
|
||||
['设备 / 链路贡献', rows(receivers, names)],
|
||||
['告警类型', rows(alarms, new Map(Object.entries(alertNames))), '次数'],
|
||||
['飞行状态(本次最高告警级别)', rows(flightStates, new Map(Object.entries(alertNames))), '飞行次数']
|
||||
];
|
||||
result.innerHTML = `${tracks ? `<p class="resultCount">今日轨迹点 ${Number(tracks.since).toLocaleString('zh-CN')} · 累计 ${Number(tracks.total).toLocaleString('zh-CN')}</p>` : ''}
|
||||
<div class="moduleSplit">${groups.map(([label]) => `<section><h3>${label}</h3><div></div></section>`).join('')}</div>`;
|
||||
result.querySelectorAll('.moduleSplit section > div').forEach((table, index) => {
|
||||
const [label, ranking, countLabel = '接收记录'] = groups[index];
|
||||
const pageSize = 10;
|
||||
const cols = [column('名次', 'rank'), column('名称', 'name'), column(countLabel, 'count')];
|
||||
function display(offset, direction) {
|
||||
table.innerHTML = renderTable(cols, ranking.slice(offset, offset + pageSize), '该时段无统计数据')
|
||||
+ (ranking.length > pageSize ? renderPager(label + '分页', offset, ranking.length, pageSize) : '');
|
||||
bindPager(table, display, direction);
|
||||
}
|
||||
display(0);
|
||||
});
|
||||
} catch (error) {
|
||||
if (live(root)) result.innerHTML = '<div class="moduleEmpty">统计未完成,可重新查询。</div>';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
onForm(root, form, load);
|
||||
await load(new FormData(form));
|
||||
}
|
||||
|
||||
async function settings(root, admin) {
|
||||
const current = await request(`${workbench}/settings`);
|
||||
if (!live(root)) return;
|
||||
body(root, section('平台信息与告警', `<form class="rid-admin-form rid-config-form">
|
||||
<fieldset ${admin ? '' : 'disabled'}>
|
||||
${editorField('平台名称', input('name', current.name, 'required maxlength="60"'))}
|
||||
<div class="rid-config-options">
|
||||
${enabled('sound', current.sound, '声音报警')}
|
||||
${enabled('flash', current.flash, '告警闪屏')}
|
||||
</div>
|
||||
${editorField('告警闪屏时长(秒)', input('flashSeconds', current.flashSeconds ?? 10, 'type="number" min="1" max="60" step="1" required'))}
|
||||
${admin ? '<button type="submit">保存平台设置</button>' : ''}
|
||||
</fieldset>
|
||||
</form>`));
|
||||
if (!admin) return;
|
||||
let savedSettings = current;
|
||||
const configForm = root.querySelector('.rid-config-form');
|
||||
onForm(root, configForm, async data => {
|
||||
savedSettings = await request(`${workbench}/settings`, 'PUT', {
|
||||
...savedSettings, name: data.get('name'),
|
||||
sound: data.has('sound'), flash: data.has('flash'), flashSeconds: Number(data.get('flashSeconds'))
|
||||
});
|
||||
if (!live(root)) return;
|
||||
configForm.elements.name.value = savedSettings.name;
|
||||
applyPlatformSettings(savedSettings);
|
||||
feedback(root, '平台设置已保存。');
|
||||
});
|
||||
}
|
||||
|
||||
const deviceListKey = data => JSON.stringify([data.receivers.map(row => row.id), data.discovery]);
|
||||
const deviceEditorOpen = root => root.querySelector('.rid-module-editor form, button[data-action]:disabled');
|
||||
|
||||
function refreshReceiverStatus(root, rows) {
|
||||
const byId = new Map(rows.map(row => [row.id, row]));
|
||||
for (const source of root.querySelectorAll('[data-rx-source]')) {
|
||||
const row = byId.get(source.dataset.rxSource);
|
||||
const tableRow = source.closest('tr');
|
||||
if (!row || !tableRow) continue;
|
||||
const status = tableRow.querySelector('[data-rx-status]');
|
||||
for (const [cell, value] of [[source, receiverSource(row)], [status, receiverState(row)],
|
||||
[tableRow.querySelector('[data-rx-time]'), time(row.status.lastDataMs)]]) {
|
||||
if (cell.textContent !== value) cell.textContent = value;
|
||||
}
|
||||
status.className = 'stateTag ' + receiverTone(row);
|
||||
}
|
||||
}
|
||||
|
||||
function watchDevices(root, admin) {
|
||||
async function poll() {
|
||||
if (!live(root)) return;
|
||||
try {
|
||||
if (document.hidden || deviceEditorOpen(root)) return;
|
||||
const data = await request(receiverPath);
|
||||
if (live(root) && !deviceEditorOpen(root)) {
|
||||
if (deviceListKey(data) !== root.receiverListKey) await devices(root, admin, '', data);
|
||||
else refreshReceiverStatus(root, data.receivers);
|
||||
}
|
||||
} catch (_) {
|
||||
// The next poll or a manual refresh can recover from a temporary failure.
|
||||
} finally {
|
||||
if (live(root)) setTimeout(poll, 2000);
|
||||
}
|
||||
}
|
||||
setTimeout(poll, 2000);
|
||||
}
|
||||
|
||||
async function devices(root, admin, notice = '', snapshot) {
|
||||
const [data, ports] = await Promise.all([
|
||||
snapshot || request(receiverPath), admin ? request('/api/receiver/ports') : { ports: [] }
|
||||
]);
|
||||
if (!live(root) || (snapshot && deviceEditorOpen(root))) return;
|
||||
const focused = snapshot && root.contains(document.activeElement) ? document.activeElement.dataset : null;
|
||||
root.receiverListKey = deviceListKey(data);
|
||||
const discovery = (data.discovery || []).map(entry => {
|
||||
const state = entry.error || (entry.listening ? '监听中 · 等待新设备' : '正在启动');
|
||||
return toolbar('<span>TCP 自动登记入口 <strong>' + esc(entry.endpoint) + '</strong> · ' +
|
||||
esc(state) + '</span>', admin ? button('取消保留', 'disable-discovery', entry.endpoint) : '');
|
||||
}).join('');
|
||||
body(root, toolbar(admin ? button('新增接收器', 'add-rx', '') : '',
|
||||
button('刷新', 'refresh-rx', '') + '<span class="muted">TCP 监听开启后,有效报文会自动登记新设备。</span>') +
|
||||
discovery + '<div class="rid-module-editor"></div>' +
|
||||
`<div class="resultCount">共 ${data.receivers.length} 台 / 32 台</div>` +
|
||||
managedTable(root, '接收器列表分页', [
|
||||
cell('设备名称', r => esc(r.name) + (r.networkDiscovered ? ' <small class="muted">自动登记</small>' : '')),
|
||||
cell('标识', r => esc(r.hardwareId || r.id)),
|
||||
cell('接入方式', r => esc(transportNames[r.config.transport])),
|
||||
cell('接收端点', r => esc(r.config.transport === 'serial' ? r.config.serialPort :
|
||||
`${r.config.bindIp}:${r.config.port}`)),
|
||||
cell('来源 IP', r => '<span data-rx-source="' + escAttr(r.id) + '">' + esc(receiverSource(r)) + '</span>'),
|
||||
cell('安装位置', r => esc(r.location ?? r.devicePlace)),
|
||||
column('备注', 'note'),
|
||||
cell('状态', r => '<span data-rx-status class="stateTag ' + receiverTone(r) + '">' + esc(receiverState(r)) + '</span>'),
|
||||
cell('最后接收', r => '<span data-rx-time>' + esc(time(r.status.lastDataMs)) + '</span>'),
|
||||
...(admin ? [cell('操作', r => button('编辑', 'edit-rx', r.id) + button(r.config.enabled ? '停用' : '启用', 'toggle-rx', r.id) +
|
||||
button('删除', 'delete-rx', r.id, true))] : [])
|
||||
], data.receivers, '暂无接收器', 12));
|
||||
bindManagedTable(root, () => devices(root, admin));
|
||||
if (focused?.action) {
|
||||
const action = CSS.escape(focused.action);
|
||||
const id = CSS.escape(focused.id ?? '');
|
||||
root.querySelector(`[data-action="${action}"][data-id="${id}"]`)?.focus({preventScroll:true});
|
||||
}
|
||||
feedback(root, data.error || notice, Boolean(data.error));
|
||||
onAction(root, 'refresh-rx', () => devices(root, admin));
|
||||
onAction(root, 'disable-discovery', async endpoint => {
|
||||
if (!confirm('取消保留 ' + endpoint + '?该端点没有启用的接收器时会停止监听。')) return;
|
||||
await request('/api/receiver/discovery', 'PUT', { endpoint, enabled: false });
|
||||
if (live(root)) await devices(root, admin, '已取消保留此 TCP 入口。');
|
||||
});
|
||||
const edit = item => {
|
||||
const c = item?.config || { transport: 'serial', format: 'rid-device-json', uidIdentity: 'source-scoped', baudRate: 115200, bindIp: '127.0.0.1', port: 8788 };
|
||||
const portList = `<datalist id="rid-board-ports">${ports.ports.map(port => `<option value="${escAttr(port)}"></option>`).join('')}</datalist>`;
|
||||
const form = editArea(root, section(item ? '编辑接收器' : '新增接收器', `<form class="rid-admin-form">
|
||||
${editorField('设备名称', input('name', item?.name, 'required maxlength="120"'))}
|
||||
${editorField('接入方式', select('transport', Object.entries(transportNames), c.transport))}
|
||||
<div data-rx-group="serial" class="rid-admin-fields">
|
||||
${editorField('COM 串口', input('serialPort', c.serialPort, 'list="rid-board-ports" maxlength="12"'))}
|
||||
${editorField('波特率', input('baudRate', c.baudRate, 'type="number" min="1200" max="4000000" required'))}
|
||||
</div>
|
||||
<div data-rx-group="network" class="rid-admin-fields">
|
||||
${editorField('监听 IP(本机网卡地址)', input('bindIp', c.bindIp, 'required maxlength="45"'))}
|
||||
${editorField('监听端口', input('port', c.port, 'type="number" min="1" max="65535" required'))}
|
||||
</div>
|
||||
<div data-rx-group="peer">
|
||||
${editorField('允许来源 IP(设备地址,可留空)', input('peerIp', c.peerIp, 'maxlength="45" placeholder="例如 192.168.1.200"'))}
|
||||
</div>
|
||||
<div data-rx-group="identity">
|
||||
${editorField('UID 归并', select('uidIdentity', [['source-scoped', '按接收源区分'], ['global-device', '按设备 UID 合并']], c.uidIdentity))}
|
||||
</div>
|
||||
${editorField('安装位置', input('location', item?.location ?? item?.devicePlace, 'maxlength="160"'))}
|
||||
${editorField('备注', input('note', item?.note, 'maxlength="160"'))}
|
||||
${enabled('enabled', c.enabled, '立即启用')}
|
||||
${portList}${editorFooter('保存设备')}
|
||||
</form>`));
|
||||
const toggleFields = () => {
|
||||
const transport = form.elements.transport.value;
|
||||
const serial = transport === 'serial';
|
||||
const uid = c.format === 'uid-json';
|
||||
for (const [group, visible] of [['serial', serial], ['network', !serial], ['peer', transport === 'tcp-listen'], ['identity', uid]]) {
|
||||
const scope = form.querySelector(`[data-rx-group="${group}"]`);
|
||||
scope.hidden = !visible;
|
||||
scope.querySelectorAll('input,select').forEach(control => { control.disabled = !visible; });
|
||||
}
|
||||
};
|
||||
form.elements.transport.onchange = toggleFields;
|
||||
toggleFields();
|
||||
onForm(root, form, async values => {
|
||||
const config = { ...c, enabled: values.has('enabled'), transport: values.get('transport'), format: receiverFormat(c.format) };
|
||||
if (values.has('serialPort')) {
|
||||
config.serialPort = values.get('serialPort').trim().toUpperCase();
|
||||
config.baudRate = Number(values.get('baudRate'));
|
||||
} else {
|
||||
config.bindIp = values.get('bindIp').trim();
|
||||
config.port = Number(values.get('port'));
|
||||
}
|
||||
config.peerIp = values.get('peerIp')?.trim() || null;
|
||||
if (values.has('uidIdentity')) config.uidIdentity = values.get('uidIdentity');
|
||||
await request(item ? `${receiverPath}/${encodeURIComponent(item.id)}` : receiverPath, item ? 'PUT' : 'POST', {
|
||||
name: values.get('name').trim(), config, location: values.get('location'), note: values.get('note')
|
||||
});
|
||||
if (live(root)) await devices(root, admin, '设备已保存。');
|
||||
});
|
||||
};
|
||||
const find = id => data.receivers.find(item => item.id === id);
|
||||
onAction(root, 'add-rx', () => edit(null));
|
||||
onAction(root, 'edit-rx', id => edit(find(id)));
|
||||
onAction(root, 'toggle-rx', async id => {
|
||||
const path = `${receiverPath}/${encodeURIComponent(id)}`;
|
||||
const item = await request(path);
|
||||
const config = { ...item.config, enabled: !item.config.enabled };
|
||||
if (config.enabled) config.format = receiverFormat(config.format);
|
||||
await request(path, 'PUT', { name: item.name, config });
|
||||
if (live(root)) await devices(root, admin, item.config.enabled ? '接收器已停用。' : '已保存启用设置,实际接收状态见下方。');
|
||||
});
|
||||
onAction(root, 'delete-rx', async id => {
|
||||
const receiver = find(id);
|
||||
const consequence = receiver.status.state === 'tcp-listening' && receiver.config.format === 'rid-device-json'
|
||||
? ' TCP 入口会继续接收,设备重新推送有效数据时会再次登记。' : '';
|
||||
if (!confirm('删除接收器「' + receiver.name + '」?已保存的接收记录会保留。' + consequence)) return;
|
||||
await request(`${receiverPath}/${encodeURIComponent(id)}`, 'DELETE');
|
||||
if (live(root)) await devices(root, admin, '设备已删除。');
|
||||
});
|
||||
}
|
||||
|
||||
const modelFields = [['serial', 'SN 前缀'], ['target', 'UAS ID'], ['model', '上报机型']];
|
||||
const modelFieldNames = Object.fromEntries(modelFields);
|
||||
|
||||
async function models(root, admin, notice = '') {
|
||||
const entries = await modelRules(true);
|
||||
if (!live(root)) return;
|
||||
body(root, toolbar(admin ? button('新增型号规则', 'add-model', '') : '',
|
||||
'<span>SN 从首位匹配,忽略大小写。多个前缀命中时取最长的一条。</span>') +
|
||||
'<div class="rid-module-editor"></div>' +
|
||||
'<div class="resultCount">共 ' + entries.length + ' 条规则</div>' +
|
||||
managedTable(root, '型号库分页', [
|
||||
cell('匹配字段', r => esc(modelFieldNames[r.field] || r.field)),
|
||||
column('关键字', 'pattern'), column('厂商', 'vendor'), column('机型', 'model'), column('备注', 'note'),
|
||||
cell('状态', r => r.enabled ? '<span class="stateTag ok">已启用</span>' : '<span class="stateTag neutral">已停用</span>'),
|
||||
...(admin ? [cell('操作', r => button('编辑', 'edit-model', r.id) + button('删除', 'delete-model', r.id, true))] : [])
|
||||
], entries, '暂无本地型号规则'));
|
||||
bindManagedTable(root, () => models(root, admin));
|
||||
feedback(root, notice);
|
||||
const edit = item => {
|
||||
const form = editArea(root, section(item ? '编辑型号规则' : '新增型号规则', `<form class="rid-admin-form">
|
||||
${editorField('匹配字段', select('field', modelFields, item?.field || 'serial'))}
|
||||
${editorField('前缀 / 关键字', input('pattern', item?.pattern, 'required maxlength="80"'))}
|
||||
${editorField('厂商', input('vendor', item?.vendor, 'maxlength="60"'))}
|
||||
${editorField('显示机型', input('model', item?.model, 'required maxlength="80"'))}
|
||||
${editorField('备注', input('note', item?.note, 'maxlength="200"'))}
|
||||
${enabled('enabled', item?.enabled ?? true, '启用规则')}${editorFooter('保存规则')}
|
||||
</form>`));
|
||||
onForm(root, form, async values => {
|
||||
const data = Object.fromEntries(values);
|
||||
data.enabled = values.has('enabled');
|
||||
await request(`${workbench}/models${item ? '/' + item.id : ''}`, item ? 'PUT' : 'POST', data);
|
||||
if (live(root)) await models(root, admin, '型号规则已保存。');
|
||||
});
|
||||
};
|
||||
onAction(root, 'add-model', () => edit(null));
|
||||
onAction(root, 'edit-model', id => edit(entries.find(item => item.id === Number(id))));
|
||||
onAction(root, 'delete-model', async id => {
|
||||
if (!confirm('删除这条型号规则?')) return;
|
||||
await request(`${workbench}/models/${id}`, 'DELETE');
|
||||
if (live(root)) await models(root, admin, '型号规则已删除。');
|
||||
});
|
||||
}
|
||||
|
||||
async function users(root, admin, notice = '') {
|
||||
if (!admin) {
|
||||
body(root, '<div class="moduleEmpty">仅管理员可管理用户。</div>');
|
||||
return;
|
||||
}
|
||||
const { entries } = await request(userPath);
|
||||
if (!live(root)) return;
|
||||
body(root, toolbar(button('新增用户', 'add-user', '')) +
|
||||
'<div class="rid-module-editor"></div>' +
|
||||
`<div class="resultCount">共 ${entries.length} 个账号</div>` +
|
||||
managedTable(root, '用户管理分页', [
|
||||
column('用户名', 'username'), cell('角色', r => esc(roleLabel(r.role))),
|
||||
cell('状态', r => r.enabled ? '启用' : '停用'),
|
||||
cell('操作', r => r.id === 0 ? '初始管理员' : button('编辑', 'edit-user', r.id) + button('删除', 'delete-user', r.id, true))
|
||||
], entries));
|
||||
bindManagedTable(root, () => users(root, admin));
|
||||
feedback(root, notice);
|
||||
const edit = item => {
|
||||
const form = editArea(root, section(item ? '编辑用户' : '新增用户', `<form class="rid-admin-form">
|
||||
${editorField('用户名', input('username', item?.username, item ? 'readonly' : 'required maxlength="40" autocomplete="off"'))}
|
||||
${editorField(item ? '新密码(留空保留原密码)' : '密码', input('password', '', `type="password" autocomplete="new-password" minlength="10" maxlength="256" ${item ? '' : 'required'}`))}
|
||||
${editorField('角色', select('role', [['viewer', '只读用户'], ['operator', '操作员']], item?.role))}
|
||||
${item ? enabled('enabled', item.enabled, '启用账号') : ''}
|
||||
${editorFooter('保存用户')}
|
||||
</form><p class="fusionNote">操作员可登记设备、维护名单和防控区、处置告警。只读用户可查看业务页面。</p>`));
|
||||
onForm(root, form, async values => {
|
||||
const password = values.get('password');
|
||||
const role = values.get('role');
|
||||
if (item) {
|
||||
await request(`${userPath}/${item.id}`, 'PUT', { password: password || null, role, enabled: values.has('enabled') });
|
||||
} else {
|
||||
await request(userPath, 'POST', { username: values.get('username'), password, role });
|
||||
}
|
||||
if (live(root)) await users(root, admin, '用户已保存。');
|
||||
});
|
||||
};
|
||||
onAction(root, 'add-user', () => edit(null));
|
||||
onAction(root, 'edit-user', id => edit(entries.find(item => item.id === Number(id))));
|
||||
onAction(root, 'delete-user', async id => {
|
||||
if (!confirm('删除此用户并退出其会话?')) return;
|
||||
await request(`${userPath}/${id}`, 'DELETE');
|
||||
if (live(root)) await users(root, admin, '用户已删除。');
|
||||
});
|
||||
}
|
||||
|
||||
async function flightPlans(root, admin, seed) {
|
||||
const account = await request('/api/auth/status');
|
||||
const editable = ['admin','operator'].includes(account.role);
|
||||
const [snapshot, archive] = await Promise.all([request('/api/flight-plans'),request('/api/records')]);
|
||||
if (!live(root)) return;
|
||||
let entries = snapshot.entries;
|
||||
const records = new Map(archive.records.map(r=>[r.id,r]));
|
||||
const names = p => records.get(p.recordId) || {};
|
||||
let keyword='', statusFilter='';
|
||||
const state = p => !p.enabled ? ['撤销','muted','cancelled'] : p.endMs<=Date.now() ? ['已过期','muted','expired']
|
||||
: p.approval==='rejected' ? ['已驳回','danger','rejected'] : p.approval!=='approved' ? ['待审批','warning','pending']
|
||||
: p.startMs>Date.now() ? ['已批准 · 未开始','white','approved'] : ['已批准 · 生效中','ok','active'];
|
||||
body(root, toolbar(`${editable?button('新增飞行报备','new-plan',''):''}${button('刷新','refresh-plans','')}<input class="planSearch" aria-label="搜索飞行报备" placeholder="搜索 SN、机型或报备名称"><label>状态 ${select('plan-filter',[['','全部'],['pending','待审批'],['approved','已批准 · 未开始'],['active','生效中'],['rejected','已驳回'],['expired','已过期'],['cancelled','已撤销']],'')}</label>`)
|
||||
+'<div class="rid-module-editor"></div><div class="planResults"></div>');
|
||||
const result=root.querySelector('.planResults');
|
||||
function geometryText(g) {return g.type==='circle' ? `圆形 · 半径 ${g.radius_m} m` : `多边形 · ${g.vertices.length} 个顶点`;}
|
||||
function render() {
|
||||
const rows=entries.filter(p=>(!statusFilter||state(p)[2]===statusFilter)&&[p.name,names(p).serialNo,names(p).modelName].join(' ').toLowerCase().includes(keyword))
|
||||
.sort((a,b)=>Number(state(b)[2]==='pending')-Number(state(a)[2]==='pending')||b.startMs-a.startMs);
|
||||
result.innerHTML=managedTable(root,'飞行报备分页',[
|
||||
cell('飞机',p=>`<strong>${esc(names(p).modelName||'未填写机型')}</strong><br><code>${esc(names(p).serialNo||'档案已移除')}</code>`),
|
||||
column('报备名称','name'),cell('飞行时段',p=>`${esc(time(p.startMs))}<br>${esc(time(p.endMs))}`),
|
||||
cell('允许区域',p=>esc(geometryText(p.geometry))),
|
||||
cell('状态',p=>{const [label,tone]=state(p);return `<span class="flightTag ${tone}">${label}</span>`;}),
|
||||
cell('审批',p=>`${esc(p.reviewedBy||'—')}${p.reviewNote?'<br>'+esc(p.reviewNote):''}`),
|
||||
cell('操作',p=>button('详情','detail-plan',p.id)+(editable?button('编辑','edit-plan',p.id):'')
|
||||
+(admin&&state(p)[2]==='pending'?button('审批','review-plan',p.id):'')
|
||||
+(editable&&p.enabled?button('撤销','cancel-plan',p.id,true):''))
|
||||
],rows,'暂无匹配的飞行报备');
|
||||
bindManagedTable(root,render);
|
||||
onAction(root,'detail-plan',id=>details(entries.find(p=>p.id===id)));
|
||||
onAction(root,'edit-plan',id=>edit(entries.find(p=>p.id===id)));
|
||||
onAction(root,'review-plan',id=>review(entries.find(p=>p.id===id)));
|
||||
onAction(root,'cancel-plan',async id=>{
|
||||
if (!confirm('撤销后该报备将不再允许飞行,确认撤销?')) return;
|
||||
const plan=entries.find(p=>p.id===id);
|
||||
await request('/api/flight-plans/'+encodeURIComponent(id),'PUT',{...plan,enabled:false});await reload();
|
||||
});
|
||||
}
|
||||
async function reload(){entries=(await request('/api/flight-plans')).entries;if(live(root)){editArea(root,'');render();}}
|
||||
function details(p){
|
||||
editArea(root,section('报备详情',`<dl class="planDetails"><dt>飞机</dt><dd>${esc(names(p).modelName)} · ${esc(names(p).serialNo)}</dd><dt>时间</dt><dd>${esc(time(p.startMs))} — ${esc(time(p.endMs))}</dd><dt>区域(经度,纬度)</dt><dd><pre>${esc((p.geometry.type==='circle'?[p.geometry.center]:p.geometry.vertices).map(v=>v.join(', ')).join('\n'))}</pre>${esc(geometryText(p.geometry))}</dd><dt>备注</dt><dd>${esc(p.note||'—')}</dd><dt>审批</dt><dd>${esc(state(p)[0])} · ${esc(p.reviewedBy||'—')} · ${esc(time(p.reviewedAtMs))}<br>${esc(p.reviewNote)}</dd></dl><button type="button" data-action="cancel-edit">关闭</button>`));
|
||||
}
|
||||
function review(p){
|
||||
const form=editArea(root,`<form class="configGroup planReviewForm"><h3>审批 ${esc(p.name)}</h3><p>${esc(names(p).serialNo)} · ${esc(time(p.startMs))} 至 ${esc(time(p.endMs))}</p><p>${esc(geometryText(p.geometry))}</p><pre>${esc((p.geometry.type==='circle'?[p.geometry.center]:p.geometry.vertices).map(v=>v.join(', ')).join('\n'))}</pre>
|
||||
${editorField('审批结果',select('decision',[['approve','批准'],['reject','驳回']],'approve'))}
|
||||
${editorField('审批意见', '<textarea name="note" maxlength="500" rows="2" placeholder="驳回时必填"></textarea>')}${editorFooter('提交审批结果')}</form>`);
|
||||
onForm(root,form,async data=>{
|
||||
await request('/api/flight-plans/'+encodeURIComponent(p.id)+'/approval','PUT',{approved:data.get('decision')==='approve',expectedRevision:p.revision,note:data.get('note')});
|
||||
await reload();feedback(root,'审批结果已保存。');
|
||||
});
|
||||
}
|
||||
function planEditor(html) {
|
||||
editArea(root,'');
|
||||
root.querySelector('.flightPlanDialog')?.remove();
|
||||
const trigger=document.activeElement;
|
||||
const modal=document.createElement('dialog');
|
||||
modal.className='flightPlanDialog';
|
||||
modal.setAttribute('aria-labelledby','flight-plan-dialog-title');
|
||||
modal.innerHTML=html;
|
||||
const form=modal.querySelector('form');
|
||||
const heading=form.querySelector('h3');
|
||||
heading.id='flight-plan-dialog-title';
|
||||
const closeButton=document.createElement('button');
|
||||
closeButton.type='button';closeButton.className='planDialogClose';
|
||||
closeButton.setAttribute('aria-label','关闭飞行报备弹窗');closeButton.textContent='×';
|
||||
form.querySelector('.planFormHeader').append(closeButton);
|
||||
const notice=document.createElement('div');
|
||||
notice.className='rid-module-feedback planDialogFeedback';
|
||||
notice.setAttribute('role','alert');notice.hidden=true;
|
||||
form.querySelector('.planFormHeader').after(notice);
|
||||
const close=()=>{
|
||||
if(form.querySelector('button[type="submit"]').disabled) return;
|
||||
modal.close();modal.remove();
|
||||
if(trigger?.isConnected) trigger.focus();
|
||||
else root.querySelector('[data-action="new-plan"]')?.focus();
|
||||
};
|
||||
closeButton.onclick=close;
|
||||
form.querySelector('[data-action="cancel-edit"]').onclick=close;
|
||||
modal.addEventListener('cancel',event=>{event.preventDefault();close();});
|
||||
root.append(modal);modal.showModal();
|
||||
form.querySelector('select,input')?.focus();
|
||||
return form;
|
||||
}
|
||||
function edit(p, recordId) {
|
||||
if (!editable) return;
|
||||
if (!records.size) {feedback(root,'请先在设备登记中登记飞机。',true);return;}
|
||||
const g=p?.geometry||{type:'circle',center:[],radius_m:500};
|
||||
const form=planEditor(`<form class="configGroup flightPlanForm"><header class="planFormHeader"><h3>${p?'修改飞行报备':'新增飞行报备'}</h3><p class="muted">提交后需管理员审批;修改已批准报备后需要重新审批。坐标使用 WGS84。</p></header><div class="planEditorColumns"><section class="planFieldGroup"><h4>飞行信息</h4><div class="planFormGrid">
|
||||
${editorField('登记飞机',select('recordId',[['','请选择登记飞机'],...archive.records.map(r=>[r.id,`${r.serialNo} · ${r.modelName||'未填写机型'}`])],p?.recordId||recordId||''))}
|
||||
${editorField('报备名称',input('name',p?.name||'','required maxlength="80"'))}
|
||||
${editorField('开始时间',input('start',p?toDatetimeLocalValue(new Date(p.startMs)):toDatetimeLocalValue(new Date()),'type="datetime-local" required'))}
|
||||
${editorField('结束时间',input('end',p?toDatetimeLocalValue(new Date(p.endMs)):toDatetimeLocalValue(new Date(Date.now()+3600000)),'type="datetime-local" required'))}
|
||||
</div>${editorField('备注','<textarea name="note" rows="3" maxlength="500" placeholder="选填飞行用途或补充说明">'+esc(p?.note||'')+'</textarea>')}</section><section class="planFieldGroup"><h4>允许飞行区域</h4><div class="planFormGrid">
|
||||
${editorField('区域形状',select('shape',[['circle','圆形'],['polygon','多边形']],g.type))}
|
||||
${editorField('圆形半径(米)',input('radius',g.radius_m||500,'type="number" min="1" max="1000000" step="any"'))}
|
||||
</div>${editorField('允许飞行区域坐标(经度,纬度)',`<textarea name="coordinates" rows="4" required spellcheck="false" placeholder="118.576700, 31.954800">${esc((g.type==='circle'?(g.center.length?[g.center]:[]):g.vertices).map(v=>v.join(', ')).join('\n'))}</textarea>`)}
|
||||
<p class="muted">圆形填写一行中心坐标;多边形每行一个顶点,按边界顺序填写,至少三个点。</p>
|
||||
</section></div>${editorFooter('提交报备')}</form>`);
|
||||
const updateShape=()=>{form.elements.radius.disabled=form.elements.shape.value!=='circle';form.elements.radius.required=!form.elements.radius.disabled;};
|
||||
form.elements.shape.onchange=updateShape;updateShape();form.elements.recordId.required=true;
|
||||
onForm(root,form,async data=>{
|
||||
const coords=String(data.get('coordinates')).trim().split(/\r?\n/).filter(line=>line.trim()).map(line=>line.trim().split(/[,,\s]+/).map(Number));
|
||||
if (coords.some(v=>v.length!==2||!v.every(Number.isFinite)||Math.abs(v[0])>180||Math.abs(v[1])>90)) throw new Error('每行请填写有效的经度、纬度');
|
||||
const circle=data.get('shape')==='circle';
|
||||
if (circle?coords.length!==1:coords.length<3) throw new Error(circle?'圆形只需一行中心坐标':'多边形至少需要三个顶点');
|
||||
const startMs=new Date(data.get('start')).getTime(),endMs=new Date(data.get('end')).getTime();
|
||||
if (!Number.isFinite(startMs)||!Number.isFinite(endMs)||startMs>=endMs||endMs<=Date.now()) throw new Error('结束时间须晚于开始时间和当前时间');
|
||||
const id=p?.id||'plan-'+crypto.randomUUID();
|
||||
await request('/api/flight-plans/'+encodeURIComponent(id),'PUT',{id,recordId:data.get('recordId'),name:data.get('name'),startMs,endMs,
|
||||
geometry:circle?{type:'circle',center:coords[0],radius_m:Number(data.get('radius'))}:{type:'polygon',vertices:coords},note:data.get('note'),enabled:true,revision:p?.revision||0});
|
||||
const modal=form.closest('dialog');
|
||||
modal.close();modal.remove();
|
||||
root.querySelector('[data-action="new-plan"]')?.focus();
|
||||
await reload();feedback(root,'报备已提交,等待管理员审批。');
|
||||
});
|
||||
}
|
||||
root.querySelector('.planSearch').oninput=event=>{keyword=event.target.value.trim().toLowerCase();root.pageOffset=0;render();};
|
||||
root.querySelector('[name="plan-filter"]').onchange=event=>{statusFilter=event.target.value;root.pageOffset=0;render();};
|
||||
onAction(root,'new-plan',()=>edit());
|
||||
onAction(root,'refresh-plans',()=>reload());
|
||||
render();if(seed?.recordId) edit(null,seed.recordId);
|
||||
}
|
||||
|
||||
const pages = {
|
||||
records, rankings, devices, models, users,
|
||||
"flight-plans": flightPlans,
|
||||
configs: settings
|
||||
};
|
||||
window.ridWorkbenchModules = Object.freeze({
|
||||
async open(name, seed) {
|
||||
const root = document.createElement('div');
|
||||
root.className = 'rid-module-page';
|
||||
root.dataset.module = name;
|
||||
root.innerHTML = '<div class="rid-module-feedback" role="status" hidden></div><div class="rid-module-content"><div class="moduleEmpty">正在加载数据…</div></div>';
|
||||
document.getElementById('moduleBody').replaceChildren(root);
|
||||
try {
|
||||
const account = await request('/api/auth/status');
|
||||
if (!live(root)) return;
|
||||
if (!account.authenticated) return location.replace('/workbench/');
|
||||
await pages[name](root, account.role === 'admin', seed);
|
||||
if (name === 'devices' && live(root)) watchDevices(root, account.role === 'admin');
|
||||
} catch (error) {
|
||||
if (!live(root)) return;
|
||||
const content = root.querySelector('.rid-module-content');
|
||||
if (content.firstElementChild?.classList.contains('moduleEmpty')) content.replaceChildren();
|
||||
feedback(root, error.message || '加载失败,请重试', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,66 @@
|
||||
.rid-pager,
|
||||
.registry-workspace .rid-pager {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px 14px;
|
||||
margin: 10px 0 0;
|
||||
padding: 9px 12px;
|
||||
border: 1px solid #29465c;
|
||||
border-radius: 7px;
|
||||
background: #102438;
|
||||
color: #c7ddeb;
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.rid-pager .rid-pager-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.rid-page-summary { color: #b3c9d9; }
|
||||
.rid-page-summary > span { color: #9db8cc; }
|
||||
.rid-page-number {
|
||||
min-width: 5.5em;
|
||||
color: #eff7fc;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rid-pager .rid-pager-actions button {
|
||||
min-width: 58px;
|
||||
min-height: 32px;
|
||||
margin: 0;
|
||||
padding: 4px 9px;
|
||||
border: 1px solid #466982;
|
||||
border-radius: 5px;
|
||||
background: #18344c;
|
||||
color: #ecf5ff;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.rid-pager .rid-pager-actions button:hover:not(:disabled) {
|
||||
background: #254f70;
|
||||
border-color: #76bbe7;
|
||||
}
|
||||
.rid-pager .rid-pager-actions button:disabled {
|
||||
border-color: #2b465b;
|
||||
background: #13283a;
|
||||
color: #91aabf;
|
||||
opacity: 1;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.rid-pager :focus-visible {
|
||||
outline: 2px solid #7ddcff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.rid-pager[aria-busy="true"] .rid-pager-actions button { cursor: wait; }
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.rid-pager, .registry-workspace .rid-pager { padding-inline: 9px; }
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>RID侦测平台</title>
|
||||
<link rel="icon" href="/workbench/assets/rid-app.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="/workbench/leaflet/leaflet.css">
|
||||
<script src="/workbench/leaflet/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="/workbench/platform.css">
|
||||
<link rel="stylesheet" href="/workbench/integration.css">
|
||||
<link rel="stylesheet" href="/workbench/pagination.css">
|
||||
<link rel="stylesheet" href="/workbench/drone-marker.css">
|
||||
<link rel="stylesheet" href="/vendor/maplibre-gl.css">
|
||||
<link rel="stylesheet" href="/workbench/live-map-3d.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="top">
|
||||
<div class="brand">
|
||||
<img class="logo brandLogo" src="/workbench/assets/bsrid_logo_icon_light.png" alt="" width="42" height="42">
|
||||
<div class="overview-totals" aria-label="工作台总览">
|
||||
<span>侦测设备 <strong id="kpiStations">0</strong></span>
|
||||
<span>实时目标 <strong id="kpiTargets">0</strong></span>
|
||||
<span>告警 <strong id="kpiAlerts">0</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="titleBox">
|
||||
<div class="title" id="platformTitle">RID侦测平台</div>
|
||||
</div>
|
||||
<nav class="nav" id="workbenchNav" aria-label="工作台导航">
|
||||
<button type="button" class="btn" data-rid-click="fitAll" aria-current="page">空域总览</button>
|
||||
<button type="button" class="btn" data-rid-click="openModule" data-rid-arg0="records">记录</button>
|
||||
<button type="button" class="btn" data-rid-click="openModule" data-rid-arg0="devices">设备管理</button>
|
||||
<button type="button" class="btn" data-rid-click="openModule" data-rid-arg0="register">档案</button>
|
||||
<button type="button" class="btn" data-rid-click="openModule" data-rid-arg0="configs">设置</button>
|
||||
<span class="nav-account" id="currentUserName">未登录</span>
|
||||
<button type="button" class="btn" data-rid-click="logout">退出</button>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="left" id="overviewLeft">
|
||||
<div class="panel deviceListPanel">
|
||||
<div class="p-title">侦测设备列表 <span id="stationSummary" class="panelCount">在线 0 · 离线 0</span></div>
|
||||
<div id="stationList" class="list compactList">
|
||||
<div class="muted">暂无侦测设备</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel targetListPanel">
|
||||
<div class="p-title">实时目标列表 <span id="targetSummary" class="panelCount">在线 0</span></div>
|
||||
<div id="droneList" class="list">
|
||||
<div class="muted">暂无目标</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mapWrap">
|
||||
<div id="map" aria-label="平面实时地图"></div>
|
||||
<div id="liveMap3D" aria-label="三维实时地图" hidden></div>
|
||||
<div class="gridOverlay"></div>
|
||||
<div class="mapDock">
|
||||
<div class="legend" role="group" aria-label="地图图例">
|
||||
<button type="button" class="mapLegendToggle" aria-controls="mapLegendContent" aria-expanded="false">
|
||||
图例与显示选项 <span class="mapLegendArrow" aria-hidden="true"></span>
|
||||
</button>
|
||||
<div class="mapLegendContent" id="mapLegendContent">
|
||||
<div class="legendStatus">
|
||||
<span><i class="dot registeredDrone"></i><em>白名单</em></span>
|
||||
<span><i class="dot registeredDrone"></i><em>已报备</em></span>
|
||||
<span><i class="dot flightWarning"></i><em>未报备告警</em></span>
|
||||
<span><i class="dot flightDanger"></i><em>未登记 / 防控区 / 黑名单告警</em></span>
|
||||
<span><i class="dot offlineDot"></i><em>待核验</em></span>
|
||||
</div>
|
||||
<div class="legendSymbols">
|
||||
<span title="轨迹"><i class="dot track"></i><em>轨迹</em></span>
|
||||
<span title="防控区"><i class="dot zone"></i><em>防控区</em></span>
|
||||
<span title="飞手/遥控器"><i class="dot pilotDot"></i><em>飞手</em></span>
|
||||
</div>
|
||||
<div class="mapDisplayOptions" role="group" aria-label="地图显示选项">
|
||||
<label><input id="showFlightTrails" type="checkbox" checked>显示轨迹</label>
|
||||
<label><input id="showModelLabels" type="checkbox" checked>显示型号</label>
|
||||
<label><input id="showPilotMarkers" type="checkbox" checked>显示遥控器</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toolbar" role="group" aria-label="地图绘图工具">
|
||||
<div class="tool" data-rid-click="startDrawZone" data-rid-arg0="polygon" title="绘制多边形防控区">
|
||||
<div>⬠</div>多边形
|
||||
</div>
|
||||
<div class="tool" data-rid-click="startDrawZone" data-rid-arg0="rectangle" title="绘制矩形防控区">
|
||||
<div>▭</div>矩形
|
||||
</div>
|
||||
<div class="tool" data-rid-click="startDrawZone" data-rid-arg0="circle" title="绘制圆形防控区">
|
||||
<div>○</div>圆形
|
||||
</div>
|
||||
<div class="tool" data-rid-click="finishDrawZone" title="完成绘制/保存防控区">
|
||||
<div>✓</div>完成
|
||||
</div>
|
||||
<div class="tool" data-rid-click="cancelDrawZone" title="取消绘制">
|
||||
<div>×</div>取消
|
||||
</div>
|
||||
<div class="tool" data-rid-click="clearAllTrackLayers" title="清除实时轨迹">
|
||||
<div>↺</div>清除实时轨迹
|
||||
</div>
|
||||
</div>
|
||||
<div class="mapSourceBox" title="选择地图底图">
|
||||
<button type="button" id="mapViewToggle" class="smallBtn" aria-pressed="false" title="切换 2D / 3D 视角">3D</button>
|
||||
<span id="baseMapIcon">▧</span>
|
||||
<select id="mapSourceSelect" aria-label="地图底图" data-rid-change="setBaseMap" data-rid-arg0="@value">
|
||||
<option value="tdt-satellite" selected>天地图影像</option>
|
||||
<option value="tdt-vector">天地图矢量</option>
|
||||
<option value="amap-vector" disabled>高德地图(待接入)</option>
|
||||
<option value="amap-satellite" disabled>高德卫星(待接入)</option>
|
||||
<option value="osm-vector" disabled>OSM地图(待接入)</option>
|
||||
<option value="esri-satellite" disabled>Esri卫星(待接入)</option>
|
||||
<option value="custom-xyz" disabled>专网自定义地图(待接入)</option>
|
||||
</select>
|
||||
<label class="labelToggle" title="卫星图可叠加道路、地名、行政区等文字标注">
|
||||
<input id="labelToggle" type="checkbox" checked data-rid-change="toggleMapLabels" data-rid-arg0="@checked"><span>标注</span>
|
||||
</label>
|
||||
<label class="cacheToggle" title="已浏览瓦片缓存到 maps/cache,手动下载的离线地图保存在 map_cache">
|
||||
<input id="mapCacheQuickToggle" type="checkbox" checked disabled title="使用 RID 现有地图缓存"><span>缓存</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="sideToggle leftToggle" data-rid-click="toggleSidePanel" data-rid-arg0="left" aria-controls="overviewLeft" aria-expanded="true" aria-label="设备与目标" title="收起设备与目标">‹</button>
|
||||
<button type="button" class="sideToggle rightToggle" data-rid-click="toggleSidePanel" data-rid-arg0="right" aria-controls="overviewRight" aria-expanded="true" aria-label="防控区与告警" title="收起防控区与告警">›</button>
|
||||
|
||||
</div>
|
||||
<div class="right" id="overviewRight">
|
||||
<section class="panel zonePanel" aria-label="防控区管理">
|
||||
<div class="p-title">防控区管理</div>
|
||||
<p class="zoneFeedback" id="zoneFeedback" role="status" hidden></p>
|
||||
<div class="list zonePanelContent">
|
||||
<details id="zoneCoordinateEntry" class="zoneCoordinateEntry">
|
||||
<summary>录入坐标</summary>
|
||||
<form id="zoneCoordinateForm">
|
||||
<div class="zoneFormFields">
|
||||
<label>区域名称<input id="coordinateZoneName" maxlength="40" required></label>
|
||||
<label>形状<select id="coordinateZoneType">
|
||||
<option value="polygon">多边形</option>
|
||||
<option value="rectangle">矩形</option>
|
||||
<option value="circle">圆形</option>
|
||||
</select></label>
|
||||
</div>
|
||||
<label>坐标(经度,纬度)
|
||||
<textarea id="zoneCoordinates" rows="3" spellcheck="false" required aria-describedby="zoneCoordinateHelp" placeholder="118.782100, 31.982300"></textarea>
|
||||
</label>
|
||||
<p id="zoneCoordinateHelp">每行一个顶点,按边界顺序输入,至少三行。</p>
|
||||
<label id="zoneRadiusField" hidden>半径(米)
|
||||
<input id="zoneRadius" type="number" inputmode="decimal" min="1" max="1000000" step="any" disabled>
|
||||
</label>
|
||||
<button type="submit" id="coordinateZoneSave">保存防控区</button>
|
||||
</form>
|
||||
</details>
|
||||
<div class="zoneDrawEditor" id="zoneDrawEditor" hidden>
|
||||
<p id="drawHint"></p>
|
||||
<div class="zoneDrawActions">
|
||||
<input id="zoneName" maxlength="40" placeholder="防控区名称" aria-label="地图绘制防控区名称">
|
||||
<button type="button" id="zoneDrawSave" data-rid-click="finishDrawZone">保存绘制</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul id="zoneList" class="zoneList"></ul>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panel alertPanel" aria-label="告警中心">
|
||||
<div class="p-title">告警中心 <span class="panelCount" id="alertBadge">未读 0 · 已读 0</span></div>
|
||||
<p id="alertFeedback" class="muted" role="status" hidden></p>
|
||||
<div id="alertList" class="list">
|
||||
<div class="muted">暂无告警</div>
|
||||
</div>
|
||||
<div class="alarmSettingRow">
|
||||
<label><input id="soundAlarmToggle" type="checkbox" checked> 声音报警</label>
|
||||
<label><input id="flashAlarmToggle" type="checkbox" checked> 告警闪屏</label>
|
||||
<button type="button" class="smallBtn gray" data-rid-click="testAlarm">测试告警</button>
|
||||
<button type="button" id="clearAlarm" class="smallBtn gray" data-rid-click="clearCurrentAlerts" disabled>清除显示</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<section id="moduleWorkspace" class="moduleWorkspace" aria-labelledby="moduleTitle">
|
||||
<h2 id="moduleTitle" tabindex="-1"></h2>
|
||||
<nav class="moduleNav" data-module-group="records" aria-label="记录分类" hidden>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="records">轨迹记录</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="alarms">报警查询</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="rankings">统计分析</button>
|
||||
</nav>
|
||||
<nav class="moduleNav" data-module-group="devices" aria-label="设备管理分类" hidden>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="devices">接收器列表</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="receivers">接收器诊断</button>
|
||||
</nav>
|
||||
<nav class="moduleNav" data-module-group="register" aria-label="档案分类" hidden>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="register">设备登记</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="archives">本地档案</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="flight-plans">飞行报备</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="drones">黑白名单</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="models">型号库</button>
|
||||
</nav>
|
||||
<nav class="moduleNav" data-module-group="configs" aria-label="设置分类" hidden>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="configs">平台设置</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="maps">地图与离线下载</button>
|
||||
<button type="button" data-rid-click="openModule" data-rid-arg0="users">用户管理</button>
|
||||
</nav>
|
||||
<div id="moduleBody" class="moduleBody"></div>
|
||||
<div id="moduleEmbed" class="moduleEmbed" hidden>
|
||||
<p id="moduleEmbedStatus" role="status" hidden></p>
|
||||
<button id="moduleEmbedRetry" type="button" hidden>重新加载</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<div id="alarmOverlay"><div class="alarmText" role="status"></div></div>
|
||||
<p id="rid-workbench-status" role="status" aria-live="polite" hidden></p>
|
||||
<script src="/workbench/drone-map.js"></script>
|
||||
<script src="/workbench/flight-status.js"></script>
|
||||
<script src="/workbench/rid-api.js"></script>
|
||||
<script src="/workbench/platform.js"></script>
|
||||
<script src="/workbench/modules.js"></script>
|
||||
<script src="/workbench/module-host.js"></script>
|
||||
<script src="/workbench/events.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,453 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// Translate the authorized reference view's shapes at one boundary. Business
|
||||
// rules, session checks, persistence, and receiver ownership stay in RID.
|
||||
async function request(path, method = 'GET', body, options = {}) {
|
||||
const response = await fetch(path, {
|
||||
...options, method, cache: 'no-store', credentials: 'same-origin',
|
||||
...(body === undefined ? {} : { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
|
||||
});
|
||||
if (response.status === 401) {
|
||||
location.replace('/workbench/');
|
||||
throw new Error('会话已结束,请重新登录');
|
||||
}
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
const error = new Error(data.error || data.message || `RID 服务返回 HTTP ${response.status}`);
|
||||
error.status = response.status;
|
||||
throw error;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
let receivers;
|
||||
let receiverRequest;
|
||||
let receiversAt = -Infinity;
|
||||
async function receiverRows(refresh = false) {
|
||||
if (!refresh && receivers && performance.now() - receiversAt < 900) return receivers;
|
||||
if (!receiverRequest) {
|
||||
receiverRequest = request('/api/receivers').then(data => {
|
||||
if (data.error) throw new Error(data.error);
|
||||
receiversAt = performance.now();
|
||||
return receivers = data.receivers;
|
||||
}).finally(() => { receiverRequest = null; });
|
||||
}
|
||||
return receiverRequest;
|
||||
}
|
||||
|
||||
const stateLabels = {
|
||||
'serial-open': '串口已打开', 'udp-listening': 'UDP 正在监听', 'tcp-listening': 'TCP 正在监听',
|
||||
'connecting': '正在连接', 'disconnected': '连接中断', 'stopped': '未连接'
|
||||
};
|
||||
function link(row) {
|
||||
const state = row?.status?.state;
|
||||
const serial = row?.config.transport === 'serial';
|
||||
const lastData = serial ? row.status?.lastValidFrameMs : row?.status?.lastDataMs;
|
||||
const connected = Boolean(row?.config.enabled && ['serial-open', 'udp-listening', 'tcp-listening'].includes(state));
|
||||
const receiving = connected && lastData != null && Date.now() - lastData <= 15000;
|
||||
const tcp = row?.config.transport === 'tcp-listen';
|
||||
let message = row?.status?.lastError || stateLabels[state] || '未连接';
|
||||
if (connected && tcp) {
|
||||
const peer = row.status.lastPeerIp;
|
||||
message = receiving && peer ? '接收中 · ' + peer : 'TCP 监听中 · 等待数据';
|
||||
}
|
||||
if (connected && serial) message = receiving ? '串口接收中' : '串口已打开 · 等待有效报文';
|
||||
return { connected, receiving, message };
|
||||
}
|
||||
|
||||
function isStation(row) {
|
||||
if (row.config.transport !== 'serial') return true;
|
||||
return row.status.lastValidFrameMs != null || Boolean(row.userConfigured && row.config.serialPort);
|
||||
}
|
||||
async function sourceStatus() {
|
||||
const rows = await receiverRows();
|
||||
const serial = rows.filter(row => row.config.transport === 'serial');
|
||||
const tcp = rows.filter(row => row.config.transport === 'tcp-listen');
|
||||
const udp = rows.filter(row => row.config.transport === 'udp');
|
||||
const collection = list => list.find(row => link(row).connected) || list[0];
|
||||
return {
|
||||
usb: link(collection(serial)), ble: { connected: false, message: '本阶段未接入 BLE' },
|
||||
tcp: link(collection(tcp)), udp: link(collection(udp)), tcpDevices: tcp.map(link)
|
||||
};
|
||||
}
|
||||
|
||||
async function changeSerial(body, enabled) {
|
||||
if (!/^COM[1-9]\d*$/i.test(body.port || '')) throw new Error('请先选择串口');
|
||||
const port = body.port.toUpperCase();
|
||||
const rows = await receiverRows(true);
|
||||
const serial = rows.find(row => row.config.transport === 'serial' && row.config.serialPort === port);
|
||||
if (!serial && !enabled) return { ok: true, connected: false, message: '该串口未被本平台打开' };
|
||||
const code = serial ? `/api/receivers/${encodeURIComponent(serial.id)}` : '/api/receivers';
|
||||
const config = { ...(serial?.config || { transport: 'serial', format: 'raw' }), enabled, serialPort: port };
|
||||
if (enabled) config.baudRate = Number(body.baud);
|
||||
await request(code, serial ? 'PUT' : 'POST', { name: serial?.name || `USB 串口 ${port}`, config });
|
||||
receiversAt = -Infinity;
|
||||
return { ok: true, connected: false, message: enabled ? '已启动串口接收任务,等待设备状态' : '串口已断开' };
|
||||
}
|
||||
|
||||
const targets = new Map();
|
||||
let ownership = new Map();
|
||||
let lastFrame = -Infinity;
|
||||
let stream;
|
||||
let retry;
|
||||
let stopped = false;
|
||||
|
||||
function applyFrame(frame) {
|
||||
if (frame.snapshot) targets.clear();
|
||||
for (const id of frame.removed) targets.delete(id);
|
||||
for (const target of frame.targets) targets.set(target.observation.target_id, target);
|
||||
lastFrame = performance.now();
|
||||
if (frame.snapshot || frame.targets.length || frame.removed.length) {
|
||||
window.dispatchEvent(new Event('rid-live-frame'));
|
||||
}
|
||||
}
|
||||
function connectStream() {
|
||||
if (stopped || stream) return;
|
||||
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
stream = new WebSocket(`${protocol}//${location.host}/api/realtime/ws?format=json`);
|
||||
stream.onmessage = ({ data }) => {
|
||||
try {
|
||||
const frame = JSON.parse(data);
|
||||
applyFrame(frame);
|
||||
stream.send(String(frame.sequence));
|
||||
} catch (_) {
|
||||
stream.close();
|
||||
}
|
||||
};
|
||||
stream.onclose = () => {
|
||||
stream = null;
|
||||
if (!stopped) retry = setTimeout(connectStream, 2500);
|
||||
};
|
||||
}
|
||||
window.addEventListener('pagehide', () => { stopped = true; clearTimeout(retry); stream?.close(); });
|
||||
window.addEventListener('pageshow', () => { stopped = false; connectStream(); });
|
||||
|
||||
let rules = [];
|
||||
let rulesExpires = 0;
|
||||
let pendingRules;
|
||||
function modelRules(refresh = false) {
|
||||
if (!refresh && performance.now() < rulesExpires) return Promise.resolve(rules);
|
||||
return pendingRules ??= request('/api/workbench/models').then(data => {
|
||||
rulesExpires = performance.now() + 10000;
|
||||
return rules = data.entries;
|
||||
}).finally(() => { pendingRules = null; });
|
||||
}
|
||||
const modelRuleIndexes = new WeakMap();
|
||||
|
||||
function indexModelRules(entries) {
|
||||
let index = modelRuleIndexes.get(entries);
|
||||
if (index) return index;
|
||||
|
||||
const prefixes = new Map();
|
||||
const keywords = [];
|
||||
for (const rule of entries) {
|
||||
if (!rule.enabled) continue;
|
||||
if (rule.field === 'serial') prefixes.set(rule.pattern.toUpperCase(), rule);
|
||||
else if (rule.field === 'target' || rule.field === 'model') keywords.push(rule);
|
||||
}
|
||||
const lengths = [...new Set([...prefixes.keys()].map(prefix => prefix.length))].sort((a, b) => b - a);
|
||||
index = {prefixes, lengths, keywords};
|
||||
modelRuleIndexes.set(entries, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
function resolveModel(targetId, reported, entries = rules, serial) {
|
||||
const {prefixes, lengths, keywords} = indexModelRules(entries);
|
||||
const sn = (serial || '').trim().toUpperCase();
|
||||
let match;
|
||||
for (const length of lengths) {
|
||||
if (length > sn.length) continue;
|
||||
match = prefixes.get(sn.slice(0, length));
|
||||
if (match) break;
|
||||
}
|
||||
if (!match) {
|
||||
const ident = (targetId || '').toLowerCase();
|
||||
const model = (reported || '').toLowerCase();
|
||||
match = keywords.find(rule => (rule.field === 'target' ? ident : model).includes(rule.pattern));
|
||||
}
|
||||
if (!match) return reported;
|
||||
const vendor = match.vendor.toLowerCase();
|
||||
const name = match.model.toLowerCase();
|
||||
if (match.field === 'serial' && (name === vendor || name.startsWith(vendor + ' '))) {
|
||||
return match.model;
|
||||
}
|
||||
return [match.vendor, match.model].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
function detectionReceiver(id) {
|
||||
const row = receivers?.find(receiver => receiver.id === id);
|
||||
if (!row) return null;
|
||||
// A network receiver with no peer restriction cannot identify which sender owns its last GNSS fix.
|
||||
const identified = row.config.transport === 'serial'
|
||||
|| (row.config.transport === 'tcp-listen' && !!row.config.peerIp);
|
||||
const fresh = performance.now() - receiversAt <= 5000;
|
||||
return {name: row.name, gnss: identified && fresh ? row.status.gnss : null};
|
||||
}
|
||||
|
||||
async function liveRows() {
|
||||
if (performance.now() - lastFrame > 2000) {
|
||||
const frame = await request('/api/realtime/snapshot');
|
||||
if (performance.now() - lastFrame > 2000) applyFrame(frame);
|
||||
}
|
||||
await Promise.all([modelRules().catch(() => rules), refreshOwnership()]);
|
||||
return cachedLiveRows();
|
||||
}
|
||||
|
||||
async function registrations(ids) {
|
||||
const unique = [...new Set(ids)];
|
||||
const batches = [];
|
||||
for (let start = 0; start < unique.length; start += 96) {
|
||||
const params = new URLSearchParams({ids: unique.slice(start, start + 96).join(',')});
|
||||
batches.push(request('/api/target-registration-status?' + params));
|
||||
}
|
||||
const rows = (await Promise.all(batches)).flatMap(response => response.entries);
|
||||
return new Map(rows.map(row => [row.targetId, row]));
|
||||
}
|
||||
|
||||
let ownershipRequest;
|
||||
let flightAssessments = new Map();
|
||||
function refreshOwnership() {
|
||||
return ownershipRequest ??= Promise.all([registrations(targets.keys()),request("/api/flight-status")]).then(([rows,status]) => {
|
||||
ownership = rows;
|
||||
flightAssessments = new Map(status.entries.map(row=>[row.targetId,row]));
|
||||
}).catch(error => {flightAssessments.clear();console.warn('飞行状态暂不可用', error.message);})
|
||||
.finally(() => { ownershipRequest = null; });
|
||||
}
|
||||
|
||||
function registrationInfo(status) {
|
||||
if (!status) return {};
|
||||
const registryClass = status.listKind === 'black' ? 'blacklist'
|
||||
: status.listKind === 'white' ? 'whitelist' : status.registered ? 'registered' : 'unregistered';
|
||||
return { registered: status.registered, registryClass };
|
||||
}
|
||||
|
||||
function cachedLiveRows() {
|
||||
return [...targets.values()].map(target => {
|
||||
const observation = target.observation;
|
||||
const telemetry = observation.telemetry || {};
|
||||
const source = target.sources?.find(source => source.observation.receiver_id === observation.receiver_id);
|
||||
return {
|
||||
uasId: observation.target_id, model: resolveModel(observation.target_id, telemetry.model || telemetry.name, rules, telemetry.serial) || 'RID 目标', bssid: telemetry.mac,
|
||||
lat: observation.latitude, lng: observation.longitude, alt: observation.altitude_m,
|
||||
pilotLat: telemetry.pilot_position?.[1], pilotLng: telemetry.pilot_position?.[0],
|
||||
geometricAltitude: telemetry.geometric_altitude_m, pressureAltitude: telemetry.pressure_altitude_m,
|
||||
heightAgl: telemetry.height_agl_m, relativeHeight: telemetry.relative_height_m,
|
||||
speed: telemetry.speed_mps, rssi: telemetry.rssi, heading: observation.heading_deg,
|
||||
source: observation.receiver_id, time: timestamp(target.received_at_ms), online: true,
|
||||
sourceCount: target.sources?.length || 1,
|
||||
receivedAtMs: source?.received_at_ms ?? target.received_at_ms, positionGeneration: target.position_generation,
|
||||
sampleId: [observation.receiver_id, observation.source_epoch, observation.sequence].join(':'),
|
||||
...registrationInfo(ownership.get(observation.target_id)),
|
||||
flightClass: flightAssessments.get(observation.target_id)?.class || "unknown",
|
||||
flightReason: flightAssessments.get(observation.target_id)?.reason,
|
||||
positionUnverified: telemetry.position_unverified === true
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function projectFence(fence) {
|
||||
const geometry = fence.geometry;
|
||||
const point = ([lng, lat]) => ({ lat, lng });
|
||||
let type = geometry.type;
|
||||
let points = geometry.vertices?.map(point);
|
||||
if (type === 'circle') points = [{ ...point(geometry.center), radius: geometry.radius_m }];
|
||||
if (type === 'polygon' && points.length === 4
|
||||
&& new Set(points.map(point => point.lat)).size === 2
|
||||
&& new Set(points.map(point => point.lng)).size === 2) {
|
||||
type = 'rectangle';
|
||||
points = [points[0], points[2]];
|
||||
}
|
||||
return { id: fence.id, name: fence.name, enabled: fence.enabled, type, points };
|
||||
}
|
||||
async function saveZone(method, id, body) {
|
||||
const snapshot = await request('/api/geofences');
|
||||
const existing = snapshot.entries.find(zone => zone.id === id);
|
||||
if (id && !existing) throw new Error('防控区已变更,请刷新后重试');
|
||||
if (method === 'DELETE') {
|
||||
await request(`/api/geofences/${encodeURIComponent(id)}?revision=${snapshot.revision}`, method);
|
||||
return { ok: true };
|
||||
}
|
||||
if (!id) id = `zone-${crypto.randomUUID()}`;
|
||||
const coord = point => [point.lng, point.lat];
|
||||
let geometry = existing?.geometry;
|
||||
if (!geometry && body.type === 'circle') {
|
||||
geometry = { type: 'circle', center: coord(body.points[0]), radius_m: body.points[0].radius };
|
||||
} else if (!geometry && body.type === 'rectangle') {
|
||||
const [a, b] = body.points;
|
||||
geometry = { type: 'polygon', vertices: [coord(a), [a.lng, b.lat], coord(b), [b.lng, a.lat]] };
|
||||
} else if (!geometry) {
|
||||
geometry = { type: 'polygon', vertices: body.points.map(coord) };
|
||||
}
|
||||
await request(`/api/geofences/${encodeURIComponent(id)}`, 'PUT', {
|
||||
expected_revision: snapshot.revision, fence: { id, name: body.name, enabled: body.enabled === true, geometry }
|
||||
});
|
||||
return { ok: true, id };
|
||||
}
|
||||
|
||||
function timestamp(ms) {
|
||||
return new Date(ms).toLocaleString('sv-SE', { hourCycle: 'h23' });
|
||||
}
|
||||
function dateArgument(value, fallback) {
|
||||
if (!value) return fallback;
|
||||
const result = new Date(value.replace(' ', 'T')).getTime();
|
||||
if (!Number.isSafeInteger(result) || result < 0) throw new Error('日期范围无效');
|
||||
return result;
|
||||
}
|
||||
function range(query) {
|
||||
return {
|
||||
fromMs: dateArgument(query.get('start'), 0),
|
||||
toMs: dateArgument(query.get('end'), Date.now()),
|
||||
q: query.get('keyword') || ''
|
||||
};
|
||||
}
|
||||
async function events(query, limit = 100, offset, center = false) {
|
||||
const { fromMs, toMs, q } = range(query);
|
||||
const params = new URLSearchParams({ limit, from_ms: fromMs, to_ms: toMs, q: q === '未登记' || q === '未登记无人机告警' ? '' : q });
|
||||
if (q === '未登记' || q === '未登记无人机告警') params.set('type','unregistered');
|
||||
if (query.get('type')) params.set('type',query.get('type'));
|
||||
if (query.get('handled')) params.set('handled', query.get('handled') === '1' ? '1' : '0');
|
||||
if (offset !== undefined) params.set('offset', offset);
|
||||
if (query.has('before')) params.set('before', query.get('before'));
|
||||
if (query.has('after')) params.set('after', query.get('after'));
|
||||
if (query.has('counts')) params.set('counts', '1');
|
||||
const data = await request(`/api/monitoring/${center ? 'center' : 'events'}?${params}`);
|
||||
const alerts = data.entries.map(event => ({
|
||||
id: event.id, time: timestamp(event.occurred_at_ms), timeMs: event.occurred_at_ms,
|
||||
uasId: event.target_id, lat: event.latitude, lng: event.longitude, kind: event.event_type,
|
||||
type: window.ridFlightStatus.meta(event.event_type).label,
|
||||
message: event.event_type === 'unregistered' ? '设备登记中未找到该目标' : event.fence_name || event.target_id,
|
||||
handled: event.acknowledged_at_ms != null,
|
||||
acknowledgedBy: event.acknowledged_by
|
||||
}));
|
||||
return { alerts, count: data.total ?? alerts.length, read: data.read, unread: data.unread };
|
||||
}
|
||||
|
||||
async function getFlights(query) {
|
||||
const params = new URLSearchParams({ ...range(query), limit: 120 });
|
||||
const response = await request('/api/workbench/observations?' + params);
|
||||
const flights = response.entries.map(row => ({
|
||||
uasId: row.targetId, flightId: row.flightKey, model: row.model || row.targetId,
|
||||
start: timestamp(row.timeMs), end: row.endMs == null ? '接收中' : timestamp(row.endMs),
|
||||
lastLat: row.latitude, lastLng: row.longitude
|
||||
}));
|
||||
return { flights, total: response.total };
|
||||
}
|
||||
|
||||
async function getPoints(flightKey) {
|
||||
const points = [];
|
||||
let after = 0;
|
||||
do {
|
||||
const params = new URLSearchParams({ flightKey, after, limit: 5000 });
|
||||
const row = await request('/api/history/flight-points?' + params);
|
||||
points.push(...row.entries);
|
||||
after = row.nextAfter;
|
||||
} while (after);
|
||||
return window.ridDroneMap.prepareTrack(points).points.map(point => {
|
||||
const osd = point.osd || {};
|
||||
return {
|
||||
lat: point.latitude, lng: point.longitude, alt: point.altitudeM,
|
||||
heading: point.headingDeg, time: timestamp(point.timeMs), timeMs: point.timeMs, segmentStart: point.segmentStart,
|
||||
speed: osd.speedMps, verticalSpeed: osd.verticalSpeedMps, rssi: osd.rssi,
|
||||
height: osd.heightAglM, relativeHeight: osd.relativeHeightM,
|
||||
geometricAltitude: osd.geometricAltitudeM, pressureAltitude: osd.pressureAltitudeM,
|
||||
pilotLat: osd.pilotPosition?.[1], pilotLng: osd.pilotPosition?.[0]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async function summary() {
|
||||
const midnight = new Date();
|
||||
midnight.setHours(0, 0, 0, 0);
|
||||
const [live, links, rows, fences, lists, recentAlerts, historyStats, alertStats] = await Promise.all([
|
||||
liveRows(), sourceStatus(), receiverRows(), request('/api/geofences'), request('/api/target-lists'),
|
||||
events(new URLSearchParams(), 6).then(result => result.alerts), request(`/api/history/summary?fromMs=${midnight.getTime()}`),
|
||||
request(`/api/monitoring/summary?from_ms=${midnight.getTime()}`)
|
||||
]);
|
||||
const userData = await request('/api/auth/users').catch(error => {
|
||||
if (error.status !== 403) throw error;
|
||||
});
|
||||
return {
|
||||
...links, onlineCount: live.length, targetCount: live.length, zones: fences.entries.length,
|
||||
deviceTotal: rows.length, userTotal: userData?.entries.length, registryTotal: lists.entries.length,
|
||||
recentAlerts, recentRecords: historyStats.recent.map(point => ({ time: timestamp(point.timeMs), uasId: point.targetId, lat: point.latitude, lng: point.longitude })),
|
||||
recordsToday: historyStats.since, recordsTotal: historyStats.total, alertsToday: alertStats.since, alertsTotal: alertStats.total
|
||||
};
|
||||
}
|
||||
|
||||
async function read(route, params) {
|
||||
switch (route) {
|
||||
case '/api/current_user': {
|
||||
const account = await request('/api/auth/status');
|
||||
if (!account.authenticated) { location.replace('/workbench/'); throw new Error('请重新登录'); }
|
||||
return { user: { displayName: account.username, role: roleLabel(account.role), canAcknowledge: ['admin', 'operator'].includes(account.role) } };
|
||||
}
|
||||
case '/api/platform_configs': {
|
||||
const prefs = await request('/api/maps/preferences');
|
||||
return { configs: [{ key: 'default_map', value: prefs.basemap === 'road' ? 'tdt-vector' : 'tdt-satellite' }] };
|
||||
}
|
||||
case '/api/status': return sourceStatus();
|
||||
case '/api/drones': {
|
||||
const [drones, status] = await Promise.all([liveRows(), sourceStatus()]);
|
||||
return { drones, count: drones.length, onlineCount: drones.length, status };
|
||||
}
|
||||
case '/api/ports': return (await request('/api/receiver/ports')).ports.map(device => ({ device }));
|
||||
case '/api/zones': return (await request('/api/geofences')).entries.map(projectFence);
|
||||
case '/api/alerts': params.set('counts', '1'); return events(params, 50, undefined, true);
|
||||
case '/api/alerts_query': return events(params, 50, params.get('offset') ?? 0);
|
||||
case '/api/local_stations': return { stations: (await receiverRows()).filter(isStation).map(row => {
|
||||
const { connected, receiving, message } = link(row);
|
||||
return {
|
||||
id: row.id, name: row.name, sn: row.hardwareId, endpoint: row.status.endpoint,
|
||||
transport: row.config.transport,
|
||||
deviceIp: row.status.lastPeerIp || row.config.peerIp,
|
||||
gnss: row.status.gnss,
|
||||
status: message, linkState: receiving ? 'online' : connected ? 'waiting' : 'offline'
|
||||
};
|
||||
}) };
|
||||
case '/api/local_fusion_info': return { sources: await sourceStatus() };
|
||||
case '/api/flights': return getFlights(params);
|
||||
case '/api/flight_track': return { points: await getPoints(params.get('flightId')) };
|
||||
case '/api/monitor_summary': return summary();
|
||||
case '/api/map_cache/status': {
|
||||
const state = await request('/api/maps/status');
|
||||
return { enabled: true, offlineOnly: state.mode === 'offline', hasTdtKey: state.keyConfigured };
|
||||
}
|
||||
default: throw new Error('此功能尚未接入本阶段');
|
||||
}
|
||||
}
|
||||
|
||||
async function mutate(route, method, body) {
|
||||
if (route === '/api/zones' || route.startsWith('/api/zones/')) return saveZone(method, route.split('/')[3], body);
|
||||
switch (route) {
|
||||
case '/api/logout': return request('/api/auth/logout', 'POST');
|
||||
case '/api/connect': return changeSerial(body, true);
|
||||
case '/api/disconnect':
|
||||
case '/api/release_port': return changeSerial(body, false);
|
||||
case '/api/alerts_query':
|
||||
return request(`/api/monitoring/events/${encodeURIComponent(body.id)}/acknowledgement`, 'PUT', {});
|
||||
default: throw new Error('此功能尚未接入本阶段');
|
||||
}
|
||||
}
|
||||
|
||||
function roleLabel(role) {
|
||||
return ({ admin: '管理员', operator: '操作员', viewer: '只读用户' })[role] || '未知角色';
|
||||
}
|
||||
|
||||
window.ridWorkbenchApi = Object.freeze({
|
||||
request, modelRules, resolveModel, roleLabel, getRecordPoints: getPoints, cachedLiveRows, detectionReceiver,
|
||||
async registration(target) { return registrationInfo((await registrations([target])).get(target)); },
|
||||
preferences: () => request('/api/maps/preferences'),
|
||||
async fetch(path, options = {}) {
|
||||
const url = new URL(path, location.origin);
|
||||
try {
|
||||
if (url.origin !== location.origin) throw new Error('仅允许访问本机 RID 接口');
|
||||
const method = options.method || 'GET';
|
||||
const body = typeof options.body === 'string' ? JSON.parse(options.body) : {};
|
||||
return Response.json(method === 'GET' ? await read(url.pathname, url.searchParams) : await mutate(url.pathname, method, body));
|
||||
} catch (error) {
|
||||
return Response.json({ ok: false, message: error.message, error: error.message }, { status: error.status || 400 });
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||