refator_comm1

This commit is contained in:
Mateusz Gruszczyński
2025-10-18 21:18:36 +02:00
parent 2682a0ff4f
commit ff4944ffb4
3 changed files with 322 additions and 129 deletions

View File

@@ -18,6 +18,16 @@ export const api = {
const body = { sid, action }; if (target) body.target = target;
return fetch('/api/vm-action', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(body)}).then(r=>r.json());
},
taskStatus: (upid, node) => fetch(`/api/task-status?upid=${encodeURIComponent(upid)}&node=${encodeURIComponent(node)}`).then(r=>r.json()),
taskLog: (upid, node, start=0) => fetch(`/api/task-log?upid=${encodeURIComponent(upid)}&node=${encodeURIComponent(node)}&start=${start}`).then(r=>r.json())
wsTaskURL: (upid, node) => {
const proto = (location.protocol === 'https:') ? 'wss' : 'ws';
return `${proto}://${location.host}/ws/task?upid=${encodeURIComponent(upid)}&node=${encodeURIComponent(node)}`;
},
// NEW:
wsObserveURL: (sid) => {
const proto = (location.protocol === 'https:') ? 'wss' : 'ws';
return `${proto}://${location.host}/ws/observe?sid=${encodeURIComponent(sid)}`;
}
};