Files
restic-manager/web/templates/pages/fleet_update.html
T
steve 6374201f6c
CI / Test (store) (pull_request) Successful in 5s
CI / Test (rest) (pull_request) Successful in 8s
CI / Build (windows/amd64) (pull_request) Successful in 7s
CI / Lint (pull_request) Successful in 11s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Test (server-http) (pull_request) Successful in 1m35s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m26s
Fix fleet update filters across refreshes
2026-08-22 12:04:26 +01:00

63 lines
4.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{define "title"}}Fleet update · restic-manager{{end}}
{{define "content"}}
{{$page := .Page}}
<div class="max-w-[1280px] mx-auto px-8 pb-14">
{{/* breadcrumbs */}}
<div class="crumbs pt-6">
<a href="/">Dashboard</a><span class="sep">/</span>
<a href="/settings">Settings</a><span class="sep">/</span>
<span class="text-ink-mid">agent updates</span>
</div>
{{/* page header */}}
<div class="flex items-baseline justify-between mt-3.5">
<div>
<h1 class="text-[22px] font-medium tracking-[-0.005em]">
Agent updates
<span class="text-ink-fade font-normal text-[14px] ml-2 mono">target {{$page.TargetVersion}}</span>
</h1>
<p class="text-ink-mute text-[12px] mt-1 max-w-[760px] leading-[1.55]">
Rolling, sequential agent self-update. One host at a time, halts on first failure,
cancellable mid-roll. Only online hosts whose <span class="mono">agent_version</span>
differs from the server are eligible.
</p>
</div>
</div>
{{template "fleet_update_inner" .}}
<script>
let fleetUpdateUIState = null
function fleetBoxes(){return Array.from(document.querySelectorAll('.fleet-host:not(:disabled)'))}
function fleetReview(){const n=fleetBoxes().filter(x=>x.checked).length;document.getElementById('fleet-selected-count').textContent=n;document.getElementById('fleet-timeout').textContent=n+' × 95s';document.getElementById('fleet-update-start-btn').disabled=n===0}
function fleetFilter(){const q=document.getElementById('fleet-filter-name').value.toLowerCase(),v=document.getElementById('fleet-filter-version').value.toLowerCase(),s=document.getElementById('fleet-filter-state').value;document.querySelectorAll('.fleet-candidate').forEach(r=>r.style.display=r.dataset.name.toLowerCase().includes(q)&&r.dataset.version.toLowerCase().includes(v)&&(s==='all'||r.dataset.state===s)?'':'none')}
function fleetSelectVisible(on){document.querySelectorAll('.fleet-candidate').forEach(r=>{const x=r.querySelector('.fleet-host:not(:disabled)');if(x&&r.style.display!=='none')x.checked=on});fleetReview()}
function fleetSelectOnly(id){fleetBoxes().forEach(x=>x.checked=x.value===id);fleetReview()}
async function fleetStart(e){e.preventDefault();const ids=fleetBoxes().filter(x=>x.checked).map(x=>x.value),out=document.getElementById('fleet-start-error');out.textContent='';const res=await fetch('/api/fleet/update',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({host_ids:ids,canary_first:document.getElementById('fleet-canary').checked})});if(res.ok){location.reload();return false}const body=await res.json();out.textContent=body.message||body.code||'Unable to start';return false}
function fleetCaptureUIState(){
const name=document.getElementById('fleet-filter-name'),version=document.getElementById('fleet-filter-version'),state=document.getElementById('fleet-filter-state'),canary=document.getElementById('fleet-canary')
if(!name)return
fleetUpdateUIState={name:name.value,version:version.value,state:state.value,canary:canary.checked,selected:fleetBoxes().filter(x=>x.checked).map(x=>x.value)}
}
function fleetRestoreUIState(){
if(!fleetUpdateUIState||!document.getElementById('fleet-filter-name'))return
document.getElementById('fleet-filter-name').value=fleetUpdateUIState.name
document.getElementById('fleet-filter-version').value=fleetUpdateUIState.version
document.getElementById('fleet-filter-state').value=fleetUpdateUIState.state
document.getElementById('fleet-canary').checked=fleetUpdateUIState.canary
const selected=new Set(fleetUpdateUIState.selected)
fleetBoxes().forEach(x=>x.checked=selected.has(x.value))
fleetFilter();fleetReview()
}
document.body.addEventListener('htmx:beforeSwap',e=>{if(e.detail.target.id==='fleet-update-panel')fleetCaptureUIState()})
document.body.addEventListener('htmx:afterSwap',e=>{if(e.detail.target.id==='fleet-update-panel')fleetRestoreUIState()})
if(document.getElementById('fleet-selected-count'))fleetReview()
</script>
</div>
{{end}}