<?php if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit; } RBAC::enforce('manage.fleet'); require_once __DIR__ . '/../modules/backups/backups_handler.php'; ?> <div class="tab-workspace" id="ws-backups"> <div class="ws-header"> <div class="ws-title-block"> <div class="ws-kicker">PROTECTION</div> <h2 class="ws-title">Backups</h2> <div class="ws-subtitle">Live snapshots of databases and files</div> </div> <button class="ws-action-btn" id="btn-create-backup">Create Backup</button> </div> <div class="ws-body"> <div id="backup-list" style="margin-top:20px"> <div style="text-align:center;padding:60px;color:var(--text-dim);font-size:12px">Loading backups...</div> </div> </div> </div> <script nonce="<?= $cspNonce ?>"> (function(){ function getCSRF(){var m=document.querySelector('meta[name="csrf-token"]');return m?m.content:'';} function load(){ var fd=new FormData(); fd.append('_backup_action','list'); fd.append('_csrf',getCSRF()); fetch('',{method:'POST',body:fd,credentials:'same-origin'}) .then(function(r){return r.json()}) .then(function(d){ if(!d.ok)return; var el=document.getElementById('backup-list'); if(!d.backups.length){el.innerHTML='<div style="text-align:center;padding:60px;color:var(--text-dim);font-size:12px">No backups found. Create one to get started.</div>';return;} var h='<table style="width:100%;border-collapse:collapse"><thead><tr style="text-align:left;color:var(--text-dim);font-size:10px;text-transform:uppercase;letter-spacing:1px"><th style="padding:8px 12px">Name</th><th style="padding:8px 12px">Date</th><th style="padding:8px 12px">Files</th><th style="padding:8px 12px">Size</th></tr></thead><tbody>'; d.backups.forEach(function(b){h+='<tr style="border-top:1px solid var(--border)"><td style="padding:10px 12px;font-family:monospace;font-size:11px;color:var(--text-bright)">'+b.name+'</td><td style="padding:10px 12px;font-size:11px">'+b.date+'</td><td style="padding:10px 12px;font-size:11px">'+b.files+'</td><td style="padding:10px 12px;font-size:11px">'+b.size+'</td></tr>';}); h+='</tbody></table>'; el.innerHTML=h; }); } document.getElementById('btn-create-backup').addEventListener('click',function(){ this.disabled=true;this.textContent='Creating...';var btn=this; var fd=new FormData();fd.append('_backup_action','create');fd.append('_csrf',getCSRF()); fetch('',{method:'POST',body:fd,credentials:'same-origin'}).then(function(r){return r.json()}).then(function(d){btn.disabled=false;btn.textContent='Create Backup';if(d.ok){load();}}); }); load(); })(); </script>