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;
|
--block-spacing-horizontal: 1rem;
|
||||||
max-height: min(70dvh, 40rem);
|
max-height: min(70dvh, 40rem);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: var(--block-spacing-vertical) var(--block-spacing-horizontal);
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.group-streets-dialog article header {
|
dialog.group-streets-dialog article header {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
user-select: 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 {
|
dialog.group-streets-dialog.is-dragging {
|
||||||
@@ -598,10 +619,14 @@ dialog.group-streets-dialog.is-dragging article header {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-streets-list li {
|
.group-streets-list li {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-street-entry {
|
.group-street-entry {
|
||||||
@@ -610,6 +635,7 @@ dialog.group-streets-dialog.is-dragging article header {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 0.6rem;
|
gap: 0.6rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.42rem 0.55rem;
|
padding: 0.42rem 0.55rem;
|
||||||
border: 0;
|
border: 0;
|
||||||
@@ -626,6 +652,7 @@ dialog.group-streets-dialog.is-dragging article header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.group-street-name {
|
.group-street-name {
|
||||||
|
flex: 1 1 auto;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
@@ -634,8 +661,12 @@ dialog.group-streets-dialog.is-dragging article header {
|
|||||||
|
|
||||||
.group-street-state {
|
.group-street-state {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
max-width: 40%;
|
||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
color: var(--muted-color, #5b6771);
|
color: var(--muted-color, #5b6771);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-streets-empty {
|
.group-streets-empty {
|
||||||
@@ -917,3 +948,59 @@ html[data-theme="dark"] .leaflet-tooltip-left::before {
|
|||||||
html[data-theme="dark"] .leaflet-tooltip-right::before {
|
html[data-theme="dark"] .leaflet-tooltip-right::before {
|
||||||
border-right-color: #141e26;
|
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,
|
chatGroupId: null,
|
||||||
chatByGroup: new Map(),
|
chatByGroup: new Map(),
|
||||||
chatKeysByGroup: new Map(),
|
chatKeysByGroup: new Map(),
|
||||||
|
infoMessages: [],
|
||||||
|
infoMessageKeys: new Set(),
|
||||||
streetSearchResults: [],
|
streetSearchResults: [],
|
||||||
streetSearchActiveIndex: -1,
|
streetSearchActiveIndex: -1,
|
||||||
streetSearchRequestId: 0,
|
streetSearchRequestId: 0,
|
||||||
@@ -63,6 +65,9 @@ const dispatcherState = {
|
|||||||
unloading: false
|
unloading: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const AudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
|
const audioCtx = new AudioContext();
|
||||||
|
|
||||||
let map;
|
let map;
|
||||||
let osmLayer;
|
let osmLayer;
|
||||||
let aerialLayer;
|
let aerialLayer;
|
||||||
@@ -1101,7 +1106,7 @@ function checkHeartbeatTimeout() {
|
|||||||
function showHeartbeatWarning() {
|
function showHeartbeatWarning() {
|
||||||
const dialog = document.getElementById('heartbeatWarningModal');
|
const dialog = document.getElementById('heartbeatWarningModal');
|
||||||
if (!dialog) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof dialog.showModal === 'function') {
|
if (typeof dialog.showModal === 'function') {
|
||||||
@@ -1765,6 +1770,10 @@ function openChat(groupId) {
|
|||||||
} else if (dialog) {
|
} else if (dialog) {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
const container = document.getElementById('chatMessages');
|
||||||
|
if (container) {
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeChatModal() {
|
function closeChatModal() {
|
||||||
@@ -1840,6 +1849,7 @@ function renderChat() {
|
|||||||
container.scrollTop = container.scrollHeight;
|
container.scrollTop = container.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSenderDisplay(senderId, messageOrPayload = null) {
|
function getSenderDisplay(senderId, messageOrPayload = null) {
|
||||||
let payload = null;
|
let payload = null;
|
||||||
if (messageOrPayload && typeof messageOrPayload === 'object') {
|
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) {
|
function showInfoMessage(message) {
|
||||||
const dialog = document.getElementById('infoMessageModal');
|
const dialog = document.getElementById('infoMessageModal');
|
||||||
if (!dialog) return;
|
if (!dialog) return;
|
||||||
@@ -1976,23 +2051,43 @@ function showInfoMessage(message) {
|
|||||||
receiver = 'alle';
|
receiver = 'alle';
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('infoMessageCode').textContent = Number.isFinite(code) ? code : '';
|
const time = formatChatTime(normalizeTimestamp(message.ts) || Date.now());
|
||||||
document.getElementById('infoMessageSender').textContent = receiver ? `${sender} -> ${receiver}` : sender;
|
const text = extractMessageText(message.msg);
|
||||||
document.getElementById('infoMessageTime').textContent = formatChatTime(
|
const senderLabel = receiver ? `${sender}` : sender;
|
||||||
normalizeTimestamp(message.ts) || Date.now()
|
const key = `${code}|${message.sender_id}|${message.receiver_id}|${time}|${text}`;
|
||||||
);
|
|
||||||
document.getElementById('infoMessageText').textContent = extractMessageText(message.msg);
|
if (!dispatcherState.infoMessageKeys.has(key)) {
|
||||||
|
dispatcherState.infoMessageKeys.add(key);
|
||||||
|
dispatcherState.infoMessages.push({
|
||||||
|
senderLabel,
|
||||||
|
time,
|
||||||
|
text
|
||||||
|
});
|
||||||
|
playNotificationSound();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderInfoMessages();
|
||||||
|
|
||||||
if (typeof dialog.showModal === 'function') {
|
if (typeof dialog.showModal === 'function') {
|
||||||
dialog.showModal();
|
dialog.showModal();
|
||||||
} else {
|
} else {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
const container = document.getElementById('infoMessages');
|
||||||
|
if (container) {
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeInfoMessageModal() {
|
function closeInfoMessageModal() {
|
||||||
const dialog = document.getElementById('infoMessageModal');
|
const dialog = document.getElementById('infoMessageModal');
|
||||||
if (dialog && dialog.open) dialog.close();
|
if (dialog && dialog.open) dialog.close();
|
||||||
|
dispatcherState.infoMessages = [];
|
||||||
|
dispatcherState.infoMessageKeys = new Set();
|
||||||
|
const container = document.getElementById('infoMessages');
|
||||||
|
if (container) {
|
||||||
|
container.innerHTML = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractMessagePayload(value) {
|
function extractMessagePayload(value) {
|
||||||
@@ -2184,6 +2279,8 @@ function handleWsMessage(event) {
|
|||||||
case 1:
|
case 1:
|
||||||
dispatcherState.lastCode0ReceivedAt = Date.now();
|
dispatcherState.lastCode0ReceivedAt = Date.now();
|
||||||
dispatcherState.heartbeatWarningShown = false;
|
dispatcherState.heartbeatWarningShown = false;
|
||||||
|
setConnectionStatus('Verbunden', 'connected');
|
||||||
|
startHeartbeatMonitoring();
|
||||||
// Heartbeat des Servers beantworten.
|
// Heartbeat des Servers beantworten.
|
||||||
if (dispatcherState.ws && dispatcherState.ws.readyState === WebSocket.OPEN) {
|
if (dispatcherState.ws && dispatcherState.ws.readyState === WebSocket.OPEN) {
|
||||||
dispatcherState.ws.send(JSON.stringify({code: 2, msg: 'pong'}));
|
dispatcherState.ws.send(JSON.stringify({code: 2, msg: 'pong'}));
|
||||||
|
|||||||
@@ -188,21 +188,14 @@
|
|||||||
|
|
||||||
<!-- Info-Dialog für Nachrichten mit Code >= 1000 -->
|
<!-- Info-Dialog für Nachrichten mit Code >= 1000 -->
|
||||||
<dialog id="infoMessageModal">
|
<dialog id="infoMessageModal">
|
||||||
<article>
|
<article class="chat-dialog">
|
||||||
<header>
|
<header>
|
||||||
<button class="close" type="button" aria-label="Schließen" onclick="closeInfoMessageModal()"></button>
|
<button class="close" type="button" aria-label="Schließen" onclick="closeInfoMessageModal()"></button>
|
||||||
<h3>Nachricht</h3>
|
<h3>Nachrichten</h3>
|
||||||
</header>
|
</header>
|
||||||
<div class="dialog-body">
|
<div class="chat-messages dialog-body" id="infoMessages"></div>
|
||||||
<div class="info-message-meta">
|
|
||||||
<div><strong>Absender:</strong> <span id="infoMessageSender"></span></div>
|
|
||||||
<div><strong>Zeit:</strong> <span id="infoMessageTime"></span></div>
|
|
||||||
<div><strong>Code:</strong> <span id="infoMessageCode"></span></div>
|
|
||||||
</div>
|
|
||||||
<div class="info-message-text" id="infoMessageText"></div>
|
|
||||||
</div>
|
|
||||||
<footer>
|
<footer>
|
||||||
<button type="button" onclick="closeInfoMessageModal()">OK</button>
|
<button type="button" onclick="closeInfoMessageModal()">Schließen</button>
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
@@ -235,7 +228,7 @@
|
|||||||
<h3>Verbindungswarnung</h3>
|
<h3>Verbindungswarnung</h3>
|
||||||
</header>
|
</header>
|
||||||
<div class="dialog-body">
|
<div class="dialog-body">
|
||||||
<p>Es wurden länger als 90 Sekunden keine Nachrichten mit Code 0 empfangen.</p>
|
<p>Länger als 90 Sekunden kein Kontakt zum Server.</p>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<button type="button" onclick="closeHeartbeatWarningModal()">OK</button>
|
<button type="button" onclick="closeHeartbeatWarningModal()">OK</button>
|
||||||
|
|||||||
Reference in new issue
Block a user