Spaces:
No application file
No application file
Update browser_automation_ui.html
Browse files
browser_automation_ui.html
CHANGED
|
@@ -147,12 +147,15 @@
|
|
| 147 |
function downloadCurrentScreenshot(){if(!lastScreenshot)return alert('No screenshot');const a=document.createElement('a');a.href=`data:image/png;base64,${lastScreenshot}`;a.download=`screenshot_${Date.now()}.png`;a.click();}
|
| 148 |
|
| 149 |
async function closeSession(id){if(!confirm(`Close session\n${id}?`))return;try{
|
| 150 |
-
await apiPost(
|
| 151 |
await refreshSessions();}catch(e){handleErr(e)}}
|
| 152 |
|
| 153 |
-
async function closeAllSessions(){
|
| 154 |
-
if(!
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
async function refreshSessions(){try{
|
| 158 |
const res=await apiGet('/sessions');const ul=document.getElementById('sessionList');ul.innerHTML='';(res.sessions||[]).forEach(s=>{
|
|
|
|
| 147 |
function downloadCurrentScreenshot(){if(!lastScreenshot)return alert('No screenshot');const a=document.createElement('a');a.href=`data:image/png;base64,${lastScreenshot}`;a.download=`screenshot_${Date.now()}.png`;a.click();}
|
| 148 |
|
| 149 |
async function closeSession(id){if(!confirm(`Close session\n${id}?`))return;try{
|
| 150 |
+
await apiPost('/browser/close', { session_id: id });log(`✖ closed ${id}`);if(id===currentSessionId){currentSessionId=null;document.getElementById('screenshot').src='';}
|
| 151 |
await refreshSessions();}catch(e){handleErr(e)}}
|
| 152 |
|
| 153 |
+
async function closeAllSessions(){
|
| 154 |
+
const list=await listSessions(); if(!list.length) return alert("No sessions");
|
| 155 |
+
if(!confirm("Close ALL sessions? This cannot be undone.")) return;
|
| 156 |
+
for(const s of list){ try{ await apiPost('/browser/close', { session_id: ${s.session_id} });}catch(e){ appendLog(`❗ close ${s.session_id}: ${e.message}`);} }
|
| 157 |
+
sessionId=null; refreshSessions(); appendLog("All sessions closed");
|
| 158 |
+
}
|
| 159 |
|
| 160 |
async function refreshSessions(){try{
|
| 161 |
const res=await apiGet('/sessions');const ul=document.getElementById('sessionList');ul.innerHTML='';(res.sessions||[]).forEach(s=>{
|