-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrefresh.js
More file actions
50 lines (47 loc) · 1.93 KB
/
Copy pathrefresh.js
File metadata and controls
50 lines (47 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Unified SOLLOL Dashboard Refresh Helper
(function () {
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsHost = location.host;
function connectOllama() {
const target = document.getElementById('ollama-activity');
if (!target) {
console.error('No #ollama-activity element found');
return;
}
const ws = new WebSocket(`${wsProtocol}//${wsHost}/ws/ollama_activity`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
const entry = document.createElement('div');
entry.style.padding = '0.35rem 0';
entry.style.borderBottom = '1px solid #1e293b';
entry.textContent = data.message || event.data;
target.appendChild(entry);
target.scrollTop = target.scrollHeight;
};
ws.onopen = () => console.log('✅ Ollama activity WebSocket refreshed');
ws.onerror = (err) => console.error('Ollama activity WS error', err);
ws.onclose = () => setTimeout(connectOllama, 5000);
}
function connectRouting() {
const target = document.getElementById('routing-events');
if (!target) {
console.error('No #routing-events element found');
return;
}
const ws = new WebSocket(`${wsProtocol}//${wsHost}/ws/routing_events`);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
const entry = document.createElement('div');
entry.style.padding = '0.35rem 0';
entry.style.borderBottom = '1px solid #1e293b';
entry.textContent = data.message || event.data;
target.appendChild(entry);
target.scrollTop = target.scrollHeight;
};
ws.onopen = () => console.log('✅ Routing events WebSocket refreshed');
ws.onerror = (err) => console.error('Routing events WS error', err);
ws.onclose = () => setTimeout(connectRouting, 5000);
}
connectOllama();
connectRouting();
})();