улучшение интерфейса
This commit is contained in:
parent
5647af6c3a
commit
0f27faf9b4
|
|
@ -29,8 +29,8 @@ fieldset { border: 1px solid #31465f; border-radius: 8px; padding: 10px; min-wid
|
|||
.filter-message { display: block; padding: 8px 2px; color: #8fa3ba; white-space: normal; line-height: 1.4; }
|
||||
.filter-error { color: #ff9a9f; }
|
||||
.check { display: flex; align-items: center; gap: 7px; }
|
||||
.access-points-toggle { color: #d8f3ff; }
|
||||
.background-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
|
||||
.background-controls[hidden] { display: none; }
|
||||
.background-controls legend { grid-column: 1 / -1; }
|
||||
.background-controls label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
|
||||
.background-controls label:last-child { grid-column: 1 / -1; }
|
||||
|
|
@ -41,12 +41,10 @@ canvas { display: block; width: 100%; min-height: 420px; }
|
|||
#objects-layer { position: absolute; inset: 0; z-index: 0; min-height: 0; pointer-events: none; }
|
||||
#heatmap { position: relative; z-index: 1; cursor: grab; touch-action: none; }
|
||||
#heatmap.dragging-background { cursor: grabbing; }
|
||||
#access-points-layer { position: absolute; inset: 0; z-index: 2; min-height: 0; pointer-events: none; }
|
||||
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: #74879d; pointer-events: none; }
|
||||
.map-tooltip { position: absolute; z-index: 3; pointer-events: none; padding: 7px 9px; border: 1px solid #53779c; border-radius: 6px; background: #07101ded; color: #edf5ff; font-size: 12px; white-space: nowrap; box-shadow: 0 5px 16px #0008; }
|
||||
.legend { position: absolute; right: 16px; bottom: 14px; display: flex; overflow: hidden; font-size: 11px; background: #07101dcc; padding: 7px; border-radius: 6px; }
|
||||
.legend span { padding: 5px 9px; color: #101722; font-weight: 700; }.legend .red { background:#ec402f; }.legend .yellow { background:#f3d93a; }.legend .green { background:#43d35c; }
|
||||
.legend .access-point { color: #d8f3ff; background: #0d3854; }
|
||||
.summary { display: flex; gap: 20px; color: #8fa3ba; font-size: 13px; }
|
||||
.status { padding: 7px 11px; border-radius: 20px; background: #28384b; font-size: 12px; }.status.ok { background: #174b36; }.status.bad { background: #702d32; }
|
||||
.error { color: #ff9a9f; margin: 0; font-size: 12px; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const state = {
|
||||
points: [], accessPoints: [], bounds: null, view: 'maximum', hitCells: [], hitAccessPoints: [],
|
||||
points: [], bounds: null, view: 'maximum', hitCells: [],
|
||||
bssids: [], agents: [], mapObjects: [],
|
||||
filters: { bssids: { loaded: false, error: '' }, agents: { loaded: false, error: '' } }
|
||||
};
|
||||
|
|
@ -11,8 +11,6 @@ const objectsCtx = objectsCanvas.getContext('2d');
|
|||
const BACKGROUND_REFERENCE_WIDTH = 1000;
|
||||
let backgroundDrag = null;
|
||||
let resizeFrame = null;
|
||||
const accessPointsCanvas = $('access-points-layer');
|
||||
const accessPointsCtx = accessPointsCanvas.getContext('2d');
|
||||
|
||||
async function loadMapObjects() {
|
||||
try {
|
||||
|
|
@ -103,7 +101,7 @@ async function loadHeatmap() {
|
|||
const response = await fetch('/api/heatmap?' + params);
|
||||
const payload = await response.json();
|
||||
if (!response.ok) throw new Error(payload.error || 'Ошибка загрузки данных');
|
||||
state.points = payload.points; state.accessPoints = payload.access_points || []; state.bounds = payload.bounds;
|
||||
state.points = payload.points; state.bounds = payload.bounds;
|
||||
$('selected-period').textContent = `${dateFrom.toLocaleString()} — ${dateTo.toLocaleString()}`;
|
||||
setStatus('Подключено', true); showError(''); draw();
|
||||
} catch (error) { setStatus('Нет связи', false); showError(error.message); }
|
||||
|
|
@ -124,12 +122,10 @@ function switchView(view) {
|
|||
function draw() {
|
||||
resizeCanvas(); ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
drawBackground();
|
||||
accessPointsCtx.clearRect(0, 0, accessPointsCanvas.width, accessPointsCanvas.height);
|
||||
state.hitCells = []; state.hitAccessPoints = [];
|
||||
state.hitCells = [];
|
||||
const points = state.points;
|
||||
const accessPoints = $('show-access-points').checked ? state.accessPoints : [];
|
||||
$('empty').hidden = Boolean(points.length || accessPoints.length);
|
||||
if ((!points.length && !accessPoints.length) || !state.bounds) { $('points-count').textContent = '0 точек'; $('samples-count').textContent = '0 измерений'; return; }
|
||||
$('empty').hidden = Boolean(points.length);
|
||||
if (!points.length || !state.bounds) { $('points-count').textContent = '0 точек'; $('samples-count').textContent = '0 измерений'; return; }
|
||||
const {min_x: minX, max_x: maxX, min_y: minY, max_y: maxY} = state.bounds;
|
||||
const padding = 55, width = canvas.width - padding * 2, height = canvas.height - padding * 2;
|
||||
const rangeX = maxX - minX + 1, rangeY = maxY - minY + 1;
|
||||
|
|
@ -143,15 +139,6 @@ function draw() {
|
|||
state.hitCells.push({ x, y, size: Math.max(1, cellSize), point });
|
||||
if (cellSize >= 5) { ctx.strokeStyle = '#07101d66'; ctx.strokeRect(x, y, cellSize, cellSize); }
|
||||
});
|
||||
accessPoints.forEach(point => {
|
||||
const x = originX + (point.x - minX) * cellSize;
|
||||
const y = originY + (maxY + 1 - point.y) * cellSize;
|
||||
const radius = 7;
|
||||
accessPointsCtx.beginPath(); accessPointsCtx.arc(x, y, radius, 0, Math.PI * 2);
|
||||
accessPointsCtx.fillStyle = '#31b9ff'; accessPointsCtx.fill();
|
||||
accessPointsCtx.lineWidth = 2; accessPointsCtx.strokeStyle = '#d8f3ff'; accessPointsCtx.stroke();
|
||||
state.hitAccessPoints.push({ x, y, radius: radius + 3, point });
|
||||
});
|
||||
$('points-count').textContent = `${points.length} точек`;
|
||||
$('samples-count').textContent = `${points.reduce((sum, point) => sum + point.samples, 0)} измерений`;
|
||||
}
|
||||
|
|
@ -184,10 +171,10 @@ function drawBackground() {
|
|||
objectsCtx.fillRect(objectX, objectY - height, width, height);
|
||||
objectsCtx.strokeRect(objectX, objectY - height, width, height);
|
||||
} else {
|
||||
const radius = Math.max(3, 3.5 * scale);
|
||||
const radius = Math.max(6, 7 * scale);
|
||||
objectsCtx.beginPath(); objectsCtx.arc(objectX, objectY, radius, 0, Math.PI * 2);
|
||||
objectsCtx.fillStyle = '#e34b55'; objectsCtx.fill();
|
||||
objectsCtx.strokeStyle = '#ffadb2'; objectsCtx.stroke();
|
||||
objectsCtx.fillStyle = '#31b9ff'; objectsCtx.fill();
|
||||
objectsCtx.strokeStyle = '#d8f3ff'; objectsCtx.stroke();
|
||||
if (object.name) {
|
||||
objectsCtx.fillStyle = '#e8edf4';
|
||||
objectsCtx.fillText(object.name, objectX + radius + 3, objectY + 3);
|
||||
|
|
@ -253,19 +240,11 @@ function showMapTooltip(event) {
|
|||
const rect = canvas.getBoundingClientRect();
|
||||
const canvasX = (event.clientX - rect.left) * canvas.width / rect.width;
|
||||
const canvasY = (event.clientY - rect.top) * canvas.height / rect.height;
|
||||
const accessPoint = state.hitAccessPoints.find(item =>
|
||||
Math.hypot(canvasX - item.x, canvasY - item.y) <= item.radius
|
||||
);
|
||||
const cell = state.hitCells.find(item =>
|
||||
canvasX >= item.x && canvasX <= item.x + item.size &&
|
||||
canvasY >= item.y && canvasY <= item.y + item.size
|
||||
);
|
||||
const tooltip = $('map-tooltip');
|
||||
if (accessPoint) {
|
||||
tooltip.textContent = `Точка доступа ${accessPoint.point.bssid}, X: ${accessPoint.point.x}, Y: ${accessPoint.point.y}`;
|
||||
positionMapTooltip(tooltip, event);
|
||||
return;
|
||||
}
|
||||
if (!cell) { tooltip.hidden = true; return; }
|
||||
const signal = Number(cell.point.signal);
|
||||
tooltip.textContent = `X: ${cell.point.x}, Y: ${cell.point.y}, сигнал: ${signal.toFixed(state.view === 'maximum' ? 0 : 1)} dBm`;
|
||||
|
|
@ -289,9 +268,6 @@ function resizeCanvas() {
|
|||
objectsCanvas.style.height = `${height}px`;
|
||||
objectsCanvas.width = Math.round(containerWidth);
|
||||
objectsCanvas.height = height;
|
||||
accessPointsCanvas.style.height = `${height}px`;
|
||||
accessPointsCanvas.width = Math.round(containerWidth);
|
||||
accessPointsCanvas.height = height;
|
||||
}
|
||||
function localDateTimeValue(date) { const local = new Date(date.getTime() - date.getTimezoneOffset() * 60_000); return local.toISOString().slice(0, 19); }
|
||||
function setStatus(text, ok) { $('connection-status').textContent = text; $('connection-status').className = `status ${ok ? 'ok' : 'bad'}`; }
|
||||
|
|
@ -304,7 +280,6 @@ $('select-none').addEventListener('click', () => document.querySelectorAll('#fil
|
|||
$('filter-list').addEventListener('change', event => {
|
||||
if (state.view === 'points' && event.target.matches('input[type="radio"]')) loadHeatmap();
|
||||
});
|
||||
$('show-access-points').addEventListener('change', draw);
|
||||
['background-x', 'background-y', 'background-scale'].forEach(id => $(id).addEventListener('input', drawBackground));
|
||||
document.querySelectorAll('.tab').forEach(tab => tab.addEventListener('click', () => switchView(tab.dataset.view)));
|
||||
canvas.addEventListener('mousemove', showMapTooltip);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@
|
|||
|
||||
<main>
|
||||
<aside class="panel controls">
|
||||
<label class="check access-points-toggle"><input id="show-access-points" type="checkbox" checked> Отображать точки доступа</label>
|
||||
<fieldset class="background-controls">
|
||||
<fieldset class="background-controls" hidden>
|
||||
<legend>Объекты плана</legend>
|
||||
<label>Смещение X<input id="background-x" type="number" step="1" value="0"></label>
|
||||
<label>Смещение Y<input id="background-y" type="number" step="1" value="0"></label>
|
||||
|
|
@ -60,10 +59,9 @@
|
|||
<div class="panel canvas-wrap">
|
||||
<canvas id="objects-layer" aria-hidden="true"></canvas>
|
||||
<canvas id="heatmap"></canvas>
|
||||
<canvas id="access-points-layer" aria-hidden="true"></canvas>
|
||||
<div id="empty" class="empty">За выбранный период данных нет</div>
|
||||
<div id="map-tooltip" class="map-tooltip" hidden></div>
|
||||
<div class="legend" aria-label="Условные обозначения"><span class="red">< −79</span><span class="yellow">−79…< −70</span><span class="green">≥ −70 dBm</span><span class="access-point">● точка доступа</span></div>
|
||||
<div class="legend" aria-label="Условные обозначения"><span class="red">< −79</span><span class="yellow">−79…< −70</span><span class="green">≥ −70 dBm</span></div>
|
||||
</div>
|
||||
<div class="summary">
|
||||
<span id="selected-period">Период не выбран</span>
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ class WebAppTest(unittest.TestCase):
|
|||
self.assertIn('data-map-max-y="110"'.encode(), response.data)
|
||||
self.assertIn('< −79'.encode(), response.data)
|
||||
self.assertIn('≥ −70 dBm'.encode(), response.data)
|
||||
self.assertIn('id="show-access-points"'.encode(), response.data)
|
||||
self.assertIn("Отображать точки доступа".encode(), response.data)
|
||||
self.assertNotIn('id="show-access-points"'.encode(), response.data)
|
||||
self.assertIn('id="background-x"'.encode(), response.data)
|
||||
self.assertIn('id="background-y"'.encode(), response.data)
|
||||
self.assertIn('id="background-scale"'.encode(), response.data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue