diff --git a/dashcaddy-api/.eslintrc.js b/dashcaddy-api/.eslintrc.js index 4fca5af..b2de5f3 100644 --- a/dashcaddy-api/.eslintrc.js +++ b/dashcaddy-api/.eslintrc.js @@ -54,11 +54,25 @@ module.exports = { }, }, { - // Frontend assets use browser globals + // Browser-side assets (client JS) files: ['assets/**/*.js', 'frontend/**/*.js'], env: { browser: true, es2021: true, + node: false, + }, + globals: { + // Common dashboard globals from status/index.html context + apiUrl: 'readonly', + API_BASE_URL: 'readonly', + CONFIG: 'readonly', + // Client-side dashboard classes (loaded via script tags) + ErrorHandler: 'readonly', + ProgressTracker: 'readonly', + ThemeAdapter: 'readonly', + DnsTemplateSelector: 'readonly', + TourManager: 'readonly', + TooltipDefinitions: 'readonly', }, rules: { 'no-undef': 'warn', diff --git a/status/dist/features.js b/status/dist/features.js index 87d40d3..d47f724 100644 --- a/status/dist/features.js +++ b/status/dist/features.js @@ -1288,7 +1288,7 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}}; - `,w+=``,w+=``,w+=`${F}`,w+=``,w+=""}w+="",B.innerHTML=w,B.querySelectorAll(".save-auto-btn").forEach(T=>{T.addEventListener("click",async()=>{const $=T.dataset.id,P=T.closest("tr"),R=P.querySelector(".auto-schedule").value,U=P.querySelector(".auto-rollback").checked,_=P.querySelector(".auto-window").value.trim();T.textContent="Saving...",T.disabled=!0;try{const F=await(await secureFetch(`/api/v1/updates/auto-update/${encodeURIComponent($)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!!R,schedule:R||"weekly",autoRollback:U,maintenanceWindow:_||void 0})})).json();if(F.success)T.textContent="\u2713 Saved";else throw new Error(F.error)}catch(J){T.textContent="\u2717 Error",showNotification("Save error: "+J.message,"error")}setTimeout(()=>{T.textContent="Save",T.disabled=!1},2e3)})})}catch(p){B.innerHTML=`
Failed: ${escapeHtml(p.message)}
`}}const x=document.getElementById("dashcaddy-current-version"),O=document.getElementById("dashcaddy-update-badge"),A=document.getElementById("dashcaddy-update-details"),N=document.getElementById("dashcaddy-new-version"),z=document.getElementById("dashcaddy-changelog"),H=document.getElementById("dashcaddy-apply-btn"),L=document.getElementById("dashcaddy-check-btn"),g=document.getElementById("dashcaddy-rollback-btn"),I=document.getElementById("dashcaddy-status-bar"),c=document.getElementById("dashcaddy-history-container");let l=null;function a(p,b){I&&(I.style.display="block",I.style.background=b==="error"?"var(--bad-bg)":b==="success"?"var(--ok-bg)":"var(--bg)",I.style.color=b==="error"?"var(--bad-fg)":b==="success"?"var(--ok-fg)":"var(--fg)",I.textContent=p)}async function n(){try{const b=await(await fetch("/api/v1/system/version")).json();b.success&&(x.textContent="v"+b.version+(b.commit?" ("+b.commit.substring(0,7)+")":""))}catch{x.textContent="Unable to fetch version"}}async function e(p){p||(L.textContent="Checking...",L.disabled=!0);try{const o=await(await fetch("/api/v1/system/update-check")).json();if(l=o,o.success&&o.available&&o.remote){O.style.display="",A.style.display="",N.textContent="v"+o.remote.version,z.textContent=o.remote.changelog||"No changelog available.";const i=document.getElementById("updates-btn");if(i&&!i.querySelector(".update-dot")){const d=document.createElement("span");d.className="update-dot",d.style.cssText="position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--accent);",i.style.position="relative",i.appendChild(d)}const v=document.getElementById("updates-dashcaddy-tab");if(v&&!v.querySelector(".update-dot")){const d=document.createElement("span");d.className="update-dot",d.style.cssText="display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--accent);margin-left:4px;vertical-align:middle;",v.appendChild(d)}}else O.style.display="none",A.style.display="none",p||a("You are running the latest version.","success");p||(L.textContent="Check for Updates",L.disabled=!1)}catch(b){p||(a("Failed to check: "+b.message,"error"),L.textContent="Check for Updates",L.disabled=!1)}}async function t(){if(confirm("Apply DashCaddy update? The API container will restart.")){H.textContent="Updating...",H.disabled=!0,a("Downloading and applying update...","info");try{const b=await(await secureFetch("/api/v1/system/update-apply",{method:"POST"})).json();if(b.success)a("Update initiated: v"+(b.fromVersion||"?")+" \u2192 v"+(b.toVersion||"?")+". The container will restart shortly.","success"),H.textContent="Applied!",document.querySelectorAll(".update-dot").forEach(o=>o.remove());else throw new Error(b.error||"Update failed")}catch(p){a("Update failed: "+p.message,"error"),H.textContent="Update Now",H.disabled=!1}}}async function s(){try{const b=await(await fetch("/api/v1/system/update-history")).json(),o=b.success&&b.history?b.history:[];if(o.length===0){c.innerHTML='
\u{1F4E6}No self-update history.
';return}let i='';i+='';for(const v of o){const d=v.status==="success"?"\u2713 success":v.status==="pending"?"\u23F3 pending":v.status==="partial"?"\u26A0 partial":"\u2717 "+v.status,w=v.status==="success"?"var(--ok-fg)":v.status==="pending"?"var(--muted)":"var(--bad-fg)";i+='',i+='",i+='",i+='",i+='",i+="",v.error&&(i+='"),v.note&&(i+='")}i+="
WhenVersionFromStatus
'+timeAgo(v.timestamp)+"v'+escapeHtml(v.version)+(v.rollback?" (rollback)":"")+"v'+escapeHtml(v.fromVersion||"?")+"'+d+"
'+escapeHtml(v.error)+"
'+escapeHtml(v.note)+"
",c.innerHTML=i}catch(p){c.innerHTML='
Failed: '+escapeHtml(p.message)+"
"}}async function r(){try{const b=await(await fetch("/api/v1/system/rollback-versions")).json(),o=b.success&&b.versions?b.versions:[];if(o.length===0){showNotification("No rollback versions available.","info");return}const i=prompt(`Available rollback versions: + `,w+=``,w+=``,w+=`${F}`,w+=``,w+=""}w+="",B.innerHTML=w,B.querySelectorAll(".save-auto-btn").forEach(T=>{T.addEventListener("click",async()=>{const $=T.dataset.id,P=T.closest("tr"),R=P.querySelector(".auto-schedule").value,U=P.querySelector(".auto-rollback").checked,_=P.querySelector(".auto-window").value.trim();T.textContent="Saving...",T.disabled=!0;try{const F=await(await secureFetch(`/api/v1/updates/auto-update/${encodeURIComponent($)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!!R,schedule:R||"weekly",autoRollback:U,maintenanceWindow:_||void 0})})).json();if(F.success)T.textContent="\u2713 Saved";else throw new Error(F.error)}catch(J){T.textContent="\u2717 Error",showNotification("Save error: "+J.message,"error")}setTimeout(()=>{T.textContent="Save",T.disabled=!1},2e3)})})}catch(p){B.innerHTML=`
Failed: ${escapeHtml(p.message)}
`}}const x=document.getElementById("dashcaddy-current-version"),O=document.getElementById("dashcaddy-update-badge"),A=document.getElementById("dashcaddy-update-details"),N=document.getElementById("dashcaddy-new-version"),z=document.getElementById("dashcaddy-changelog"),H=document.getElementById("dashcaddy-apply-btn"),L=document.getElementById("dashcaddy-check-btn"),g=document.getElementById("dashcaddy-rollback-btn"),I=document.getElementById("dashcaddy-status-bar"),c=document.getElementById("dashcaddy-history-container");let l=null;function a(p,b){I&&(I.style.display="block",I.style.background=b==="error"?"var(--bad-bg)":b==="success"?"var(--ok-bg)":"var(--bg)",I.style.color=b==="error"?"var(--bad-fg)":b==="success"?"var(--ok-fg)":"var(--fg)",I.textContent=p)}async function n(){try{const b=await(await fetch("/api/v1/system/version")).json();b.success&&(x.textContent="v"+b.version+(b.commit?" ("+b.commit.substring(0,7)+")":""))}catch{x.textContent="Unable to fetch version"}}async function e(p){p||(L.textContent="Checking...",L.disabled=!0);try{const o=await(await fetch("/api/v1/system/update-check")).json();if(l=o,o.success&&o.available&&o.remote){O.style.display="",A.style.display="",N.textContent="v"+o.remote.version,z.textContent=o.remote.changelog||"No changelog available.";const i=document.getElementById("updates-btn");if(i&&!i.querySelector(".update-dot")){const d=document.createElement("span");d.className="update-dot",d.style.cssText="position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--accent);",i.style.position="relative",i.appendChild(d)}const v=document.getElementById("updates-dashcaddy-tab");if(v&&!v.querySelector(".update-dot")){const d=document.createElement("span");d.className="update-dot",d.style.cssText="display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--accent);margin-left:4px;vertical-align:middle;",v.appendChild(d)}}else O.style.display="none",A.style.display="none",await n(),p||a("You are running the latest version.","success");p||(L.textContent="Check for Updates",L.disabled=!1)}catch(b){p||(a("Failed to check: "+b.message,"error"),L.textContent="Check for Updates",L.disabled=!1)}}async function t(){if(confirm("Apply DashCaddy update? The API container will restart.")){H.textContent="Updating...",H.disabled=!0,a("Downloading and applying update...","info");try{const b=await(await secureFetch("/api/v1/system/update-apply",{method:"POST"})).json();if(b.success)a("Update initiated: v"+(b.fromVersion||"?")+" \u2192 v"+(b.toVersion||"?")+". The container will restart shortly.","success"),H.textContent="Applied!",document.querySelectorAll(".update-dot").forEach(o=>o.remove());else throw new Error(b.error||"Update failed")}catch(p){a("Update failed: "+p.message,"error"),H.textContent="Update Now",H.disabled=!1}}}async function s(){try{const b=await(await fetch("/api/v1/system/update-history")).json(),o=b.success&&b.history?b.history:[];if(o.length===0){c.innerHTML='
\u{1F4E6}No self-update history.
';return}let i='';i+='';for(const v of o){const d=v.status==="success"?"\u2713 success":v.status==="pending"?"\u23F3 pending":v.status==="partial"?"\u26A0 partial":"\u2717 "+v.status,w=v.status==="success"?"var(--ok-fg)":v.status==="pending"?"var(--muted)":"var(--bad-fg)";i+='',i+='",i+='",i+='",i+='",i+="",v.error&&(i+='"),v.note&&(i+='")}i+="
WhenVersionFromStatus
'+timeAgo(v.timestamp)+"v'+escapeHtml(v.version)+(v.rollback?" (rollback)":"")+"v'+escapeHtml(v.fromVersion||"?")+"'+d+"
'+escapeHtml(v.error)+"
'+escapeHtml(v.note)+"
",c.innerHTML=i}catch(p){c.innerHTML='
Failed: '+escapeHtml(p.message)+"
"}}async function r(){try{const b=await(await fetch("/api/v1/system/rollback-versions")).json(),o=b.success&&b.versions?b.versions:[];if(o.length===0){showNotification("No rollback versions available.","info");return}const i=prompt(`Available rollback versions: `+o.join(` `)+` diff --git a/status/js/update-management.js b/status/js/update-management.js index ff9a9f7..2ae6e98 100644 --- a/status/js/update-management.js +++ b/status/js/update-management.js @@ -378,6 +378,7 @@ } else { dcUpdateBadge.style.display = 'none'; dcUpdateDetails.style.display = 'none'; + await dcLoadVersion(); if (!silent) dcShowStatus('You are running the latest version.', 'success'); }