bmc_hub/patch_js_events.py
Christian ceb560e2f2 feat: Add bottom bar functionality with real-time updates and manual endpoint tests
- Implemented a new bottom bar feature in `bottom-bar.js` that fetches and displays various notifications and statuses in real-time.
- Added functions for handling visibility, state updates, and user interactions within the bottom bar.
- Introduced WebSocket connection for real-time updates and fallback polling mechanism.
- Created a manual testing script `test_manual.py` to validate API endpoints for the manual module.
- Included tests for various paths to ensure expected responses from the server.
2026-04-12 02:27:01 +02:00

55 lines
2.0 KiB
Python

import re
with open("static/js/bottom-bar.js", "r") as f:
content = f.read()
events = """
function bindDynamicActions() {
const listContainer = byId('bbDynamicList');
if (!listContainer) return;
listContainer.addEventListener('click', function (e) {
const target = e.target;
const btn = target.closest('button');
if (!btn) return;
if (btn.id === 'btnNextTask') {
console.log("-> Beder backend om næste opgave...");
btn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Henter...';
btn.disabled = true;
setTimeout(() => {
btn.innerHTML = '<i class="bi bi-magic me-2"></i>Du fik tildelt Sag #8192!';
btn.classList.add('btn-success');
btn.classList.remove('btn-primary');
}, 1000);
}
if (btn.id === 'btnSendMsg') {
const input = byId('chatInputQuick');
if (input && input.value.trim() !== '') {
console.log("-> Sender besked:", input.value);
input.value = '';
const msgDiv = document.createElement('div');
msgDiv.className = 'mb-1 text-end';
msgDiv.innerHTML = '<div class="d-inline-block bg-primary text-white p-2 rounded-3" style="max-width: 80%;"><strong>Mig:</strong> ' + msgDiv.textContent + ' (Mock)</div>';
listContainer.insertBefore(msgDiv, listContainer.lastElementChild);
listContainer.scrollTop = listContainer.scrollHeight;
}
}
});
}
function init() {"""
content = re.sub(r' function init\(\) \{', events, content)
init_bindings = """
bindSideTabs();
bindDynamicActions();
"""
content = re.sub(r' bindSideTabs\(\);', init_bindings, content)
with open("static/js/bottom-bar.js", "w") as f:
f.write(content)