noch mehr UI und playSound
This commit is contained in:
1 parent
77be29e010
commit
79a73ac8da
3 files changed
+197
-20
No files matched your search
@@ -559,15 +559,36 @@ dialog.group-streets-dialog article {
|
||||
--block-spacing-horizontal: 1rem;
|
||||
max-height: min(70dvh, 40rem);
|
||||
margin: 0;
|
||||
padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
dialog.group-streets-dialog article header {
|
||||
cursor: move;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
flex: 0 0 auto;
|
||||
padding: var(--block-spacing-vertical) var(--block-spacing-horizontal) 0.5rem;
|
||||
}
|
||||
|
||||
dialog.group-streets-dialog article > footer {
|
||||
flex: 0 0 auto;
|
||||
padding: 0.5rem var(--block-spacing-horizontal) var(--block-spacing-vertical);
|
||||
}
|
||||
|
||||
dialog.group-streets-dialog article > #groupStreetsContent {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overscroll-behavior: contain;
|
||||
padding: 0 var(--block-spacing-horizontal) 0.25rem;
|
||||
}
|
||||
|
||||
dialog.group-streets-dialog.is-dragging {
|
||||
@@ -598,10 +619,14 @@ dialog.group-streets-dialog.is-dragging article header {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.group-streets-list li {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.group-street-entry {
|
||||
@@ -610,6 +635,7 @@ dialog.group-streets-dialog.is-dragging article header {
|
||||
justify-content: space-between;
|
||||
gap: 0.6rem;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 0.42rem 0.55rem;
|
||||
border: 0;
|
||||
@@ -626,6 +652,7 @@ dialog.group-streets-dialog.is-dragging article header {
|
||||
}
|
||||
|
||||
.group-street-name {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -634,8 +661,12 @@ dialog.group-streets-dialog.is-dragging article header {
|
||||
|
||||
.group-street-state {
|
||||
flex: 0 0 auto;
|
||||
max-width: 40%;
|
||||
font-size: 0.68rem;
|
||||
color: var(--muted-color, #5b6771);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.group-streets-empty {
|
||||
@@ -917,3 +948,59 @@ html[data-theme="dark"] .leaflet-tooltip-left::before {
|
||||
html[data-theme="dark"] .leaflet-tooltip-right::before {
|
||||
border-right-color: #141e26;
|
||||
}
|
||||
|
||||
.dispatcher-page .leaflet-control-zoom {
|
||||
border: none;
|
||||
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.dispatcher-page .leaflet-control-zoom .leaflet-bar {
|
||||
background: var(--card-bg) !important;
|
||||
background-color: var(--card-bg) !important;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.dispatcher-page .leaflet-bar a,
|
||||
.dispatcher-page .leaflet-bar a:hover,
|
||||
.dispatcher-page .leaflet-bar a:focus,
|
||||
.dispatcher-page .leaflet-bar a:active {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
background-color: var(--card-bg) !important;
|
||||
background-image: none !important;
|
||||
background: var(--card-bg) !important;
|
||||
color: var(--text-primary) !important;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
opacity: 1 !important;
|
||||
filter: none !important;
|
||||
backdrop-filter: none !important;
|
||||
-webkit-backdrop-filter: none !important;
|
||||
}
|
||||
|
||||
.dispatcher-page .leaflet-bar a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.dispatcher-page .leaflet-touch .leaflet-control-zoom-in,
|
||||
.dispatcher-page .leaflet-touch .leaflet-control-zoom-out {
|
||||
font-size: 18px;
|
||||
line-height: 30px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background-color: var(--card-bg) !important;
|
||||
background-image: none !important;
|
||||
}
|
||||
@@ -56,6 +56,8 @@ const dispatcherState = {
|
||||
chatGroupId: null,
|
||||
chatByGroup: new Map(),
|
||||
chatKeysByGroup: new Map(),
|
||||
infoMessages: [],
|
||||
infoMessageKeys: new Set(),
|
||||
streetSearchResults: [],
|
||||
streetSearchActiveIndex: -1,
|
||||
streetSearchRequestId: 0,
|
||||
@@ -63,6 +65,9 @@ const dispatcherState = {
|
||||
unloading: false
|
||||
};
|
||||
|
||||
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||
const audioCtx = new AudioContext();
|
||||
|
||||
let map;
|
||||
let osmLayer;
|
||||
let aerialLayer;
|
||||
@@ -1101,7 +1106,7 @@ function checkHeartbeatTimeout() {
|
||||
function showHeartbeatWarning() {
|
||||
const dialog = document.getElementById('heartbeatWarningModal');
|
||||
if (!dialog) {
|
||||
alert('Keine Nachrichten mit Code 0 seit mehr als 90 Sekunden erhalten.');
|
||||
alert('Seit mehr als 90 Sekunden kein Kontakt zum Server.');
|
||||
return;
|
||||
}
|
||||
if (typeof dialog.showModal === 'function') {
|
||||
@@ -1765,6 +1770,10 @@ function openChat(groupId) {
|
||||
} else if (dialog) {
|
||||
dialog.show();
|
||||
}
|
||||
const container = document.getElementById('chatMessages');
|
||||
if (container) {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
function closeChatModal() {
|
||||
@@ -1840,6 +1849,7 @@ function renderChat() {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
|
||||
|
||||
function getSenderDisplay(senderId, messageOrPayload = null) {
|
||||
let payload = null;
|
||||
if (messageOrPayload && typeof messageOrPayload === 'object') {
|
||||
@@ -1946,6 +1956,71 @@ function addChatMessage(groupId, entry) {
|
||||
}
|
||||
}
|
||||
|
||||
function playNotificationSound() {
|
||||
try {
|
||||
if (!AudioContext) return;
|
||||
if (audioCtx.state === 'suspended') {
|
||||
audioCtx.resume();
|
||||
}
|
||||
const oscillator = audioCtx.createOscillator();
|
||||
const gain = audioCtx.createGain();
|
||||
oscillator.connect(gain);
|
||||
gain.connect(audioCtx.destination);
|
||||
oscillator.frequency.setValueAtTime(880, audioCtx.currentTime);
|
||||
oscillator.frequency.exponentialRampToValueAtTime(440, audioCtx.currentTime + 0.15);
|
||||
gain.gain.setValueAtTime(0.1, audioCtx.currentTime);
|
||||
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.3);
|
||||
oscillator.start(audioCtx.currentTime);
|
||||
oscillator.stop(audioCtx.currentTime + 0.3);
|
||||
} catch (error) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
function renderInfoMessages() {
|
||||
const container = document.getElementById('infoMessages');
|
||||
if (!container) return;
|
||||
container.innerHTML = '';
|
||||
|
||||
if (!dispatcherState.infoMessages.length) {
|
||||
const empty = document.createElement('div');
|
||||
empty.className = 'chat-empty';
|
||||
empty.textContent = 'Noch keine Nachrichten.';
|
||||
container.appendChild(empty);
|
||||
} else {
|
||||
dispatcherState.infoMessages.forEach(entry => {
|
||||
const message = document.createElement('div');
|
||||
message.className = 'chat-message';
|
||||
|
||||
const header = document.createElement('div');
|
||||
header.className = 'chat-message-header';
|
||||
|
||||
const sender = document.createElement('span');
|
||||
sender.textContent = entry.senderLabel;
|
||||
|
||||
const time = document.createElement('span');
|
||||
time.textContent = entry.time;
|
||||
|
||||
header.append(sender, time);
|
||||
|
||||
const meta = document.createElement('div');
|
||||
meta.className = 'chat-message-text';
|
||||
meta.style.fontSize = '0.8rem';
|
||||
meta.style.opacity = '0.8';
|
||||
meta.textContent = entry.meta;
|
||||
|
||||
const text = document.createElement('div');
|
||||
text.className = 'chat-message-text';
|
||||
text.textContent = entry.text;
|
||||
|
||||
message.append(header, meta, text);
|
||||
container.appendChild(message);
|
||||
});
|
||||
}
|
||||
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
|
||||
function showInfoMessage(message) {
|
||||
const dialog = document.getElementById('infoMessageModal');
|
||||
if (!dialog) return;
|
||||
@@ -1976,23 +2051,43 @@ function showInfoMessage(message) {
|
||||
receiver = 'alle';
|
||||
}
|
||||
|
||||
document.getElementById('infoMessageCode').textContent = Number.isFinite(code) ? code : '';
|
||||
document.getElementById('infoMessageSender').textContent = receiver ? `${sender} -> ${receiver}` : sender;
|
||||
document.getElementById('infoMessageTime').textContent = formatChatTime(
|
||||
normalizeTimestamp(message.ts) || Date.now()
|
||||
);
|
||||
document.getElementById('infoMessageText').textContent = extractMessageText(message.msg);
|
||||
const time = formatChatTime(normalizeTimestamp(message.ts) || Date.now());
|
||||
const text = extractMessageText(message.msg);
|
||||
const senderLabel = receiver ? `${sender}` : sender;
|
||||
const key = `${code}|${message.sender_id}|${message.receiver_id}|${time}|${text}`;
|
||||
|
||||
if (!dispatcherState.infoMessageKeys.has(key)) {
|
||||
dispatcherState.infoMessageKeys.add(key);
|
||||
dispatcherState.infoMessages.push({
|
||||
senderLabel,
|
||||
time,
|
||||
text
|
||||
});
|
||||
playNotificationSound();
|
||||
}
|
||||
|
||||
renderInfoMessages();
|
||||
|
||||
if (typeof dialog.showModal === 'function') {
|
||||
dialog.showModal();
|
||||
} else {
|
||||
dialog.show();
|
||||
}
|
||||
const container = document.getElementById('infoMessages');
|
||||
if (container) {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
function closeInfoMessageModal() {
|
||||
const dialog = document.getElementById('infoMessageModal');
|
||||
if (dialog && dialog.open) dialog.close();
|
||||
dispatcherState.infoMessages = [];
|
||||
dispatcherState.infoMessageKeys = new Set();
|
||||
const container = document.getElementById('infoMessages');
|
||||
if (container) {
|
||||
container.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
function extractMessagePayload(value) {
|
||||
@@ -2184,6 +2279,8 @@ function handleWsMessage(event) {
|
||||
case 1:
|
||||
dispatcherState.lastCode0ReceivedAt = Date.now();
|
||||
dispatcherState.heartbeatWarningShown = false;
|
||||
setConnectionStatus('Verbunden', 'connected');
|
||||
startHeartbeatMonitoring();
|
||||
// Heartbeat des Servers beantworten.
|
||||
if (dispatcherState.ws && dispatcherState.ws.readyState === WebSocket.OPEN) {
|
||||
dispatcherState.ws.send(JSON.stringify({code: 2, msg: 'pong'}));
|
||||
|
||||
Reference in new issue
Block a user