simoncck commited on
Commit
472832d
·
verified ·
1 Parent(s): ad9f1f8

Update browser_automation_ui.html

Browse files
Files changed (1) hide show
  1. browser_automation_ui.html +7 -4
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(`/browser/close/`,${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(){const list=document.querySelectorAll('.session-item');if(!list.length)return alert('No sessions');
154
- if(!confirm(`Close ALL ${list.length} sessions?`))return;try{
155
- for(const li of list){await apiPost(`/browser/close/`,${li.dataset.id});}currentSessionId=null;document.getElementById('screenshot').src='';lastScreenshot=null;await refreshSessions();log('✖ all sessions closed');}catch(e){handleErr(e)}}
 
 
 
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=>{