[pending-judge] feat(DC-168 r4): calendar widget — month-following fetch, window-authoritative event cache, universal theme contrast
Owner directives: "show no upcoming appointments" when empty; "days and times highlighted" per appointment; "properly stylize ... to fit with each theme correctly"; "relatively small widget basically about the size of the weather widget". r3 judge blockers fixed: - Cache semantics extracted to status/js/calendar-cache.js (bundled ahead of the widget; module.exports for tests, window.CalendarCache for browser): entries keyed by uid+start (recurring instances kept distinct); a FETCHED WINDOW IS AUTHORITATIVE — on refetch, entries starting inside that window are replaced/purged (deletions + reschedules propagate), entries outside survive. 5 direct contract tests cover merge, duplicate suppression, recurring instances, stale removal on refetch, cross-window survival. - Chip filters by CURRENT INSTANT against event END (ongoing appointments qualify; started-long-ago with no end excluded). Covered by contract test. - Contract suite (4 cache tests) + ns suite (9) + widget-contract (4) = 18 calendar tests; smoke harness DC168-SMOKE-OK; eslint clean. r1/r2 items carried: universal light-bg contrast (objective WCAG >= 4.5:1 for all 10 builtin themes, worst 4.60 ocean), month-following fetch with refetch on navigation, weather-widget-sized chip, month grid with highlighted days.
This commit is contained in:
9 files changed
+997
-304
No files matched your search
Vendored
+273
-268
@@ -90,19 +90,19 @@
|
||||
<button id="logo-save" class="btn-accent">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("logo-modal"),E=document.getElementById("logo-preview-dark"),j=document.getElementById("logo-preview-light"),h=document.getElementById("logo-status"),P=document.getElementById("logo-same-both"),A=document.getElementById("logo-dual-uploads"),D=document.getElementById("logo-single-upload"),R=document.getElementById("logo-upload-dark"),y=document.getElementById("logo-upload-light"),$=document.getElementById("logo-upload-single"),k=document.querySelector("#brand .brand-logo-dark"),H=document.querySelector("#brand .brand-logo-light"),T=document.querySelector(".top-row"),z=document.getElementById("dashboard-title"),C=DC.NAME;let M=null,b=null,d=null,v="left",S=C;P?.addEventListener("change",()=>{P.checked?(A.style.display="none",D.style.display="",M=null,b=null):(A.style.display="flex",D.style.display="none",d=null)});function O(t,e){if(!t||!t.type.startsWith("image/")){showNotification("Please select an image file","warning");return}const s=new FileReader;s.onload=n=>e(n.target.result),s.readAsDataURL(t)}R?.addEventListener("change",t=>{O(t.target.files[0],e=>{M=e,E.src=e,h.textContent="New dark logo ready to save"})}),y?.addEventListener("change",t=>{O(t.target.files[0],e=>{b=e,j.src=e,h.textContent="New light logo ready to save"})}),$?.addEventListener("change",t=>{O(t.target.files[0],e=>{d=e,E.src=e,j.src=e,h.textContent="New logo ready to save (both themes)"})});function m(t){T.setAttribute("data-logo-pos",t),document.querySelectorAll(".logo-pos-btn").forEach(e=>{e.style.background=e.dataset.pos===t?"var(--accent)":"var(--card-bg)",e.style.color=e.dataset.pos===t?"white":"var(--fg)"})}function f(t){S=t||C,document.title=S;const e=document.querySelector(".dashboard-title");e&&(e.textContent=S)}async function B(){try{const t=await fetch("/api/v1/logo");if(t.ok){const e=await t.json();e.customLogoDark&&(k.src=e.customLogoDark,E.src=e.customLogoDark),e.customLogoLight&&(H.src=e.customLogoLight,j.src=e.customLogoLight),!e.customLogoDark&&!e.customLogoLight&&e.customLogo&&(k.src=e.customLogo,H.src=e.customLogo,E.src=e.customLogo,j.src=e.customLogo),e.isDefault||(h.textContent="Using custom logo"),e.position&&(v=e.position,m(e.position)),e.dashboardTitle&&f(e.dashboardTitle)}}catch(t){console.warn("Could not load custom logo:",t.message)}}document.querySelectorAll(".logo-pos-btn").forEach(t=>{t.addEventListener("click",()=>{v=t.dataset.pos,m(v)})}),document.getElementById("brand")?.addEventListener("click",()=>{M=null,b=null,d=null,R&&(R.value=""),y&&(y.value=""),$&&($.value=""),P&&(P.checked=!1),A.style.display="flex",D.style.display="none",E.src=k.src,j.src=H.src;const t=k.src.includes("custom-logo")||H.src.includes("custom-logo");h.textContent=t?"Using custom logo":"Using default logos",m(v),z.value=S,x.classList.add("show")}),document.getElementById("logo-save")?.addEventListener("click",async()=>{try{const t=z.value.trim()||C,e={position:v,dashboardTitle:t};P?.checked&&d?(e.dataDark=d,e.dataLight=d):(M&&(e.dataDark=M),b&&(e.dataLight=b));const s=await secureFetch("/api/v1/logo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(s.ok){const n=await s.json(),r="?t="+Date.now();n.pathDark&&(k.src=n.pathDark+r,E.src=n.pathDark+r),n.pathLight&&(H.src=n.pathLight+r,j.src=n.pathLight+r),m(v),f(t),x.classList.remove("show")}else{const n=await s.json();showNotification("Failed to save: "+n.error,"error")}}catch(t){showNotification("Error saving: "+t.message,"error")}}),document.getElementById("logo-reset")?.addEventListener("click",async()=>{if(confirm(`Reset all branding to DashCaddy defaults?
|
||||
</div>`);const b=document.getElementById("logo-modal"),h=document.getElementById("logo-preview-dark"),j=document.getElementById("logo-preview-light"),m=document.getElementById("logo-status"),N=document.getElementById("logo-same-both"),A=document.getElementById("logo-dual-uploads"),D=document.getElementById("logo-single-upload"),R=document.getElementById("logo-upload-dark"),g=document.getElementById("logo-upload-light"),L=document.getElementById("logo-upload-single"),k=document.querySelector("#brand .brand-logo-dark"),M=document.querySelector("#brand .brand-logo-light"),I=document.querySelector(".top-row"),$=document.getElementById("dashboard-title"),E=DC.NAME;let T=null,P=null,v=null,B="left",z=E;N?.addEventListener("change",()=>{N.checked?(A.style.display="none",D.style.display="",T=null,P=null):(A.style.display="flex",D.style.display="none",v=null)});function O(n,t){if(!n||!n.type.startsWith("image/")){showNotification("Please select an image file","warning");return}const r=new FileReader;r.onload=e=>t(e.target.result),r.readAsDataURL(n)}R?.addEventListener("change",n=>{O(n.target.files[0],t=>{T=t,h.src=t,m.textContent="New dark logo ready to save"})}),g?.addEventListener("change",n=>{O(n.target.files[0],t=>{P=t,j.src=t,m.textContent="New light logo ready to save"})}),L?.addEventListener("change",n=>{O(n.target.files[0],t=>{v=t,h.src=t,j.src=t,m.textContent="New logo ready to save (both themes)"})});function u(n){I.setAttribute("data-logo-pos",n),document.querySelectorAll(".logo-pos-btn").forEach(t=>{t.style.background=t.dataset.pos===n?"var(--accent)":"var(--card-bg)",t.style.color=t.dataset.pos===n?"white":"var(--fg)"})}function y(n){z=n||E,document.title=z;const t=document.querySelector(".dashboard-title");t&&(t.textContent=z)}async function C(){try{const n=await fetch("/api/v1/logo");if(n.ok){const t=await n.json();t.customLogoDark&&(k.src=t.customLogoDark,h.src=t.customLogoDark),t.customLogoLight&&(M.src=t.customLogoLight,j.src=t.customLogoLight),!t.customLogoDark&&!t.customLogoLight&&t.customLogo&&(k.src=t.customLogo,M.src=t.customLogo,h.src=t.customLogo,j.src=t.customLogo),t.isDefault||(m.textContent="Using custom logo"),t.position&&(B=t.position,u(t.position)),t.dashboardTitle&&y(t.dashboardTitle)}}catch(n){console.warn("Could not load custom logo:",n.message)}}document.querySelectorAll(".logo-pos-btn").forEach(n=>{n.addEventListener("click",()=>{B=n.dataset.pos,u(B)})}),document.getElementById("brand")?.addEventListener("click",()=>{T=null,P=null,v=null,R&&(R.value=""),g&&(g.value=""),L&&(L.value=""),N&&(N.checked=!1),A.style.display="flex",D.style.display="none",h.src=k.src,j.src=M.src;const n=k.src.includes("custom-logo")||M.src.includes("custom-logo");m.textContent=n?"Using custom logo":"Using default logos",u(B),$.value=z,b.classList.add("show")}),document.getElementById("logo-save")?.addEventListener("click",async()=>{try{const n=$.value.trim()||E,t={position:B,dashboardTitle:n};N?.checked&&v?(t.dataDark=v,t.dataLight=v):(T&&(t.dataDark=T),P&&(t.dataLight=P));const r=await secureFetch("/api/v1/logo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r.ok){const e=await r.json(),o="?t="+Date.now();e.pathDark&&(k.src=e.pathDark+o,h.src=e.pathDark+o),e.pathLight&&(M.src=e.pathLight+o,j.src=e.pathLight+o),u(B),y(n),b.classList.remove("show")}else{const e=await r.json();showNotification("Failed to save: "+e.error,"error")}}catch(n){showNotification("Error saving: "+n.message,"error")}}),document.getElementById("logo-reset")?.addEventListener("click",async()=>{if(confirm(`Reset all branding to DashCaddy defaults?
|
||||
|
||||
This will reset the logo, favicon, title, and position.`))try{if((await secureFetch("/api/v1/logo",{method:"DELETE"})).ok&&(k.src="/assets/dashcaddy-logo-dark.png",H.src="/assets/dashcaddy-logo-light.png",E.src="/assets/dashcaddy-logo-dark.png",j.src="/assets/dashcaddy-logo-light.png",h.textContent="Using default logos",M=null,b=null,d=null,z.value=C,f(C),v="left",m("left")),(await secureFetch("/api/v1/favicon",{method:"DELETE"})).ok){const s=document.querySelector('link[rel="icon"]'),n=document.getElementById("favicon-preview"),r=document.getElementById("favicon-status");s&&(s.href="/assets/dashcaddy-favicon.ico?t="+Date.now()),n&&(n.src="/assets/dashcaddy-favicon.ico?t="+Date.now()),r&&(r.textContent="Using DashCaddy favicon"),l=null}}catch(t){showNotification("Error resetting branding: "+t.message,"error")}}),wireModal(x,document.getElementById("logo-cancel"));const w=document.getElementById("favicon-preview"),L=document.getElementById("favicon-status"),o=document.getElementById("favicon-upload"),u=document.querySelector('link[rel="icon"]')||document.createElement("link");let l=null;document.querySelector('link[rel="icon"]')||(u.rel="icon",u.href="/assets/dashcaddy-favicon.ico",document.head.appendChild(u));async function g(){try{const t=await fetch("/api/v1/favicon");if(t.ok){const e=await t.json();e.customFavicon&&(u.href=e.customFavicon+"?t="+Date.now(),w.src=e.customFavicon+"?t="+Date.now(),L.textContent="Using custom favicon")}}catch(t){console.warn("Could not load custom favicon:",t.message)}}o?.addEventListener("change",t=>{const e=t.target.files[0];if(!e)return;if(!e.type.match(/^image\/(png|svg\+xml)$/)){showNotification("Please select a PNG or SVG file","warning"),o.value="";return}const s=new FileReader;s.onload=n=>{l=n.target.result,w.src=l,L.textContent="New favicon ready to save"},s.readAsDataURL(e)}),document.getElementById("logo-save")?.addEventListener("click",async()=>{if(l)try{const t=await secureFetch("/api/v1/favicon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(t.ok){const e=await t.json();u.href=e.path+"?t="+Date.now(),w.src=e.path+"?t="+Date.now(),L.textContent="Using custom favicon",l=null}else{const e=await t.json();showNotification("Failed to save favicon: "+e.error,"error")}}catch(t){showNotification("Error saving favicon: "+t.message,"error")}}),g(),B();const p=document.getElementById("settings-timezone");p&&(new MutationObserver(()=>{x.classList.contains("show")&&p.options.length===0&&(async()=>{let e;try{const s=await fetch("/api/v1/config");s.ok&&(e=(await s.json()).timezone)}catch{}window.populateTimezoneSelect(p,e)})()}).observe(x,{attributes:!0,attributeFilter:["class"]}),document.getElementById("logo-save")?.addEventListener("click",async()=>{const e=p.value;if(e)try{const s=await fetch("/api/v1/config");if(!s.ok)return;const n=await s.json();n.timezone=e,n.updatedAt=new Date().toISOString(),await secureFetch("/api/v1/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch(s){console.warn("Failed to save timezone:",s.message)}}))})(),window.populateTimezoneSelect=function(x,E){const j=Intl.supportedValuesOf("timeZone"),h=E||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";x.innerHTML="";for(const P of j){const A=document.createElement("option");A.value=P,A.textContent=P.replace(/_/g," "),P===h&&(A.selected=!0),x.appendChild(A)}},(function(){let x="homelab",E=null;async function j(){try{const f=await fetch("/api/v1/config");if(f.ok&&(E=await f.json(),E&&E.setupComplete))return document.getElementById("setup-wizard").style.display="none",!0}catch(f){console.warn("Could not fetch server config, checking localStorage fallback:",f.message)}return safeGet("dashcaddy-setup")?(document.getElementById("setup-wizard").style.display="none",!0):(document.getElementById("setup-wizard").style.display="flex",!1)}j();const h=document.getElementById("setup-timezone");h&&window.populateTimezoneSelect(h);function P(m){document.querySelectorAll(".setup-step").forEach(B=>{B.style.display="none"});const f=document.getElementById(m);f&&(f.style.display="block")}function A(){const m=document.getElementById("setup-summary-content");if(!m)return;let f='<div style="display: grid; gap: 20px;">';if(x==="homelab"){const w=document.getElementById("setup-tld")?.value?.trim()||".home",L=document.getElementById("setup-ca-name")?.value?.trim()||"",o=document.getElementById("setup-dns-ip")?.value?.trim()||"",u=document.getElementById("setup-dns-port")?.value?.trim()||DC.DEFAULTS.DNS_PORT;f+=`
|
||||
This will reset the logo, favicon, title, and position.`))try{if((await secureFetch("/api/v1/logo",{method:"DELETE"})).ok&&(k.src="/assets/dashcaddy-logo-dark.png",M.src="/assets/dashcaddy-logo-light.png",h.src="/assets/dashcaddy-logo-dark.png",j.src="/assets/dashcaddy-logo-light.png",m.textContent="Using default logos",T=null,P=null,v=null,$.value=E,y(E),B="left",u("left")),(await secureFetch("/api/v1/favicon",{method:"DELETE"})).ok){const r=document.querySelector('link[rel="icon"]'),e=document.getElementById("favicon-preview"),o=document.getElementById("favicon-status");r&&(r.href="/assets/dashcaddy-favicon.ico?t="+Date.now()),e&&(e.src="/assets/dashcaddy-favicon.ico?t="+Date.now()),o&&(o.textContent="Using DashCaddy favicon"),l=null}}catch(n){showNotification("Error resetting branding: "+n.message,"error")}}),wireModal(b,document.getElementById("logo-cancel"));const w=document.getElementById("favicon-preview"),S=document.getElementById("favicon-status"),i=document.getElementById("favicon-upload"),p=document.querySelector('link[rel="icon"]')||document.createElement("link");let l=null;document.querySelector('link[rel="icon"]')||(p.rel="icon",p.href="/assets/dashcaddy-favicon.ico",document.head.appendChild(p));async function f(){try{const n=await fetch("/api/v1/favicon");if(n.ok){const t=await n.json();t.customFavicon&&(p.href=t.customFavicon+"?t="+Date.now(),w.src=t.customFavicon+"?t="+Date.now(),S.textContent="Using custom favicon")}}catch(n){console.warn("Could not load custom favicon:",n.message)}}i?.addEventListener("change",n=>{const t=n.target.files[0];if(!t)return;if(!t.type.match(/^image\/(png|svg\+xml)$/)){showNotification("Please select a PNG or SVG file","warning"),i.value="";return}const r=new FileReader;r.onload=e=>{l=e.target.result,w.src=l,S.textContent="New favicon ready to save"},r.readAsDataURL(t)}),document.getElementById("logo-save")?.addEventListener("click",async()=>{if(l)try{const n=await secureFetch("/api/v1/favicon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(n.ok){const t=await n.json();p.href=t.path+"?t="+Date.now(),w.src=t.path+"?t="+Date.now(),S.textContent="Using custom favicon",l=null}else{const t=await n.json();showNotification("Failed to save favicon: "+t.error,"error")}}catch(n){showNotification("Error saving favicon: "+n.message,"error")}}),f(),C();const c=document.getElementById("settings-timezone");c&&(new MutationObserver(()=>{b.classList.contains("show")&&c.options.length===0&&(async()=>{let t;try{const r=await fetch("/api/v1/config");r.ok&&(t=(await r.json()).timezone)}catch{}window.populateTimezoneSelect(c,t)})()}).observe(b,{attributes:!0,attributeFilter:["class"]}),document.getElementById("logo-save")?.addEventListener("click",async()=>{const t=c.value;if(t)try{const r=await fetch("/api/v1/config");if(!r.ok)return;const e=await r.json();e.timezone=t,e.updatedAt=new Date().toISOString(),await secureFetch("/api/v1/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(r){console.warn("Failed to save timezone:",r.message)}}))})(),window.populateTimezoneSelect=function(b,h){const j=Intl.supportedValuesOf("timeZone"),m=h||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";b.innerHTML="";for(const N of j){const A=document.createElement("option");A.value=N,A.textContent=N.replace(/_/g," "),N===m&&(A.selected=!0),b.appendChild(A)}},(function(){let b="homelab",h=null;async function j(){try{const y=await fetch("/api/v1/config");if(y.ok&&(h=await y.json(),h&&h.setupComplete))return document.getElementById("setup-wizard").style.display="none",!0}catch(y){console.warn("Could not fetch server config, checking localStorage fallback:",y.message)}return safeGet("dashcaddy-setup")?(document.getElementById("setup-wizard").style.display="none",!0):(document.getElementById("setup-wizard").style.display="flex",!1)}j();const m=document.getElementById("setup-timezone");m&&window.populateTimezoneSelect(m);function N(u){document.querySelectorAll(".setup-step").forEach(C=>{C.style.display="none"});const y=document.getElementById(u);y&&(y.style.display="block")}function A(){const u=document.getElementById("setup-summary-content");if(!u)return;let y='<div style="display: grid; gap: 20px;">';if(b==="homelab"){const w=document.getElementById("setup-tld")?.value?.trim()||".home",S=document.getElementById("setup-ca-name")?.value?.trim()||"",i=document.getElementById("setup-dns-ip")?.value?.trim()||"",p=document.getElementById("setup-dns-port")?.value?.trim()||DC.DEFAULTS.DNS_PORT;y+=`
|
||||
<div>
|
||||
<h3 style="margin: 0 0 12px; color: var(--accent);">Home Lab Configuration</h3>
|
||||
<div style="display: grid; gap: 12px; font-size: 0.95rem;">
|
||||
<div><strong>TLD:</strong> ${w}</div>
|
||||
<div><strong>Certificate Authority:</strong> ${L}</div>
|
||||
<div><strong>DNS Server:</strong> ${o}:${u}</div>
|
||||
<div><strong>Certificate Authority:</strong> ${S}</div>
|
||||
<div><strong>DNS Server:</strong> ${i}:${p}</div>
|
||||
<div><strong>Example URLs:</strong> https://uptime${w}, https://nextcloud${w}</div>
|
||||
</div>
|
||||
</div>
|
||||
`}else if(x==="simple"){const w=document.getElementById("setup-simple-ip")?.value?.trim()||"localhost";f+=`
|
||||
`}else if(b==="simple"){const w=document.getElementById("setup-simple-ip")?.value?.trim()||"localhost";y+=`
|
||||
<div>
|
||||
<h3 style="margin: 0 0 12px; color: var(--accent);">Simple Setup</h3>
|
||||
<div style="display: grid; gap: 12px; font-size: 0.95rem;">
|
||||
@@ -112,22 +112,22 @@ This will reset the logo, favicon, title, and position.`))try{if((await secureFe
|
||||
<div><strong>Example URLs:</strong> http://${w}:8080, http://${w}:3000</div>
|
||||
</div>
|
||||
</div>
|
||||
`}else if(x==="public"){const w=document.getElementById("setup-public-domain")?.value?.trim()||"",L=document.getElementById("setup-public-email")?.value?.trim()||"",o=document.querySelector('input[name="routing-mode"]:checked')?.value||"subdirectory",u=o==="subdirectory"?`https://${w}/sonarr, https://${w}/grafana`:`https://sonarr.${w}, https://grafana.${w}`;f+=`
|
||||
`}else if(b==="public"){const w=document.getElementById("setup-public-domain")?.value?.trim()||"",S=document.getElementById("setup-public-email")?.value?.trim()||"",i=document.querySelector('input[name="routing-mode"]:checked')?.value||"subdirectory",p=i==="subdirectory"?`https://${w}/sonarr, https://${w}/grafana`:`https://sonarr.${w}, https://grafana.${w}`;y+=`
|
||||
<div>
|
||||
<h3 style="margin: 0 0 12px; color: var(--accent);">Public Server</h3>
|
||||
<div style="display: grid; gap: 12px; font-size: 0.95rem;">
|
||||
<div><strong>Domain:</strong> ${w}</div>
|
||||
<div><strong>SSL:</strong> Let's Encrypt</div>
|
||||
<div><strong>Email:</strong> ${L}</div>
|
||||
<div><strong>Routing:</strong> ${o==="subdirectory"?"Subdirectory (domain.com/app)":"Subdomain (app.domain.com)"}</div>
|
||||
<div><strong>Example URLs:</strong> ${u}</div>
|
||||
<div><strong>Email:</strong> ${S}</div>
|
||||
<div><strong>Routing:</strong> ${i==="subdirectory"?"Subdirectory (domain.com/app)":"Subdomain (app.domain.com)"}</div>
|
||||
<div><strong>Example URLs:</strong> ${p}</div>
|
||||
</div>
|
||||
</div>
|
||||
`}const B=document.getElementById("setup-timezone")?.value||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";f+=`
|
||||
`}const C=document.getElementById("setup-timezone")?.value||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC";y+=`
|
||||
<div style="margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border);">
|
||||
<div style="font-size: 0.95rem;"><strong>Timezone:</strong> ${B.replace(/_/g," ")}</div>
|
||||
<div style="font-size: 0.95rem;"><strong>Timezone:</strong> ${C.replace(/_/g," ")}</div>
|
||||
</div>
|
||||
`,f+="</div>",m.innerHTML=f,P("setup-step-summary")}async function D(m){try{const f=await secureFetch("/api/v1/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});return f.ok?(await f.json(),!0):(errorHandler.logError("[SetupWizard] Save Config",new Error(`Server returned ${f.status}`),{function:"saveConfigToServer"}),!1)}catch(f){return errorHandler.logError("[SetupWizard] Save Config",f,{function:"saveConfigToServer"}),!1}}async function R(){const m={setupComplete:!0,configurationType:x,timestamp:new Date().toISOString(),timezone:document.getElementById("setup-timezone")?.value||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"};if(x==="homelab"){m.tld=document.getElementById("setup-tld")?.value?.trim()||".home",m.caName=document.getElementById("setup-ca-name")?.value?.trim()||"";const L=document.getElementById("setup-dns-provider")?.value||"technitium";m.dns={provider:L,ip:document.getElementById("setup-dns-ip")?.value?.trim()||"",port:document.getElementById("setup-dns-port")?.value?.trim()||DC.DEFAULTS.DNS_PORT,token:document.getElementById("setup-dns-token")?.value?.trim()||""},m.defaults={dnsType:"private",sslType:"internal",targetIP:"localhost"}}else x==="simple"?(m.defaultIP=document.getElementById("setup-simple-ip")?.value?.trim()||"localhost",m.defaults={dnsType:"none",sslType:"none",targetIP:m.defaultIP}):x==="public"&&(m.domain=document.getElementById("setup-public-domain")?.value?.trim()||"",m.email=document.getElementById("setup-public-email")?.value?.trim()||"",m.routingMode=document.querySelector('input[name="routing-mode"]:checked')?.value||"subdirectory",m.defaults={dnsType:m.routingMode==="subdirectory"?"none":"public",sslType:"letsencrypt",targetIP:"localhost"});const f=await D(m);safeSet("dashcaddy-config",JSON.stringify(m)),safeSet("dashcaddy-setup","completed"),document.getElementById("setup-wizard").style.display="none";const B=x==="homelab"?"Professional Home Lab":x==="simple"?"Simple Setup":"Public Server",w=f?"server (shared across all devices)":"locally (this browser only)";showNotification(`Setup Complete! Configured for: ${B}. Settings saved to: ${w}`,"success",5e3),setTimeout(()=>location.reload(),500)}const y=document.getElementById("setup-step-1-next");y&&(y.onclick=function(m){m.preventDefault();const f=document.querySelector('input[name="config-type"]:checked');f&&(x=f.value),P(x==="homelab"?"setup-step-homelab":x==="simple"?"setup-step-simple":x==="public"?"setup-step-public":"setup-step-homelab")});const $=document.getElementById("setup-skip");$&&($.onclick=async function(m){m.preventDefault(),confirm("Skip setup? You can run it later from Settings.")&&(await D({setupComplete:!0,skipped:!0,timestamp:new Date().toISOString()}),safeSet("dashcaddy-setup","skipped"),document.getElementById("setup-wizard").style.display="none")});const k=document.getElementById("setup-tld");k&&(k.oninput=function(m){const f=m.target.value||".home",B=document.getElementById("tld-preview"),w=document.getElementById("tld-preview-2");B&&(B.textContent=f),w&&(w.textContent=f)});const H=document.getElementById("setup-homelab-back");H&&(H.onclick=function(m){m.preventDefault(),P("setup-step-1")});const T=document.getElementById("setup-homelab-next");T&&(T.onclick=function(m){m.preventDefault();const f=document.getElementById("setup-tld")?.value?.trim()||"",B=document.getElementById("setup-ca-name")?.value?.trim()||"",w=document.getElementById("setup-dns-ip")?.value?.trim()||"";if(!f||!f.startsWith(".")){showNotification("Please enter a valid TLD starting with a dot (e.g., .home)","warning");return}if(!B){showNotification("Please enter a Certificate Authority name","warning");return}if(!w){showNotification("Please enter your DNS server IP address","warning");return}A()});const z=document.getElementById("setup-simple-back");z&&(z.onclick=function(m){m.preventDefault(),P("setup-step-1")});const C=document.getElementById("setup-simple-next");C&&(C.onclick=function(m){m.preventDefault(),A()}),document.querySelectorAll('input[name="routing-mode"]').forEach(function(m){m.onchange=function(){var f=document.getElementById("dns-requirement-note");f&&(f.textContent=this.value==="subdirectory"?"Only one DNS record needed (for the main domain)":"You'll need to configure DNS manually for each subdomain")}});const M=document.getElementById("setup-public-back");M&&(M.onclick=function(m){m.preventDefault(),P("setup-step-1")});const b=document.getElementById("setup-public-next");b&&(b.onclick=function(m){m.preventDefault();const f=document.getElementById("setup-public-domain")?.value?.trim()||"",B=document.getElementById("setup-public-email")?.value?.trim()||"";if(!f){showNotification("Please enter your domain name","warning");return}if(!B||!B.includes("@")){showNotification("Please enter a valid email address","warning");return}A()});const d=document.getElementById("setup-summary-back");d&&(d.onclick=function(m){m.preventDefault(),x==="homelab"?P("setup-step-homela
Line truncated
|
||||
`,y+="</div>",u.innerHTML=y,N("setup-step-summary")}async function D(u){try{const y=await secureFetch("/api/v1/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});return y.ok?(await y.json(),!0):(errorHandler.logError("[SetupWizard] Save Config",new Error(`Server returned ${y.status}`),{function:"saveConfigToServer"}),!1)}catch(y){return errorHandler.logError("[SetupWizard] Save Config",y,{function:"saveConfigToServer"}),!1}}async function R(){const u={setupComplete:!0,configurationType:b,timestamp:new Date().toISOString(),timezone:document.getElementById("setup-timezone")?.value||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"};if(b==="homelab"){u.tld=document.getElementById("setup-tld")?.value?.trim()||".home",u.caName=document.getElementById("setup-ca-name")?.value?.trim()||"";const S=document.getElementById("setup-dns-provider")?.value||"technitium";u.dns={provider:S,ip:document.getElementById("setup-dns-ip")?.value?.trim()||"",port:document.getElementById("setup-dns-port")?.value?.trim()||DC.DEFAULTS.DNS_PORT,token:document.getElementById("setup-dns-token")?.value?.trim()||""},u.defaults={dnsType:"private",sslType:"internal",targetIP:"localhost"}}else b==="simple"?(u.defaultIP=document.getElementById("setup-simple-ip")?.value?.trim()||"localhost",u.defaults={dnsType:"none",sslType:"none",targetIP:u.defaultIP}):b==="public"&&(u.domain=document.getElementById("setup-public-domain")?.value?.trim()||"",u.email=document.getElementById("setup-public-email")?.value?.trim()||"",u.routingMode=document.querySelector('input[name="routing-mode"]:checked')?.value||"subdirectory",u.defaults={dnsType:u.routingMode==="subdirectory"?"none":"public",sslType:"letsencrypt",targetIP:"localhost"});const y=await D(u);safeSet("dashcaddy-config",JSON.stringify(u)),safeSet("dashcaddy-setup","completed"),document.getElementById("setup-wizard").style.display="none";const C=b==="homelab"?"Professional Home Lab":b==="simple"?"Simple Setup":"Public Server",w=y?"server (shared across all devices)":"locally (this browser only)";showNotification(`Setup Complete! Configured for: ${C}. Settings saved to: ${w}`,"success",5e3),setTimeout(()=>location.reload(),500)}const g=document.getElementById("setup-step-1-next");g&&(g.onclick=function(u){u.preventDefault();const y=document.querySelector('input[name="config-type"]:checked');y&&(b=y.value),N(b==="homelab"?"setup-step-homelab":b==="simple"?"setup-step-simple":b==="public"?"setup-step-public":"setup-step-homelab")});const L=document.getElementById("setup-skip");L&&(L.onclick=async function(u){u.preventDefault(),confirm("Skip setup? You can run it later from Settings.")&&(await D({setupComplete:!0,skipped:!0,timestamp:new Date().toISOString()}),safeSet("dashcaddy-setup","skipped"),document.getElementById("setup-wizard").style.display="none")});const k=document.getElementById("setup-tld");k&&(k.oninput=function(u){const y=u.target.value||".home",C=document.getElementById("tld-preview"),w=document.getElementById("tld-preview-2");C&&(C.textContent=y),w&&(w.textContent=y)});const M=document.getElementById("setup-homelab-back");M&&(M.onclick=function(u){u.preventDefault(),N("setup-step-1")});const I=document.getElementById("setup-homelab-next");I&&(I.onclick=function(u){u.preventDefault();const y=document.getElementById("setup-tld")?.value?.trim()||"",C=document.getElementById("setup-ca-name")?.value?.trim()||"",w=document.getElementById("setup-dns-ip")?.value?.trim()||"";if(!y||!y.startsWith(".")){showNotification("Please enter a valid TLD starting with a dot (e.g., .home)","warning");return}if(!C){showNotification("Please enter a Certificate Authority name","warning");return}if(!w){showNotification("Please enter your DNS server IP address","warning");return}A()});const $=document.getElementById("setup-simple-back");$&&($.onclick=function(u){u.preventDefault(),N("setup-step-1")});const E=document.getElementById("setup-simple-next");E&&(E.onclick=function(u){u.preventDefault(),A()}),document.querySelectorAll('input[name="routing-mode"]').forEach(function(u){u.onchange=function(){var y=document.getElementById("dns-requirement-note");y&&(y.textContent=this.value==="subdirectory"?"Only one DNS record needed (for the main domain)":"You'll need to configure DNS manually for each subdomain")}});const T=document.getElementById("setup-public-back");T&&(T.onclick=function(u){u.preventDefault(),N("setup-step-1")});const P=document.getElementById("setup-public-next");P&&(P.onclick=function(u){u.preventDefault();const y=document.getElementById("setup-public-domain")?.value?.trim()||"",C=document.getElementById("setup-public-email")?.value?.trim()||"";if(!y){showNotification("Please enter your domain name","warning");return}if(!C||!C.includes("@")){showNotification("Please enter a valid email address","warning");return}A()});const v=document.getElementById("setup-summary-back");v&&(v.onclick=function(u){u.preventDefault(),b==="homelab"?N("setup-step-homela
Line truncated
|
||||
<div class="app-selector-content">
|
||||
<h2 style="margin: 0 0 24px; color: var(--fg); text-align: center;">Choose an App</h2>
|
||||
<div id="app-selector-grid" class="app-selector-grid"></div>
|
||||
@@ -333,52 +333,52 @@ This will reset the logo, favicon, title, and position.`))try{if((await secureFe
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const E="custom-apps";let j=null,h=null;const P=document.getElementById("app-selector-modal"),A=document.getElementById("app-selector-grid");async function D(){try{const u=await(await fetch("/api/v1/apps/templates")).json();if(u.success)return j=u.templates,h=u.categories,!0}catch(o){x.logError("[AppSelector] Fetch Templates",o,{function:"fetchApiTemplates"})}return!1}async function R(o){try{return await(await fetch(`/api/v1/apps/ports/${o}/check`)).json()}catch(u){return x.logError("[AppSelector] Check Port",u,{function:"checkPortAvailability"}),{available:!0}}}async function y(o){try{const l=await(await fetch(`/api/v1/apps/ports/${o}/suggest`)).json();if(l.success)return l.suggestedPort}catch(u){x.logError("[AppSelector] Get Suggested Port",u,{function:"getSuggestedPort"})}return o}async function $(){if(A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--muted);">Loading app templates...</div>',!j&&!await D()){A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--error);">Failed to load app templates. Please try again.</div>';return}A.innerHTML="";const o={};for(const[l,g]of Object.entries(j)){const p=g.category||"Other";o[p]||(o[p]=[]),o[p].push({id:l,...g})}const u=h?Object.keys(h):Object.keys(o).sort();for(const l of u){const g=o[l];if(!g||g.length===0)continue;g.sort((e,s)=>(s.popularity||0)-(e.popularity||0));const p=document.createElement("div");p.className="app-category-header";const t=h?.[l]||{};p.innerHTML=`${escapeHtml(t.icon||"")} ${escapeHtml(l)}`,t.color&&(p.style.borderBottomColor=t.color),A.appendChild(p),g.forEach(e=>{const s=document.createElement("div");s.className="app-option";const n=e.isDashboardWidget,r=n&&safeGet("widget-"+e.id+"-enabled")!=="false",a=n?`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: ${r?"#2ecc7130":"#e74c3c30"}; color: ${r?"#2ecc71":"#e74c3c"}; font-weight: 600;">${r?"ON":"OFF"}</div>`:"",i=!n&&e.difficulty?`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: ${e.difficulty==="Easy"?"#2ecc71":e.difficulty==="Intermediate"?"#f39c12":"#e74c3c"}20; color: ${e.difficulty==="Easy"?"#2ecc71":e.difficulty==="Intermediate"?"#f39c12":"#e74c3c"};">${escapeHtml(e.difficulty)}</div>`:"";s.innerHTML=`
|
||||
<div class="app-option-icon">${escapeHtml(e.icon||"\u{1F4E6}")}</div>
|
||||
<div class="app-option-name">${escapeHtml(e.name)}</div>
|
||||
<div class="app-option-desc">${escapeHtml(e.description||"")}</div>
|
||||
${a}${i}
|
||||
`,n?s.onclick=()=>k(e,s):s.onclick=()=>H(e),A.appendChild(s)})}window.renderRecipeCards&&await window.renderRecipeCards(A)}function k(o,u){const l="widget-"+o.id+"-enabled",p=!(safeGet(l)!=="false");safeSet(l,String(p));const t=o.widgetSelector;if(t){const s=document.querySelector(t);s&&(s.style.display=p?"":"none")}const e=u.querySelector('div[style*="border-radius: 4px"]');e&&(e.textContent=p?"ON":"OFF",e.style.background=p?"#2ecc7130":"#e74c3c30",e.style.color=p?"#2ecc71":"#e74c3c"),showNotification(`${o.name} widget ${p?"enabled":"disabled"}`,"success",2e3)}async function H(o){const u=document.getElementById("app-deploy-modal"),l=document.getElementById("app-deploy-title"),g=document.getElementById("deploy-subdomain"),p=document.getElementById("deploy-url-preview"),t=document.getElementById("deploy-ip"),e=document.getElementById("deploy-port"),s=document.getElementById("deploy-tailscale-only"),n=document.getElementById("tailscale-status");try{const G=await(await secureFetch("/api/v1/apps/check-existing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:o.id})})).json();if(G.success&&G.exists){const V=G.container;confirm(`Found existing ${o.name} container:
|
||||
</div>`);const h="custom-apps";let j=null,m=null;const N=document.getElementById("app-selector-modal"),A=document.getElementById("app-selector-grid");async function D(){try{const p=await(await fetch("/api/v1/apps/templates")).json();if(p.success)return j=p.templates,m=p.categories,!0}catch(i){b.logError("[AppSelector] Fetch Templates",i,{function:"fetchApiTemplates"})}return!1}async function R(i){try{return await(await fetch(`/api/v1/apps/ports/${i}/check`)).json()}catch(p){return b.logError("[AppSelector] Check Port",p,{function:"checkPortAvailability"}),{available:!0}}}async function g(i){try{const l=await(await fetch(`/api/v1/apps/ports/${i}/suggest`)).json();if(l.success)return l.suggestedPort}catch(p){b.logError("[AppSelector] Get Suggested Port",p,{function:"getSuggestedPort"})}return i}async function L(){if(A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--muted);">Loading app templates...</div>',!j&&!await D()){A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--error);">Failed to load app templates. Please try again.</div>';return}A.innerHTML="";const i={};for(const[l,f]of Object.entries(j)){const c=f.category||"Other";i[c]||(i[c]=[]),i[c].push({id:l,...f})}const p=m?Object.keys(m):Object.keys(i).sort();for(const l of p){const f=i[l];if(!f||f.length===0)continue;f.sort((t,r)=>(r.popularity||0)-(t.popularity||0));const c=document.createElement("div");c.className="app-category-header";const n=m?.[l]||{};c.innerHTML=`${escapeHtml(n.icon||"")} ${escapeHtml(l)}`,n.color&&(c.style.borderBottomColor=n.color),A.appendChild(c),f.forEach(t=>{const r=document.createElement("div");r.className="app-option";const e=t.isDashboardWidget,o=e&&safeGet("widget-"+t.id+"-enabled")!=="false",a=e?`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: ${o?"#2ecc7130":"#e74c3c30"}; color: ${o?"#2ecc71":"#e74c3c"}; font-weight: 600;">${o?"ON":"OFF"}</div>`:"",s=!e&&t.difficulty?`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: ${t.difficulty==="Easy"?"#2ecc71":t.difficulty==="Intermediate"?"#f39c12":"#e74c3c"}20; color: ${t.difficulty==="Easy"?"#2ecc71":t.difficulty==="Intermediate"?"#f39c12":"#e74c3c"};">${escapeHtml(t.difficulty)}</div>`:"";r.innerHTML=`
|
||||
<div class="app-option-icon">${escapeHtml(t.icon||"\u{1F4E6}")}</div>
|
||||
<div class="app-option-name">${escapeHtml(t.name)}</div>
|
||||
<div class="app-option-desc">${escapeHtml(t.description||"")}</div>
|
||||
${a}${s}
|
||||
`,e?r.onclick=()=>k(t,r):r.onclick=()=>M(t),A.appendChild(r)})}window.renderRecipeCards&&await window.renderRecipeCards(A)}function k(i,p){const l="widget-"+i.id+"-enabled",c=!(safeGet(l)!=="false");safeSet(l,String(c));const n=i.widgetSelector;if(n){const r=document.querySelector(n);r&&(r.style.display=c?"":"none")}const t=p.querySelector('div[style*="border-radius: 4px"]');t&&(t.textContent=c?"ON":"OFF",t.style.background=c?"#2ecc7130":"#e74c3c30",t.style.color=c?"#2ecc71":"#e74c3c"),showNotification(`${i.name} widget ${c?"enabled":"disabled"}`,"success",2e3)}async function M(i){const p=document.getElementById("app-deploy-modal"),l=document.getElementById("app-deploy-title"),f=document.getElementById("deploy-subdomain"),c=document.getElementById("deploy-url-preview"),n=document.getElementById("deploy-ip"),t=document.getElementById("deploy-port"),r=document.getElementById("deploy-tailscale-only"),e=document.getElementById("tailscale-status");try{const G=await(await secureFetch("/api/v1/apps/check-existing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:i.id})})).json();if(G.success&&G.exists){const K=G.container;confirm(`Found existing ${i.name} container:
|
||||
|
||||
Container: ${V.name}
|
||||
Status: ${V.status}
|
||||
Port: ${V.primaryPort||"N/A"}
|
||||
Container: ${K.name}
|
||||
Status: ${K.status}
|
||||
Port: ${K.primaryPort||"N/A"}
|
||||
|
||||
Would you like to use this existing container?
|
||||
|
||||
Click OK to configure DNS/Caddy for the existing container.
|
||||
Click Cancel to deploy a new container.`)&&(o._useExisting=!0,o._existingContainer=V)}}catch{}l.textContent=`Deploy ${o.name}`;const r=o.subdomain||o.id.replace(/-/g,"");g.value=r;const a=document.getElementById("subpath-compat-warning");if(a)if(SITE.routingMode==="subdirectory"){const W=o.subpathSupport||"strip";W==="none"?(a.style.display="block",a.innerHTML='<span style="color: #ff9800;">⚠ <strong>'+o.name+"</strong> does not support subdirectory mode. It may not work correctly at a subpath.</span>"):W==="strip"?(a.style.display="block",a.innerHTML='<span style="color: var(--muted);">ⓘ '+o.name+" has unverified subdirectory support. It may require additional configuration.</span>"):a.style.display="none"}else a.style.display="none";const i=SITE.defaults.dnsType||(SITE.configurationType==="public"?"public":"private"),c=SITE.defaults.sslType||(SITE.configurationType==="public"?"letsencrypt":"internal"),I=document.querySelector(`input[name="dns-type"][value="${i}"]`),N=document.querySelector(`input[name="ssl-type"][value="${c}"]`);I?I.checked=!0:document.querySelector('input[name="dns-type"][value="private"]').checked=!0,N?N.checked=!0:document.querySelector('input[name="ssl-type"][value="internal"]').checked=!0,t.value=SITE.defaults.targetIP||"localhost",s.checked=!1;const U=document.querySelector("#app-deploy-modal .flex-col-gap")?.closest("div"),_=document.querySelector("#app-deploy-modal details"),F=_?.querySelector("div");if(_&&F&&(SITE.configurationType==="public"||SITE.configurationType==="homelab")){const W=document.querySelectorAll('#app-deploy-modal input[name="dns-type"]')[0]?.closest("div.flex-col-gap")?.parentElement,G=document.querySelectorAll('#app-deploy-modal input[name="ssl-type"]')[0]?.closest("div.flex-col-gap")?.parentElement;W&&!W.dataset.moved&&(F.appendChild(W),W.dataset.moved="1"),G&&!G.dataset.moved&&(F.appendChild(G),G.dataset.moved="1")}const q=document.getElementById("media-path-section"),J=document.getElementById("deploy-media-path"),X=document.getElementById("media-path-description");if(o.mediaMount){q.style.display="block",J.value="",J.placeholder="/media/Movies, /media/TVShows or click Browse";const W=document.getElementById("detected-mounts-container"),G=document.getElementById("detected-mounts-list");try{const K=await(await fetch("/api/v1/media/detected-mounts")).json();if(K.success&&K.mounts.length>0){W.style.display="block",G.innerHTML="";const te=[...new Set(K.mounts.map(ee=>ee.hostPath))];J.value=te.join(", "),K.mounts.forEach(ee=>{const Z=document.createElement("button");Z.type="button";const de=te.includes(ee.hostPath);Z.style.cssText=`padding: 8px 14px; font-size: 0.85rem; background: color-mix(in srgb, var(--success) ${de?"40%":"15%"}, var(--card-bg)); border: 1px solid var(--success); border-radius: 6px; cursor: pointer; color: var(--fg);`,Z.innerHTML=`<span style="font-weight: 500;">${escapeHtml(ee.folderName)}</span><br><span style="font-size: 0.7rem; color: var(--muted);">from ${escapeHtml(ee.sourceImage)}</span>`,Z.title=`${ee.hostPath} (from ${ee.sourceContainer})`,Z.onclick=()=>{const le=J.value.split(",").map(ce=>ce.trim()).filter(ce=>ce),pe=le.indexOf(ee.hostPath);pe>=0?(le.splice(pe,1),Z.style.background="color-mix(in srgb, var(--success) 15%, var(--card-bg))"):(le.push(ee.hostPath),Z.style.background="color-mix(in srgb, var(--success) 40%, var(--card-bg))"),J.value=le.join(", ")},G.appendChild(Z)})}else W.style.display="none"}catch{W.style.display="none"}document.getElementById("browse-media-btn").onclick=()=>{openFolderBrowser(J)}}else q.style.display="none",J.value="",document.getElementById("detected-mounts-container").style.display="none";const Q=document.getElementById("plex-claim-section");Q&&(o.id==="plex"||o.claimToken?(Q.style.display="block",document.getElementById("deploy-plex-claim").value=""):Q.style.display="none");const ne=document.getElementById("volume-mounts-section"),oe=document.getElementById("volume-mounts-list");if(oe.innerHTML="",o.docker?.volumes?.length){const W=o.mediaMount?.containerPath,G=o.docker.volumes.filter(V=>!V.includes("{{MEDIA_PATH}}")&&!(W&&V.endsWith(":"+W)));G.length>0?(ne.style.display="block",G.forEach((V,K)=>{const[te,ee]=V.split(":"),Z=document.createElement("div");Z.style.cssText="display: flex; gap: 6px; align-items: center;",Z.innerHTML=`
|
||||
<input type="text" class="vol-host-path" data-container-path="${ee}" value="${te}"
|
||||
Click Cancel to deploy a new container.`)&&(i._useExisting=!0,i._existingContainer=K)}}catch{}l.textContent=`Deploy ${i.name}`;const o=i.subdomain||i.id.replace(/-/g,"");f.value=o;const a=document.getElementById("subpath-compat-warning");if(a)if(SITE.routingMode==="subdirectory"){const W=i.subpathSupport||"strip";W==="none"?(a.style.display="block",a.innerHTML='<span style="color: #ff9800;">⚠ <strong>'+i.name+"</strong> does not support subdirectory mode. It may not work correctly at a subpath.</span>"):W==="strip"?(a.style.display="block",a.innerHTML='<span style="color: var(--muted);">ⓘ '+i.name+" has unverified subdirectory support. It may require additional configuration.</span>"):a.style.display="none"}else a.style.display="none";const s=SITE.defaults.dnsType||(SITE.configurationType==="public"?"public":"private"),d=SITE.defaults.sslType||(SITE.configurationType==="public"?"letsencrypt":"internal"),x=document.querySelector(`input[name="dns-type"][value="${s}"]`),H=document.querySelector(`input[name="ssl-type"][value="${d}"]`);x?x.checked=!0:document.querySelector('input[name="dns-type"][value="private"]').checked=!0,H?H.checked=!0:document.querySelector('input[name="ssl-type"][value="internal"]').checked=!0,n.value=SITE.defaults.targetIP||"localhost",r.checked=!1;const U=document.querySelector("#app-deploy-modal .flex-col-gap")?.closest("div"),_=document.querySelector("#app-deploy-modal details"),F=_?.querySelector("div");if(_&&F&&(SITE.configurationType==="public"||SITE.configurationType==="homelab")){const W=document.querySelectorAll('#app-deploy-modal input[name="dns-type"]')[0]?.closest("div.flex-col-gap")?.parentElement,G=document.querySelectorAll('#app-deploy-modal input[name="ssl-type"]')[0]?.closest("div.flex-col-gap")?.parentElement;W&&!W.dataset.moved&&(F.appendChild(W),W.dataset.moved="1"),G&&!G.dataset.moved&&(F.appendChild(G),G.dataset.moved="1")}const q=document.getElementById("media-path-section"),J=document.getElementById("deploy-media-path"),V=document.getElementById("media-path-description");if(i.mediaMount){q.style.display="block",J.value="",J.placeholder="/media/Movies, /media/TVShows or click Browse";const W=document.getElementById("detected-mounts-container"),G=document.getElementById("detected-mounts-list");try{const Y=await(await fetch("/api/v1/media/detected-mounts")).json();if(Y.success&&Y.mounts.length>0){W.style.display="block",G.innerHTML="";const ae=[...new Set(Y.mounts.map(te=>te.hostPath))];J.value=ae.join(", "),Y.mounts.forEach(te=>{const ee=document.createElement("button");ee.type="button";const de=ae.includes(te.hostPath);ee.style.cssText=`padding: 8px 14px; font-size: 0.85rem; background: color-mix(in srgb, var(--success) ${de?"40%":"15%"}, var(--card-bg)); border: 1px solid var(--success); border-radius: 6px; cursor: pointer; color: var(--fg);`,ee.innerHTML=`<span style="font-weight: 500;">${escapeHtml(te.folderName)}</span><br><span style="font-size: 0.7rem; color: var(--muted);">from ${escapeHtml(te.sourceImage)}</span>`,ee.title=`${te.hostPath} (from ${te.sourceContainer})`,ee.onclick=()=>{const le=J.value.split(",").map(ce=>ce.trim()).filter(ce=>ce),pe=le.indexOf(te.hostPath);pe>=0?(le.splice(pe,1),ee.style.background="color-mix(in srgb, var(--success) 15%, var(--card-bg))"):(le.push(te.hostPath),ee.style.background="color-mix(in srgb, var(--success) 40%, var(--card-bg))"),J.value=le.join(", ")},G.appendChild(ee)})}else W.style.display="none"}catch{W.style.display="none"}document.getElementById("browse-media-btn").onclick=()=>{openFolderBrowser(J)}}else q.style.display="none",J.value="",document.getElementById("detected-mounts-container").style.display="none";const X=document.getElementById("plex-claim-section");X&&(i.id==="plex"||i.claimToken?(X.style.display="block",document.getElementById("deploy-plex-claim").value=""):X.style.display="none");const ne=document.getElementById("volume-mounts-section"),oe=document.getElementById("volume-mounts-list");if(oe.innerHTML="",i.docker?.volumes?.length){const W=i.mediaMount?.containerPath,G=i.docker.volumes.filter(K=>!K.includes("{{MEDIA_PATH}}")&&!(W&&K.endsWith(":"+W)));G.length>0?(ne.style.display="block",G.forEach((K,Y)=>{const[ae,te]=K.split(":"),ee=document.createElement("div");ee.style.cssText="display: flex; gap: 6px; align-items: center;",ee.innerHTML=`
|
||||
<input type="text" class="vol-host-path" data-container-path="${te}" value="${ae}"
|
||||
style="flex: 1; padding: 8px; background: var(--card-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem;" />
|
||||
<span style="color: var(--muted); font-size: 0.85rem; white-space: nowrap;">\u2192 ${ee}</span>
|
||||
<span style="color: var(--muted); font-size: 0.85rem; white-space: nowrap;">\u2192 ${te}</span>
|
||||
<button type="button" class="vol-browse-btn" style="padding: 8px 10px; background: var(--accent); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.8rem;">\u{1F4C2}</button>
|
||||
`,oe.appendChild(Z),Z.querySelector(".vol-browse-btn").onclick=()=>{const de=Z.querySelector(".vol-host-path");openFolderBrowser(de)}})):ne.style.display="none"}else ne.style.display="none";const se=o.defaultPort||8080;e.value="",e.placeholder=`Default: ${se}`;let Y=document.getElementById("deploy-port-status");Y||(Y=document.createElement("div"),Y.id="deploy-port-status",Y.style.cssText="font-size: 0.8rem; margin-top: 4px;",e.parentNode.appendChild(Y));async function ie(){const W=e.value||se;Y.innerHTML='<span style="color: var(--muted);">Checking port...</span>';const G=await R(W);if(G.available)Y.innerHTML=`<span style="color: #4caf50;">Port ${escapeHtml(String(W))} is available</span>`;else{const V=await y(se);Y.innerHTML=`
|
||||
`,oe.appendChild(ee),ee.querySelector(".vol-browse-btn").onclick=()=>{const de=ee.querySelector(".vol-host-path");openFolderBrowser(de)}})):ne.style.display="none"}else ne.style.display="none";const Z=i.defaultPort||8080;t.value="",t.placeholder=`Default: ${Z}`;let Q=document.getElementById("deploy-port-status");Q||(Q=document.createElement("div"),Q.id="deploy-port-status",Q.style.cssText="font-size: 0.8rem; margin-top: 4px;",t.parentNode.appendChild(Q));async function ie(){const W=t.value||Z;Q.innerHTML='<span style="color: var(--muted);">Checking port...</span>';const G=await R(W);if(G.available)Q.innerHTML=`<span style="color: #4caf50;">Port ${escapeHtml(String(W))} is available</span>`;else{const K=await g(Z);Q.innerHTML=`
|
||||
<span style="color: #e74c3c;">Port ${escapeHtml(W)} in use by ${escapeHtml(G.conflict?.usedBy||"unknown")}</span>
|
||||
`;const K=document.createElement("button");K.type="button",K.textContent=`Use ${V}`,K.style.cssText="margin-left: 8px; padding: 2px 8px; font-size: 0.75rem; cursor: pointer;",K.onclick=()=>{document.getElementById("deploy-port").value=V,Y.innerHTML=`<span style="color: #4caf50;">Using suggested port ${escapeHtml(String(V))}</span>`},Y.appendChild(K)}}let re;e.oninput=function(){clearTimeout(re),re=setTimeout(ie,500)},ie();try{const G=await(await fetch("/api/v1/tailscale/status")).json();G.success&&G.installed&&G.connected?n.innerHTML=`
|
||||
`;const Y=document.createElement("button");Y.type="button",Y.textContent=`Use ${K}`,Y.style.cssText="margin-left: 8px; padding: 2px 8px; font-size: 0.75rem; cursor: pointer;",Y.onclick=()=>{document.getElementById("deploy-port").value=K,Q.innerHTML=`<span style="color: #4caf50;">Using suggested port ${escapeHtml(String(K))}</span>`},Q.appendChild(Y)}}let re;t.oninput=function(){clearTimeout(re),re=setTimeout(ie,500)},ie();try{const G=await(await fetch("/api/v1/tailscale/status")).json();G.success&&G.installed&&G.connected?e.innerHTML=`
|
||||
<span style="color: #4caf50;">Connected</span>
|
||||
<span style="color: var(--muted); margin-left: 8px;">${G.self?.hostname} (${G.self?.ip})</span>
|
||||
<span style="color: var(--muted); margin-left: 8px;">| ${G.deviceCount} devices</span>
|
||||
`:G.installed?n.innerHTML='<span style="color: #ff9800;">Not connected</span>':(n.innerHTML='<span style="color: var(--muted);">Not available</span>',s.disabled=!0)}catch{n.innerHTML='<span style="color: var(--muted);">Could not check status</span>'}function ae(){const W=g.value||"subdomain",G=document.querySelector('input[name="dns-type"]:checked').value,V=document.querySelector('input[name="ssl-type"]:checked').value;let K="";if(SITE.routingMode==="subdirectory"&&SITE.domain)K=`https://${SITE.domain}/${W}`;else if(G==="private")K=`${V==="none"?"http":"https"}://${buildDomain(W)}`;else if(G==="public"){const te=V==="none"?"http":"https",ee=SITE.domain||W;K=SITE.domain?`${te}://${W}.${SITE.domain}`:`${te}://${W}`}else{const te=e.value||o.defaultPort||DC.DEFAULTS.SERVICE_PORT;K=`http://${t.value}:${te}`}p.textContent=K}g.oninput=ae,t.oninput=ae,e.oninput=ae,document.querySelectorAll('input[name="dns-type"]').forEach(W=>{W.onchange=ae}),document.querySelectorAll('input[name="ssl-type"]').forEach(W=>{W.onchange=ae}),ae(),P.classList.remove("show"),u.classList.add("show"),u.dataset.appTemplate=JSON.stringify(o)}async function T(o){const u=o.appTemplate,l=safeGetJSON(E,[]),g=u._useExisting&&u._existingContainer,p=l.find(t=>t.id===o.subdomain);if(!(p&&!g&&!confirm(`An app with subdomain "${o.subdomain}" already exists. Redeploy?`))){if(p){const t=l.indexOf(p);l.splice(t,1),safeSet(E,JSON.stringify(l))}if(g)o.port=u._existingContainer.primaryPort;else{const t=o.port||u.defaultPort||8080;showNotification(`Checking port ${t} availability...`,"info",0);const e=await R(t);if(!e.available){const s=await y(u.defaultPort||8080);if(confirm(`Port ${t} is already in use by ${e.conflict?.usedBy||"another container"}.
|
||||
`:G.installed?e.innerHTML='<span style="color: #ff9800;">Not connected</span>':(e.innerHTML='<span style="color: var(--muted);">Not available</span>',r.disabled=!0)}catch{e.innerHTML='<span style="color: var(--muted);">Could not check status</span>'}function se(){const W=f.value||"subdomain",G=document.querySelector('input[name="dns-type"]:checked').value,K=document.querySelector('input[name="ssl-type"]:checked').value;let Y="";if(SITE.routingMode==="subdirectory"&&SITE.domain)Y=`https://${SITE.domain}/${W}`;else if(G==="private")Y=`${K==="none"?"http":"https"}://${buildDomain(W)}`;else if(G==="public"){const ae=K==="none"?"http":"https",te=SITE.domain||W;Y=SITE.domain?`${ae}://${W}.${SITE.domain}`:`${ae}://${W}`}else{const ae=t.value||i.defaultPort||DC.DEFAULTS.SERVICE_PORT;Y=`http://${n.value}:${ae}`}c.textContent=Y}f.oninput=se,n.oninput=se,t.oninput=se,document.querySelectorAll('input[name="dns-type"]').forEach(W=>{W.onchange=se}),document.querySelectorAll('input[name="ssl-type"]').forEach(W=>{W.onchange=se}),se(),N.classList.remove("show"),p.classList.add("show"),p.dataset.appTemplate=JSON.stringify(i)}async function I(i){const p=i.appTemplate,l=safeGetJSON(h,[]),f=p._useExisting&&p._existingContainer,c=l.find(n=>n.id===i.subdomain);if(!(c&&!f&&!confirm(`An app with subdomain "${i.subdomain}" already exists. Redeploy?`))){if(c){const n=l.indexOf(c);l.splice(n,1),safeSet(h,JSON.stringify(l))}if(f)i.port=p._existingContainer.primaryPort;else{const n=i.port||p.defaultPort||8080;showNotification(`Checking port ${n} availability...`,"info",0);const t=await R(n);if(!t.available){const r=await g(p.defaultPort||8080);if(confirm(`Port ${n} is already in use by ${t.conflict?.usedBy||"another container"}.
|
||||
|
||||
Would you like to use port ${s} instead?`))o.port=s;else{showNotification("Deployment cancelled - port conflict","error",5e3);return}}}showNotification(g?`Configuring ${u.name} with existing container...`:`Deploying ${u.name}...`,"info",0);try{const t={appId:u.id,config:{subdomain:o.subdomain,ip:o.ip,createDns:o.dnsType==="private",port:o.port||u.defaultPort||null,sslType:o.sslType,dnsType:o.dnsType,tailscaleOnly:o.tailscaleOnly||!1,mediaPath:o.mediaPath||null,plexClaimToken:o.plexClaimToken||null,customVolumes:o.customVolumes||null}};g&&(t.config.useExisting=!0,t.config.existingContainerId=u._existingContainer.id,t.config.existingPort=u._existingContainer.primaryPort,!o.port&&u._existingContainer.primaryPort&&(t.config.port=u._existingContainer.primaryPort));const e={app:u.id,port:o.port||u.defaultPort||null,subdomain:o.subdomain||"",media_path:o.mediaPath||"",env:o.plexClaimToken?{PLEX_CLAIM:o.plexClaimToken}:{}},n=await(await secureFetch("/api/v1/deploys/catalog/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json();if(n.success){const r={id:o.subdomain,name:u.name,logo:`/assets/${u.id}.png`,containerId:null,url:n.url||`http://127.0.0.1:${e.port}`,ip:o.ip,appTemplate:u.id,tailscaleOnly:o.tailscaleOnly||!1};l.push(r),safeSet(E,JSON.stringify(l)),window.APPS&&!window.APPS.some(i=>i.id===u.id)&&(window.APPS.push(r),typeof window.buildGrid=="function"&&window.buildGrid(),typeof window.refreshAll=="function"&&setTimeout(()=>window.refreshAll(),500));let a=n.usedExisting?`${u.name} configured with existing container!
|
||||
URL: ${n.url}`:`${u.name} deployed successfully!
|
||||
URL: ${n.url}`;n.warning&&(a+=`
|
||||
Would you like to use port ${r} instead?`))i.port=r;else{showNotification("Deployment cancelled - port conflict","error",5e3);return}}}showNotification(f?`Configuring ${p.name} with existing container...`:`Deploying ${p.name}...`,"info",0);try{const n={appId:p.id,config:{subdomain:i.subdomain,ip:i.ip,createDns:i.dnsType==="private",port:i.port||p.defaultPort||null,sslType:i.sslType,dnsType:i.dnsType,tailscaleOnly:i.tailscaleOnly||!1,mediaPath:i.mediaPath||null,plexClaimToken:i.plexClaimToken||null,customVolumes:i.customVolumes||null}};f&&(n.config.useExisting=!0,n.config.existingContainerId=p._existingContainer.id,n.config.existingPort=p._existingContainer.primaryPort,!i.port&&p._existingContainer.primaryPort&&(n.config.port=p._existingContainer.primaryPort));const t={app:p.id,port:i.port||p.defaultPort||null,subdomain:i.subdomain||"",media_path:i.mediaPath||"",env:i.plexClaimToken?{PLEX_CLAIM:i.plexClaimToken}:{}},e=await(await secureFetch("/api/v1/deploys/catalog/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json();if(e.success){const o={id:i.subdomain,name:p.name,logo:`/assets/${p.id}.png`,containerId:null,url:e.url||`http://127.0.0.1:${t.port}`,ip:i.ip,appTemplate:p.id,tailscaleOnly:i.tailscaleOnly||!1};l.push(o),safeSet(h,JSON.stringify(l)),window.APPS&&!window.APPS.some(s=>s.id===p.id)&&(window.APPS.push(o),typeof window.buildGrid=="function"&&window.buildGrid(),typeof window.refreshAll=="function"&&setTimeout(()=>window.refreshAll(),500));let a=e.usedExisting?`${p.name} configured with existing container!
|
||||
URL: ${e.url}`:`${p.name} deployed successfully!
|
||||
URL: ${e.url}`;e.warning&&(a+=`
|
||||
|
||||
\u26A0 Warning: ${n.warning}`),showNotification(a,"success",8e3),delete u._useExisting,delete u._existingContainer,n.url&&n.url.startsWith("https://")&&z(n.url,u.name),n.setupInstructions&&n.setupInstructions.length>0&&setTimeout(()=>{const i=n.setupInstructions.join(`
|
||||
`);showNotification(`Setup Instructions for ${u.name}: ${i}`,"info",1e4)},1e3)}else throw new Error(n.error||"Deployment failed")}catch(t){x.logError("[AppSelector] Deployment",t,{function:"deploy"}),showNotification(`Failed to deploy ${u.name}: ${t.message}`,"error",8e3)}}}async function z(o,u){showNotification(`\u23F3 Generating SSL certificate for ${u}...`,"warning",6e4);let l=0;const g=12,p=async()=>{l++;try{const t=await fetch(o,{method:"HEAD",mode:"no-cors"});return showNotification(`\u2705 ${u} is ready! SSL certificate generated.`,"success",5e3),!0}catch{return l<g?setTimeout(p,5e3):showNotification(`\u26A0\uFE0F ${u} deployed but SSL certificate may still be generating.
|
||||
Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};setTimeout(p,3e3)}function C(){safeGetJSON(E,[]).forEach(u=>{window.APPS.some(l=>l.id===u.id)||window.APPS.push(u)})}document.getElementById("add-service-btn")?.addEventListener("click",()=>{$(),P.classList.add("show")}),window.openDeployConfigFor=async function(o){if(!j&&!await D())return!1;const u=String(o||"").toLowerCase(),l=Object.entries(j).find(([p])=>p.toLowerCase()===u);if(!l)return!1;const g={id:l[0],...l[1]};return g.isDashboardWidget?(await $(),P.classList.add("show"),"selector"):(await H(g),!0)},wireModal(P,document.getElementById("app-selector-cancel"));const M=document.getElementById("app-deploy-modal");document.getElementById("app-deploy-cancel")?.addEventListener("click",()=>{M.classList.remove("show")}),document.getElementById("app-deploy-confirm")?.addEventListener("click",()=>{const o=JSON.parse(M.dataset.appTemplate),u=document.getElementById("deploy-media-path").value.trim(),l=[];document.querySelectorAll("#volume-mounts-list .vol-host-path").forEach(p=>{l.push({hostPath:p.value.trim(),containerPath:p.dataset.containerPath})});const g={appTemplate:o,subdomain:document.getElementById("deploy-subdomain").value.trim(),dnsType:document.querySelector('input[name="dns-type"]:checked').value,sslType:document.querySelector('input[name="ssl-type"]:checked').value,ip:document.getElementById("deploy-ip").value.trim(),port:document.getElementById("deploy-port").value.trim(),tailscaleOnly:document.getElementById("deploy-tailscale-only").checked,mediaPath:u||null,plexClaimToken:document.getElementById("deploy-plex-claim")?.value.trim()||null,customVolumes:l.length>0?l:null,resources:{cpus:parseFloat(document.getElementById("deploy-cpu-limit").value)||0,memory:parseFloat(document.getElementById("deploy-memory-limit").value)||0}};if(!g.subdomain){showNotification("Please enter a subdomain or domain name","warning");return}if(o.mediaMount?.required&&!u){showNotification("Please enter a media library path for this application","warning");return}M.classList.remove("show"),T(g)}),wireModal(M);const b=document.getElementById("folder-browser-modal"),d=document.getElementById("folder-browser-path"),v=document.getElementById("folder-browser-list"),S=document.getElementById("folder-browser-selected"),O=document.getElementById("folder-browser-selected-list");let m="",f=[],B=null;window.openFolderBrowser=function(o){B=o,f=o.value.split(",").map(u=>u.trim()).filter(u=>u),m="",L(),w(""),b.classList.add("show")};async function w(o){d.textContent=o||"Select a drive...",v.innerHTML='<div style="padding: 20px; text-align: center; color: var(--muted);">Loading...</div>';try{const l=await(await fetch(`/api/v1/browse/directories?path=${encodeURIComponent(o)}`)).json();if(!l.success){v.innerHTML=`<div style="padding: 20px; text-align: center; color: var(--error);">Error: ${escapeHtml(l.error)}</div>`;return}m=l.path||"",d.textContent=m||"Select a drive...";let g="";l.parent&&l.parent!==l.path&&(g+=`<div class="folder-item" data-path="${escapeHtml(l.parent)}" style="padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 10px;">
|
||||
\u26A0 Warning: ${e.warning}`),showNotification(a,"success",8e3),delete p._useExisting,delete p._existingContainer,e.url&&e.url.startsWith("https://")&&$(e.url,p.name),e.setupInstructions&&e.setupInstructions.length>0&&setTimeout(()=>{const s=e.setupInstructions.join(`
|
||||
`);showNotification(`Setup Instructions for ${p.name}: ${s}`,"info",1e4)},1e3)}else throw new Error(e.error||"Deployment failed")}catch(n){b.logError("[AppSelector] Deployment",n,{function:"deploy"}),showNotification(`Failed to deploy ${p.name}: ${n.message}`,"error",8e3)}}}async function $(i,p){showNotification(`\u23F3 Generating SSL certificate for ${p}...`,"warning",6e4);let l=0;const f=12,c=async()=>{l++;try{const n=await fetch(i,{method:"HEAD",mode:"no-cors"});return showNotification(`\u2705 ${p} is ready! SSL certificate generated.`,"success",5e3),!0}catch{return l<f?setTimeout(c,5e3):showNotification(`\u26A0\uFE0F ${p} deployed but SSL certificate may still be generating.
|
||||
Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};setTimeout(c,3e3)}function E(){safeGetJSON(h,[]).forEach(p=>{window.APPS.some(l=>l.id===p.id)||window.APPS.push(p)})}document.getElementById("add-service-btn")?.addEventListener("click",()=>{L(),N.classList.add("show")}),window.openDeployConfigFor=async function(i){if(!j&&!await D())return!1;const p=String(i||"").toLowerCase(),l=Object.entries(j).find(([c])=>c.toLowerCase()===p);if(!l)return!1;const f={id:l[0],...l[1]};return f.isDashboardWidget?(await L(),N.classList.add("show"),"selector"):(await M(f),!0)},wireModal(N,document.getElementById("app-selector-cancel"));const T=document.getElementById("app-deploy-modal");document.getElementById("app-deploy-cancel")?.addEventListener("click",()=>{T.classList.remove("show")}),document.getElementById("app-deploy-confirm")?.addEventListener("click",()=>{const i=JSON.parse(T.dataset.appTemplate),p=document.getElementById("deploy-media-path").value.trim(),l=[];document.querySelectorAll("#volume-mounts-list .vol-host-path").forEach(c=>{l.push({hostPath:c.value.trim(),containerPath:c.dataset.containerPath})});const f={appTemplate:i,subdomain:document.getElementById("deploy-subdomain").value.trim(),dnsType:document.querySelector('input[name="dns-type"]:checked').value,sslType:document.querySelector('input[name="ssl-type"]:checked').value,ip:document.getElementById("deploy-ip").value.trim(),port:document.getElementById("deploy-port").value.trim(),tailscaleOnly:document.getElementById("deploy-tailscale-only").checked,mediaPath:p||null,plexClaimToken:document.getElementById("deploy-plex-claim")?.value.trim()||null,customVolumes:l.length>0?l:null,resources:{cpus:parseFloat(document.getElementById("deploy-cpu-limit").value)||0,memory:parseFloat(document.getElementById("deploy-memory-limit").value)||0}};if(!f.subdomain){showNotification("Please enter a subdomain or domain name","warning");return}if(i.mediaMount?.required&&!p){showNotification("Please enter a media library path for this application","warning");return}T.classList.remove("show"),I(f)}),wireModal(T);const P=document.getElementById("folder-browser-modal"),v=document.getElementById("folder-browser-path"),B=document.getElementById("folder-browser-list"),z=document.getElementById("folder-browser-selected"),O=document.getElementById("folder-browser-selected-list");let u="",y=[],C=null;window.openFolderBrowser=function(i){C=i,y=i.value.split(",").map(p=>p.trim()).filter(p=>p),u="",S(),w(""),P.classList.add("show")};async function w(i){v.textContent=i||"Select a drive...",B.innerHTML='<div style="padding: 20px; text-align: center; color: var(--muted);">Loading...</div>';try{const l=await(await fetch(`/api/v1/browse/directories?path=${encodeURIComponent(i)}`)).json();if(!l.success){B.innerHTML=`<div style="padding: 20px; text-align: center; color: var(--error);">Error: ${escapeHtml(l.error)}</div>`;return}u=l.path||"",v.textContent=u||"Select a drive...";let f="";l.parent&&l.parent!==l.path&&(f+=`<div class="folder-item" data-path="${escapeHtml(l.parent)}" style="padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 10px;">
|
||||
<span style="font-size: 1.2rem;">\u2B06\uFE0F</span>
|
||||
<span style="color: var(--muted);">.. Parent Directory</span>
|
||||
</div>`),l.items.length===0&&!l.parent?g+='<div style="padding: 20px; text-align: center; color: var(--muted);">No browseable drives configured. Check your docker-compose.yml volume mounts.</div>':l.items.length===0?g+='<div style="padding: 20px; text-align: center; color: var(--muted);">No subfolders found</div>':l.items.forEach(p=>{const t=p.type==="drive"?"\u{1F4BE}":"\u{1F4C1}",e=f.includes(p.path),s=e?"background: color-mix(in srgb, var(--success) 20%, transparent);":"";g+=`<div class="folder-item" data-path="${escapeHtml(p.path)}" style="padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 10px; ${s}">
|
||||
<span style="font-size: 1.2rem;">${t}</span>
|
||||
<span style="flex: 1;">${escapeHtml(p.name)}</span>
|
||||
${e?'<span style="color: var(--success);">\u2713</span>':""}
|
||||
</div>`}),v.innerHTML=g,v.querySelectorAll(".folder-item").forEach(p=>{p.addEventListener("click",()=>{w(p.dataset.path)}),p.addEventListener("mouseenter",()=>{p.style.background="var(--card-bg)"}),p.addEventListener("mouseleave",()=>{const t=f.includes(p.dataset.path);p.style.background=t?"color-mix(in srgb, var(--success) 20%, transparent)":""})})}catch(u){v.innerHTML=`<div style="padding: 20px; text-align: center; color: var(--error);">Failed to load: ${escapeHtml(u.message)}</div>`}}function L(){if(f.length===0){S.style.display="none";return}S.style.display="block",O.innerHTML=f.map(o=>`
|
||||
</div>`),l.items.length===0&&!l.parent?f+='<div style="padding: 20px; text-align: center; color: var(--muted);">No browseable drives configured. Check your docker-compose.yml volume mounts.</div>':l.items.length===0?f+='<div style="padding: 20px; text-align: center; color: var(--muted);">No subfolders found</div>':l.items.forEach(c=>{const n=c.type==="drive"?"\u{1F4BE}":"\u{1F4C1}",t=y.includes(c.path),r=t?"background: color-mix(in srgb, var(--success) 20%, transparent);":"";f+=`<div class="folder-item" data-path="${escapeHtml(c.path)}" style="padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 10px; ${r}">
|
||||
<span style="font-size: 1.2rem;">${n}</span>
|
||||
<span style="flex: 1;">${escapeHtml(c.name)}</span>
|
||||
${t?'<span style="color: var(--success);">\u2713</span>':""}
|
||||
</div>`}),B.innerHTML=f,B.querySelectorAll(".folder-item").forEach(c=>{c.addEventListener("click",()=>{w(c.dataset.path)}),c.addEventListener("mouseenter",()=>{c.style.background="var(--card-bg)"}),c.addEventListener("mouseleave",()=>{const n=y.includes(c.dataset.path);c.style.background=n?"color-mix(in srgb, var(--success) 20%, transparent)":""})})}catch(p){B.innerHTML=`<div style="padding: 20px; text-align: center; color: var(--error);">Failed to load: ${escapeHtml(p.message)}</div>`}}function S(){if(y.length===0){z.style.display="none";return}z.style.display="block",O.innerHTML=y.map(i=>`
|
||||
<span style="padding: 6px 12px; background: var(--card-bg); border: 1px solid var(--success); border-radius: 4px; display: flex; align-items: center; gap: 6px;">
|
||||
${escapeHtml(o)}
|
||||
<button type="button" onclick="removeSelectedFolder('${escapeHtml(o)}')" style="background: none; border: none; cursor: pointer; color: var(--error); font-size: 1rem; padding: 0;">\xD7</button>
|
||||
${escapeHtml(i)}
|
||||
<button type="button" onclick="removeSelectedFolder('${escapeHtml(i)}')" style="background: none; border: none; cursor: pointer; color: var(--error); font-size: 1rem; padding: 0;">\xD7</button>
|
||||
</span>
|
||||
`).join("")}window.removeSelectedFolder=function(o){f=f.filter(u=>u!==o),L(),w(m)},document.getElementById("folder-browser-select-current").addEventListener("click",()=>{m&&!f.includes(m)&&(f.push(m),L(),w(m))}),wireModal(b,document.getElementById("folder-browser-cancel")),document.getElementById("folder-browser-done").addEventListener("click",()=>{B&&(B.value=f.join(", ")),b.classList.remove("show")}),C()})(),(function(){injectModal("recipe-deploy-modal",`<div id="recipe-deploy-modal" class="weather-modal">
|
||||
`).join("")}window.removeSelectedFolder=function(i){y=y.filter(p=>p!==i),S(),w(u)},document.getElementById("folder-browser-select-current").addEventListener("click",()=>{u&&!y.includes(u)&&(y.push(u),S(),w(u))}),wireModal(P,document.getElementById("folder-browser-cancel")),document.getElementById("folder-browser-done").addEventListener("click",()=>{C&&(C.value=y.join(", ")),P.classList.remove("show")}),E()})(),(function(){injectModal("recipe-deploy-modal",`<div id="recipe-deploy-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 620px; max-width: 740px;">
|
||||
<h3 id="recipe-deploy-title">Deploy Recipe</h3>
|
||||
|
||||
@@ -445,38 +445,38 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="recipe-next" class="btn-accent-solid">Next</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);let x=null,E=null,j=null,h=1,P=!1;const A=document.getElementById("recipe-deploy-modal"),D=document.getElementById("recipe-cancel"),R=document.getElementById("recipe-prev"),y=document.getElementById("recipe-next");wireModal(A,D);async function $(){try{const m=await fetch("/api/v1/recipes/templates"),f=await m.json();if(f.success)return x=f.templates,E=f.categories,!0;if(m.status===403)return P=!1,!1}catch(m){console.warn("Failed to fetch recipe templates:",m.message)}return!1}async function k(){try{P=(await(await fetch("/api/v1/license/feature/recipes")).json()).available}catch{P=!1}return P}window.renderRecipeCards=async function(m){await k();let f;if(P&&x?f=x:f=H(),!f||f.length===0)return;const B=document.createElement("div");B.className="app-category-header",B.innerHTML="\u{1F9EA} Recipes",B.style.borderBottomColor="#8e44ad",m.appendChild(B);const w=Array.isArray(f)?f:Object.values(f);w.sort((L,o)=>(o.popularity||0)-(L.popularity||0));for(const L of w){const o=document.createElement("div");o.className="app-option",o.style.position="relative";const u=`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: rgba(142,68,173,0.2); color: #a855f7;">${L.componentCount||L.components?.length||"?"} apps</div>`,l=P?"":'<div style="position: absolute; top: 6px; right: 6px; font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; background: rgba(241,196,15,0.2); color: #f1c40f; font-weight: 600;">PREMIUM</div>';o.innerHTML=`
|
||||
</div>`);let b=null,h=null,j=null,m=1,N=!1;const A=document.getElementById("recipe-deploy-modal"),D=document.getElementById("recipe-cancel"),R=document.getElementById("recipe-prev"),g=document.getElementById("recipe-next");wireModal(A,D);async function L(){try{const u=await fetch("/api/v1/recipes/templates"),y=await u.json();if(y.success)return b=y.templates,h=y.categories,!0;if(u.status===403)return N=!1,!1}catch(u){console.warn("Failed to fetch recipe templates:",u.message)}return!1}async function k(){try{N=(await(await fetch("/api/v1/license/feature/recipes")).json()).available}catch{N=!1}return N}window.renderRecipeCards=async function(u){await k();let y;if(N&&b?y=b:y=M(),!y||y.length===0)return;const C=document.createElement("div");C.className="app-category-header",C.innerHTML="\u{1F9EA} Recipes",C.style.borderBottomColor="#8e44ad",u.appendChild(C);const w=Array.isArray(y)?y:Object.values(y);w.sort((S,i)=>(i.popularity||0)-(S.popularity||0));for(const S of w){const i=document.createElement("div");i.className="app-option",i.style.position="relative";const p=`<div style="font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-top: 4px; background: rgba(142,68,173,0.2); color: #a855f7;">${S.componentCount||S.components?.length||"?"} apps</div>`,l=N?"":'<div style="position: absolute; top: 6px; right: 6px; font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; background: rgba(241,196,15,0.2); color: #f1c40f; font-weight: 600;">PREMIUM</div>';i.innerHTML=`
|
||||
${l}
|
||||
<div class="app-option-icon">${escapeHtml(L.icon||"\u{1F9EA}")}</div>
|
||||
<div class="app-option-name">${escapeHtml(L.name)}</div>
|
||||
<div class="app-option-desc">${escapeHtml(L.description||"")}</div>
|
||||
${u}
|
||||
`,o.onclick=()=>{if(!P){showNotification("Recipes require a DashCaddy Premium license. Click the License button to activate.","warning",5e3),window.openLicenseModal&&window.openLicenseModal();return}T(L)},m.appendChild(o)}};function H(){return[{id:"htpc-suite",name:"HTPC Suite",icon:"\u{1F3AC}",description:"Complete media automation: find, download, organize, and stream",componentCount:6,popularity:98},{id:"nextcloud-complete",name:"Nextcloud Complete",icon:"\u2601\uFE0F",description:"Full productivity suite: cloud storage, office editing, and collaboration",componentCount:4,popularity:90},{id:"smart-home",name:"Smart Home Hub",icon:"\u{1F3E0}",description:"Home automation: control, automate, and monitor IoT devices",componentCount:4,popularity:88},{id:"dev-environment",name:"Dev Environment",icon:"\u{1F4BB}",description:"Self-hosted development workflow: Git, CI/CD, IDE, and database",componentCount:4,popularity:82}]}function T(m){j=m,h=1;const f=document.getElementById("app-selector-modal");f&&f.classList.remove("show"),document.getElementById("recipe-deploy-title").textContent=`Deploy ${m.name}`,z(),C(),A.classList.add("show")}function z(){document.querySelectorAll("#recipe-steps .recipe-step").forEach(m=>{const f=parseInt(m.dataset.step);m.classList.toggle("active",f===h),m.classList.toggle("completed",f<h)});for(let m=1;m<=4;m++){const f=document.getElementById(`recipe-step-${m}`);f&&(f.style.display=m===h?"":"none")}R.style.display=h>1&&h<4?"":"none",h===4?(y.style.display="none",D.textContent="Close"):h===3?(y.textContent="\u{1F680} Deploy",y.style.display="",D.textContent="Cancel"):(y.textContent="Next",y.style.display="",D.textContent="Cancel")}function C(){const m=document.getElementById("recipe-component-list");m.innerHTML="";const f=j.components||[];for(const B of f){const w=document.createElement("div");w.style.cssText="display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; background: var(--card-bg); border: 1px solid var(--border);";const L=B.required,o=B.internal;w.innerHTML=`
|
||||
<input type="checkbox" ${L?"checked disabled":"checked"} data-component-id="${B.id}"
|
||||
<div class="app-option-icon">${escapeHtml(S.icon||"\u{1F9EA}")}</div>
|
||||
<div class="app-option-name">${escapeHtml(S.name)}</div>
|
||||
<div class="app-option-desc">${escapeHtml(S.description||"")}</div>
|
||||
${p}
|
||||
`,i.onclick=()=>{if(!N){showNotification("Recipes require a DashCaddy Premium license. Click the License button to activate.","warning",5e3),window.openLicenseModal&&window.openLicenseModal();return}I(S)},u.appendChild(i)}};function M(){return[{id:"htpc-suite",name:"HTPC Suite",icon:"\u{1F3AC}",description:"Complete media automation: find, download, organize, and stream",componentCount:6,popularity:98},{id:"nextcloud-complete",name:"Nextcloud Complete",icon:"\u2601\uFE0F",description:"Full productivity suite: cloud storage, office editing, and collaboration",componentCount:4,popularity:90},{id:"smart-home",name:"Smart Home Hub",icon:"\u{1F3E0}",description:"Home automation: control, automate, and monitor IoT devices",componentCount:4,popularity:88},{id:"dev-environment",name:"Dev Environment",icon:"\u{1F4BB}",description:"Self-hosted development workflow: Git, CI/CD, IDE, and database",componentCount:4,popularity:82}]}function I(u){j=u,m=1;const y=document.getElementById("app-selector-modal");y&&y.classList.remove("show"),document.getElementById("recipe-deploy-title").textContent=`Deploy ${u.name}`,$(),E(),A.classList.add("show")}function $(){document.querySelectorAll("#recipe-steps .recipe-step").forEach(u=>{const y=parseInt(u.dataset.step);u.classList.toggle("active",y===m),u.classList.toggle("completed",y<m)});for(let u=1;u<=4;u++){const y=document.getElementById(`recipe-step-${u}`);y&&(y.style.display=u===m?"":"none")}R.style.display=m>1&&m<4?"":"none",m===4?(g.style.display="none",D.textContent="Close"):m===3?(g.textContent="\u{1F680} Deploy",g.style.display="",D.textContent="Cancel"):(g.textContent="Next",g.style.display="",D.textContent="Cancel")}function E(){const u=document.getElementById("recipe-component-list");u.innerHTML="";const y=j.components||[];for(const C of y){const w=document.createElement("div");w.style.cssText="display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 8px; background: var(--card-bg); border: 1px solid var(--border);";const S=C.required,i=C.internal;w.innerHTML=`
|
||||
<input type="checkbox" ${S?"checked disabled":"checked"} data-component-id="${C.id}"
|
||||
style="width: 18px; height: 18px; accent-color: var(--accent);" />
|
||||
<div style="flex: 1;">
|
||||
<div style="font-weight: 600; font-size: 0.9rem;">${escapeHtml(B.role||B.id)}</div>
|
||||
<div style="font-weight: 600; font-size: 0.9rem;">${escapeHtml(C.role||C.id)}</div>
|
||||
<div style="font-size: 0.78rem; color: var(--muted);">
|
||||
${B.templateRef?escapeHtml(B.templateRef):"Built-in"}
|
||||
${L?'<span style="color: var(--accent); margin-left: 6px;">Required</span>':'<span style="color: var(--muted); margin-left: 6px;">Optional</span>'}
|
||||
${o?'<span style="color: var(--muted); margin-left: 6px;">(Internal)</span>':""}
|
||||
${C.templateRef?escapeHtml(C.templateRef):"Built-in"}
|
||||
${S?'<span style="color: var(--accent); margin-left: 6px;">Required</span>':'<span style="color: var(--muted); margin-left: 6px;">Optional</span>'}
|
||||
${i?'<span style="color: var(--muted); margin-left: 6px;">(Internal)</span>':""}
|
||||
</div>
|
||||
${B.note?`<div style="font-size: 0.75rem; color: var(--warn-fg); margin-top: 4px;">\u26A0 ${escapeHtml(B.note)}</div>`:""}
|
||||
${C.note?`<div style="font-size: 0.75rem; color: var(--warn-fg); margin-top: 4px;">\u26A0 ${escapeHtml(C.note)}</div>`:""}
|
||||
</div>
|
||||
`,m.appendChild(w)}}function M(){const m=document.getElementById("recipe-volumes-section"),f=document.getElementById("recipe-volume-list"),B=j.sharedVolumes;if(B&&Object.keys(B).length>0){m.style.display="",f.innerHTML="";for(const[w,L]of Object.entries(B)){const o=document.createElement("div");o.style.cssText="display: grid; gap: 4px;",o.innerHTML=`
|
||||
<label style="font-weight: 500; font-size: 0.85rem;">${escapeHtml(L.label||w)}</label>
|
||||
<input type="text" data-volume-key="${w}" value="${escapeHtml(L.defaultPath||"")}"
|
||||
placeholder="${escapeHtml(L.defaultPath||"/path")}"
|
||||
`,u.appendChild(w)}}function T(){const u=document.getElementById("recipe-volumes-section"),y=document.getElementById("recipe-volume-list"),C=j.sharedVolumes;if(C&&Object.keys(C).length>0){u.style.display="",y.innerHTML="";for(const[w,S]of Object.entries(C)){const i=document.createElement("div");i.style.cssText="display: grid; gap: 4px;",i.innerHTML=`
|
||||
<label style="font-weight: 500; font-size: 0.85rem;">${escapeHtml(S.label||w)}</label>
|
||||
<input type="text" data-volume-key="${w}" value="${escapeHtml(S.defaultPath||"")}"
|
||||
placeholder="${escapeHtml(S.defaultPath||"/path")}"
|
||||
style="width: 100%; padding: 8px 12px; background: var(--card-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; font-family: monospace; font-size: 0.85rem;" />
|
||||
<div class="form-hint-sm">${escapeHtml(L.description||"")}</div>
|
||||
`,f.appendChild(o)}}else m.style.display="none"}function b(){const m=document.getElementById("recipe-review-content"),f=d(),B=document.querySelectorAll("#recipe-volume-list input[data-volume-key]"),w={};B.forEach(l=>{w[l.dataset.volumeKey]=l.value});const L=document.getElementById("recipe-timezone").value||"UTC",o=document.getElementById("recipe-ip").value||"host.docker.internal",u=document.getElementById("recipe-tailscale").checked;m.innerHTML=`
|
||||
<div class="form-hint-sm">${escapeHtml(S.description||"")}</div>
|
||||
`,y.appendChild(i)}}else u.style.display="none"}function P(){const u=document.getElementById("recipe-review-content"),y=v(),C=document.querySelectorAll("#recipe-volume-list input[data-volume-key]"),w={};C.forEach(l=>{w[l.dataset.volumeKey]=l.value});const S=document.getElementById("recipe-timezone").value||"UTC",i=document.getElementById("recipe-ip").value||"host.docker.internal",p=document.getElementById("recipe-tailscale").checked;u.innerHTML=`
|
||||
<div style="font-weight: 600; font-size: 1rem; margin-bottom: 12px;">${escapeHtml(j.name)}</div>
|
||||
<div style="color: var(--muted); margin-bottom: 16px;">${escapeHtml(j.description||"")}</div>
|
||||
|
||||
<div style="margin-bottom: 12px;">
|
||||
<strong>Components (${f.length}):</strong>
|
||||
<strong>Components (${y.length}):</strong>
|
||||
<div style="display: grid; gap: 4px; margin-top: 6px;">
|
||||
${f.map(l=>`<div style="padding: 4px 0; font-size: 0.85rem;">
|
||||
${y.map(l=>`<div style="padding: 4px 0; font-size: 0.85rem;">
|
||||
\u2022 <strong>${escapeHtml(l.role||l.id)}</strong> ${l.internal?'<span style="color:var(--muted)">(internal)</span>':""}
|
||||
</div>`).join("")}
|
||||
</div>
|
||||
@@ -484,31 +484,31 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
|
||||
${Object.keys(w).length>0?`<div style="margin-bottom: 12px;">
|
||||
<strong>Volumes:</strong>
|
||||
${Object.entries(w).map(([l,g])=>`<div style="font-size: 0.85rem; font-family: monospace; color: var(--muted);">${l}: ${escapeHtml(g)}</div>`).join("")}
|
||||
${Object.entries(w).map(([l,f])=>`<div style="font-size: 0.85rem; font-family: monospace; color: var(--muted);">${l}: ${escapeHtml(f)}</div>`).join("")}
|
||||
</div>`:""}
|
||||
|
||||
<div style="font-size: 0.85rem; color: var(--muted);">
|
||||
Timezone: ${escapeHtml(L)} • IP: ${escapeHtml(o)} ${u?"• Tailscale only":""}
|
||||
Timezone: ${escapeHtml(S)} • IP: ${escapeHtml(i)} ${p?"• Tailscale only":""}
|
||||
</div>
|
||||
|
||||
${j.network?`<div style="font-size: 0.85rem; color: var(--muted); margin-top: 4px;">Docker network: <code>${escapeHtml(j.network.name)}</code></div>`:""}
|
||||
`}function d(){const m=document.querySelectorAll("#recipe-component-list input[data-component-id]"),f=new Set;m.forEach(w=>{w.checked&&f.add(w.dataset.componentId)});const B=j.components||[];return B.filter(w=>w.required).forEach(w=>f.add(w.id)),B.filter(w=>f.has(w.id))}async function v(){const m=document.getElementById("recipe-progress-list"),f=document.getElementById("recipe-deploy-result");f.style.display="none",m.innerHTML="";const B=d();for(const u of B){const l=document.createElement("div");l.id=`recipe-progress-${u.id}`,l.style.cssText="display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; background: var(--card-bg); border: 1px solid var(--border); font-size: 0.85rem;",l.innerHTML=`
|
||||
`}function v(){const u=document.querySelectorAll("#recipe-component-list input[data-component-id]"),y=new Set;u.forEach(w=>{w.checked&&y.add(w.dataset.componentId)});const C=j.components||[];return C.filter(w=>w.required).forEach(w=>y.add(w.id)),C.filter(w=>y.has(w.id))}async function B(){const u=document.getElementById("recipe-progress-list"),y=document.getElementById("recipe-deploy-result");y.style.display="none",u.innerHTML="";const C=v();for(const p of C){const l=document.createElement("div");l.id=`recipe-progress-${p.id}`,l.style.cssText="display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px; background: var(--card-bg); border: 1px solid var(--border); font-size: 0.85rem;",l.innerHTML=`
|
||||
<span class="recipe-progress-icon" style="font-size: 1.1rem;">\u23F3</span>
|
||||
<span style="flex:1; font-weight: 500;">${escapeHtml(u.role||u.id)}</span>
|
||||
<span style="flex:1; font-weight: 500;">${escapeHtml(p.role||p.id)}</span>
|
||||
<span class="recipe-progress-status" style="color: var(--muted);">Queued</span>
|
||||
`,m.appendChild(l)}const w=document.querySelectorAll("#recipe-volume-list input[data-volume-key]"),L={};w.forEach(u=>{L[u.dataset.volumeKey]=u.value});const o={selectedComponents:B.map(u=>u.id),sharedConfig:{ip:document.getElementById("recipe-ip").value||"host.docker.internal",timezone:document.getElementById("recipe-timezone").value||"UTC",tailscaleOnly:document.getElementById("recipe-tailscale").checked,volumes:L},componentOverrides:{}};for(const u of B)S(u.id,"deploying","Deploying...");try{const l=await(await secureFetch("/api/v1/recipes/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({recipeId:j.id,config:o})})).json();if(l.success){for(const g of l.deployed||[])S(g.id,"success",g.url?`Running \u2192 ${g.url}`:"Running");for(const g of l.errors||[])S(g.componentId,"error",g.error);f.style.display="",f.innerHTML=`
|
||||
`,u.appendChild(l)}const w=document.querySelectorAll("#recipe-volume-list input[data-volume-key]"),S={};w.forEach(p=>{S[p.dataset.volumeKey]=p.value});const i={selectedComponents:C.map(p=>p.id),sharedConfig:{ip:document.getElementById("recipe-ip").value||"host.docker.internal",timezone:document.getElementById("recipe-timezone").value||"UTC",tailscaleOnly:document.getElementById("recipe-tailscale").checked,volumes:S},componentOverrides:{}};for(const p of C)z(p.id,"deploying","Deploying...");try{const l=await(await secureFetch("/api/v1/recipes/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({recipeId:j.id,config:i})})).json();if(l.success){for(const f of l.deployed||[])z(f.id,"success",f.url?`Running \u2192 ${f.url}`:"Running");for(const f of l.errors||[])z(f.componentId,"error",f.error);y.style.display="",y.innerHTML=`
|
||||
<div style="padding: 14px; border-radius: 8px; background: rgba(46,204,113,0.1); border: 1px solid rgba(46,204,113,0.3);">
|
||||
<div style="font-weight: 600; color: var(--ok-fg); margin-bottom: 6px;">${escapeHtml(l.message||"Deployed!")}</div>
|
||||
${l.setupInstructions?`<div style="font-size: 0.8rem; color: var(--muted); margin-top: 8px;">
|
||||
<strong>Setup tips:</strong>
|
||||
<ul style="margin: 4px 0 0 16px; padding: 0;">${l.setupInstructions.map(g=>`<li>${escapeHtml(g)}</li>`).join("")}</ul>
|
||||
<ul style="margin: 4px 0 0 16px; padding: 0;">${l.setupInstructions.map(f=>`<li>${escapeHtml(f)}</li>`).join("")}</ul>
|
||||
</div>`:""}
|
||||
</div>
|
||||
`,showNotification(`${j.name} recipe deployed successfully!`,"success",5e3),window.loadServices&&window.loadServices()}else f.style.display="",f.innerHTML=`<div style="padding: 14px; border-radius: 8px; background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.3); color: var(--bad-fg);">
|
||||
`,showNotification(`${j.name} recipe deployed successfully!`,"success",5e3),window.loadServices&&window.loadServices()}else y.style.display="",y.innerHTML=`<div style="padding: 14px; border-radius: 8px; background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.3); color: var(--bad-fg);">
|
||||
<strong>Deployment failed:</strong> ${escapeHtml(l.error||"Unknown error")}
|
||||
</div>`,showNotification(`Recipe deployment failed: ${l.error}`,"error",5e3)}catch(u){f.style.display="",f.innerHTML=`<div style="padding: 14px; border-radius: 8px; background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.3); color: var(--bad-fg);">
|
||||
<strong>Network error:</strong> ${escapeHtml(u.message)}
|
||||
</div>`}}function S(m,f,B){const w=document.getElementById(`recipe-progress-${m}`);if(!w)return;const L=w.querySelector(".recipe-progress-icon"),o=w.querySelector(".recipe-progress-status");f==="deploying"?(L.textContent="\u23F3",o.style.color="var(--accent)"):f==="success"?(L.textContent="\u2705",o.style.color="var(--ok-fg)"):f==="error"&&(L.textContent="\u274C",o.style.color="var(--bad-fg)"),o.textContent=B}y.addEventListener("click",()=>{if(h===3){h=4,z(),v();return}h<3&&(h++,z(),h===2&&M(),h===3&&b())}),R.addEventListener("click",()=>{h>1&&h<4&&(h--,z())}),window.groupRecipeCards=function(){const m=document.querySelectorAll(".service-card[data-recipe-id]");if(m.length===0)return;const f={};m.forEach(B=>{const w=B.dataset.recipeId;f[w]||(f[w]=[]),f[w].push(B)});for(const[B,w]of Object.entries(f))w.length<2||w.forEach((L,o)=>{if(L.style.borderLeft="3px solid rgba(142,68,173,0.5)",o===0){let u=L.querySelector(".recipe-group-label");u||(u=document.createElement("div"),u.className="recipe-group-label",u.style.cssText="position: absolute; top: -8px; left: 12px; font-size: 0.6rem; padding: 1px 8px; border-radius: 8px; background: rgba(142,68,173,0.3); color: #d4a5ff; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;",u.textContent=B.replace(/-/g," "),L.style.position="relative",L.appendChild(u))}})},window.manageRecipe=async function(m,f){const B=`/api/v1/recipes/${m}/${f}`,w=f==="remove"?"DELETE":"POST",L=f==="remove"?`/api/v1/recipes/${m}`:B;if(!(f==="remove"&&!confirm(`Remove the entire ${m} recipe? This will delete all containers and configuration.`)))try{const u=await(await secureFetch(L,{method:w})).json();u.success?(showNotification(`Recipe ${f}: ${u.results?.filter(l=>l.status!=="failed").length||0} components processed`,"success",4e3),window.loadServices&&window.loadServices()):showNotification(`Recipe ${f} failed: ${u.error}`,"error",5e3)}catch(o){showNotification(`Network error: ${o.message}`,"error",5e3)}};const O=document.createElement("style");O.textContent=`
|
||||
</div>`,showNotification(`Recipe deployment failed: ${l.error}`,"error",5e3)}catch(p){y.style.display="",y.innerHTML=`<div style="padding: 14px; border-radius: 8px; background: rgba(231,76,60,0.1); border: 1px solid rgba(231,76,60,0.3); color: var(--bad-fg);">
|
||||
<strong>Network error:</strong> ${escapeHtml(p.message)}
|
||||
</div>`}}function z(u,y,C){const w=document.getElementById(`recipe-progress-${u}`);if(!w)return;const S=w.querySelector(".recipe-progress-icon"),i=w.querySelector(".recipe-progress-status");y==="deploying"?(S.textContent="\u23F3",i.style.color="var(--accent)"):y==="success"?(S.textContent="\u2705",i.style.color="var(--ok-fg)"):y==="error"&&(S.textContent="\u274C",i.style.color="var(--bad-fg)"),i.textContent=C}g.addEventListener("click",()=>{if(m===3){m=4,$(),B();return}m<3&&(m++,$(),m===2&&T(),m===3&&P())}),R.addEventListener("click",()=>{m>1&&m<4&&(m--,$())}),window.groupRecipeCards=function(){const u=document.querySelectorAll(".service-card[data-recipe-id]");if(u.length===0)return;const y={};u.forEach(C=>{const w=C.dataset.recipeId;y[w]||(y[w]=[]),y[w].push(C)});for(const[C,w]of Object.entries(y))w.length<2||w.forEach((S,i)=>{if(S.style.borderLeft="3px solid rgba(142,68,173,0.5)",i===0){let p=S.querySelector(".recipe-group-label");p||(p=document.createElement("div"),p.className="recipe-group-label",p.style.cssText="position: absolute; top: -8px; left: 12px; font-size: 0.6rem; padding: 1px 8px; border-radius: 8px; background: rgba(142,68,173,0.3); color: #d4a5ff; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;",p.textContent=C.replace(/-/g," "),S.style.position="relative",S.appendChild(p))}})},window.manageRecipe=async function(u,y){const C=`/api/v1/recipes/${u}/${y}`,w=y==="remove"?"DELETE":"POST",S=y==="remove"?`/api/v1/recipes/${u}`:C;if(!(y==="remove"&&!confirm(`Remove the entire ${u} recipe? This will delete all containers and configuration.`)))try{const p=await(await secureFetch(S,{method:w})).json();p.success?(showNotification(`Recipe ${y}: ${p.results?.filter(l=>l.status!=="failed").length||0} components processed`,"success",4e3),window.loadServices&&window.loadServices()):showNotification(`Recipe ${y} failed: ${p.error}`,"error",5e3)}catch(i){showNotification(`Network error: ${i.message}`,"error",5e3)}};const O=document.createElement("style");O.textContent=`
|
||||
.recipe-step {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
@@ -550,7 +550,7 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
.recipe-step-panel {
|
||||
min-height: 180px;
|
||||
}
|
||||
`,document.head.appendChild(O),k()})(),(function(){document.getElementById("reload-caddy-top")?.addEventListener("click",async()=>{const x=document.getElementById("reload-caddy-top"),E=x.textContent;try{x.textContent="\u23F3 Reloading...",x.disabled=!0;const j=await secureFetch("/api/v1/caddy/reload",{method:"POST",headers:{"Content-Type":"application/json"}}),h=await j.json();if(j.ok&&h.success)x.textContent="\u2705 Reloaded!",setTimeout(()=>{x.textContent=E,x.disabled=!1},2e3);else throw new Error(h.error||"Reload failed")}catch(j){x.textContent="\u274C Failed",showNotification(`Failed to reload Caddy: ${j.message}`,"error"),setTimeout(()=>{x.textContent=E,x.disabled=!1},2e3)}})})(),(function(){injectModal("error-log-modal",`<div id="error-log-modal" class="weather-modal">
|
||||
`,document.head.appendChild(O),k()})(),(function(){document.getElementById("reload-caddy-top")?.addEventListener("click",async()=>{const b=document.getElementById("reload-caddy-top"),h=b.textContent;try{b.textContent="\u23F3 Reloading...",b.disabled=!0;const j=await secureFetch("/api/v1/caddy/reload",{method:"POST",headers:{"Content-Type":"application/json"}}),m=await j.json();if(j.ok&&m.success)b.textContent="\u2705 Reloaded!",setTimeout(()=>{b.textContent=h,b.disabled=!1},2e3);else throw new Error(m.error||"Reload failed")}catch(j){b.textContent="\u274C Failed",showNotification(`Failed to reload Caddy: ${j.message}`,"error"),setTimeout(()=>{b.textContent=h,b.disabled=!1},2e3)}})})(),(function(){injectModal("error-log-modal",`<div id="error-log-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 950px; max-width: 1150px;">
|
||||
<h3>\u{1F4CB} Error Logs</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -597,8 +597,8 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="error-log-close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("error-log-modal"),E=document.getElementById("view-error-logs"),j=document.getElementById("error-log-refresh"),h=document.getElementById("error-log-clear"),P=document.getElementById("error-log-close"),A=document.getElementById("error-log-level"),D=document.getElementById("error-log-context"),R=document.getElementById("error-log-search"),y=document.getElementById("error-log-since"),$=document.getElementById("error-log-until"),k=document.getElementById("error-log-container"),H=document.getElementById("error-log-load-more"),T=document.getElementById("error-log-total"),z=50;let C=0,M=null,b=0,d=[];function v(L){if(!L)return null;const o=new Date(L);return isNaN(o.getTime())?null:o.toISOString()}async function S(){try{const L=await fetch("/api/v1/error-logs/contexts");if(!L.ok)return;const o=await L.json();if(!o.success||!Array.isArray(o.contexts))return;d=o.contexts;const u=D.value;D.innerHTML='<option value="">All</option>';for(const l of o.contexts){const g=document.createElement("option");g.value=l.name,g.textContent=`${l.name} (${l.count})`,D.appendChild(g)}u&&o.contexts.some(l=>l.name===u)&&(D.value=u)}catch{}}function O(){const L=new URLSearchParams;L.set("limit",String(z)),L.set("offset",String(C)),A.value&&L.set("level",A.value),D.value&&L.set("context",D.value);const o=v(y.value),u=v($.value);o&&L.set("since",o),u&&L.set("until",u);const l=(R.value||"").trim();return l&&L.set("search",l),L}async function m(L){try{L?(M&&M.abort(),M=new AbortController):(M&&M.abort(),M=new AbortController,C=0,b++,k.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading...</div>');const o=b,u=O(),l=await fetch("/api/v1/error-logs?"+u.toString(),{signal:M.signal});if(!l.ok){k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: HTTP ${l.status}</div>`,H.style.display="none",T.textContent="";return}const g=await l.json();if(!g.success){k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(g.error||"unknown")}</div>`,H.style.display="none",T.textContent="";return}if(!L&&o!==b)return;const p=Array.isArray(g.logs)?g.logs:[];if(p.length===0&&!L){const e=g.filters&&(g.filters.level||g.filters.context||g.filters.search||g.filters.since||g.filters.until)?"No error log entries match your filters.":"\u2705 No errors logged! Everything is working smoothly.";k.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4CB}</span>${escapeHtml(e)}</div>`,H.style.display="none",T.textContent=g.total?`${g.total} total`:"";return}let t="";L||(t='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',t+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);">',t+='<th style="padding: 6px; text-align: left; width: 160px;">When</th>',t+='<th style="padding: 6px; text-align: left; width: 80px;">Level</th>',t+='<th style="padding: 6px; text-align: left; width: 140px;">Context</th>',t+='<th style="padding: 6px; text-align: left;">Message</th>',t+='<th style="padding: 6px; text-align: left; width: 110px;">IP</th>',t+="</tr>");for(const e of p){const s=(e.level||"?").toUpperCase(),n=s==="ERR"?"var(--bad-fg)":s==="WARN"?"var(--warn-fg, #f0c674)":"var(--muted)",r=e.timestamp?new Date(e.timestamp).toLocaleString():"\u2014",a=e.context||"\u2014",i=(e.error||"").split(`
|
||||
`)[0],c=e.request&&e.request.ip||"";t+='<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" class="error-log-row">',t+=`<td style="padding: 6px; color: var(--muted);" title="${escapeHtml(e.timestamp||"")}">${escapeHtml(r)}</td>`,t+=`<td style="padding: 6px;"><span style="color: ${n}; font-weight: 600;">${escapeHtml(s)}</span></td>`,t+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(a)}</td>`,t+=`<td style="padding: 6px;">${escapeHtml(i)}</td>`,t+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(c)}</td>`,t+="</tr>",e.detail&&(t+=`<tr class="error-log-detail" style="display: none;"><td colspan="5" style="padding: 6px 6px 10px; font-size: 0.78rem; color: var(--muted);"><pre style="margin: 0; white-space: pre-wrap; font-family: monospace; max-height: 320px; overflow: auto;">${escapeHtml(e.detail)}</pre></td></tr>`)}if(!L)t+="</table>",k.innerHTML=t;else{const e=k.querySelector("table");e&&e.insertAdjacentHTML("beforeend",t)}C+=p.length,H.style.display=g.hasMore?"":"none",T.textContent=`${g.total} total${g.hasMore?" (showing "+C+")":""}`,k.querySelectorAll(".error-log-row").forEach(e=>{e.dataset.wired||(e.dataset.wired="true",e.addEventListener("click",()=>{const s=e.nextElementSibling;s&&s.classList.contains("error-log-detail")&&(s.style.display=s.style.display==="none"?"":"none")}))})}catch(o){if(o&&o.name==="AbortError")return;k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(o.message)}</div>`,T.textContent=""}}async function f(){if(confirm("Clear the entire error log? This cannot be undone."))try{const o=await(await secureFetch("/api/v1/error-logs",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({confirm:"CLEAR"})})).json();o.success?(await S(),m(!1),showNotification("\u2705 Error logs cleared","success",3e3)):showNotification("\u274C "+(o.error||"Clear failed"),"error",4e3)}catch(L){showNotification("\u274C "+L.message,"error",4e3)}}let B;function w(){A?.addEventListener("change",()=>m(!1)),D?.addEventListener("change",()=>m(!1)),R?.addEventListener("input",()=>{clearTimeout(B),B=setTimeout(()=>m(!1),250)});let L;[y,$].forEach(o=>{o?.addEventListener("change",()=>{clearTimeout(L),L=setTimeout(()=>m(!1),250)})}),j?.addEventListener("click",()=>m(!1)),H?.addEventListener("click",()=>m(!0)),h?.addEventListener("click",f),wireModal(x,P)}E?.addEventListener("click",async()=>{x?.classList.add("show"),await S(),m(!1)}),w()})(),(function(){injectModal("container-logs-modal",`<div id="container-logs-modal" class="weather-modal" style="z-index: 1001;">
|
||||
</div>`);const b=document.getElementById("error-log-modal"),h=document.getElementById("view-error-logs"),j=document.getElementById("error-log-refresh"),m=document.getElementById("error-log-clear"),N=document.getElementById("error-log-close"),A=document.getElementById("error-log-level"),D=document.getElementById("error-log-context"),R=document.getElementById("error-log-search"),g=document.getElementById("error-log-since"),L=document.getElementById("error-log-until"),k=document.getElementById("error-log-container"),M=document.getElementById("error-log-load-more"),I=document.getElementById("error-log-total"),$=50;let E=0,T=null,P=0,v=[];function B(S){if(!S)return null;const i=new Date(S);return isNaN(i.getTime())?null:i.toISOString()}async function z(){try{const S=await fetch("/api/v1/error-logs/contexts");if(!S.ok)return;const i=await S.json();if(!i.success||!Array.isArray(i.contexts))return;v=i.contexts;const p=D.value;D.innerHTML='<option value="">All</option>';for(const l of i.contexts){const f=document.createElement("option");f.value=l.name,f.textContent=`${l.name} (${l.count})`,D.appendChild(f)}p&&i.contexts.some(l=>l.name===p)&&(D.value=p)}catch{}}function O(){const S=new URLSearchParams;S.set("limit",String($)),S.set("offset",String(E)),A.value&&S.set("level",A.value),D.value&&S.set("context",D.value);const i=B(g.value),p=B(L.value);i&&S.set("since",i),p&&S.set("until",p);const l=(R.value||"").trim();return l&&S.set("search",l),S}async function u(S){try{S?(T&&T.abort(),T=new AbortController):(T&&T.abort(),T=new AbortController,E=0,P++,k.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading...</div>');const i=P,p=O(),l=await fetch("/api/v1/error-logs?"+p.toString(),{signal:T.signal});if(!l.ok){k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: HTTP ${l.status}</div>`,M.style.display="none",I.textContent="";return}const f=await l.json();if(!f.success){k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(f.error||"unknown")}</div>`,M.style.display="none",I.textContent="";return}if(!S&&i!==P)return;const c=Array.isArray(f.logs)?f.logs:[];if(c.length===0&&!S){const t=f.filters&&(f.filters.level||f.filters.context||f.filters.search||f.filters.since||f.filters.until)?"No error log entries match your filters.":"\u2705 No errors logged! Everything is working smoothly.";k.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4CB}</span>${escapeHtml(t)}</div>`,M.style.display="none",I.textContent=f.total?`${f.total} total`:"";return}let n="";S||(n='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',n+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);">',n+='<th style="padding: 6px; text-align: left; width: 160px;">When</th>',n+='<th style="padding: 6px; text-align: left; width: 80px;">Level</th>',n+='<th style="padding: 6px; text-align: left; width: 140px;">Context</th>',n+='<th style="padding: 6px; text-align: left;">Message</th>',n+='<th style="padding: 6px; text-align: left; width: 110px;">IP</th>',n+="</tr>");for(const t of c){const r=(t.level||"?").toUpperCase(),e=r==="ERR"?"var(--bad-fg)":r==="WARN"?"var(--warn-fg, #f0c674)":"var(--muted)",o=t.timestamp?new Date(t.timestamp).toLocaleString():"\u2014",a=t.context||"\u2014",s=(t.error||"").split(`
|
||||
`)[0],d=t.request&&t.request.ip||"";n+='<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" class="error-log-row">',n+=`<td style="padding: 6px; color: var(--muted);" title="${escapeHtml(t.timestamp||"")}">${escapeHtml(o)}</td>`,n+=`<td style="padding: 6px;"><span style="color: ${e}; font-weight: 600;">${escapeHtml(r)}</span></td>`,n+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(a)}</td>`,n+=`<td style="padding: 6px;">${escapeHtml(s)}</td>`,n+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(d)}</td>`,n+="</tr>",t.detail&&(n+=`<tr class="error-log-detail" style="display: none;"><td colspan="5" style="padding: 6px 6px 10px; font-size: 0.78rem; color: var(--muted);"><pre style="margin: 0; white-space: pre-wrap; font-family: monospace; max-height: 320px; overflow: auto;">${escapeHtml(t.detail)}</pre></td></tr>`)}if(!S)n+="</table>",k.innerHTML=n;else{const t=k.querySelector("table");t&&t.insertAdjacentHTML("beforeend",n)}E+=c.length,M.style.display=f.hasMore?"":"none",I.textContent=`${f.total} total${f.hasMore?" (showing "+E+")":""}`,k.querySelectorAll(".error-log-row").forEach(t=>{t.dataset.wired||(t.dataset.wired="true",t.addEventListener("click",()=>{const r=t.nextElementSibling;r&&r.classList.contains("error-log-detail")&&(r.style.display=r.style.display==="none"?"":"none")}))})}catch(i){if(i&&i.name==="AbortError")return;k.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(i.message)}</div>`,I.textContent=""}}async function y(){if(confirm("Clear the entire error log? This cannot be undone."))try{const i=await(await secureFetch("/api/v1/error-logs",{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({confirm:"CLEAR"})})).json();i.success?(await z(),u(!1),showNotification("\u2705 Error logs cleared","success",3e3)):showNotification("\u274C "+(i.error||"Clear failed"),"error",4e3)}catch(S){showNotification("\u274C "+S.message,"error",4e3)}}let C;function w(){A?.addEventListener("change",()=>u(!1)),D?.addEventListener("change",()=>u(!1)),R?.addEventListener("input",()=>{clearTimeout(C),C=setTimeout(()=>u(!1),250)});let S;[g,L].forEach(i=>{i?.addEventListener("change",()=>{clearTimeout(S),S=setTimeout(()=>u(!1),250)})}),j?.addEventListener("click",()=>u(!1)),M?.addEventListener("click",()=>u(!0)),m?.addEventListener("click",y),wireModal(b,N)}h?.addEventListener("click",async()=>{b?.classList.add("show"),await z(),u(!1)}),w()})(),(function(){injectModal("container-logs-modal",`<div id="container-logs-modal" class="weather-modal" style="z-index: 1001;">
|
||||
<div class="weather-modal-content" style="min-width: 900px; max-width: 95vw; height: 80vh; display: flex; flex-direction: column;">
|
||||
<div class="logs-header" style="display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px;">
|
||||
<div>
|
||||
@@ -648,14 +648,14 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="cl-close-btn" class="btn-secondary">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("container-logs-modal"),E=document.getElementById("cl-container-select"),j=document.getElementById("cl-log-content"),h=document.getElementById("cl-log-search"),P=document.getElementById("cl-log-tail"),A=document.getElementById("cl-refresh"),D=document.getElementById("cl-stream"),R=document.getElementById("cl-download"),y=document.getElementById("cl-clear-search"),$=document.getElementById("cl-close"),k=document.getElementById("cl-close-btn"),H=document.getElementById("cl-stream-status"),T=document.getElementById("cl-stream-indicator"),z=document.getElementById("cl-stream-text"),C=document.getElementById("cl-line-count"),M=document.getElementById("cl-filter-count"),b=document.getElementById("cl-image"),d=document.getElementById("cl-status"),v=document.getElementById("cl-created");let S=null,O=[],m=[],f=null,B=!1,w=null;function L(i){if(!i)return"-";const c=new Date(i);return isNaN(c.getTime())?i:c.toLocaleString()}function o(i){if(!i)return"";const c=document.createElement("div");return c.textContent=i,c.innerHTML}function u(i,c){const I=i.stream==="stderr"?"log-stderr":"log-stdout",N=i.stream==="stderr"?"\u26A0\uFE0F":"\u{1F4E4}";return`
|
||||
<div class="log-entry ${I}" data-index="${c}" style="padding: 4px 8px; border-bottom: 1px solid #333; display: flex; gap: 8px;">
|
||||
<span class="log-line-num" style="color: #666; min-width: 40px; text-align: right; user-select: none;">${c+1}</span>
|
||||
<span class="log-stream-icon" style="color: ${i.stream==="stderr"?"#f59e0b":"#22c55e"};">${N}</span>
|
||||
<span class="log-text" style="flex: 1; white-space: pre-wrap; word-break: break-all; color: #e5e5e5;">${o(i.text)}</span>
|
||||
</div>`);const b=document.getElementById("container-logs-modal"),h=document.getElementById("cl-container-select"),j=document.getElementById("cl-log-content"),m=document.getElementById("cl-log-search"),N=document.getElementById("cl-log-tail"),A=document.getElementById("cl-refresh"),D=document.getElementById("cl-stream"),R=document.getElementById("cl-download"),g=document.getElementById("cl-clear-search"),L=document.getElementById("cl-close"),k=document.getElementById("cl-close-btn"),M=document.getElementById("cl-stream-status"),I=document.getElementById("cl-stream-indicator"),$=document.getElementById("cl-stream-text"),E=document.getElementById("cl-line-count"),T=document.getElementById("cl-filter-count"),P=document.getElementById("cl-image"),v=document.getElementById("cl-status"),B=document.getElementById("cl-created");let z=null,O=[],u=[],y=null,C=!1,w=null;function S(s){if(!s)return"-";const d=new Date(s);return isNaN(d.getTime())?s:d.toLocaleString()}function i(s){if(!s)return"";const d=document.createElement("div");return d.textContent=s,d.innerHTML}function p(s,d){const x=s.stream==="stderr"?"log-stderr":"log-stdout",H=s.stream==="stderr"?"\u26A0\uFE0F":"\u{1F4E4}";return`
|
||||
<div class="log-entry ${x}" data-index="${d}" style="padding: 4px 8px; border-bottom: 1px solid #333; display: flex; gap: 8px;">
|
||||
<span class="log-line-num" style="color: #666; min-width: 40px; text-align: right; user-select: none;">${d+1}</span>
|
||||
<span class="log-stream-icon" style="color: ${s.stream==="stderr"?"#f59e0b":"#22c55e"};">${H}</span>
|
||||
<span class="log-text" style="flex: 1; white-space: pre-wrap; word-break: break-all; color: #e5e5e5;">${i(s.text)}</span>
|
||||
</div>
|
||||
`}function l(i,c=""){if(!i||i.length===0){j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs available</div>',C.textContent="0 lines",M.textContent="0 filtered";return}if(O=i,m=c?i.filter(I=>I.text&&I.text.toLowerCase().includes(c.toLowerCase())):i,C.textContent=`${i.length} lines`,M.textContent=c?`${m.length} of ${i.length} shown`:`${i.length} shown`,m.length===0){j.innerHTML=`<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs match "${o(c)}"</div>`;return}j.innerHTML=m.map((I,N)=>u(I,N)).join(""),j.scrollTop=j.scrollHeight}async function g(){try{const c=(await getJSON("/api/v1/logs/containers")).containers||[],I=E.value;E.innerHTML='<option value="">Select a container...</option>',c.forEach(N=>{const U=document.createElement("option");U.value=N.id,U.textContent=`${N.name} (${N.image.split(":")[0]}) - ${N.status}`,U.dataset.name=N.name,U.dataset.image=N.image,U.dataset.status=N.status,U.dataset.created=N.created,E.appendChild(U)}),I&&E.querySelector(`option[value="${I}"]`)&&(E.value=I,p(I))}catch(i){console.error("Failed to load containers:",i)}}function p(i){const c=E.querySelector(`option[value="${i}"]`);c&&(b.textContent=c.dataset.image||"-",d.textContent=c.dataset.status||"-",d.style.color=c.dataset.status==="running"?"var(--ok-fg, #4ade80)":"var(--bad-fg, #ef4444)",v.textContent=L(c.dataset.created))}async function t(){const i=E.value;if(!i){j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Select a container to view logs</div>';return}s(),S=i,p(i);const c=P.value,I=h.value.trim();j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Loading logs...</div>';try{const N=`/api/v1/logs/container/${i}${c!=="all"?`?tail=${c}`:""}`,U=await getJSON(N);U.logs&&U.logs.length>0?l(U.logs,I):(j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs found for this container</div>',C.textContent="0 lines",M.textContent="0 filtered")}catch(N){j.innerHTML=`<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Error loading logs: ${o(N.message)}</div>`}}function e(){const i=E.value;if(!i)return;s(),B=!0,D.textContent="\u23F9 Stop",H.style.display="flex",T.textContent="\u{1F7E2}",z.textContent="Connecting...";const c=`/api/v1/logs/stream/${i}`;f=new EventSource(c),f.onopen=()=>{T.textContent="\u{1F7E2}",z.textContent="Connected - streaming logs"},f.onmessage=I=>{try{const N=JSON.parse(I.data);if(N.error){T.textContent="\u{1F534}",z.textContent=`Error: ${N.error}`;return}O.push(N),m.push(N),C.textContent=`${O.length} lines`,M.textContent=`${m.length} shown`;const U=h.value.trim();if(!U||N.text&&N.text.toLowerCase().includes(U.toLowerCase())){const _=document.createElement("div");_.innerHTML=u(N,m.length-1);const F=_.firstElementChild;F.style.background="#1a3a1a",j.appendChild(F),j.scrollTop=j.scrollHeight}}catch(N){console.error("Error parsing log:",N)}},f.onerror=()=>{T.textContent="\u{1F534}",z.textContent="Disconnected",B=!1,D.textContent="\u25B6 Stream"},x._eventSource=f}function s(){f&&(f.close(),f=null),x._eventSource&&(x._eventSource.close(),x._eventSource=null),B=!1,D.textContent="\u25B6 Stream",H.style.display="none"}function n(){if(!O||O.length===0){showNotification("No logs to download","error");return}const i=E.querySelector(`option[value="${S}"]`)?.dataset.name||S,c=new Date().toISOString().replace(/[:.]/g,"-"),I=`${i}-logs-${c}.txt`,N=O.map(q=>{const J=q.timestamp||"",X=q.stream==="stderr"?"[ERR]":"[OUT]";return`${J?J+" ":""}${X} ${q.text}`}).join(`
|
||||
`),U=new Blob([N],{type:"text/plain"}),_=URL.createObjectURL(U),F=document.createElement("a");F.href=_,F.download=I,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(_),showNotification(`Downloaded ${O.length} log lines`,"success")}E?.addEventListener("change",()=>{t()}),P?.addEventListener("change",()=>{t()}),A?.addEventListener("click",()=>{t()}),D?.addEventListener("click",()=>{B?s():e()}),R?.addEventListener("click",()=>{n()}),y?.addEventListener("click",()=>{h.value="",l(O,"")}),h?.addEventListener("input",()=>{clearTimeout(w),w=setTimeout(()=>{l(O,h.value.trim())},300)}),h?.addEventListener("keydown",i=>{i.key==="Escape"&&(h.value="",l(O,""))}),document.getElementById("view-container-logs")?.addEventListener("click",()=>{x.classList.add("show"),g()});function a(){s(),x.classList.remove("show")}$?.addEventListener("click",a),k?.addEventListener("click",a),document.addEventListener("keydown",i=>{i.key==="Escape"&&x.classList.contains("show")&&a()}),x.addEventListener("click",i=>{i.target===x&&a()}),window.openContainerLogsModal=function(i,c){x.classList.add("show"),g().then(()=>{const I=Array.from(E.options).find(N=>N.value===i||N.dataset.name===c);I?(E.value=I.value,p(I.value),t()):i?(S=i,b.textContent=c||i,d.textContent="-",v.textContent="-",t()):j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Select a container to view logs</div>'})}})(),(function(){"use strict";const x=[{unit:"caddy",label:"Caddy (reverse proxy)"},{unit:"dashcaddy-api",label:"DashCaddy API (host systemd unit, not this container)"},{unit:"docker",label:"Docker daemon"},{unit:"ssh",label:"SSH server"},{unit:"systemd-journald",label:"systemd-journald"},{unit:"tailscaled",label:"Tailscale"},{unit:"networkd-dispatcher",label:"Networkd dispatcher"}];injectModal("journald-modal",`
|
||||
`}function l(s,d=""){if(!s||s.length===0){j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs available</div>',E.textContent="0 lines",T.textContent="0 filtered";return}if(O=s,u=d?s.filter(x=>x.text&&x.text.toLowerCase().includes(d.toLowerCase())):s,E.textContent=`${s.length} lines`,T.textContent=d?`${u.length} of ${s.length} shown`:`${s.length} shown`,u.length===0){j.innerHTML=`<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs match "${i(d)}"</div>`;return}j.innerHTML=u.map((x,H)=>p(x,H)).join(""),j.scrollTop=j.scrollHeight}async function f(){try{const d=(await getJSON("/api/v1/logs/containers")).containers||[],x=h.value;h.innerHTML='<option value="">Select a container...</option>',d.forEach(H=>{const U=document.createElement("option");U.value=H.id,U.textContent=`${H.name} (${H.image.split(":")[0]}) - ${H.status}`,U.dataset.name=H.name,U.dataset.image=H.image,U.dataset.status=H.status,U.dataset.created=H.created,h.appendChild(U)}),x&&h.querySelector(`option[value="${x}"]`)&&(h.value=x,c(x))}catch(s){console.error("Failed to load containers:",s)}}function c(s){const d=h.querySelector(`option[value="${s}"]`);d&&(P.textContent=d.dataset.image||"-",v.textContent=d.dataset.status||"-",v.style.color=d.dataset.status==="running"?"var(--ok-fg, #4ade80)":"var(--bad-fg, #ef4444)",B.textContent=S(d.dataset.created))}async function n(){const s=h.value;if(!s){j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Select a container to view logs</div>';return}r(),z=s,c(s);const d=N.value,x=m.value.trim();j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Loading logs...</div>';try{const H=`/api/v1/logs/container/${s}${d!=="all"?`?tail=${d}`:""}`,U=await getJSON(H);U.logs&&U.logs.length>0?l(U.logs,x):(j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No logs found for this container</div>',E.textContent="0 lines",T.textContent="0 filtered")}catch(H){j.innerHTML=`<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Error loading logs: ${i(H.message)}</div>`}}function t(){const s=h.value;if(!s)return;r(),C=!0,D.textContent="\u23F9 Stop",M.style.display="flex",I.textContent="\u{1F7E2}",$.textContent="Connecting...";const d=`/api/v1/logs/stream/${s}`;y=new EventSource(d),y.onopen=()=>{I.textContent="\u{1F7E2}",$.textContent="Connected - streaming logs"},y.onmessage=x=>{try{const H=JSON.parse(x.data);if(H.error){I.textContent="\u{1F534}",$.textContent=`Error: ${H.error}`;return}O.push(H),u.push(H),E.textContent=`${O.length} lines`,T.textContent=`${u.length} shown`;const U=m.value.trim();if(!U||H.text&&H.text.toLowerCase().includes(U.toLowerCase())){const _=document.createElement("div");_.innerHTML=p(H,u.length-1);const F=_.firstElementChild;F.style.background="#1a3a1a",j.appendChild(F),j.scrollTop=j.scrollHeight}}catch(H){console.error("Error parsing log:",H)}},y.onerror=()=>{I.textContent="\u{1F534}",$.textContent="Disconnected",C=!1,D.textContent="\u25B6 Stream"},b._eventSource=y}function r(){y&&(y.close(),y=null),b._eventSource&&(b._eventSource.close(),b._eventSource=null),C=!1,D.textContent="\u25B6 Stream",M.style.display="none"}function e(){if(!O||O.length===0){showNotification("No logs to download","error");return}const s=h.querySelector(`option[value="${z}"]`)?.dataset.name||z,d=new Date().toISOString().replace(/[:.]/g,"-"),x=`${s}-logs-${d}.txt`,H=O.map(q=>{const J=q.timestamp||"",V=q.stream==="stderr"?"[ERR]":"[OUT]";return`${J?J+" ":""}${V} ${q.text}`}).join(`
|
||||
`),U=new Blob([H],{type:"text/plain"}),_=URL.createObjectURL(U),F=document.createElement("a");F.href=_,F.download=x,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(_),showNotification(`Downloaded ${O.length} log lines`,"success")}h?.addEventListener("change",()=>{n()}),N?.addEventListener("change",()=>{n()}),A?.addEventListener("click",()=>{n()}),D?.addEventListener("click",()=>{C?r():t()}),R?.addEventListener("click",()=>{e()}),g?.addEventListener("click",()=>{m.value="",l(O,"")}),m?.addEventListener("input",()=>{clearTimeout(w),w=setTimeout(()=>{l(O,m.value.trim())},300)}),m?.addEventListener("keydown",s=>{s.key==="Escape"&&(m.value="",l(O,""))}),document.getElementById("view-container-logs")?.addEventListener("click",()=>{b.classList.add("show"),f()});function a(){r(),b.classList.remove("show")}L?.addEventListener("click",a),k?.addEventListener("click",a),document.addEventListener("keydown",s=>{s.key==="Escape"&&b.classList.contains("show")&&a()}),b.addEventListener("click",s=>{s.target===b&&a()}),window.openContainerLogsModal=function(s,d){b.classList.add("show"),f().then(()=>{const x=Array.from(h.options).find(H=>H.value===s||H.dataset.name===d);x?(h.value=x.value,c(x.value),n()):s?(z=s,P.textContent=d||s,v.textContent="-",B.textContent="-",n()):j.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Select a container to view logs</div>'})}})(),(function(){"use strict";const b=[{unit:"caddy",label:"Caddy (reverse proxy)"},{unit:"dashcaddy-api",label:"DashCaddy API (host systemd unit, not this container)"},{unit:"docker",label:"Docker daemon"},{unit:"ssh",label:"SSH server"},{unit:"systemd-journald",label:"systemd-journald"},{unit:"tailscaled",label:"Tailscale"},{unit:"networkd-dispatcher",label:"Networkd dispatcher"}];injectModal("journald-modal",`
|
||||
<div id="journald-modal" class="weather-modal" style="z-index: 1002;">
|
||||
<div class="weather-modal-content" style="min-width: 900px; max-width: 95vw; height: 80vh; display: flex; flex-direction: column;">
|
||||
<div class="logs-header" style="display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px;">
|
||||
@@ -698,7 +698,7 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`);const E=document.getElementById("journald-modal"),j=document.getElementById("jd-unit-select"),h=document.getElementById("jd-search"),P=document.getElementById("jd-tail"),A=document.getElementById("jd-refresh"),D=document.getElementById("jd-stream"),R=document.getElementById("jd-clear-search"),y=document.getElementById("jd-close"),$=document.getElementById("jd-close-btn"),k=document.getElementById("jd-content"),H=document.getElementById("jd-line-count"),T=document.getElementById("jd-filter-count"),z=document.getElementById("jd-overflow"),C=document.getElementById("jd-unit-display"),M=document.getElementById("jd-stream-state");let b=!1,d=[],v=!1,S=null,O=null;function m(p){const t=document.createElement("div");return t.textContent=String(p),t.innerHTML}function f(p){b=p,j.innerHTML="",x.forEach(t=>{const e=document.createElement("option");e.value=t.unit,e.textContent=t.label+" ("+t.unit+")",j.appendChild(e)}),j.disabled=!p,p?(A.disabled=!1,D.disabled=!1):(k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">journald bind-mount not available in this container.<br/><small>Requires <code>/var/log/journal</code> + <code>/usr/bin/journalctl</code> mounted (start.sh).</small></div>',A.disabled=!0,D.disabled=!0)}async function B(){try{const p=await fetch("/api/v1/logs/journal/units");if(!p.ok){f(!1);return}const t=await p.json();f(!!t.available)}catch{f(!1)}}function w(){const p=(h.value||"").trim().toLowerCase(),t=p?d.filter(e=>(e.textContent||"").toLowerCase().includes(p)):d;if(t.length===0)k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No entries'+(p?` matching "${m(p)}"`:"")+"</div>";else{const e=t.map(n=>{const r=n.timestamp?m(n.timestamp):"\u2014",a=m(n.textContent);return`<div class="jd-line" style="padding: 1px 0; line-height: 1.4; color: #d4d4d4;"><span style="color: var(--muted); margin-right: 8px;">${r}</span>${a}</div>`}).join("");k.innerHTML=e,k.scrollHeight-k.scrollTop-k.clientHeight<80&&(k.scrollTop=k.scrollHeight)}H.textContent=`${d.length} entries`,T.textContent=p?`${t.length} of ${d.length} shown`:`${d.length} shown`}async function L(){if(!b)return;u();const p=j.value;if(!p)return;const t=Math.max(1,Math.min(5e3,Number(P.value)||200)),e=(h.value||"").trim();k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Loading\u2026</div>';try{const s=new URL("/api/v1/logs/journal",window.location.origin);s.searchParams.set("unit",p),s.searchParams.set("tail",String(t)),e&&s.searchParams.set("search",e);const n=await fetch(s.toString()),r=await n.json();if(!n.ok||!r.success){k.innerHTML='<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Failed: '+m(r&&r.error||"HTTP "+n.status)+"</div>";return}C.textContent=p,d=(r.entries||[]).map(a=>({timestamp:a.timestamp,unit:a.unit,textContent:a.text||""})),z.style.display="none",w()}catch(s){k.innerHTML='<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Error: '+m(s.message)+"</div>"}}function o(){if(!b)return;u();const p=j.value;if(!p)return;const t=(h.value||"").trim();C.textContent=p,D.textContent="\u23F8 Stop",D.classList.add("streaming"),M.textContent="streaming",M.style.color="var(--ok-fg, #4ade80)",d=[],w(),z.style.display="none";const e=new URL("/api/v1/logs/journal/stream",window.location.origin);e.searchParams.set("unit",p),t&&e.searchParams.set("search",t),S=new EventSource(e.toString()),S.onmessage=s=>{try{const n=JSON.parse(s.data);if(n.error){/stream (exceeded|line cap)/.test(n.error)&&(z.style.display="",u()),k.innerHTML+='<div class="jd-line" style="color: var(--bad-fg, #ef4444); padding: 4px 0;">\u26A0 '+m(n.error)+"</div>",k.scrollTop=k.scrollHeight;return}d.push({timestamp:n.timestamp,unit:n.unit||p,textContent:n.text||""}),d.length>5e3&&(d=d.slice(d.length-5e3),z.style.display=""),w()}catch{}},S.onerror=()=>{},v=!0}function u(){if(v=!1,S){try{S.close()}catch{}S=null}D.textContent="\u25B6 Stream",D.classList.remove("streaming"),M.textContent="disconnected",M.style.color="var(--muted)"}function l(){u(),E.classList.remove("show")}A.addEventListener("click",L),D.addEventListener("click",()=>v?u():o()),R.addEventListener("click",()=>{h.value="",w()}),h.addEventListener("input",()=>{clearTimeout(O),O=setTimeout(w,200)}),h.addEventListener("keydown",p=>{p.key==="Escape"&&(h.value="",w())}),y.addEventListener("click",l),$.addEventListener("click",l),E.addEventListener("click",p=>{p.target===E&&l()}),document.addEventListener("keydown",p=>{p.key==="Escape"&&E.classList.contains("show")&&l()}),j.addEventListener("change",()=>{d.length>0&&L()});function g(){E.classList.add("show"),B()}window.openJournaldModal=g,document.getElementById("view-journald-logs")?.addEventListener("click",g)})(),(function(){injectModal("snapshot-modal",`<div id="snapshot-modal" class="weather-modal">
|
||||
`);const h=document.getElementById("journald-modal"),j=document.getElementById("jd-unit-select"),m=document.getElementById("jd-search"),N=document.getElementById("jd-tail"),A=document.getElementById("jd-refresh"),D=document.getElementById("jd-stream"),R=document.getElementById("jd-clear-search"),g=document.getElementById("jd-close"),L=document.getElementById("jd-close-btn"),k=document.getElementById("jd-content"),M=document.getElementById("jd-line-count"),I=document.getElementById("jd-filter-count"),$=document.getElementById("jd-overflow"),E=document.getElementById("jd-unit-display"),T=document.getElementById("jd-stream-state");let P=!1,v=[],B=!1,z=null,O=null;function u(c){const n=document.createElement("div");return n.textContent=String(c),n.innerHTML}function y(c){P=c,j.innerHTML="",b.forEach(n=>{const t=document.createElement("option");t.value=n.unit,t.textContent=n.label+" ("+n.unit+")",j.appendChild(t)}),j.disabled=!c,c?(A.disabled=!1,D.disabled=!1):(k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">journald bind-mount not available in this container.<br/><small>Requires <code>/var/log/journal</code> + <code>/usr/bin/journalctl</code> mounted (start.sh).</small></div>',A.disabled=!0,D.disabled=!0)}async function C(){try{const c=await fetch("/api/v1/logs/journal/units");if(!c.ok){y(!1);return}const n=await c.json();y(!!n.available)}catch{y(!1)}}function w(){const c=(m.value||"").trim().toLowerCase(),n=c?v.filter(t=>(t.textContent||"").toLowerCase().includes(c)):v;if(n.length===0)k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">No entries'+(c?` matching "${u(c)}"`:"")+"</div>";else{const t=n.map(e=>{const o=e.timestamp?u(e.timestamp):"\u2014",a=u(e.textContent);return`<div class="jd-line" style="padding: 1px 0; line-height: 1.4; color: #d4d4d4;"><span style="color: var(--muted); margin-right: 8px;">${o}</span>${a}</div>`}).join("");k.innerHTML=t,k.scrollHeight-k.scrollTop-k.clientHeight<80&&(k.scrollTop=k.scrollHeight)}M.textContent=`${v.length} entries`,I.textContent=c?`${n.length} of ${v.length} shown`:`${v.length} shown`}async function S(){if(!P)return;p();const c=j.value;if(!c)return;const n=Math.max(1,Math.min(5e3,Number(N.value)||200)),t=(m.value||"").trim();k.innerHTML='<div class="logs-loading" style="color: var(--muted); text-align: center; padding: 40px;">Loading\u2026</div>';try{const r=new URL("/api/v1/logs/journal",window.location.origin);r.searchParams.set("unit",c),r.searchParams.set("tail",String(n)),t&&r.searchParams.set("search",t);const e=await fetch(r.toString()),o=await e.json();if(!e.ok||!o.success){k.innerHTML='<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Failed: '+u(o&&o.error||"HTTP "+e.status)+"</div>";return}E.textContent=c,v=(o.entries||[]).map(a=>({timestamp:a.timestamp,unit:a.unit,textContent:a.text||""})),$.style.display="none",w()}catch(r){k.innerHTML='<div class="logs-loading" style="color: var(--bad-fg, #ef4444); text-align: center; padding: 40px;">Error: '+u(r.message)+"</div>"}}function i(){if(!P)return;p();const c=j.value;if(!c)return;const n=(m.value||"").trim();E.textContent=c,D.textContent="\u23F8 Stop",D.classList.add("streaming"),T.textContent="streaming",T.style.color="var(--ok-fg, #4ade80)",v=[],w(),$.style.display="none";const t=new URL("/api/v1/logs/journal/stream",window.location.origin);t.searchParams.set("unit",c),n&&t.searchParams.set("search",n),z=new EventSource(t.toString()),z.onmessage=r=>{try{const e=JSON.parse(r.data);if(e.error){/stream (exceeded|line cap)/.test(e.error)&&($.style.display="",p()),k.innerHTML+='<div class="jd-line" style="color: var(--bad-fg, #ef4444); padding: 4px 0;">\u26A0 '+u(e.error)+"</div>",k.scrollTop=k.scrollHeight;return}v.push({timestamp:e.timestamp,unit:e.unit||c,textContent:e.text||""}),v.length>5e3&&(v=v.slice(v.length-5e3),$.style.display=""),w()}catch{}},z.onerror=()=>{},B=!0}function p(){if(B=!1,z){try{z.close()}catch{}z=null}D.textContent="\u25B6 Stream",D.classList.remove("streaming"),T.textContent="disconnected",T.style.color="var(--muted)"}function l(){p(),h.classList.remove("show")}A.addEventListener("click",S),D.addEventListener("click",()=>B?p():i()),R.addEventListener("click",()=>{m.value="",w()}),m.addEventListener("input",()=>{clearTimeout(O),O=setTimeout(w,200)}),m.addEventListener("keydown",c=>{c.key==="Escape"&&(m.value="",w())}),g.addEventListener("click",l),L.addEventListener("click",l),h.addEventListener("click",c=>{c.target===h&&l()}),document.addEventListener("keydown",c=>{c.key==="Escape"&&h.classList.contains("show")&&l()}),j.addEventListener("change",()=>{v.length>0&&S()});function f(){h.classList.add("show"),C()}window.openJournaldModal=f,document.getElementById("view-journald-logs")?.addEventListener("click",f)})(),(function(){injectModal("snapshot-modal",`<div id="snapshot-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 700px; max-width: 850px;">
|
||||
<h3>\u{1F4BE} Container Snapshots</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -752,7 +752,7 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="snapshot-close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("snapshot-modal"),E=document.getElementById("snapshot-btn"),j=document.getElementById("snapshot-close"),h=document.getElementById("snapshot-container-select"),P=document.getElementById("snapshot-details"),A=document.getElementById("snapshot-create-btn"),D=document.getElementById("snapshot-create-status");let R=null;async function y(){try{const C=await(await fetch("/api/v1/containers")).json();if(!C.success||!C.containers)return;h.innerHTML='<option value="">-- Select a container --</option>';for(const M of C.containers){const b=document.createElement("option");b.value=M.id,b.textContent=`${M.name||M.id} (${M.image||"unknown"})`,b.dataset.name=M.name,b.dataset.image=M.image,b.dataset.status=M.status,b.dataset.created=M.created,h.appendChild(b)}}catch(z){console.error("Failed to load containers:",z)}}function $(z){if(!z||!z.value){P.style.display="none",R=null;return}R=z.value,document.getElementById("snapshot-image").textContent=z.dataset.image||"-",document.getElementById("snapshot-status").textContent=z.dataset.status||"-",document.getElementById("snapshot-created").textContent=z.dataset.created?new Date(z.dataset.created*1e3).toLocaleString():"-",document.getElementById("snapshot-id").textContent=z.value.substring(0,12),P.style.display=""}async function k(){if(!R){D.textContent="Please select a container first",D.style.color="var(--bad-fg)";return}const z=document.getElementById("snapshot-name").value.trim();if(!z){D.textContent="Please enter a snapshot name",D.style.color="var(--bad-fg)";return}const C=document.getElementById("snapshot-leave-running").checked;A.disabled=!0,A.textContent="Creating...",D.textContent="";try{const b=await(await fetch(`/api/v1/containers/${encodeURIComponent(R)}/checkpoint`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,leaveRunning:C})})).json();b.success?(D.textContent=`\u2713 Snapshot "${z}" created successfully`,D.style.color="var(--ok-fg)",document.getElementById("snapshot-name").value=""):(D.textContent=`\u2717 Failed: ${b.error||"Unknown error"}`,D.style.color="var(--bad-fg)")}catch(M){D.textContent=`\u2717 Error: ${M.message}`,D.style.color="var(--bad-fg)"}finally{A.disabled=!1,A.textContent="\u{1F4BE} Create Snapshot"}}function H(){x.classList.add("show"),y()}function T(){x.classList.remove("show"),P.style.display="none",R=null,h.selectedIndex=0}E?.addEventListener("click",H),j?.addEventListener("click",T),wireModal(x,j),h?.addEventListener("change",z=>{const C=h.options[h.selectedIndex];$(C)}),A?.addEventListener("click",k),x?.querySelectorAll(".panel-tab").forEach(z=>{z.addEventListener("click",()=>{x.querySelectorAll(".panel-tab").forEach(C=>C.classList.remove("active")),x.querySelectorAll(".panel-section").forEach(C=>C.classList.remove("active")),z.classList.add("active"),x.querySelector(`#${z.dataset.panel}`).classList.add("active")})})})(),(function(){injectModal("arr-setup-modal",`<div id="arr-setup-modal" class="weather-modal">
|
||||
</div>`);const b=document.getElementById("snapshot-modal"),h=document.getElementById("snapshot-btn"),j=document.getElementById("snapshot-close"),m=document.getElementById("snapshot-container-select"),N=document.getElementById("snapshot-details"),A=document.getElementById("snapshot-create-btn"),D=document.getElementById("snapshot-create-status");let R=null;async function g(){try{const E=await(await fetch("/api/v1/containers")).json();if(!E.success||!E.containers)return;m.innerHTML='<option value="">-- Select a container --</option>';for(const T of E.containers){const P=document.createElement("option");P.value=T.id,P.textContent=`${T.name||T.id} (${T.image||"unknown"})`,P.dataset.name=T.name,P.dataset.image=T.image,P.dataset.status=T.status,P.dataset.created=T.created,m.appendChild(P)}}catch($){console.error("Failed to load containers:",$)}}function L($){if(!$||!$.value){N.style.display="none",R=null;return}R=$.value,document.getElementById("snapshot-image").textContent=$.dataset.image||"-",document.getElementById("snapshot-status").textContent=$.dataset.status||"-",document.getElementById("snapshot-created").textContent=$.dataset.created?new Date($.dataset.created*1e3).toLocaleString():"-",document.getElementById("snapshot-id").textContent=$.value.substring(0,12),N.style.display=""}async function k(){if(!R){D.textContent="Please select a container first",D.style.color="var(--bad-fg)";return}const $=document.getElementById("snapshot-name").value.trim();if(!$){D.textContent="Please enter a snapshot name",D.style.color="var(--bad-fg)";return}const E=document.getElementById("snapshot-leave-running").checked;A.disabled=!0,A.textContent="Creating...",D.textContent="";try{const P=await(await fetch(`/api/v1/containers/${encodeURIComponent(R)}/checkpoint`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$,leaveRunning:E})})).json();P.success?(D.textContent=`\u2713 Snapshot "${$}" created successfully`,D.style.color="var(--ok-fg)",document.getElementById("snapshot-name").value=""):(D.textContent=`\u2717 Failed: ${P.error||"Unknown error"}`,D.style.color="var(--bad-fg)")}catch(T){D.textContent=`\u2717 Error: ${T.message}`,D.style.color="var(--bad-fg)"}finally{A.disabled=!1,A.textContent="\u{1F4BE} Create Snapshot"}}function M(){b.classList.add("show"),g()}function I(){b.classList.remove("show"),N.style.display="none",R=null,m.selectedIndex=0}h?.addEventListener("click",M),j?.addEventListener("click",I),wireModal(b,j),m?.addEventListener("change",$=>{const E=m.options[m.selectedIndex];L(E)}),A?.addEventListener("click",k),b?.querySelectorAll(".panel-tab").forEach($=>{$.addEventListener("click",()=>{b.querySelectorAll(".panel-tab").forEach(E=>E.classList.remove("active")),b.querySelectorAll(".panel-section").forEach(E=>E.classList.remove("active")),$.classList.add("active"),b.querySelector(`#${$.dataset.panel}`).classList.add("active")})})})(),(function(){injectModal("arr-setup-modal",`<div id="arr-setup-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 600px; max-width: 720px;">
|
||||
<h3>\u{1F3AC} Smart Arr Connect</h3>
|
||||
<p style="color: var(--muted); margin: 0 0 16px; font-size: 0.9rem;">
|
||||
@@ -831,73 +831,73 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="arr-setup-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("arr-setup-modal"),E=document.getElementById("arr-setup-btn"),j=document.getElementById("arr-setup-cancel"),h=document.getElementById("smart-connect-btn"),P=document.getElementById("smart-phase-detect"),A=document.getElementById("smart-phase-credentials"),D=document.getElementById("smart-phase-progress"),R=document.getElementById("smart-phase-results"),y=document.getElementById("smart-detect-results"),$=document.getElementById("smart-credential-inputs"),k=document.getElementById("smart-progress-steps"),H=document.getElementById("smart-results-content"),T=document.getElementById("smart-plex-libraries"),z=document.getElementById("smart-retry-btn");let C=null;const M={plex:"\u{1F3AC}",radarr:"\u{1F3AC}",sonarr:"\u{1F4FA}",prowlarr:"\u{1F50D}",seerr:"\u{1F4CB}"},b={plex:"Plex",radarr:"Radarr (Movies)",sonarr:"Sonarr (TV)",prowlarr:"Prowlarr (Indexers)",seerr:"Seerr"};function d(w){P.style.display=w==="detect"?"block":"none",A.style.display=w==="credentials"?"block":"none",D.style.display=w==="progress"?"block":"none",R.style.display=w==="results"?"block":"none"}function v(w){const L={connected:{bg:"var(--ok-fg)",icon:"✓",text:"Connected"},needs_key:{bg:"#f39c12",icon:"🔑",text:"Needs API Key"},not_found:{bg:"var(--muted)",icon:"—",text:"Not Found"},error:{bg:"var(--bad-fg)",icon:"✗",text:"Error"}},o=L[w]||L.not_found;return`<span style="display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; background: color-mix(in srgb, ${o.bg} 20%, transparent); color: ${o.bg};">${o.icon} ${o.text}</span>`}async function S(){d("detect"),y.style.display="none";try{if(C=await(await fetch("/api/v1/arr/smart-detect")).json(),!C.success){y.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Detection failed: ${escapeHtml(C.error)}</div>`,y.style.display="block";return}let L='<div style="display: flex; flex-direction: column; gap: 8px;">';for(const[u,l]of Object.entries(C.services)){const g=M[u]||"\u{1F4E6}",p=b[u]||u,t=l.source?`<span style="font-size: 0.7rem; color: var(--muted); padding: 1px 6px; background: var(--card-bg); border-radius: 3px;">${escapeHtml(l.source)}</span>`:"",e=l.version?`<span style="font-size: 0.7rem; color: var(--muted);">v${escapeHtml(l.version)}</span>`:"",s=(l.hasApiKey||l.hasToken)&&l.status==="connected"?'<span style="font-size: 0.7rem; color: var(--ok-fg);">Key saved</span>':"";L+=`<div style="display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<span style="font-size: 1.1rem;">${g}</span>
|
||||
</div>`);const b=document.getElementById("arr-setup-modal"),h=document.getElementById("arr-setup-btn"),j=document.getElementById("arr-setup-cancel"),m=document.getElementById("smart-connect-btn"),N=document.getElementById("smart-phase-detect"),A=document.getElementById("smart-phase-credentials"),D=document.getElementById("smart-phase-progress"),R=document.getElementById("smart-phase-results"),g=document.getElementById("smart-detect-results"),L=document.getElementById("smart-credential-inputs"),k=document.getElementById("smart-progress-steps"),M=document.getElementById("smart-results-content"),I=document.getElementById("smart-plex-libraries"),$=document.getElementById("smart-retry-btn");let E=null;const T={plex:"\u{1F3AC}",radarr:"\u{1F3AC}",sonarr:"\u{1F4FA}",prowlarr:"\u{1F50D}",seerr:"\u{1F4CB}"},P={plex:"Plex",radarr:"Radarr (Movies)",sonarr:"Sonarr (TV)",prowlarr:"Prowlarr (Indexers)",seerr:"Seerr"};function v(w){N.style.display=w==="detect"?"block":"none",A.style.display=w==="credentials"?"block":"none",D.style.display=w==="progress"?"block":"none",R.style.display=w==="results"?"block":"none"}function B(w){const S={connected:{bg:"var(--ok-fg)",icon:"✓",text:"Connected"},needs_key:{bg:"#f39c12",icon:"🔑",text:"Needs API Key"},not_found:{bg:"var(--muted)",icon:"—",text:"Not Found"},error:{bg:"var(--bad-fg)",icon:"✗",text:"Error"}},i=S[w]||S.not_found;return`<span style="display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; background: color-mix(in srgb, ${i.bg} 20%, transparent); color: ${i.bg};">${i.icon} ${i.text}</span>`}async function z(){v("detect"),g.style.display="none";try{if(E=await(await fetch("/api/v1/arr/smart-detect")).json(),!E.success){g.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Detection failed: ${escapeHtml(E.error)}</div>`,g.style.display="block";return}let S='<div style="display: flex; flex-direction: column; gap: 8px;">';for(const[p,l]of Object.entries(E.services)){const f=T[p]||"\u{1F4E6}",c=P[p]||p,n=l.source?`<span style="font-size: 0.7rem; color: var(--muted); padding: 1px 6px; background: var(--card-bg); border-radius: 3px;">${escapeHtml(l.source)}</span>`:"",t=l.version?`<span style="font-size: 0.7rem; color: var(--muted);">v${escapeHtml(l.version)}</span>`:"",r=(l.hasApiKey||l.hasToken)&&l.status==="connected"?'<span style="font-size: 0.7rem; color: var(--ok-fg);">Key saved</span>':"";S+=`<div style="display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<span style="font-size: 1.1rem;">${f}</span>
|
||||
<div style="flex: 1;">
|
||||
<div style="font-weight: 500; font-size: 0.9rem;">${p}</div>
|
||||
<div style="font-weight: 500; font-size: 0.9rem;">${c}</div>
|
||||
<div style="display: flex; gap: 6px; align-items: center; flex-wrap: wrap;">
|
||||
${t} ${e} ${s}
|
||||
${n} ${t} ${r}
|
||||
</div>
|
||||
</div>
|
||||
${v(l.status)}
|
||||
</div>`}L+="</div>";const o=C.summary;L+=`<div style="margin-top: 12px; padding: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; font-size: 0.85rem;">
|
||||
${escapeHtml(String(o.fullyConnected))}/${escapeHtml(String(o.totalDetected+(5-o.totalDetected)))} services detected ·
|
||||
${escapeHtml(String(o.fullyConnected))} connected${o.needsApiKey>0?` · <strong>${escapeHtml(String(o.needsApiKey))} needs API key</strong>`:""}
|
||||
</div>`,y.innerHTML=L,y.style.display="block",O(C),setTimeout(()=>{d("credentials")},800)}catch(w){y.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Error: ${escapeHtml(w.message)}</div>`,y.style.display="block"}}function O(w){let L="";const o=w.services,u=["radarr","sonarr","prowlarr"];for(const p of u){const t=o[p];if(!t||t.status==="not_found"&&!t.url)continue;const e=M[p],s=b[p],n=t.status==="connected";L+=`<div style="margin-bottom: 10px; padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${n?"var(--ok-fg)":"var(--border)"};">
|
||||
${B(l.status)}
|
||||
</div>`}S+="</div>";const i=E.summary;S+=`<div style="margin-top: 12px; padding: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; font-size: 0.85rem;">
|
||||
${escapeHtml(String(i.fullyConnected))}/${escapeHtml(String(i.totalDetected+(5-i.totalDetected)))} services detected ·
|
||||
${escapeHtml(String(i.fullyConnected))} connected${i.needsApiKey>0?` · <strong>${escapeHtml(String(i.needsApiKey))} needs API key</strong>`:""}
|
||||
</div>`,g.innerHTML=S,g.style.display="block",O(E),setTimeout(()=>{v("credentials")},800)}catch(w){g.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Error: ${escapeHtml(w.message)}</div>`,g.style.display="block"}}function O(w){let S="";const i=w.services,p=["radarr","sonarr","prowlarr"];for(const c of p){const n=i[c];if(!n||n.status==="not_found"&&!n.url)continue;const t=T[c],r=P[c],e=n.status==="connected";S+=`<div style="margin-bottom: 10px; padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${e?"var(--ok-fg)":"var(--border)"};">
|
||||
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
|
||||
<span style="font-size: 1.1rem;">${e}</span>
|
||||
<span style="font-weight: 500;">${s}</span>
|
||||
<span id="smart-${p}-status" style="margin-left: auto; font-size: 0.75rem;">
|
||||
${n?'<span style="color: var(--ok-fg);">✓ Connected</span>':""}
|
||||
<span style="font-size: 1.1rem;">${t}</span>
|
||||
<span style="font-weight: 500;">${r}</span>
|
||||
<span id="smart-${c}-status" style="margin-left: auto; font-size: 0.75rem;">
|
||||
${e?'<span style="color: var(--ok-fg);">✓ Connected</span>':""}
|
||||
</span>
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 8px;">
|
||||
<div>
|
||||
<label style="font-size: 0.75rem; color: var(--muted);">URL:</label>
|
||||
<input type="text" id="smart-${p}-url" value="${escapeHtml(t.url||"")}" placeholder="https://seedbox.com/${p}/"
|
||||
<input type="text" id="smart-${c}-url" value="${escapeHtml(n.url||"")}" placeholder="https://seedbox.com/${c}/"
|
||||
style="width: 100%; font-size: 0.85rem; padding: 6px 8px; background: var(--card-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px;" />
|
||||
</div>
|
||||
<div>
|
||||
<label style="font-size: 0.75rem; color: var(--muted);">API Key:</label>
|
||||
<input type="password" id="smart-${p}-key" placeholder="${n?"(saved)":"Paste API key"}"
|
||||
<input type="password" id="smart-${c}-key" placeholder="${e?"(saved)":"Paste API key"}"
|
||||
style="width: 100%; font-size: 0.85rem; padding: 6px 8px; background: var(--card-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px;" />
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="smartTestConnection('${p}')" style="margin-top: 8px; padding: 4px 12px; font-size: 0.75rem; cursor: pointer;">Test</button>
|
||||
</div>`}const l=o.plex;if(l){const p=l.status==="connected";L+=`<div style="padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${p?"var(--ok-fg)":"var(--border)"}; margin-bottom: 10px;">
|
||||
<button onclick="smartTestConnection('${c}')" style="margin-top: 8px; padding: 4px 12px; font-size: 0.75rem; cursor: pointer;">Test</button>
|
||||
</div>`}const l=i.plex;if(l){const c=l.status==="connected";S+=`<div style="padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${c?"var(--ok-fg)":"var(--border)"}; margin-bottom: 10px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.1rem;">\u{1F3AC}</span>
|
||||
<span style="font-weight: 500;">Plex</span>
|
||||
${v(l.status)}
|
||||
${B(l.status)}
|
||||
<span style="margin-left: auto; font-size: 0.75rem; color: var(--muted);">${escapeHtml(l.source||"")}</span>
|
||||
</div>
|
||||
</div>`}const g=o.seerr;if(g){const p=g.status==="connected";let t="";if(g.configuredServices){const e=g.configuredServices;t=`<div style="font-size: 0.75rem; color: var(--muted); margin-top: 4px;">
|
||||
Configured: ${e.radarr?"✓ Radarr":"✗ Radarr"} ·
|
||||
${e.sonarr?"✓ Sonarr":"✗ Sonarr"} ·
|
||||
${e.plex?"✓ Plex":"✗ Plex"}
|
||||
</div>`}L+=`<div style="padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${p?"var(--ok-fg)":"var(--border)"};">
|
||||
</div>`}const f=i.seerr;if(f){const c=f.status==="connected";let n="";if(f.configuredServices){const t=f.configuredServices;n=`<div style="font-size: 0.75rem; color: var(--muted); margin-top: 4px;">
|
||||
Configured: ${t.radarr?"✓ Radarr":"✗ Radarr"} ·
|
||||
${t.sonarr?"✓ Sonarr":"✗ Sonarr"} ·
|
||||
${t.plex?"✓ Plex":"✗ Plex"}
|
||||
</div>`}S+=`<div style="padding: 10px 12px; background: var(--card-base); border-radius: 8px; border: 1px solid ${c?"var(--ok-fg)":"var(--border)"};">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span style="font-size: 1.1rem;">\u{1F4CB}</span>
|
||||
<span style="font-weight: 500;">Seerr</span>
|
||||
${v(g.status)}
|
||||
${B(f.status)}
|
||||
</div>
|
||||
${t}
|
||||
</div>`}$.innerHTML=L}window.smartTestConnection=async function(w){const L=document.getElementById(`smart-${w}-url`),o=document.getElementById(`smart-${w}-key`),u=document.getElementById(`smart-${w}-status`),l=L?.value.trim(),g=o?.value.trim();if(!l||!g){u.innerHTML='<span style="color: var(--bad-fg);">Enter URL and API key</span>';return}u.innerHTML='<span class="brand-spinner"></span>';try{const t=await(await secureFetch("/api/v1/arr/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:w,url:l,apiKey:g})})).json();t.success?u.innerHTML=`<span style="color: var(--ok-fg);">✓ ${escapeHtml(t.appName||"Connected")} v${escapeHtml(t.version||"")}</span>`:u.innerHTML=`<span style="color: var(--bad-fg);">✗ ${escapeHtml(t.error)}</span>`}catch(p){u.innerHTML=`<span style="color: var(--bad-fg);">✗ ${escapeHtml(p.message)}</span>`}};async function m(){d("progress"),k.innerHTML='<div style="text-align: center; padding: 20px;"><span class="brand-spinner"></span><div style="color: var(--muted); margin-top: 8px;">Connecting services...</div></div>';const w={};for(const o of["radarr","sonarr","prowlarr"]){const u=document.getElementById(`smart-${o}-url`)?.value.trim(),l=document.getElementById(`smart-${o}-key`)?.value.trim();l&&u?w[o]={apiKey:l,url:u}:l&&(w[o]={apiKey:l})}const L={services:Object.keys(w).length>0?w:void 0,configurePlex:document.getElementById("smart-opt-plex")?.checked,configureProwlarr:document.getElementById("smart-opt-prowlarr")?.checked,configureSeerr:document.getElementById("smart-opt-seerr")?.checked,saveCredentials:document.getElementById("smart-opt-save")?.checked};try{const u=await(await secureFetch("/api/v1/arr/smart-connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L)})).json();let l="";for(const g of u.steps||[]){const p=g.status==="success"?'<span style="color: var(--ok-fg);">✓</span>':'<span style="color: var(--bad-fg);">✗</span>',t=g.status==="success"?"var(--muted)":"var(--bad-fg)";l+=`<div style="display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card-base); border-radius: 6px; font-size: 0.85rem;">
|
||||
${p}
|
||||
<span>${escapeHtml(g.step)}</span>
|
||||
<span style="margin-left: auto; font-size: 0.75rem; color: ${t};">${escapeHtml(g.details||"")}</span>
|
||||
</div>`}k.innerHTML=l,setTimeout(()=>f(u),500)}catch(o){k.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Connection error: ${escapeHtml(o.message)}</div>`}}function f(w){d("results");const L=w.summary||{},o=L.failed===0&&L.succeeded>0,u=o?"var(--ok-fg)":"#f39c12",l=o?"✓":"⚠",g=o?"All Connected!":`${escapeHtml(String(L.succeeded))}/${escapeHtml(String(L.totalSteps))} Steps Succeeded`;let p=`<div style="text-align: center; padding: 16px; background: color-mix(in srgb, ${u} 12%, transparent); border-radius: 10px; border: 1px solid ${u}; margin-bottom: 12px;">
|
||||
<div style="font-size: 1.5rem; color: ${u};">${l}</div>
|
||||
<div style="font-size: 1.1rem; font-weight: 600; color: ${u};">${g}</div>
|
||||
<div style="font-size: 0.85rem; color: var(--muted); margin-top: 4px;">${escapeHtml(String(L.succeeded))} succeeded, ${escapeHtml(String(L.failed))} failed</div>
|
||||
</div>`;p+='<div style="display: flex; flex-direction: column; gap: 4px;">';for(const t of w.steps||[]){const e=t.status==="success"?'<span style="color: var(--ok-fg);">✓</span>':'<span style="color: var(--bad-fg);">✗</span>';p+=`<div style="display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 0.8rem;">
|
||||
${e} ${escapeHtml(t.step)} <span style="margin-left: auto; color: var(--muted); font-size: 0.75rem;">${escapeHtml(t.details||"")}</span>
|
||||
</div>`}p+="</div>",H.innerHTML=p,z.style.display=L.failed>0?"block":"none",w.steps?.some(t=>t.step.includes("Plex")&&t.status==="success")&&B()}async function B(){try{const L=await(await fetch("/api/v1/plex/libraries")).json();if(L.success&&L.libraries?.length>0){let o=`<div style="padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<h4 style="margin: 0 0 8px; font-size: 0.85rem; color: var(--accent);">\u{1F3AC} ${escapeHtml(L.serverName)} Libraries</h4>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px;">`;for(const u of L.libraries){const l=u.type==="movie"?"\u{1F3AC}":u.type==="show"?"\u{1F4FA}":"\u{1F3B5}";o+=`<div style="padding: 8px 12px; background: var(--card-bg); border-radius: 6px; font-size: 0.85rem;">
|
||||
${l} <strong>${escapeHtml(u.title)}</strong>
|
||||
<span style="color: var(--muted); font-size: 0.75rem;">${escapeHtml(String(u.count))} items</span>
|
||||
</div>`}o+="</div></div>",T.innerHTML=o,T.style.display="block"}}catch{}}E?.addEventListener("click",()=>{x.classList.add("show"),T.style.display="none",S()}),wireModal(x,j),h?.addEventListener("click",m),z?.addEventListener("click",m)})(),(function(){const x=new ErrorHandler;injectModal("notifications-modal",`<div id="notifications-modal" class="weather-modal">
|
||||
${n}
|
||||
</div>`}L.innerHTML=S}window.smartTestConnection=async function(w){const S=document.getElementById(`smart-${w}-url`),i=document.getElementById(`smart-${w}-key`),p=document.getElementById(`smart-${w}-status`),l=S?.value.trim(),f=i?.value.trim();if(!l||!f){p.innerHTML='<span style="color: var(--bad-fg);">Enter URL and API key</span>';return}p.innerHTML='<span class="brand-spinner"></span>';try{const n=await(await secureFetch("/api/v1/arr/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:w,url:l,apiKey:f})})).json();n.success?p.innerHTML=`<span style="color: var(--ok-fg);">✓ ${escapeHtml(n.appName||"Connected")} v${escapeHtml(n.version||"")}</span>`:p.innerHTML=`<span style="color: var(--bad-fg);">✗ ${escapeHtml(n.error)}</span>`}catch(c){p.innerHTML=`<span style="color: var(--bad-fg);">✗ ${escapeHtml(c.message)}</span>`}};async function u(){v("progress"),k.innerHTML='<div style="text-align: center; padding: 20px;"><span class="brand-spinner"></span><div style="color: var(--muted); margin-top: 8px;">Connecting services...</div></div>';const w={};for(const i of["radarr","sonarr","prowlarr"]){const p=document.getElementById(`smart-${i}-url`)?.value.trim(),l=document.getElementById(`smart-${i}-key`)?.value.trim();l&&p?w[i]={apiKey:l,url:p}:l&&(w[i]={apiKey:l})}const S={services:Object.keys(w).length>0?w:void 0,configurePlex:document.getElementById("smart-opt-plex")?.checked,configureProwlarr:document.getElementById("smart-opt-prowlarr")?.checked,configureSeerr:document.getElementById("smart-opt-seerr")?.checked,saveCredentials:document.getElementById("smart-opt-save")?.checked};try{const p=await(await secureFetch("/api/v1/arr/smart-connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)})).json();let l="";for(const f of p.steps||[]){const c=f.status==="success"?'<span style="color: var(--ok-fg);">✓</span>':'<span style="color: var(--bad-fg);">✗</span>',n=f.status==="success"?"var(--muted)":"var(--bad-fg)";l+=`<div style="display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--card-base); border-radius: 6px; font-size: 0.85rem;">
|
||||
${c}
|
||||
<span>${escapeHtml(f.step)}</span>
|
||||
<span style="margin-left: auto; font-size: 0.75rem; color: ${n};">${escapeHtml(f.details||"")}</span>
|
||||
</div>`}k.innerHTML=l,setTimeout(()=>y(p),500)}catch(i){k.innerHTML=`<div style="padding: 12px; color: var(--bad-fg);">Connection error: ${escapeHtml(i.message)}</div>`}}function y(w){v("results");const S=w.summary||{},i=S.failed===0&&S.succeeded>0,p=i?"var(--ok-fg)":"#f39c12",l=i?"✓":"⚠",f=i?"All Connected!":`${escapeHtml(String(S.succeeded))}/${escapeHtml(String(S.totalSteps))} Steps Succeeded`;let c=`<div style="text-align: center; padding: 16px; background: color-mix(in srgb, ${p} 12%, transparent); border-radius: 10px; border: 1px solid ${p}; margin-bottom: 12px;">
|
||||
<div style="font-size: 1.5rem; color: ${p};">${l}</div>
|
||||
<div style="font-size: 1.1rem; font-weight: 600; color: ${p};">${f}</div>
|
||||
<div style="font-size: 0.85rem; color: var(--muted); margin-top: 4px;">${escapeHtml(String(S.succeeded))} succeeded, ${escapeHtml(String(S.failed))} failed</div>
|
||||
</div>`;c+='<div style="display: flex; flex-direction: column; gap: 4px;">';for(const n of w.steps||[]){const t=n.status==="success"?'<span style="color: var(--ok-fg);">✓</span>':'<span style="color: var(--bad-fg);">✗</span>';c+=`<div style="display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 0.8rem;">
|
||||
${t} ${escapeHtml(n.step)} <span style="margin-left: auto; color: var(--muted); font-size: 0.75rem;">${escapeHtml(n.details||"")}</span>
|
||||
</div>`}c+="</div>",M.innerHTML=c,$.style.display=S.failed>0?"block":"none",w.steps?.some(n=>n.step.includes("Plex")&&n.status==="success")&&C()}async function C(){try{const S=await(await fetch("/api/v1/plex/libraries")).json();if(S.success&&S.libraries?.length>0){let i=`<div style="padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<h4 style="margin: 0 0 8px; font-size: 0.85rem; color: var(--accent);">\u{1F3AC} ${escapeHtml(S.serverName)} Libraries</h4>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px;">`;for(const p of S.libraries){const l=p.type==="movie"?"\u{1F3AC}":p.type==="show"?"\u{1F4FA}":"\u{1F3B5}";i+=`<div style="padding: 8px 12px; background: var(--card-bg); border-radius: 6px; font-size: 0.85rem;">
|
||||
${l} <strong>${escapeHtml(p.title)}</strong>
|
||||
<span style="color: var(--muted); font-size: 0.75rem;">${escapeHtml(String(p.count))} items</span>
|
||||
</div>`}i+="</div></div>",I.innerHTML=i,I.style.display="block"}}catch{}}h?.addEventListener("click",()=>{b.classList.add("show"),I.style.display="none",z()}),wireModal(b,j),m?.addEventListener("click",u),$?.addEventListener("click",u)})(),(function(){const b=new ErrorHandler;injectModal("notifications-modal",`<div id="notifications-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 550px; max-width: 650px;">
|
||||
<h3>\u{1F514} Notification Settings</h3>
|
||||
|
||||
@@ -1109,15 +1109,15 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="notifications-save" class="btn-accent">Save Settings</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const E=document.getElementById("notifications-modal"),j=document.getElementById("manage-notifications"),h=document.getElementById("notifications-save"),P=document.getElementById("notifications-cancel");["discord","telegram","ntfy","email"].forEach(T=>{const z=document.getElementById(`${T}-enabled`),C=document.getElementById(`${T}-config`);z?.addEventListener("change",()=>{C.style.display=z.checked?"block":"none"})});const A=document.getElementById("health-check-enabled"),D=document.getElementById("health-check-config");A?.addEventListener("change",()=>{D.style.opacity=A.checked?"1":"0.5"});async function R(){try{const z=await(await fetch("/api/v1/notifications/config")).json();if(z.success){const C=z.config;document.getElementById("notifications-enabled").checked=C.enabled,document.getElementById("discord-enabled").checked=C.providers?.discord?.enabled||!1,document.getElementById("telegram-enabled").checked=C.providers?.telegram?.enabled||!1,document.getElementById("ntfy-enabled").checked=C.providers?.ntfy?.enabled||!1,document.getElementById("email-enabled").checked=C.providers?.email?.enabled||!1,document.getElementById("discord-config").style.display=C.providers?.discord?.enabled?"block":"none",document.getElementById("telegram-config").style.display=C.providers?.telegram?.enabled?"block":"none",document.getElementById("ntfy-config").style.display=C.providers?.ntfy?.enabled?"block":"none",document.getElementById("email-config").style.display=C.providers?.email?.enabled?"block":"none",C.providers?.ntfy?.serverUrl&&(document.getElementById("ntfy-server").value=C.providers.ntfy.serverUrl),C.providers?.email?.host&&(document.getElementById("email-host").value=C.providers.email.host),C.providers?.email?.from&&(document.getElementById("email-from").value=C.providers.email.from),C.providers?.email?.to&&(document.getElementById("email-to").value=C.providers.email.to),C.providers?.email?.port&&(document.getElementById("email-port").value=C.providers.email.port),C.providers?.email?.secure!==void 0&&(document.getElementById("email-secure").checked=C.providers.email.secure===!0),C.providers?.email?.username&&(document.getElementById("email-user").value=C.providers.email.username);const M=document.getElementById("email-pass");C.providers?.email?.hasPassword?(M.value="",M.placeholder="saved \u2014 leave blank to keep"):M.placeholder="app password",document.getElementById("health-check-enabled").checked=C.healthCheck?.enabled||!1,C.healthCheck?.intervalMinutes&&(document.getElementById("health-check-interval").value=C.healthCheck.intervalMinutes),C.healthCheck?.lastCheck&&(document.getElementById("health-check-status").textContent=`Last check: ${new Date(C.healthCheck.lastCheck).toLocaleString()}`),document.getElementById("event-container-down").checked=C.events?.["container-down"]!==!1,document.getElementById("event-container-up").checked=C.events?.["container-up"]===!0,document.getElementById("event-deploy-success").checked=C.events?.["deploy-success"]!==!1,document.getElementById("event-deploy-failed").checked=C.events?.["deploy-failed"]!==!1,document.getElementById("event-ssl-cert-expiry").checked=C.events?.["ssl-cert-expiry"]!==!1,document.getElementById("event-dns-propagation").checked=C.events?.["dns-propagation"]!==!1,document.getElementById("event-drift-detected").checked=C.events?.["drift-detected"]!==!1,document.getElementById("event-dependency-restart").checked=C.events?.["dependency-restart"]!==!1,document.getElementById("event-recipe-removed").checked=C.events?.["recipe-removed"]!==!1,document.getElementById("event-workflow").checked=C.events?.workflow!==!1,document.getElementById("event-backup-complete").checked=C.events?.["backup-complete"]!==!1,document.getElementById("event-backup-failed").checked=C.events?.["backup-failed"]!==!1,document.getElementById("event-update-available").checked=C.events?.["update-available"]!==!1,document.getElementById("event-resource-alert").checked=C.events?.alert!==!1}}catch(T){x.logError("[Notifications] Load Config",T,{function:"loadConfig"})}}async function y(){try{const z=await(await fetch("/api/v1/notifications/history?limit=10")).json(),C=document.getElementById("notification-history");z.success&&z.history?.length>0?C.innerHTML=z.history.map(M=>{const b=new Date(M.timestamp).toLocaleString();return`
|
||||
</div>`);const h=document.getElementById("notifications-modal"),j=document.getElementById("manage-notifications"),m=document.getElementById("notifications-save"),N=document.getElementById("notifications-cancel");["discord","telegram","ntfy","email"].forEach(I=>{const $=document.getElementById(`${I}-enabled`),E=document.getElementById(`${I}-config`);$?.addEventListener("change",()=>{E.style.display=$.checked?"block":"none"})});const A=document.getElementById("health-check-enabled"),D=document.getElementById("health-check-config");A?.addEventListener("change",()=>{D.style.opacity=A.checked?"1":"0.5"});async function R(){try{const $=await(await fetch("/api/v1/notifications/config")).json();if($.success){const E=$.config;document.getElementById("notifications-enabled").checked=E.enabled,document.getElementById("discord-enabled").checked=E.providers?.discord?.enabled||!1,document.getElementById("telegram-enabled").checked=E.providers?.telegram?.enabled||!1,document.getElementById("ntfy-enabled").checked=E.providers?.ntfy?.enabled||!1,document.getElementById("email-enabled").checked=E.providers?.email?.enabled||!1,document.getElementById("discord-config").style.display=E.providers?.discord?.enabled?"block":"none",document.getElementById("telegram-config").style.display=E.providers?.telegram?.enabled?"block":"none",document.getElementById("ntfy-config").style.display=E.providers?.ntfy?.enabled?"block":"none",document.getElementById("email-config").style.display=E.providers?.email?.enabled?"block":"none",E.providers?.ntfy?.serverUrl&&(document.getElementById("ntfy-server").value=E.providers.ntfy.serverUrl),E.providers?.email?.host&&(document.getElementById("email-host").value=E.providers.email.host),E.providers?.email?.from&&(document.getElementById("email-from").value=E.providers.email.from),E.providers?.email?.to&&(document.getElementById("email-to").value=E.providers.email.to),E.providers?.email?.port&&(document.getElementById("email-port").value=E.providers.email.port),E.providers?.email?.secure!==void 0&&(document.getElementById("email-secure").checked=E.providers.email.secure===!0),E.providers?.email?.username&&(document.getElementById("email-user").value=E.providers.email.username);const T=document.getElementById("email-pass");E.providers?.email?.hasPassword?(T.value="",T.placeholder="saved \u2014 leave blank to keep"):T.placeholder="app password",document.getElementById("health-check-enabled").checked=E.healthCheck?.enabled||!1,E.healthCheck?.intervalMinutes&&(document.getElementById("health-check-interval").value=E.healthCheck.intervalMinutes),E.healthCheck?.lastCheck&&(document.getElementById("health-check-status").textContent=`Last check: ${new Date(E.healthCheck.lastCheck).toLocaleString()}`),document.getElementById("event-container-down").checked=E.events?.["container-down"]!==!1,document.getElementById("event-container-up").checked=E.events?.["container-up"]===!0,document.getElementById("event-deploy-success").checked=E.events?.["deploy-success"]!==!1,document.getElementById("event-deploy-failed").checked=E.events?.["deploy-failed"]!==!1,document.getElementById("event-ssl-cert-expiry").checked=E.events?.["ssl-cert-expiry"]!==!1,document.getElementById("event-dns-propagation").checked=E.events?.["dns-propagation"]!==!1,document.getElementById("event-drift-detected").checked=E.events?.["drift-detected"]!==!1,document.getElementById("event-dependency-restart").checked=E.events?.["dependency-restart"]!==!1,document.getElementById("event-recipe-removed").checked=E.events?.["recipe-removed"]!==!1,document.getElementById("event-workflow").checked=E.events?.workflow!==!1,document.getElementById("event-backup-complete").checked=E.events?.["backup-complete"]!==!1,document.getElementById("event-backup-failed").checked=E.events?.["backup-failed"]!==!1,document.getElementById("event-update-available").checked=E.events?.["update-available"]!==!1,document.getElementById("event-resource-alert").checked=E.events?.alert!==!1}}catch(I){b.logError("[Notifications] Load Config",I,{function:"loadConfig"})}}async function g(){try{const $=await(await fetch("/api/v1/notifications/history?limit=10")).json(),E=document.getElementById("notification-history");$.success&&$.history?.length>0?E.innerHTML=$.history.map(T=>{const P=new Date(T.timestamp).toLocaleString();return`
|
||||
<div style="padding: 6px 8px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-start;">
|
||||
<span style="color: ${{success:"var(--ok-fg)",error:"var(--bad-fg)",warning:"#f39c12",info:"var(--accent)"}[M.type]||"var(--muted)"}">${M.type==="success"?"\u2713":M.type==="error"?"\u2717":"\u2139"}</span>
|
||||
<span style="color: ${{success:"var(--ok-fg)",error:"var(--bad-fg)",warning:"#f39c12",info:"var(--accent)"}[T.type]||"var(--muted)"}">${T.type==="success"?"\u2713":T.type==="error"?"\u2717":"\u2139"}</span>
|
||||
<div style="flex: 1; min-width: 0;">
|
||||
<div style="font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${escapeHtml(M.title)}</div>
|
||||
<div style="font-size: 0.7rem; color: var(--muted);">${b}</div>
|
||||
<div style="font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${escapeHtml(T.title)}</div>
|
||||
<div style="font-size: 0.7rem; color: var(--muted);">${P}</div>
|
||||
</div>
|
||||
</div>
|
||||
`}).join(""):C.innerHTML='<div style="color: var(--muted); text-align: center; padding: 20px;">No notifications yet</div>'}catch(T){x.logError("[Notifications] Load History",T,{function:"loadHistory"})}}async function $(){try{const T={enabled:document.getElementById("notifications-enabled").checked,providers:{discord:{enabled:document.getElementById("discord-enabled").checked,webhookUrl:document.getElementById("discord-webhook").value.trim()},telegram:{enabled:document.getElementById("telegram-enabled").checked,botToken:document.getElementById("telegram-bot-token").value.trim(),chatId:document.getElementById("telegram-chat-id").value.trim()},ntfy:{enabled:document.getElementById("ntfy-enabled").checked,serverUrl:document.getElementById("ntfy-server").value.trim()||"https://ntfy.sh",topic:document.getElementById("ntfy-topic").value.trim()},email:{enabled:document.getElementById("email-enabled").checked,host:document.getElementById("email-host").value.trim(),port:parseInt(document.getElementById("email-port").value)||587,secure:document.getElementById("email-secure").checked,username:document.getElementById("email-user").value.trim(),password:document.getElementById("email-pass").value.trim(),from:document.getElementById("email-from").value.trim(),to:document.getElementById("email-to").value.trim()}},events:{"container-down":document.getElementById("event-container-down").checked,"container-up":document.getElementById("event-container-up").checked,"deploy-success":document.getElementById("event-deploy-success").checked,"deploy-failed":document.getElementById("event-deploy-failed").checked,"ssl-cert-expiry":document.getElementById("event-ssl-cert-expiry").checked,"dns-propagation":document.getElementById("event-dns-propagation").checked,"drift-detected":document.getElementById("event-drift-detected").checked,"dependency-restart":document.getElementById("event-dependency-restart").checked,"recipe-removed":document.getElementById("event-recipe-removed").checked,workflow:document.getElementById("event-workflow").checked,"backup-complete":document.getElementById("event-backup-complete").checked,"backup-failed":document.getElementById("event-backup-failed").checked,"update-available":document.getElementById("event-update-available").checked,alert:document.getElementById("event-resource-alert").checked},healthCheck:{enabled:document.getElementById("health-check-enabled").checked,intervalMinutes:parseInt(document.getElementById("health-check-interval").value)||5}},C=await(await secureFetch("/api/v1/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)})).json();C.success?(showNotification("Notification settings saved","success",3e3),E.classList.remove("show")):showNotification(`Failed to save: ${C.error}`,"error",3e3)}catch(T){showNotification(`Error: ${T.message}`,"error",3e3)}}async function k(T){try{const C=await(await secureFetch("/api/v1/notifications/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T})})).json();C.success?showNotification(`Test ${T} notification sent!`,"success",3e3):showNotification(`Test failed: ${C.error}`,"error",3e3)}catch(z){showNotification(`Error: ${z.message}`,"error",3e3)}}document.getElementById("discord-test")?.addEventListener("click",()=>k("discord")),document.getElementById("telegram-test")?.addEventListener("click",()=>k("telegram")),document.getElementById("ntfy-test")?.addEventListener("click",()=>k("ntfy")),document.getElementById("email-test")?.addEventListener("click",()=>k("email")),document.getElementById("health-check-now")?.addEventListener("click",async()=>{try{const z=await(await secureFetch("/api/v1/notifications/health-check",{method:"POST"})).json();z.success&&(document.getElementById("health-check-status").textContent=`Last check: ${new Date(z.lastCheck).toLocaleString()} (${z.containersMonitored} containers)`,showNotification("Health check completed","success",2e3))}catch(T){showNotification(`Error: ${T.message}`,"error",3e3)}}),j?.addEventListener("click",()=>{E.classList.add("show"),R(),y()}),h?.addEventListener("click",$),document.getElementById("notifications-send-test")?.addEventListener("click",async()=>{const T=document.getElementById("notifications-send-test"),z=T.textContent;T.textContent="Sending...",T.disabled=!0;try{const M=await(await secureFetch("/api/v1/notifications/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"test",data:{message:"This is a test notification from DashCaddy."},type:"info"})})).json();M.success?(showNotification("Test notification sent!","success",3e3),H()):showNotification(`Test failed: ${M.results?.map(b=>`${b.provider}: ${b.error||"ok"}`).join(", ")}`,"error",5e3)}catch(C){showNotification(`Error: ${C.message}`,"error",3e3)}finally{T.textContent=z,T.disabled=!1}});async function H(){try{const z=await(await fetch("/api/v1/notifications/status")).json();if(z.success&&z.lastSent){
Line truncated
|
||||
`}).join(""):E.innerHTML='<div style="color: var(--muted); text-align: center; padding: 20px;">No notifications yet</div>'}catch(I){b.logError("[Notifications] Load History",I,{function:"loadHistory"})}}async function L(){try{const I={enabled:document.getElementById("notifications-enabled").checked,providers:{discord:{enabled:document.getElementById("discord-enabled").checked,webhookUrl:document.getElementById("discord-webhook").value.trim()},telegram:{enabled:document.getElementById("telegram-enabled").checked,botToken:document.getElementById("telegram-bot-token").value.trim(),chatId:document.getElementById("telegram-chat-id").value.trim()},ntfy:{enabled:document.getElementById("ntfy-enabled").checked,serverUrl:document.getElementById("ntfy-server").value.trim()||"https://ntfy.sh",topic:document.getElementById("ntfy-topic").value.trim()},email:{enabled:document.getElementById("email-enabled").checked,host:document.getElementById("email-host").value.trim(),port:parseInt(document.getElementById("email-port").value)||587,secure:document.getElementById("email-secure").checked,username:document.getElementById("email-user").value.trim(),password:document.getElementById("email-pass").value.trim(),from:document.getElementById("email-from").value.trim(),to:document.getElementById("email-to").value.trim()}},events:{"container-down":document.getElementById("event-container-down").checked,"container-up":document.getElementById("event-container-up").checked,"deploy-success":document.getElementById("event-deploy-success").checked,"deploy-failed":document.getElementById("event-deploy-failed").checked,"ssl-cert-expiry":document.getElementById("event-ssl-cert-expiry").checked,"dns-propagation":document.getElementById("event-dns-propagation").checked,"drift-detected":document.getElementById("event-drift-detected").checked,"dependency-restart":document.getElementById("event-dependency-restart").checked,"recipe-removed":document.getElementById("event-recipe-removed").checked,workflow:document.getElementById("event-workflow").checked,"backup-complete":document.getElementById("event-backup-complete").checked,"backup-failed":document.getElementById("event-backup-failed").checked,"update-available":document.getElementById("event-update-available").checked,alert:document.getElementById("event-resource-alert").checked},healthCheck:{enabled:document.getElementById("health-check-enabled").checked,intervalMinutes:parseInt(document.getElementById("health-check-interval").value)||5}},E=await(await secureFetch("/api/v1/notifications/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)})).json();E.success?(showNotification("Notification settings saved","success",3e3),h.classList.remove("show")):showNotification(`Failed to save: ${E.error}`,"error",3e3)}catch(I){showNotification(`Error: ${I.message}`,"error",3e3)}}async function k(I){try{const E=await(await secureFetch("/api/v1/notifications/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:I})})).json();E.success?showNotification(`Test ${I} notification sent!`,"success",3e3):showNotification(`Test failed: ${E.error}`,"error",3e3)}catch($){showNotification(`Error: ${$.message}`,"error",3e3)}}document.getElementById("discord-test")?.addEventListener("click",()=>k("discord")),document.getElementById("telegram-test")?.addEventListener("click",()=>k("telegram")),document.getElementById("ntfy-test")?.addEventListener("click",()=>k("ntfy")),document.getElementById("email-test")?.addEventListener("click",()=>k("email")),document.getElementById("health-check-now")?.addEventListener("click",async()=>{try{const $=await(await secureFetch("/api/v1/notifications/health-check",{method:"POST"})).json();$.success&&(document.getElementById("health-check-status").textContent=`Last check: ${new Date($.lastCheck).toLocaleString()} (${$.containersMonitored} containers)`,showNotification("Health check completed","success",2e3))}catch(I){showNotification(`Error: ${I.message}`,"error",3e3)}}),j?.addEventListener("click",()=>{h.classList.add("show"),R(),g()}),m?.addEventListener("click",L),document.getElementById("notifications-send-test")?.addEventListener("click",async()=>{const I=document.getElementById("notifications-send-test"),$=I.textContent;I.textContent="Sending...",I.disabled=!0;try{const T=await(await secureFetch("/api/v1/notifications/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:"test",data:{message:"This is a test notification from DashCaddy."},type:"info"})})).json();T.success?(showNotification("Test notification sent!","success",3e3),M()):showNotification(`Test failed: ${T.results?.map(P=>`${P.provider}: ${P.error||"ok"}`).join(", ")}`,"error",5e3)}catch(E){showNotification(`Error: ${E.message}`,"error",3e3)}finally{I.textContent=$,I.disabled=!1}});async function M(){try{const $=await(await fetch("/api/v1/notifications/status")).json();if($.success&&$.lastSent){
Line truncated
|
||||
<div class="weather-modal-content" style="min-width: 550px; max-width: 650px;">
|
||||
<h3>\u{1F4BE} Backup & Restore</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1223,9 +1223,9 @@ Try refreshing in a moment if you see a certificate error.`,"warning",1e4),!1}};
|
||||
<button id="backup-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);var A=document.getElementById("backup-modal"),D=document.getElementById("backup-restore-btn"),R=document.getElementById("backup-cancel"),y=document.getElementById("backup-export-btn"),$=document.getElementById("backup-select-file"),k=document.getElementById("backup-file-input"),H=document.getElementById("backup-file-name"),T=document.getElementById("backup-preview"),z=document.getElementById("backup-preview-content"),C=document.getElementById("backup-do-restore-btn"),M=document.getElementById("backup-result"),b=document.getElementById("backup-schedules-container"),d=document.getElementById("backup-history-container"),v=document.getElementById("backup-disk-container"),S=document.getElementById("pointintime-container"),O=null;D?.addEventListener("click",function(){A.classList.add("show"),M&&(M.style.display="none"),T&&(T.style.display="none"),H&&(H.style.display="none"),O=null}),wireModal(A,R),y?.addEventListener("click",async function(){y.disabled=!0,y.innerHTML='<span class="brand-spinner"></span> Exporting...';try{var e=await fetch("/api/v1/backup/export"),s=await e.json();s.browserState=E();var n=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(n),a=document.createElement("a");a.href=r,a.download="dashcaddy-backup-"+new Date().toISOString().split("T")[0]+".json",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r);var i=Object.keys(s.browserState).length,c=s.themes?Object.keys(s.themes).length:0;M.innerHTML="\u2705 Full backup downloaded \u2014 server config + "+i+" browser settings"+(c?" + "+c+" themes":""),M.style.display="block",M.style.background="color-mix(in srgb, var(--ok-fg) 15%, transparent)",M.style.border="1px solid var(--ok-fg)"}catch(I){M.innerHTML="\u274C Export failed: "+escapeHtml(I.message),M.style.display="block",M.style.background="color-mix(in srgb, var(--bad-fg) 15%, transparent)",M.style.border="1px solid var(--bad-fg)"}y.disabled=!1,y.innerHTML="\u2B07\uFE0F Download Full Backup"}),$?.addEventListener("click",function(){k.click()}),k?.addEventListener("change",async function(e){var s=e.target.files[0];if(s){H.textContent="\u{1F4C4} "+s.name,H.style.display="block",M.style.display="none";try{var n=await s.text(),r=JSON.parse(n);if(h(r)){O=r;var a='<div style="margin-bottom: 8px; color: var(--muted); font-size: 0.8rem;">Legacy format (v'+escapeHtml(r.version)+")</div>";a+='<div style="display: flex; flex-wrap: wrap; gap: 6px;">',r.services?.length&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F4CB} '+r.services.length+" services</span>"),r.customApps?.length&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F4E6} '+r.customApps.length+" custom apps</span>"),r.theme&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F3A8} Theme: '+escapeHtml(r.theme)+"</span>"),r.userThemes&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F3A8} '+Object.keys(r.userThemes).length+" custom themes</span>"),a+="</div>",z.innerHTML=a,T.style.display="block";return}var i=await secureFetch("/api/v1/backup/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),c=await i.json();if(c.success){O=r;var a='<div style="margin-bottom: 8px; color: var(--muted); font-size: 0.8rem;">Exported: '+new Date(r.exportedAt).toLocaleString()+" (v"+escapeHtml(r.version)+")</div>";a+='<div style="margin-bottom: 6px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;">Server Config</div>',a+='<div style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;">';for(var I in c.preview.files){var N=c.preview.files[I],U=N.action==="create"?"\u{1F195}":"\u{1F4DD}";a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">'+U+" "+escapeHtml(N.description)+"</span>"}a+="</div>",c.preview.serviceCount&&(a+='<div style="font-size: 0.8rem; color: var(--accent); margin-bottom: 6px;">'+c.preview.serviceCount+" services</div>"),c.preview.themeCount&&(a+='<div style="font-size: 0.8rem; color: var(--accent); margin-bottom: 6px;">\u{1F3A8} '+c.preview.themeCount+" custom themes</div>"),c.preview.browserStateCount&&(a+='<div style="margin-top: 6px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;">Browser Preferences</div>',a+='<div style="font-size: 0.8rem; color: var(--accent);">\u{1F5A5}\uFE0F '+c.preview.browserStateCount+" saved settings (theme, weather, clock, widgets, etc.)</div>"),z.innerHTML=a,T.style.display="block"}else M.innerHTML="\u26A0\uFE0F Invalid backup file: "+escapeHtml(c.error),M.style.display="block",M.style.background="color-mix(in srgb, #f39c12 15%, transparent)",M.style.border="1px solid #f39c12",T.style.display="none"}catch(_){M.innerHTML="\u274CLine truncated
|
||||
</div>`);var A=document.getElementById("backup-modal"),D=document.getElementById("backup-restore-btn"),R=document.getElementById("backup-cancel"),g=document.getElementById("backup-export-btn"),L=document.getElementById("backup-select-file"),k=document.getElementById("backup-file-input"),M=document.getElementById("backup-file-name"),I=document.getElementById("backup-preview"),$=document.getElementById("backup-preview-content"),E=document.getElementById("backup-do-restore-btn"),T=document.getElementById("backup-result"),P=document.getElementById("backup-schedules-container"),v=document.getElementById("backup-history-container"),B=document.getElementById("backup-disk-container"),z=document.getElementById("pointintime-container"),O=null;D?.addEventListener("click",function(){A.classList.add("show"),T&&(T.style.display="none"),I&&(I.style.display="none"),M&&(M.style.display="none"),O=null}),wireModal(A,R),g?.addEventListener("click",async function(){g.disabled=!0,g.innerHTML='<span class="brand-spinner"></span> Exporting...';try{var t=await fetch("/api/v1/backup/export"),r=await t.json();r.browserState=h();var e=new Blob([JSON.stringify(r,null,2)],{type:"application/json"}),o=URL.createObjectURL(e),a=document.createElement("a");a.href=o,a.download="dashcaddy-backup-"+new Date().toISOString().split("T")[0]+".json",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o);var s=Object.keys(r.browserState).length,d=r.themes?Object.keys(r.themes).length:0;T.innerHTML="\u2705 Full backup downloaded \u2014 server config + "+s+" browser settings"+(d?" + "+d+" themes":""),T.style.display="block",T.style.background="color-mix(in srgb, var(--ok-fg) 15%, transparent)",T.style.border="1px solid var(--ok-fg)"}catch(x){T.innerHTML="\u274C Export failed: "+escapeHtml(x.message),T.style.display="block",T.style.background="color-mix(in srgb, var(--bad-fg) 15%, transparent)",T.style.border="1px solid var(--bad-fg)"}g.disabled=!1,g.innerHTML="\u2B07\uFE0F Download Full Backup"}),L?.addEventListener("click",function(){k.click()}),k?.addEventListener("change",async function(t){var r=t.target.files[0];if(r){M.textContent="\u{1F4C4} "+r.name,M.style.display="block",T.style.display="none";try{var e=await r.text(),o=JSON.parse(e);if(m(o)){O=o;var a='<div style="margin-bottom: 8px; color: var(--muted); font-size: 0.8rem;">Legacy format (v'+escapeHtml(o.version)+")</div>";a+='<div style="display: flex; flex-wrap: wrap; gap: 6px;">',o.services?.length&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F4CB} '+o.services.length+" services</span>"),o.customApps?.length&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F4E6} '+o.customApps.length+" custom apps</span>"),o.theme&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F3A8} Theme: '+escapeHtml(o.theme)+"</span>"),o.userThemes&&(a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">\u{1F3A8} '+Object.keys(o.userThemes).length+" custom themes</span>"),a+="</div>",$.innerHTML=a,I.style.display="block";return}var s=await secureFetch("/api/v1/backup/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}),d=await s.json();if(d.success){O=o;var a='<div style="margin-bottom: 8px; color: var(--muted); font-size: 0.8rem;">Exported: '+new Date(o.exportedAt).toLocaleString()+" (v"+escapeHtml(o.version)+")</div>";a+='<div style="margin-bottom: 6px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;">Server Config</div>',a+='<div style="display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;">';for(var x in d.preview.files){var H=d.preview.files[x],U=H.action==="create"?"\u{1F195}":"\u{1F4DD}";a+='<span style="padding: 4px 8px; background: var(--base); border-radius: 4px; font-size: 0.8rem;">'+U+" "+escapeHtml(H.description)+"</span>"}a+="</div>",d.preview.serviceCount&&(a+='<div style="font-size: 0.8rem; color: var(--accent); margin-bottom: 6px;">'+d.preview.serviceCount+" services</div>"),d.preview.themeCount&&(a+='<div style="font-size: 0.8rem; color: var(--accent); margin-bottom: 6px;">\u{1F3A8} '+d.preview.themeCount+" custom themes</div>"),d.preview.browserStateCount&&(a+='<div style="margin-top: 6px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;">Browser Preferences</div>',a+='<div style="font-size: 0.8rem; color: var(--accent);">\u{1F5A5}\uFE0F '+d.preview.browserStateCount+" saved settings (theme, weather, clock, widgets, etc.)</div>"),$.innerHTML=a,I.style.display="block"}else T.innerHTML="\u26A0\uFE0F Invalid backup file: "+escapeHtml(d.error),T.style.display="block",T.style.background="color-mix(in srgb, #f39c12 15%, transparent)",T.style.border="1px solid #f39c12",I.style.display="none"}catch(_){T.innerHTML="\u274CLine truncated
|
||||
|
||||
This will replace current configuration, credentials, and data. Containers will be restarted.`))try{var n=await secureFetch("/api/v1/apps/"+encodeURIComponent(e)+"/revert/"+encodeURIComponent(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restartContainers:!0})}),r=await n.json();r.success?(showNotification(e+" restored to "+s,"success"),setTimeout(function(){location.reload()},1500)):showNotification("Restore failed: "+(r.error||"Unknown"),"error")}catch(a){showNotification("Restore error: "+a.message,"error")}}})(),(function(){injectModal("stats-modal",`<div id="stats-modal" class="weather-modal">
|
||||
This will replace current configuration, credentials, and data. Containers will be restarted.`))try{var e=await secureFetch("/api/v1/apps/"+encodeURIComponent(t)+"/revert/"+encodeURIComponent(r),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restartContainers:!0})}),o=await e.json();o.success?(showNotification(t+" restored to "+r,"success"),setTimeout(function(){location.reload()},1500)):showNotification("Restore failed: "+(o.error||"Unknown"),"error")}catch(a){showNotification("Restore error: "+a.message,"error")}}})(),(function(){injectModal("stats-modal",`<div id="stats-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 750px; max-width: 950px;">
|
||||
<h3>\u{1F4CA} Resource Monitor</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1305,72 +1305,72 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<button id="stats-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("stats-modal"),E=document.getElementById("container-stats-btn"),j=document.getElementById("stats-cancel"),h=document.getElementById("stats-refresh-btn"),P=document.getElementById("stats-auto-refresh"),A=document.getElementById("stats-container"),D=document.getElementById("stats-aggregated-container"),R=document.getElementById("stats-alerts-container"),y=document.getElementById("stats-last-update");let $=null,k=null;function H(l){if(l===0||!l)return"0 B";const g=1024,p=["B","KB","MB","GB"],t=Math.floor(Math.log(l)/Math.log(g));return parseFloat((l/Math.pow(g,t)).toFixed(1))+" "+p[t]}function T(l){return l<30?"#2ecc71":l<70?"#f39c12":"#e74c3c"}function z(l){return l<50?"#2ecc71":l<80?"#f39c12":"#e74c3c"}async function C(){try{let l=null,g=!1;try{const e=await(await fetch("/api/v1/monitoring/stats")).json();e.success&&e.stats&&(l=e.stats,g=!0,k=e.stats)}catch{}if(!g){const e=await(await fetch("/api/v1/stats/containers")).json();if(e.success&&e.stats){l={};for(const s of e.stats)l[s.name]={name:s.name,current:{cpu:s.cpu,memory:{percent:s.memory.percent,usage:s.memory.used,limit:s.memory.limit,usageMB:Math.round(s.memory.used/1048576),limitMB:Math.round(s.memory.limit/1048576)},network:{rxBytes:s.network.rx,txBytes:s.network.tx,rxMB:(s.network.rx/1048576).toFixed(1),txMB:(s.network.tx/1048576).toFixed(1)},disk:{readMB:0,writeMB:0}},status:s.status};k=l}}if(!l||Object.keys(l).length===0){A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--muted);">No running containers found</div>';return}let p='<div style="display: flex; flex-direction: column; gap: 8px;">';for(const[t,e]of Object.entries(l)){const s=e.current||e,n=s.cpu?.percent||0,r=s.memory?.percent||0,a=T(n),i=z(r),c=s.memory?.usage||s.memory?.used||0,I=s.memory?.limit||0,N=s.network?.rxBytes||s.network?.rx||0,U=s.network?.txBytes||s.network?.tx||0,_=e.aggregated;p+=`
|
||||
</div>`);const b=document.getElementById("stats-modal"),h=document.getElementById("container-stats-btn"),j=document.getElementById("stats-cancel"),m=document.getElementById("stats-refresh-btn"),N=document.getElementById("stats-auto-refresh"),A=document.getElementById("stats-container"),D=document.getElementById("stats-aggregated-container"),R=document.getElementById("stats-alerts-container"),g=document.getElementById("stats-last-update");let L=null,k=null;function M(l){if(l===0||!l)return"0 B";const f=1024,c=["B","KB","MB","GB"],n=Math.floor(Math.log(l)/Math.log(f));return parseFloat((l/Math.pow(f,n)).toFixed(1))+" "+c[n]}function I(l){return l<30?"#2ecc71":l<70?"#f39c12":"#e74c3c"}function $(l){return l<50?"#2ecc71":l<80?"#f39c12":"#e74c3c"}async function E(){try{let l=null,f=!1;try{const t=await(await fetch("/api/v1/monitoring/stats")).json();t.success&&t.stats&&(l=t.stats,f=!0,k=t.stats)}catch{}if(!f){const t=await(await fetch("/api/v1/stats/containers")).json();if(t.success&&t.stats){l={};for(const r of t.stats)l[r.name]={name:r.name,current:{cpu:r.cpu,memory:{percent:r.memory.percent,usage:r.memory.used,limit:r.memory.limit,usageMB:Math.round(r.memory.used/1048576),limitMB:Math.round(r.memory.limit/1048576)},network:{rxBytes:r.network.rx,txBytes:r.network.tx,rxMB:(r.network.rx/1048576).toFixed(1),txMB:(r.network.tx/1048576).toFixed(1)},disk:{readMB:0,writeMB:0}},status:r.status};k=l}}if(!l||Object.keys(l).length===0){A.innerHTML='<div style="text-align: center; padding: 40px; color: var(--muted);">No running containers found</div>';return}let c='<div style="display: flex; flex-direction: column; gap: 8px;">';for(const[n,t]of Object.entries(l)){const r=t.current||t,e=r.cpu?.percent||0,o=r.memory?.percent||0,a=I(e),s=$(o),d=r.memory?.usage||r.memory?.used||0,x=r.memory?.limit||0,H=r.network?.rxBytes||r.network?.rx||0,U=r.network?.txBytes||r.network?.tx||0,_=t.aggregated;c+=`
|
||||
<div style="padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<div style="display: flex; align-items: center; gap: 12px; margin-bottom: 10px;">
|
||||
<span style="font-weight: 600; flex: 1;">${e.name||t}</span>
|
||||
<span style="font-weight: 600; flex: 1;">${t.name||n}</span>
|
||||
${_?`<span style="font-size: 0.65rem; color: var(--muted); padding: 2px 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 4px;">avg ${_.cpu?.avg?.toFixed(0)||0}% cpu</span>`:""}
|
||||
<span style="font-size: 0.75rem; color: var(--muted); background: var(--base); padding: 2px 8px; border-radius: 4px;">${e.status||"running"}</span>
|
||||
<span style="font-size: 0.75rem; color: var(--muted); background: var(--base); padding: 2px 8px; border-radius: 4px;">${t.status||"running"}</span>
|
||||
</div>
|
||||
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;">
|
||||
<div>
|
||||
<div style="font-size: 0.7rem; color: var(--muted); margin-bottom: 4px;">CPU</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="flex: 1; height: 6px; background: var(--base); border-radius: 3px; overflow: hidden;">
|
||||
<div style="height: 100%; width: ${Math.min(n,100)}%; background: ${a}; border-radius: 3px; transition: width 0.3s;"></div>
|
||||
<div style="height: 100%; width: ${Math.min(e,100)}%; background: ${a}; border-radius: 3px; transition: width 0.3s;"></div>
|
||||
</div>
|
||||
<span style="font-size: 0.8rem; font-weight: 500; color: ${a}; min-width: 45px; text-align: right;">${n.toFixed(1)}%</span>
|
||||
<span style="font-size: 0.8rem; font-weight: 500; color: ${a}; min-width: 45px; text-align: right;">${e.toFixed(1)}%</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 0.7rem; color: var(--muted); margin-bottom: 4px;">Memory</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<div style="flex: 1; height: 6px; background: var(--base); border-radius: 3px; overflow: hidden;">
|
||||
<div style="height: 100%; width: ${Math.min(r,100)}%; background: ${i}; border-radius: 3px; transition: width 0.3s;"></div>
|
||||
<div style="height: 100%; width: ${Math.min(o,100)}%; background: ${s}; border-radius: 3px; transition: width 0.3s;"></div>
|
||||
</div>
|
||||
<span style="font-size: 0.8rem; font-weight: 500; color: ${i}; min-width: 45px; text-align: right;">${r.toFixed(1)}%</span>
|
||||
<span style="font-size: 0.8rem; font-weight: 500; color: ${s}; min-width: 45px; text-align: right;">${o.toFixed(1)}%</span>
|
||||
</div>
|
||||
<div style="font-size: 0.65rem; color: var(--muted); margin-top: 2px;">${H(c)} / ${H(I)}</div>
|
||||
<div style="font-size: 0.65rem; color: var(--muted); margin-top: 2px;">${M(d)} / ${M(x)}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size: 0.7rem; color: var(--muted); margin-bottom: 4px;">Network</div>
|
||||
<div style="font-size: 0.8rem;">
|
||||
<span style="color: #3498db;">\u2193 ${H(N)}</span>
|
||||
<span style="color: #3498db;">\u2193 ${M(H)}</span>
|
||||
<span style="color: var(--muted); margin: 0 4px;">/</span>
|
||||
<span style="color: #e74c3c;">\u2191 ${H(U)}</span>
|
||||
<span style="color: #e74c3c;">\u2191 ${M(U)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`}p+="</div>",A.innerHTML=p,y.textContent="Updated: "+new Date().toLocaleTimeString()}catch(l){A.innerHTML=`<div style="text-align: center; padding: 40px; color: var(--bad-fg);">\u274C Failed to load stats: ${escapeHtml(l.message)}</div>`}}async function M(){if(!D)return;const l=k;if(!l||Object.keys(l).length===0){D.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4C8}</span>No monitoring data available. Open the Live Stats tab first.</div>';return}let g='<div style="display: flex; flex-direction: column; gap: 12px;">';for(const[p,t]of Object.entries(l)){const e=t.aggregated;e&&(g+=`<div style="padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<div style="font-weight: 600; margin-bottom: 10px;">${t.name||p}</div>
|
||||
</div>`}c+="</div>",A.innerHTML=c,g.textContent="Updated: "+new Date().toLocaleTimeString()}catch(l){A.innerHTML=`<div style="text-align: center; padding: 40px; color: var(--bad-fg);">\u274C Failed to load stats: ${escapeHtml(l.message)}</div>`}}async function T(){if(!D)return;const l=k;if(!l||Object.keys(l).length===0){D.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4C8}</span>No monitoring data available. Open the Live Stats tab first.</div>';return}let f='<div style="display: flex; flex-direction: column; gap: 12px;">';for(const[c,n]of Object.entries(l)){const t=n.aggregated;t&&(f+=`<div style="padding: 12px; background: var(--card-base); border-radius: 8px; border: 1px solid var(--border);">
|
||||
<div style="font-weight: 600; margin-bottom: 10px;">${n.name||c}</div>
|
||||
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;">
|
||||
<div class="stat-mini-card"><span class="stat-val">${e.cpu?.avg?.toFixed(1)||0}%</span><span class="stat-lbl">Avg CPU</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${e.cpu?.max?.toFixed(1)||0}%</span><span class="stat-lbl">Max CPU</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${e.memory?.avg?.toFixed(1)||0}%</span><span class="stat-lbl">Avg Mem</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${e.memory?.max?.toFixed(1)||0}%</span><span class="stat-lbl">Max Mem</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${t.cpu?.avg?.toFixed(1)||0}%</span><span class="stat-lbl">Avg CPU</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${t.cpu?.max?.toFixed(1)||0}%</span><span class="stat-lbl">Max CPU</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${t.memory?.avg?.toFixed(1)||0}%</span><span class="stat-lbl">Avg Mem</span></div>
|
||||
<div class="stat-mini-card"><span class="stat-val">${t.memory?.max?.toFixed(1)||0}%</span><span class="stat-lbl">Max Mem</span></div>
|
||||
</div>
|
||||
${e.dataPoints?`<div style="font-size: 0.7rem; color: var(--muted); margin-top: 6px;">${e.dataPoints} data points over ${e.timeRange||24}h</div>`:""}
|
||||
</div>`)}g+="</div>",D.innerHTML=g}async function b(){if(!R)return;R.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading alerts...</div>';const l=k;if(!l||Object.keys(l).length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F514}</span>No containers found. Open the Live Stats tab first.</div>';return}let g=!1;try{g=(await(await fetch("/api/v1/license/feature/resource-alerts")).json()).available}catch{g=!1}let p=[];try{const i=await(await fetch("/api/v1/monitoring/alerts?limit=50")).json();i.success&&(p=i.history||[])}catch{}let t={};try{const i=await(await fetch("/api/v1/monitoring/alerts/config")).json();i.success&&(t=i.configs||{})}catch{}const s=Object.entries(l).map(([a,i])=>{const c=t[a]||{cpuThreshold:80,memoryThreshold:90,diskIOThreshold:50,autoRestart:!1,enabled:!1};return`
|
||||
${t.dataPoints?`<div style="font-size: 0.7rem; color: var(--muted); margin-top: 6px;">${t.dataPoints} data points over ${t.timeRange||24}h</div>`:""}
|
||||
</div>`)}f+="</div>",D.innerHTML=f}async function P(){if(!R)return;R.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading alerts...</div>';const l=k;if(!l||Object.keys(l).length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F514}</span>No containers found. Open the Live Stats tab first.</div>';return}let f=!1;try{f=(await(await fetch("/api/v1/license/feature/resource-alerts")).json()).available}catch{f=!1}let c=[];try{const s=await(await fetch("/api/v1/monitoring/alerts?limit=50")).json();s.success&&(c=s.history||[])}catch{}let n={};try{const s=await(await fetch("/api/v1/monitoring/alerts/config")).json();s.success&&(n=s.configs||{})}catch{}const r=Object.entries(l).map(([a,s])=>{const d=n[a]||{cpuThreshold:80,memoryThreshold:90,diskIOThreshold:50,autoRestart:!1,enabled:!1};return`
|
||||
<tr data-container="${a}">
|
||||
<td style="font-weight: 600; padding: 8px;">${i.name||a}</td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-cpu" value="${c.cpuThreshold??80}" min="0" max="100" style="width: 60px; font-size: 0.8rem; padding: 2px 4px;" ${g?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-mem" value="${c.memoryThreshold??90}" min="0" max="100" style="width: 60px; font-size: 0.8rem; padding: 2px 4px;" ${g?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-disk" value="${c.diskIOThreshold??50}" min="0" max="1000" style="width: 70px; font-size: 0.8rem; padding: 2px 4px;" ${g?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="checkbox" class="alert-autorestart" ${c.autoRestart?"checked":""} ${g?"":"disabled"} /></td>
|
||||
<td style="font-weight: 600; padding: 8px;">${s.name||a}</td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-cpu" value="${d.cpuThreshold??80}" min="0" max="100" style="width: 60px; font-size: 0.8rem; padding: 2px 4px;" ${f?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-mem" value="${d.memoryThreshold??90}" min="0" max="100" style="width: 60px; font-size: 0.8rem; padding: 2px 4px;" ${f?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="number" class="alert-disk" value="${d.diskIOThreshold??50}" min="0" max="1000" style="width: 70px; font-size: 0.8rem; padding: 2px 4px;" ${f?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;"><input type="checkbox" class="alert-autorestart" ${d.autoRestart?"checked":""} ${f?"":"disabled"} /></td>
|
||||
<td style="padding: 4px 8px;">
|
||||
<button class="alert-test-btn btn-xs" data-container="${a}" data-name="${i.name||a}" style="padding: 2px 8px; font-size: 0.75rem; background: var(--card-base); border: 1px solid var(--border); border-radius: 4px; cursor: pointer;">Test</button>
|
||||
<button class="alert-test-btn btn-xs" data-container="${a}" data-name="${s.name||a}" style="padding: 2px 8px; font-size: 0.75rem; background: var(--card-base); border: 1px solid var(--border); border-radius: 4px; cursor: pointer;">Test</button>
|
||||
</td>
|
||||
</tr>
|
||||
`}).join(""),n=p.map(a=>{const i=new Date(a.timestamp).toLocaleString(),c=a.notified?"\u2713":"\u2014";return`
|
||||
`}).join(""),e=c.map(a=>{const s=new Date(a.timestamp).toLocaleString(),d=a.notified?"\u2713":"\u2014";return`
|
||||
<tr>
|
||||
<td style="padding: 6px 8px; font-size: 0.8rem; color: var(--muted);">${i}</td>
|
||||
<td style="padding: 6px 8px; font-size: 0.8rem; color: var(--muted);">${s}</td>
|
||||
<td style="padding: 6px 8px; font-weight: 500;">${a.containerName||a.containerId}</td>
|
||||
<td style="padding: 6px 8px; text-transform: capitalize;">${a.metric||a.type}</td>
|
||||
<td style="padding: 6px 8px;">${typeof a.value=="number"?a.value.toFixed(1):a.value}${a.metric==="disk"?" MB/s":"%"}</td>
|
||||
<td style="padding: 6px 8px; text-align: center;">${c}</td>
|
||||
<td style="padding: 6px 8px; text-align: center;">${d}</td>
|
||||
<td style="padding: 6px 8px; font-size: 0.75rem; color: ${a.autoRestartTriggered?"#f39c12":"var(--muted)"};">${a.autoRestartTriggered?"\u21BB":""}</td>
|
||||
</tr>
|
||||
`}).join(""),r=g?`
|
||||
`}).join(""),o=f?`
|
||||
<div style="margin-bottom: 20px;">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;">
|
||||
<h4 style="margin: 0; font-size: 0.9rem;">\u2699\uFE0F Alert Configuration</h4>
|
||||
@@ -1388,7 +1388,7 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<th style="padding: 6px 8px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${s}</tbody>
|
||||
<tbody>${r}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="margin-top: 12px; display: flex; justify-content: flex-end;">
|
||||
@@ -1402,10 +1402,10 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<button id="upgrade-for-alerts" style="margin-top: 8px; padding: 4px 12px; font-size: 0.75rem; background: #f1c40f; color: #000; border: none; border-radius: 4px; cursor: pointer; font-weight: 600;">Upgrade Now</button>
|
||||
</div>
|
||||
`;R.innerHTML=`
|
||||
${r}
|
||||
${o}
|
||||
<div>
|
||||
<h4 style="margin: 0 0 10px; font-size: 0.9rem;">\u{1F4CB} Recent Alerts</h4>
|
||||
${n?`
|
||||
${e?`
|
||||
<div style="overflow-x: auto;">
|
||||
<table style="width: 100%; border-collapse: collapse; font-size: 0.8rem;">
|
||||
<thead>
|
||||
@@ -1418,26 +1418,26 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<th style="padding: 6px 8px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${n}</tbody>
|
||||
<tbody>${e}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
`:'<div style="color: var(--muted); text-align: center; padding: 20px;">No alerts recorded yet.</div>'}
|
||||
</div>
|
||||
`,document.getElementById("save-all-alerts")?.addEventListener("click",async()=>{const a={};document.querySelectorAll("#stats-alerts-container tr[data-container]").forEach(i=>{const c=i.dataset.container;a[c]={cpuThreshold:parseInt(i.querySelector(".alert-cpu")?.value)||80,memoryThreshold:parseInt(i.querySelector(".alert-mem")?.value)||90,diskIOThreshold:parseInt(i.querySelector(".alert-disk")?.value)||50,autoRestart:!!i.querySelector(".alert-autorestart")?.checked,enabled:!0}});try{const c=await(await secureFetch("/api/v1/monitoring/alerts/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({configs:a})})).json(),I=document.getElementById("save-all-alerts");I.textContent=c.success?"\u2705 Saved":"\u274C Failed",setTimeout(()=>{I.textContent="Save All"},2e3)}catch{const c=document.getElementById("save-all-alerts");c.textContent="\u274C Error",setTimeout(()=>{c.textContent="Save All"},2e3)}}),document.getElementById("go-to-notifications")?.addEventListener("click",a=>{a.preventDefault(),x.classList.remove("show"),v(),document.getElementById("manage-notifications")?.click()}),document.querySelectorAll(".alert-test-btn").forEach(a=>{a.addEventListener("click",async()=>{const i=a.textContent;a.textContent="...";try{await secureFetch(`/api/v1/monitoring/alerts/${a.dataset.container}/test`,{method:"POST"}),a.textContent="\u2705",showNotification("Test alert sent for "+a.dataset.name,"success",3e3)}catch{a.textContent="\u274C"}setTimeout(()=>{a.textContent=i},2e3)})}),document.getElementById("upgrade-for-alerts")?.addEventListener("click",()=>{x.classList.remove("show"),v(),typeof openLicenseModal=="function"&&openLicenseModal()})}function d(){$&&clearInterval($),P?.checked&&($=setInterval(C,DC.POLL.STATS))}function v(){$&&(clearInterval($),$=null)}E?.addEventListener("click",()=>{x.classList.add("show"),C(),d()}),j?.addEventListener("click",()=>{x.classList.remove("show"),v()}),x?.addEventListener("click",l=>{l.target===x&&(x.classList.remove("show"),v())}),h?.addEventListener("click",C),P?.addEventListener("change",()=>{P.checked?d():v()}),document.querySelector('[data-panel="stats-aggregated"]')?.addEventListener("click",M),document.querySelector('[data-panel="stats-alerts"]')?.addEventListener("click",b);const S=document.getElementById("stats-history-container"),O=document.getElementById("stats-history-container-area"),m=document.querySelectorAll(".stats-range-btn");let f="1h";function B(l){switch(l){case"1h":return 3600*1e3;case"24h":return 1440*60*1e3;case"7d":return 10080*60*1e3;case"30d":return 720*60*60*1e3;case"1y":return 365*24*60*60*1e3;default:return 3600*1e3}}function w(l){return l==="raw"?"live (10s samples)":l==="hourly"?"hourly average":l==="daily"?"daily average":l}function L(l,g,p,t,e){if(!l||l.length===0)return`<div style="text-align: center; color: var(--muted); padding: 20px;">No data for ${escapeHtml(t)}</div>`;const s=l.map(g).filter(q=>q!=null);if(s.length===0)return`<div style="text-align: center; color: var(--muted); padding: 20px;">No data for ${escapeHtml(t)}</div>`;const n=Math.max(...s,1),r=Math.min(...s,0),a=n-r||1,i=600,c=80,I=4,N=(i-I*2)/Math.max(s.length-1,1),U=s.map((q,J)=>{const X=I+J*N,Q=c-I-(q-r)/a*(c-I*2);return`${X.toFixed(1)},${Q.toFixed(1)}`}).join(" "),_=s[s.length-1],F=s.reduce((q,J)=>q+J,0)/s.length;return`
|
||||
`,document.getElementById("save-all-alerts")?.addEventListener("click",async()=>{const a={};document.querySelectorAll("#stats-alerts-container tr[data-container]").forEach(s=>{const d=s.dataset.container;a[d]={cpuThreshold:parseInt(s.querySelector(".alert-cpu")?.value)||80,memoryThreshold:parseInt(s.querySelector(".alert-mem")?.value)||90,diskIOThreshold:parseInt(s.querySelector(".alert-disk")?.value)||50,autoRestart:!!s.querySelector(".alert-autorestart")?.checked,enabled:!0}});try{const d=await(await secureFetch("/api/v1/monitoring/alerts/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({configs:a})})).json(),x=document.getElementById("save-all-alerts");x.textContent=d.success?"\u2705 Saved":"\u274C Failed",setTimeout(()=>{x.textContent="Save All"},2e3)}catch{const d=document.getElementById("save-all-alerts");d.textContent="\u274C Error",setTimeout(()=>{d.textContent="Save All"},2e3)}}),document.getElementById("go-to-notifications")?.addEventListener("click",a=>{a.preventDefault(),b.classList.remove("show"),B(),document.getElementById("manage-notifications")?.click()}),document.querySelectorAll(".alert-test-btn").forEach(a=>{a.addEventListener("click",async()=>{const s=a.textContent;a.textContent="...";try{await secureFetch(`/api/v1/monitoring/alerts/${a.dataset.container}/test`,{method:"POST"}),a.textContent="\u2705",showNotification("Test alert sent for "+a.dataset.name,"success",3e3)}catch{a.textContent="\u274C"}setTimeout(()=>{a.textContent=s},2e3)})}),document.getElementById("upgrade-for-alerts")?.addEventListener("click",()=>{b.classList.remove("show"),B(),typeof openLicenseModal=="function"&&openLicenseModal()})}function v(){L&&clearInterval(L),N?.checked&&(L=setInterval(E,DC.POLL.STATS))}function B(){L&&(clearInterval(L),L=null)}h?.addEventListener("click",()=>{b.classList.add("show"),E(),v()}),j?.addEventListener("click",()=>{b.classList.remove("show"),B()}),b?.addEventListener("click",l=>{l.target===b&&(b.classList.remove("show"),B())}),m?.addEventListener("click",E),N?.addEventListener("change",()=>{N.checked?v():B()}),document.querySelector('[data-panel="stats-aggregated"]')?.addEventListener("click",T),document.querySelector('[data-panel="stats-alerts"]')?.addEventListener("click",P);const z=document.getElementById("stats-history-container"),O=document.getElementById("stats-history-container-area"),u=document.querySelectorAll(".stats-range-btn");let y="1h";function C(l){switch(l){case"1h":return 3600*1e3;case"24h":return 1440*60*1e3;case"7d":return 10080*60*1e3;case"30d":return 720*60*60*1e3;case"1y":return 365*24*60*60*1e3;default:return 3600*1e3}}function w(l){return l==="raw"?"live (10s samples)":l==="hourly"?"hourly average":l==="daily"?"daily average":l}function S(l,f,c,n,t){if(!l||l.length===0)return`<div style="text-align: center; color: var(--muted); padding: 20px;">No data for ${escapeHtml(n)}</div>`;const r=l.map(f).filter(q=>q!=null);if(r.length===0)return`<div style="text-align: center; color: var(--muted); padding: 20px;">No data for ${escapeHtml(n)}</div>`;const e=Math.max(...r,1),o=Math.min(...r,0),a=e-o||1,s=600,d=80,x=4,H=(s-x*2)/Math.max(r.length-1,1),U=r.map((q,J)=>{const V=x+J*H,X=d-x-(q-o)/a*(d-x*2);return`${V.toFixed(1)},${X.toFixed(1)}`}).join(" "),_=r[r.length-1],F=r.reduce((q,J)=>q+J,0)/r.length;return`
|
||||
<div style="margin-bottom: 14px;">
|
||||
<div style="display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px;">
|
||||
<span style="font-weight: 600; font-size: 0.9rem;">${escapeHtml(t)}</span>
|
||||
<span style="font-size: 0.75rem; color: var(--muted);">last ${_.toFixed(1)}${e} \xB7 avg ${F.toFixed(1)}${e} \xB7 max ${n.toFixed(1)}${e}</span>
|
||||
<span style="font-weight: 600; font-size: 0.9rem;">${escapeHtml(n)}</span>
|
||||
<span style="font-size: 0.75rem; color: var(--muted);">last ${_.toFixed(1)}${t} \xB7 avg ${F.toFixed(1)}${t} \xB7 max ${e.toFixed(1)}${t}</span>
|
||||
</div>
|
||||
<svg viewBox="0 0 ${i} ${c}" preserveAspectRatio="none" style="width: 100%; height: ${c}px; background: var(--base); border-radius: 4px;">
|
||||
<polyline fill="none" stroke="${p}" stroke-width="1.5" points="${U}" />
|
||||
<svg viewBox="0 0 ${s} ${d}" preserveAspectRatio="none" style="width: 100%; height: ${d}px; background: var(--base); border-radius: 4px;">
|
||||
<polyline fill="none" stroke="${c}" stroke-width="1.5" points="${U}" />
|
||||
</svg>
|
||||
</div>
|
||||
`}function o(){if(!S)return;const l=k||{},g=S.value,p=Object.entries(l);if(p.length===0){S.innerHTML='<option value="">No containers</option>';return}S.innerHTML=p.map(([t,e])=>`<option value="${escapeHtml(t)}">${escapeHtml(e.name||t)}</option>`).join(""),g&&l[g]&&(S.value=g)}async function u(){if(!O||!S)return;const l=S.value;if(!l){O.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4CA}</span>No container selected.</div>';return}const g=Date.now(),p=g-B(f);O.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading history...</div>';try{const e=await(await fetch(`/api/v1/monitoring/history/${encodeURIComponent(l)}?startTime=${p}&endTime=${g}`)).json();if(!e.success)throw new Error(e.error||"Failed to load history");const s=e.samples||[],n=e.tier||"raw";if(s.length===0){O.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4CA}</span>No data for the last ${f}. Tier: ${w(n)}.</div>`;return}const r=n==="raw",a=r?U=>U.cpu?.percent:U=>U.cpu?.avg,i=r?U=>U.memory?.percent:U=>U.memory?.avgPercent,c=r?U=>U.network?.rxMB||0:U=>U.network?.rxMB||0,I=r?U=>U.network?.txMB||0:U=>U.network?.txMB||0;let N=`
|
||||
`}function i(){if(!z)return;const l=k||{},f=z.value,c=Object.entries(l);if(c.length===0){z.innerHTML='<option value="">No containers</option>';return}z.innerHTML=c.map(([n,t])=>`<option value="${escapeHtml(n)}">${escapeHtml(t.name||n)}</option>`).join(""),f&&l[f]&&(z.value=f)}async function p(){if(!O||!z)return;const l=z.value;if(!l){O.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4CA}</span>No container selected.</div>';return}const f=Date.now(),c=f-C(y);O.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading history...</div>';try{const t=await(await fetch(`/api/v1/monitoring/history/${encodeURIComponent(l)}?startTime=${c}&endTime=${f}`)).json();if(!t.success)throw new Error(t.error||"Failed to load history");const r=t.samples||[],e=t.tier||"raw";if(r.length===0){O.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4CA}</span>No data for the last ${y}. Tier: ${w(e)}.</div>`;return}const o=e==="raw",a=o?U=>U.cpu?.percent:U=>U.cpu?.avg,s=o?U=>U.memory?.percent:U=>U.memory?.avgPercent,d=o?U=>U.network?.rxMB||0:U=>U.network?.rxMB||0,x=o?U=>U.network?.txMB||0:U=>U.network?.txMB||0;let H=`
|
||||
<div style="font-size: 0.75rem; color: var(--muted); margin-bottom: 8px;">
|
||||
${s.length} samples \xB7 ${escapeHtml(w(n))} \xB7 ${new Date(p).toLocaleString()} \u2192 ${new Date(g).toLocaleString()}
|
||||
${r.length} samples \xB7 ${escapeHtml(w(e))} \xB7 ${new Date(c).toLocaleString()} \u2192 ${new Date(f).toLocaleString()}
|
||||
</div>
|
||||
`;N+=L(s,a,"#2ecc71","CPU","%"),N+=L(s,i,"#3498db","Memory","%"),N+=L(s,c,"#9b59b6","Network RX"," MB"),N+=L(s,I,"#e67e22","Network TX"," MB"),O.innerHTML=N}catch(t){O.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u26A0\uFE0F</span>Failed to load history: ${escapeHtml(t.message)}</div>`}}m.forEach(l=>{l.addEventListener("click",()=>{m.forEach(g=>g.classList.remove("active")),l.classList.add("active"),f=l.dataset.range,u()})}),S?.addEventListener("change",u),document.querySelector('[data-panel="stats-history"]')?.addEventListener("click",()=>{o(),u()})})(),(function(){injectModal("health-modal",`<div id="health-modal" class="weather-modal">
|
||||
`;H+=S(r,a,"#2ecc71","CPU","%"),H+=S(r,s,"#3498db","Memory","%"),H+=S(r,d,"#9b59b6","Network RX"," MB"),H+=S(r,x,"#e67e22","Network TX"," MB"),O.innerHTML=H}catch(n){O.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u26A0\uFE0F</span>Failed to load history: ${escapeHtml(n.message)}</div>`}}u.forEach(l=>{l.addEventListener("click",()=>{u.forEach(f=>f.classList.remove("active")),l.classList.add("active"),y=l.dataset.range,p()})}),z?.addEventListener("change",p),document.querySelector('[data-panel="stats-history"]')?.addEventListener("click",()=>{i(),p()})})(),(function(){injectModal("health-modal",`<div id="health-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 800px; max-width: 1000px;">
|
||||
<h3>\u{1F3E5} Health Check Dashboard</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1561,7 +1561,7 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<button id="health-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("health-modal"),E=document.getElementById("health-check-btn"),j=document.getElementById("health-cancel"),h=document.getElementById("health-refresh-btn"),P=document.getElementById("health-status-container"),A=document.getElementById("health-incidents-container"),D=document.getElementById("health-config-container"),R=document.getElementById("health-last-update"),y=document.getElementById("health-add-btn"),$=document.getElementById("health-config-form"),k=document.getElementById("health-form-title"),H=document.getElementById("health-form-cancel"),T=document.getElementById("health-form-save"),z="dashcaddy-health-settings",C={retentionDays:30,pollingInterval:60,statsPollingInterval:30,maxEntriesPerService:500,diskUsageThreshold:80},M=document.getElementById("health-global-save"),b=document.getElementById("health-global-reset"),d=document.getElementById("health-global-status"),v=document.getElementById("health-setting-retention"),S=document.getElementById("health-setting-interval"),O=document.getElementById("health-setting-stats-interval"),m=document.getElementById("health-setting-max-entries"),f=document.getElementById("health-setting-disk-threshold");function B(){try{const r=safeGet(z),a=r?JSON.parse(r):{};return Object.assign({},C,a)}catch{return Object.assign({},C)}}function w(){const r=B();v&&(v.value=r.retentionDays),S&&(S.value=r.pollingInterval),O&&(O.value=r.statsPollingInterval),m&&(m.value=r.maxEntriesPerService),f&&(f.value=r.diskUsageThreshold)}function L(){const r={retentionDays:Math.max(1,Math.min(3650,parseInt(v?.value)||C.retentionDays)),pollingInterval:Math.max(5,Math.min(3600,parseInt(S?.value)||C.pollingInterval)),statsPollingInterval:Math.max(5,Math.min(3600,parseInt(O?.value)||C.statsPollingInterval)),maxEntriesPerService:Math.max(10,Math.min(1e5,parseInt(m?.value)||C.maxEntriesPerService)),diskUsageThreshold:Math.max(50,Math.min(99,parseInt(f?.value)||C.diskUsageThreshold))};try{safeSet(z,JSON.stringify(r)),w(),d&&(d.textContent="Saved \u2713",d.style.color="var(--ok-fg)",setTimeout(()=>{d&&(d.textContent="")},2500)),typeof showNotification=="function"&&showNotification("Global health settings saved","success")}catch(a){d&&(d.textContent="Save failed",d.style.color="var(--bad-fg)"),typeof showNotification=="function"&&showNotification("Failed to save settings: "+a.message,"error")}}function o(){try{safeSet(z,JSON.stringify(C))}catch{}w(),d&&(d.textContent="Reset to defaults \u2713",d.style.color="var(--ok-fg)",setTimeout(()=>{d&&(d.textContent="")},2500))}w(),M?.addEventListener("click",L),b?.addEventListener("click",o);let u=null;function l(r){return r>=99.9?"var(--ok-fg)":r>=95?"#f39c12":"var(--bad-fg)"}function g(r){const a={critical:"var(--bad-fg)",high:"#ff6b6b",medium:"#f39c12",low:"var(--muted)"};return`<span style="padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; background: ${a[r]||"var(--muted)"}20; color: ${a[r]||"var(--muted)"};">${r}</span>`}async function p(){try{const a=await(await fetch("/api/v1/health-checks/status")).json();if(!a.success||!a.status||Object.keys(a.status).length===0){P.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F3E5}</span>No health checks configured. Go to the Configure tab to add services.</div>';return}const i=Object.values(a.status);let c='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';c+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted); text-align: left;">',c+='<th style="padding: 8px;">Service</th><th style="padding: 8px;">Status</th>',c+='<th style="padding: 8px;">Uptime 24h</th><th style="padding: 8px;">Uptime 7d</th>',c+='<th style="padding: 8px;">Avg Response</th><th style="padding: 8px;">Last Check</th></tr>';for(const I of i){const N=I.status==="up",U=N?"var(--dot-ok)":"var(--dot-bad)",_=I.uptime?.["24h"]??"-",F=I.uptime?.["7d"]??"-",q=I.avgResponseTime!=null?Math.round(I.avgResponseTime)+"ms":"-",J=I.timestamp?timeAgo(I.timestamp):"-";c+=`<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" data-health-id="${escapeHtml(I.serviceId)}">`,c+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(I.name||I.serviceId)}</td>`,c+=`<td style="padding: 8px;"><span style="display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: ${U}; margin-right: 6px;"></span>${N?"Up":"Down"}</td>`,c+=`<td style="padding: 8px; color: ${typeof _=="number"?l(_):"var(--muted)"};">${typeof _=="number"?_.toFixed(1)+"%":_}</td>`,c+=`<td style="padding: 8px; color: ${typeof F=="number"?l(F):"var(--muted)"};">${typeof F=="number"?F.toFixed(1)+"%":F}</td>`,c+=`<td style="padding: 8px;">${q}</td>`,c+=`<td style="padding: 8px; color: var(--muted);">${J}</td>`,c+="</tr>",c+=`<tr id="health-detail-${escapeHtml(I.serviceId)}" style="display: none;"><td colspan="6" style="padding: 12px; background: var(--bg); border-bottom: 1px solid var(--border);"><div class="panel-empty"><span class="brand-spinner"></span> Loading Line truncated
|
||||
</div>`);const b=document.getElementById("health-modal"),h=document.getElementById("health-check-btn"),j=document.getElementById("health-cancel"),m=document.getElementById("health-refresh-btn"),N=document.getElementById("health-status-container"),A=document.getElementById("health-incidents-container"),D=document.getElementById("health-config-container"),R=document.getElementById("health-last-update"),g=document.getElementById("health-add-btn"),L=document.getElementById("health-config-form"),k=document.getElementById("health-form-title"),M=document.getElementById("health-form-cancel"),I=document.getElementById("health-form-save"),$="dashcaddy-health-settings",E={retentionDays:30,pollingInterval:60,statsPollingInterval:30,maxEntriesPerService:500,diskUsageThreshold:80},T=document.getElementById("health-global-save"),P=document.getElementById("health-global-reset"),v=document.getElementById("health-global-status"),B=document.getElementById("health-setting-retention"),z=document.getElementById("health-setting-interval"),O=document.getElementById("health-setting-stats-interval"),u=document.getElementById("health-setting-max-entries"),y=document.getElementById("health-setting-disk-threshold");function C(){try{const o=safeGet($),a=o?JSON.parse(o):{};return Object.assign({},E,a)}catch{return Object.assign({},E)}}function w(){const o=C();B&&(B.value=o.retentionDays),z&&(z.value=o.pollingInterval),O&&(O.value=o.statsPollingInterval),u&&(u.value=o.maxEntriesPerService),y&&(y.value=o.diskUsageThreshold)}function S(){const o={retentionDays:Math.max(1,Math.min(3650,parseInt(B?.value)||E.retentionDays)),pollingInterval:Math.max(5,Math.min(3600,parseInt(z?.value)||E.pollingInterval)),statsPollingInterval:Math.max(5,Math.min(3600,parseInt(O?.value)||E.statsPollingInterval)),maxEntriesPerService:Math.max(10,Math.min(1e5,parseInt(u?.value)||E.maxEntriesPerService)),diskUsageThreshold:Math.max(50,Math.min(99,parseInt(y?.value)||E.diskUsageThreshold))};try{safeSet($,JSON.stringify(o)),w(),v&&(v.textContent="Saved \u2713",v.style.color="var(--ok-fg)",setTimeout(()=>{v&&(v.textContent="")},2500)),typeof showNotification=="function"&&showNotification("Global health settings saved","success")}catch(a){v&&(v.textContent="Save failed",v.style.color="var(--bad-fg)"),typeof showNotification=="function"&&showNotification("Failed to save settings: "+a.message,"error")}}function i(){try{safeSet($,JSON.stringify(E))}catch{}w(),v&&(v.textContent="Reset to defaults \u2713",v.style.color="var(--ok-fg)",setTimeout(()=>{v&&(v.textContent="")},2500))}w(),T?.addEventListener("click",S),P?.addEventListener("click",i);let p=null;function l(o){return o>=99.9?"var(--ok-fg)":o>=95?"#f39c12":"var(--bad-fg)"}function f(o){const a={critical:"var(--bad-fg)",high:"#ff6b6b",medium:"#f39c12",low:"var(--muted)"};return`<span style="padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; background: ${a[o]||"var(--muted)"}20; color: ${a[o]||"var(--muted)"};">${o}</span>`}async function c(){try{const a=await(await fetch("/api/v1/health-checks/status")).json();if(!a.success||!a.status||Object.keys(a.status).length===0){N.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F3E5}</span>No health checks configured. Go to the Configure tab to add services.</div>';return}const s=Object.values(a.status);let d='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';d+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted); text-align: left;">',d+='<th style="padding: 8px;">Service</th><th style="padding: 8px;">Status</th>',d+='<th style="padding: 8px;">Uptime 24h</th><th style="padding: 8px;">Uptime 7d</th>',d+='<th style="padding: 8px;">Avg Response</th><th style="padding: 8px;">Last Check</th></tr>';for(const x of s){const H=x.status==="up",U=H?"var(--dot-ok)":"var(--dot-bad)",_=x.uptime?.["24h"]??"-",F=x.uptime?.["7d"]??"-",q=x.avgResponseTime!=null?Math.round(x.avgResponseTime)+"ms":"-",J=x.timestamp?timeAgo(x.timestamp):"-";d+=`<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" data-health-id="${escapeHtml(x.serviceId)}">`,d+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(x.name||x.serviceId)}</td>`,d+=`<td style="padding: 8px;"><span style="display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: ${U}; margin-right: 6px;"></span>${H?"Up":"Down"}</td>`,d+=`<td style="padding: 8px; color: ${typeof _=="number"?l(_):"var(--muted)"};">${typeof _=="number"?_.toFixed(1)+"%":_}</td>`,d+=`<td style="padding: 8px; color: ${typeof F=="number"?l(F):"var(--muted)"};">${typeof F=="number"?F.toFixed(1)+"%":F}</td>`,d+=`<td style="padding: 8px;">${q}</td>`,d+=`<td style="padding: 8px; color: var(--muted);">${J}</td>`,d+="</tr>",d+=`<tr id="health-detail-${escapeHtml(x.serviceId)}" style="display: none;"><td colspan="6" style="padding: 12px; background: var(--bg); border-bottom: 1px solid var(--border);"><div class="panel-empty"><span class="brand-spinner"></span> Loading Line truncated
|
||||
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; font-size: 0.82rem;">
|
||||
<div><span style="color: var(--muted);">Total Checks</span><br><strong>${q.totalChecks||0}</strong></div>
|
||||
<div><span style="color: var(--muted);">Uptime</span><br><strong style="color: ${l(q.uptime||0)};">${(q.uptime||0).toFixed(2)}%</strong></div>
|
||||
@@ -1571,14 +1571,14 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<div><span style="color: var(--muted);">Max Response</span><br><strong>${Math.round(J.max||0)}ms</strong></div>
|
||||
<div><span style="color: var(--muted);">Up Checks</span><br><strong style="color: var(--ok-fg);">${q.upChecks||0}</strong></div>
|
||||
<div><span style="color: var(--muted);">Down Checks</span><br><strong style="color: var(--bad-fg);">${q.downChecks||0}</strong></div>
|
||||
</div>`}else U.querySelector("td").innerHTML='<div class="panel-empty">No detailed stats available for this period.</div>'}catch(_){U.querySelector("td").innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(_.message)}</div>`}}})})}catch(r){P.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed to load health status: ${escapeHtml(r.message)}</div>`}}async function t(){try{const[r,a]=await Promise.all([fetch("/api/v1/health-checks/incidents"),fetch("/api/v1/health-checks/incidents/history?limit=50")]),i=await r.json(),c=await a.json();let I="";const N=i.success&&i.incidents?i.incidents:[];if(N.length>0){I+='<div style="margin-bottom: 16px;"><h4 style="color: var(--bad-fg); margin: 0 0 8px;">Open Incidents ('+N.length+")</h4>";for(const _ of N)I+=`<div style="padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--bad-fg)30; border-radius: 8px; background: var(--bad-bg);">
|
||||
</div>`}else U.querySelector("td").innerHTML='<div class="panel-empty">No detailed stats available for this period.</div>'}catch(_){U.querySelector("td").innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(_.message)}</div>`}}})})}catch(o){N.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed to load health status: ${escapeHtml(o.message)}</div>`}}async function n(){try{const[o,a]=await Promise.all([fetch("/api/v1/health-checks/incidents"),fetch("/api/v1/health-checks/incidents/history?limit=50")]),s=await o.json(),d=await a.json();let x="";const H=s.success&&s.incidents?s.incidents:[];if(H.length>0){x+='<div style="margin-bottom: 16px;"><h4 style="color: var(--bad-fg); margin: 0 0 8px;">Open Incidents ('+H.length+")</h4>";for(const _ of H)x+=`<div style="padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--bad-fg)30; border-radius: 8px; background: var(--bad-bg);">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<span style="font-weight: 500;">${escapeHtml(_.serviceId)}</span>
|
||||
<span>${g(_.severity)}</span>
|
||||
<span>${f(_.severity)}</span>
|
||||
</div>
|
||||
<div style="font-size: 0.82rem; color: var(--muted); margin-top: 4px;">${escapeHtml(_.message)}</div>
|
||||
<div style="font-size: 0.75rem; color: var(--muted); margin-top: 4px;">Started ${timeAgo(_.createdAt)} \xB7 ${_.occurrences||1} occurrence(s)</div>
|
||||
</div>`;I+="</div>"}else I+='<div style="padding: 12px; margin-bottom: 16px; border: 1px solid var(--ok-fg)30; border-radius: 8px; background: var(--ok-bg); text-align: center; color: var(--ok-fg); font-size: 0.9rem;">All services operational \u2014 no open incidents</div>';const U=c.success&&c.history?c.history:[];if(U.length>0){I+='<h4 style="margin: 0 0 8px; color: var(--muted);">Incident History</h4>',I+='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',I+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Service</th><th style="padding: 6px; text-align: left;">Type</th><th style="padding: 6px; text-align: left;">Severity</th><th style="padding: 6px; text-align: left;">Status</th><th style="padding: 6px; text-align: left;">Duration</th><th style="padding: 6px; text-align: left;">When</th></tr>';for(const _ of U){const F=_.status==="resolved",q=F&&_.duration?_.duration<6e4?Math.round(_.duration/1e3)+"s":Math.round(_.duration/6e4)+"m":"-";I+='<tr style="border-bottom: 1px solid var(--border);">',I+=`<td style="padding: 6px;">${escapeHtml(_.serviceId)}</td>`,I+=`<td style="padding: 6px;">${escapeHtml(_.type)}</td>`,I+=`<td style="padding: 6px;">${g(_.severity)}</td>`,I+=`<td style="padding: 6px;"><span style="color: ${F?"var(--ok-fg)":"var(--bad-fg)"};">${_.status}</span></td>`,I+=`<td style="padding: 6px;">${q}</td>`,I+=`<td style="padding: 6px; color: var(--muted);">${timeAgo(_.createdAt)}</td>`,I+="</tr>"}I+="</table>"}A.innerHTML=I||'<div class="panel-empty"><span class="empty-icon">\u{1F6A8}</span>No incidents recorded yet.</div>'}catch(r){A.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(r.message)}</div>`}}async function e(){try{const a=await(await fetch("/api/v1/health-checks/status")).json(),i=a.success&&a.status?Object.values(a.status):[];if(i.length===0){D.innerHTML='<div class="panel-empty"><span class="empty-icon">\u2699\uFE0F</span>No health checks configured yet. Click "Add Health Check" below.</div>';return}let c='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';c+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 8px; text-align: left;">Service</th><th style="padding: 8px; text-align: left;">Status</th><th style="padding: 8px; text-align: left;">SLA Target</th><th style="padding: 8px; text-align: right;">Actions</th></tr>';for(const I of i){const N=I.status==="up";c+='<tr style="border-bottom: 1px solid var(--border);">',c+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(I.name||I.serviceId)}</td>`,c+=`<td style="padding: 8px; color: ${N?"var(--ok-fg)":"var(--bad-fg)"};">${N?"Up":"Down"}</td>`,c+=`<td style="padding: 8px;">${I.sla?.target?I.sla.target+"%":"-"}</td>`,c+='<td style="padding: 8px; text-align: right;">',c+=`<button onclick="document.dispatchEvent(new CustomEvent('health-edit', {detail:'${escapeHtml(I.serviceId)}'}))" style="padding: 4px 10px; font-size: 0.78rem; margin-right: 4px;">Edit</button>`,c+=`<button onclick="document.dispatchEvent(new CustomEvent('health-delete', {detail:'${escapeHtml(I.serviceId)}'}))" style="padding: 4px 10px; font-size: 0.78rem; color: var(--bad-fg); border-color: var(--bad-fg);">Delete</button>`,c+="</td></tr>"}c+="</table>",D.innerHTML=c}catch(r){D.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(r.message)}</div>`}}function s(r,a,i,c,I,N,U){u=r||null,k.textContent=r?"Edit Health Check":"Add Health Check",document.getElementById("health-form-id").value=r||"",document.getElementById("health-form-id").disabled=!!r,document.getElementById("health-form-name").value=a||"",document.getElementById("health-form-url").value=i||"",document.getElementById("health-form-timeout").value=c||1e4,document.getElementById("health-form-codes").value=I||"200",document.getElementById("health-form-sla").value=N||99.9,document.getElementById("health-form-slow").value=U||5e3,$.style.display="",y.style.display="none"}function n(){$.style.display="none",y.style.display="",u=null}y?.addEventListener("click",()=>s("","","",1e4,"200",99.9,5e3)),H?.addEventListener("click",n),T?.addEventListener("click",async()=>{const r=u||document.getElementById("health-form-id").value.trim();if(!r)return showNotification("Service ID is required","warning");const a=document.getElementById("health-form-url").value.trim();if(!a)return showNotification("URL is required","warning");const i=document.getElementById("health-form-codes").value.split(",").map(I=>parseInt(I.trim())).filter(Boolean),c={name:document.getElementById("health-form-name").value.trim()||r,url:a,timeout:parseInt(document.getElementById("health-form-timeout").value)||1e4,expectedStatusCodes:i.length?i:[200],sla:{target:parseFloat(document.getElementById("health-form-sla").value)||99.9},slowResponseThreshold:parseInt(document.getElementById("health-form-slow").value)|Line truncated
|
||||
</div>`;x+="</div>"}else x+='<div style="padding: 12px; margin-bottom: 16px; border: 1px solid var(--ok-fg)30; border-radius: 8px; background: var(--ok-bg); text-align: center; color: var(--ok-fg); font-size: 0.9rem;">All services operational \u2014 no open incidents</div>';const U=d.success&&d.history?d.history:[];if(U.length>0){x+='<h4 style="margin: 0 0 8px; color: var(--muted);">Incident History</h4>',x+='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',x+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Service</th><th style="padding: 6px; text-align: left;">Type</th><th style="padding: 6px; text-align: left;">Severity</th><th style="padding: 6px; text-align: left;">Status</th><th style="padding: 6px; text-align: left;">Duration</th><th style="padding: 6px; text-align: left;">When</th></tr>';for(const _ of U){const F=_.status==="resolved",q=F&&_.duration?_.duration<6e4?Math.round(_.duration/1e3)+"s":Math.round(_.duration/6e4)+"m":"-";x+='<tr style="border-bottom: 1px solid var(--border);">',x+=`<td style="padding: 6px;">${escapeHtml(_.serviceId)}</td>`,x+=`<td style="padding: 6px;">${escapeHtml(_.type)}</td>`,x+=`<td style="padding: 6px;">${f(_.severity)}</td>`,x+=`<td style="padding: 6px;"><span style="color: ${F?"var(--ok-fg)":"var(--bad-fg)"};">${_.status}</span></td>`,x+=`<td style="padding: 6px;">${q}</td>`,x+=`<td style="padding: 6px; color: var(--muted);">${timeAgo(_.createdAt)}</td>`,x+="</tr>"}x+="</table>"}A.innerHTML=x||'<div class="panel-empty"><span class="empty-icon">\u{1F6A8}</span>No incidents recorded yet.</div>'}catch(o){A.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(o.message)}</div>`}}async function t(){try{const a=await(await fetch("/api/v1/health-checks/status")).json(),s=a.success&&a.status?Object.values(a.status):[];if(s.length===0){D.innerHTML='<div class="panel-empty"><span class="empty-icon">\u2699\uFE0F</span>No health checks configured yet. Click "Add Health Check" below.</div>';return}let d='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';d+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 8px; text-align: left;">Service</th><th style="padding: 8px; text-align: left;">Status</th><th style="padding: 8px; text-align: left;">SLA Target</th><th style="padding: 8px; text-align: right;">Actions</th></tr>';for(const x of s){const H=x.status==="up";d+='<tr style="border-bottom: 1px solid var(--border);">',d+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(x.name||x.serviceId)}</td>`,d+=`<td style="padding: 8px; color: ${H?"var(--ok-fg)":"var(--bad-fg)"};">${H?"Up":"Down"}</td>`,d+=`<td style="padding: 8px;">${x.sla?.target?x.sla.target+"%":"-"}</td>`,d+='<td style="padding: 8px; text-align: right;">',d+=`<button onclick="document.dispatchEvent(new CustomEvent('health-edit', {detail:'${escapeHtml(x.serviceId)}'}))" style="padding: 4px 10px; font-size: 0.78rem; margin-right: 4px;">Edit</button>`,d+=`<button onclick="document.dispatchEvent(new CustomEvent('health-delete', {detail:'${escapeHtml(x.serviceId)}'}))" style="padding: 4px 10px; font-size: 0.78rem; color: var(--bad-fg); border-color: var(--bad-fg);">Delete</button>`,d+="</td></tr>"}d+="</table>",D.innerHTML=d}catch(o){D.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(o.message)}</div>`}}function r(o,a,s,d,x,H,U){p=o||null,k.textContent=o?"Edit Health Check":"Add Health Check",document.getElementById("health-form-id").value=o||"",document.getElementById("health-form-id").disabled=!!o,document.getElementById("health-form-name").value=a||"",document.getElementById("health-form-url").value=s||"",document.getElementById("health-form-timeout").value=d||1e4,document.getElementById("health-form-codes").value=x||"200",document.getElementById("health-form-sla").value=H||99.9,document.getElementById("health-form-slow").value=U||5e3,L.style.display="",g.style.display="none"}function e(){L.style.display="none",g.style.display="",p=null}g?.addEventListener("click",()=>r("","","",1e4,"200",99.9,5e3)),M?.addEventListener("click",e),I?.addEventListener("click",async()=>{const o=p||document.getElementById("health-form-id").value.trim();if(!o)return showNotification("Service ID is required","warning");const a=document.getElementById("health-form-url").value.trim();if(!a)return showNotification("URL is required","warning");const s=document.getElementById("health-form-codes").value.split(",").map(x=>parseInt(x.trim())).filter(Boolean),d={name:document.getElementById("health-form-name").value.trim()||o,url:a,timeout:parseInt(document.getElementById("health-form-timeout").value)||1e4,expectedStatusCodes:s.length?s:[200],sla:{target:parseFloat(document.getElementById("health-form-sla").value)||99.9},slowResponseThreshold:parseInt(document.getElementById("health-form-slow").value)|Line truncated
|
||||
<div class="weather-modal-content" style="min-width: 750px; max-width: 950px;">
|
||||
<h3>\u2B06\uFE0F Update Management</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1652,17 +1652,17 @@ This will replace current configuration, credentials, and data. Containers will
|
||||
<button id="updates-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("updates-modal"),E=document.getElementById("updates-btn"),j=document.getElementById("updates-cancel"),h=document.getElementById("updates-check-btn"),P=document.getElementById("updates-available-container"),A=document.getElementById("updates-history-container"),D=document.getElementById("updates-auto-container"),R=document.getElementById("updates-last-check");async function y(){try{const t=await(await fetch("/api/v1/updates/available")).json();if(!t.success)throw new Error(t.error);const e=t.updates||[];if(e.length===0){P.innerHTML='<div class="panel-empty"><span class="empty-icon">\u2705</span>All containers are up to date.</div>',R.textContent="",document.getElementById("updates-update-all-btn").style.display="none",document.getElementById("updates-count-badge").style.display="none",window._pendingUpdates=[];return}let s='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';s+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 8px; text-align: left;">Container</th><th style="padding: 8px; text-align: left;">Image</th><th style="padding: 8px; text-align: left;">Current</th><th style="padding: 8px; text-align: left;">Latest</th><th style="padding: 8px; text-align: right;">Actions</th></tr>';for(const a of e){const i=(()=>{const c=window.APPS||[];for(const I of c)if(I.containerId===a.containerId||I.name===a.containerName||I.id===a.containerName)return I.id;return a.containerName})();s+=`<tr data-app-id="${escapeHtml(i)}" style="border-bottom: 1px solid var(--border);">`,s+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(a.containerName)}</td>`,s+=`<td style="padding: 8px; color: var(--muted);">${escapeHtml(a.imageName)}</td>`,s+=`<td style="padding: 8px;"><code style="font-size: 0.78rem; background: var(--bg); padding: 2px 6px; border-radius: 4px;">${escapeHtml(a.currentDigest)}</code></td>`,s+=`<td style="padding: 8px;"><code style="font-size: 0.78rem; background: var(--ok-bg); color: var(--ok-fg); padding: 2px 6px; border-radius: 4px;">${escapeHtml(a.latestDigest)}</code></td>`,s+='<td style="padding: 8px; text-align: right;">',s+=`<button class="update-now-btn" data-id="${escapeHtml(a.containerId)}" data-name="${escapeHtml(a.containerName)}" style="padding: 4px 10px; font-size: 0.78rem; background: var(--accent); color: var(--bg); border-color: var(--accent); margin-right: 4px;">Update</button>`,s+=`<button class="rollback-btn" data-id="${escapeHtml(a.containerId)}" data-name="${escapeHtml(a.containerName)}" style="padding: 4px 10px; font-size: 0.78rem;">Rollback</button>`,s+="</td></tr>"}s+="</table>",P.innerHTML=s,R.textContent=e.length+" update(s) available";const n=document.getElementById("updates-count-badge"),r=document.getElementById("updates-update-all-btn");n&&(n.textContent=e.length+" pending",n.style.display=""),r&&e.length>0&&(r.style.display=""),window._pendingUpdates=e,P.querySelectorAll(".update-now-btn").forEach(a=>{a.addEventListener("click",async()=>{const i=a.dataset.id,c=a.dataset.name;if(confirm(`Update "${c}" to the latest version? The container will restart.`)){a.textContent="Updating...",a.disabled=!0;try{const N=await(await secureFetch(`/api/v1/updates/update/${encodeURIComponent(i)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoRollback:!0})})).json();if(N.success)a.textContent="Done!",a.style.background="var(--ok-fg)",setTimeout(()=>y(),2e3);else throw new Error(N.error||"Update failed")}catch(I){a.textContent="Failed",a.style.color="var(--bad-fg)",showNotification("Update error: "+I.message,"error"),setTimeout(()=>{a.textContent="Update",a.disabled=!1,a.style.color="",a.style.background=""},3e3)}}})}),P.querySelectorAll(".rollback-btn").forEach(a=>{a.addEventListener("click",async()=>{const i=a.dataset.id,c=a.dataset.name;if(confirm(`Rollback "${c}" to its previous version?`)){a.textContent="Rolling back...",a.disabled=!0;try{const N=await(await secureFetch(`/api/v1/updates/rollback/${encodeURIComponent(i)}`,{method:"POST"})).json();if(N.success)a.textContent="Rolled back!",setTimeout(()=>y(),2e3);else throw new Error(N.error||"Rollback failed")}catch(I){a.textContent="Failed",showNotification("Rollback error: "+I.message,"error"),setTimeout(()=>{a.textContent="Rollback",a.disabled=!1},3e3)}}})})}catch(p){P.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(p.message)}</div>`}}async function $(){const p=window._pendingUpdates||[];if(!p.length)return;const t=document.getElementById("updates-update-all-btn");if(!confirm(`Update all ${p.length} containers? Each will restart.`))return;t.textContent="\u23F3 Updating...",t.disabled=!0;let e=0,s=0;for(const n of p)try{(await(await secureFetch(`/api/v1/updates/update/${encodeURIComponent(n.containerId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoRollback:!0})})).json()).success?e++:s++}catch{s++}t.textCLine truncated
|
||||
<select class="auto-schedule" data-id="${escapeHtml(I)}" style="padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); font-size: 0.82rem;">
|
||||
</div>`);const b=document.getElementById("updates-modal"),h=document.getElementById("updates-btn"),j=document.getElementById("updates-cancel"),m=document.getElementById("updates-check-btn"),N=document.getElementById("updates-available-container"),A=document.getElementById("updates-history-container"),D=document.getElementById("updates-auto-container"),R=document.getElementById("updates-last-check");async function g(){try{const n=await(await fetch("/api/v1/updates/available")).json();if(!n.success)throw new Error(n.error);const t=n.updates||[];if(t.length===0){N.innerHTML='<div class="panel-empty"><span class="empty-icon">\u2705</span>All containers are up to date.</div>',R.textContent="",document.getElementById("updates-update-all-btn").style.display="none",document.getElementById("updates-count-badge").style.display="none",window._pendingUpdates=[];return}let r='<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem;">';r+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 8px; text-align: left;">Container</th><th style="padding: 8px; text-align: left;">Image</th><th style="padding: 8px; text-align: left;">Current</th><th style="padding: 8px; text-align: left;">Latest</th><th style="padding: 8px; text-align: right;">Actions</th></tr>';for(const a of t){const s=(()=>{const d=window.APPS||[];for(const x of d)if(x.containerId===a.containerId||x.name===a.containerName||x.id===a.containerName)return x.id;return a.containerName})();r+=`<tr data-app-id="${escapeHtml(s)}" style="border-bottom: 1px solid var(--border);">`,r+=`<td style="padding: 8px; font-weight: 500;">${escapeHtml(a.containerName)}</td>`,r+=`<td style="padding: 8px; color: var(--muted);">${escapeHtml(a.imageName)}</td>`,r+=`<td style="padding: 8px;"><code style="font-size: 0.78rem; background: var(--bg); padding: 2px 6px; border-radius: 4px;">${escapeHtml(a.currentDigest)}</code></td>`,r+=`<td style="padding: 8px;"><code style="font-size: 0.78rem; background: var(--ok-bg); color: var(--ok-fg); padding: 2px 6px; border-radius: 4px;">${escapeHtml(a.latestDigest)}</code></td>`,r+='<td style="padding: 8px; text-align: right;">',r+=`<button class="update-now-btn" data-id="${escapeHtml(a.containerId)}" data-name="${escapeHtml(a.containerName)}" style="padding: 4px 10px; font-size: 0.78rem; background: var(--accent); color: var(--bg); border-color: var(--accent); margin-right: 4px;">Update</button>`,r+=`<button class="rollback-btn" data-id="${escapeHtml(a.containerId)}" data-name="${escapeHtml(a.containerName)}" style="padding: 4px 10px; font-size: 0.78rem;">Rollback</button>`,r+="</td></tr>"}r+="</table>",N.innerHTML=r,R.textContent=t.length+" update(s) available";const e=document.getElementById("updates-count-badge"),o=document.getElementById("updates-update-all-btn");e&&(e.textContent=t.length+" pending",e.style.display=""),o&&t.length>0&&(o.style.display=""),window._pendingUpdates=t,N.querySelectorAll(".update-now-btn").forEach(a=>{a.addEventListener("click",async()=>{const s=a.dataset.id,d=a.dataset.name;if(confirm(`Update "${d}" to the latest version? The container will restart.`)){a.textContent="Updating...",a.disabled=!0;try{const H=await(await secureFetch(`/api/v1/updates/update/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoRollback:!0})})).json();if(H.success)a.textContent="Done!",a.style.background="var(--ok-fg)",setTimeout(()=>g(),2e3);else throw new Error(H.error||"Update failed")}catch(x){a.textContent="Failed",a.style.color="var(--bad-fg)",showNotification("Update error: "+x.message,"error"),setTimeout(()=>{a.textContent="Update",a.disabled=!1,a.style.color="",a.style.background=""},3e3)}}})}),N.querySelectorAll(".rollback-btn").forEach(a=>{a.addEventListener("click",async()=>{const s=a.dataset.id,d=a.dataset.name;if(confirm(`Rollback "${d}" to its previous version?`)){a.textContent="Rolling back...",a.disabled=!0;try{const H=await(await secureFetch(`/api/v1/updates/rollback/${encodeURIComponent(s)}`,{method:"POST"})).json();if(H.success)a.textContent="Rolled back!",setTimeout(()=>g(),2e3);else throw new Error(H.error||"Rollback failed")}catch(x){a.textContent="Failed",showNotification("Rollback error: "+x.message,"error"),setTimeout(()=>{a.textContent="Rollback",a.disabled=!1},3e3)}}})})}catch(c){N.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(c.message)}</div>`}}async function L(){const c=window._pendingUpdates||[];if(!c.length)return;const n=document.getElementById("updates-update-all-btn");if(!confirm(`Update all ${c.length} containers? Each will restart.`))return;n.textContent="\u23F3 Updating...",n.disabled=!0;let t=0,r=0;for(const e of c)try{(await(await secureFetch(`/api/v1/updates/update/${encodeURIComponent(e.containerId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoRollback:!0})})).json()).success?t++:r++}catch{r++}n.textCLine truncated
|
||||
<select class="auto-schedule" data-id="${escapeHtml(x)}" style="padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); font-size: 0.82rem;">
|
||||
<option value=""${U?"":" selected"}>Disabled</option>
|
||||
<option value="daily"${U==="daily"?" selected":""}>Daily</option>
|
||||
<option value="weekly"${U==="weekly"?" selected":""}>Weekly</option>
|
||||
<option value="monthly"${U==="monthly"?" selected":""}>Monthly</option>
|
||||
</select></td>`,a+=`<td style="padding: 8px;"><input type="text" class="auto-window" data-id="${escapeHtml(I)}" value="${escapeHtml(F)}" placeholder="02:00-04:00" style="width: 90px; padding: 3px 6px; font-size: 0.78rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--fg);" /></td>`,a+=`<td style="padding: 8px;"><input type="checkbox" class="auto-rollback" data-id="${escapeHtml(I)}"${_?" checked":""} /></td>`,a+=`<td style="padding: 8px; font-size: 0.78rem; color: var(--muted);">${q}</td>`,a+=`<td style="padding: 8px; text-align: right;"><button class="save-auto-btn" data-id="${escapeHtml(I)}" data-name="${escapeHtml(c)}" style="padding: 4px 10px; font-size: 0.78rem;">Save</button></td>`,a+="</tr>"}a+="</table>",D.innerHTML=a,D.querySelectorAll(".save-auto-btn").forEach(i=>{i.addEventListener("click",async()=>{const c=i.dataset.id,I=i.closest("tr"),N=I.querySelector(".auto-schedule").value,U=I.querySelector(".auto-rollback").checked,_=I.querySelector(".auto-window").value.trim();i.textContent="Saving...",i.disabled=!0;try{const q=await(await secureFetch(`/api/v1/updates/auto-update/${encodeURIComponent(c)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!!N,schedule:N||"weekly",autoRollback:U,maintenanceWindow:_||void 0})})).json();if(q.success)i.textContent="\u2713 Saved";else throw new Error(q.error)}catch(F){i.textContent="\u2717 Error",showNotification("Save error: "+F.message,"error")}setTimeout(()=>{i.textContent="Save",i.disabled=!1},2e3)})})}catch(p){D.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(p.message)}</div>`}}const z=document.getElementById("dashcaddy-current-version"),C=document.getElementById("dashcaddy-update-badge"),M=document.getElementById("dashcaddy-update-details"),b=document.getElementById("dashcaddy-new-version"),d=document.getElementById("dashcaddy-changelog"),v=document.getElementById("dashcaddy-apply-btn"),S=document.getElementById("dashcaddy-check-btn"),O=document.getElementById("dashcaddy-rollback-btn"),m=document.getElementById("dashcaddy-status-bar"),f=document.getElementById("dashcaddy-history-container");let B=null;function w(p,t){m&&(m.style.display="block",m.style.background=t==="error"?"var(--bad-bg)":t==="success"?"var(--ok-bg)":"var(--bg)",m.style.color=t==="error"?"var(--bad-fg)":t==="success"?"var(--ok-fg)":"var(--fg)",m.textContent=p)}async function L(){try{const t=await(await fetch("/api/v1/system/version")).json();if(t.success){const e=t.commit&&t.commit!=="unknown"?t.commit:null;z.textContent="v"+t.version+(e?" ("+e.substring(0,7)+")":"")}}catch{z.textContent="Unable to fetch version"}}async function o(p){p||(S.textContent="Checking...",S.disabled=!0);try{const e=await(await fetch("/api/v1/system/update-check")).json();if(B=e,e.success&&e.available&&e.remote){C.style.display="",M.style.display="",b.textContent="v"+e.remote.version,d.textContent=e.remote.changelog||"No changelog available.";const s=document.getElementById("updates-btn");if(s&&!s.querySelector(".update-dot")){const r=document.createElement("span");r.className="update-dot",r.style.cssText="position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--accent);",s.style.position="relative",s.appendChild(r)}const n=document.getElementById("updates-dashcaddy-tab");if(n&&!n.querySelector(".update-dot")){const r=document.createElement("span");r.className="update-dot",r.style.cssText="display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--accent);margin-left:4px;vertical-align:middle;",n.appendChild(r)}}else C.style.display="none",M.style.display="none",await L(),p||w("You are running the latest version.","success");p||(S.textContent="Check for Updates",S.disabled=!1)}catch(t){p||(w("Failed to check: "+t.message,"error"),S.textContent="Check for Updates",S.disabled=!1)}}async function u(){if(!confirm("Apply DashCaddy update? The API container will restart."))return!1;v.textContent="Updating...",v.disabled=!0,w("Downloading and applying update...","info");try{const t=await(await secureFetch("/api/v1/system/update-apply",{method:"POST"})).json();if(t.success)return w("Update initiated: v"+(t.fromVersion||"?")+" \u2192 v"+(t.toVersion||"?")+". The container will restart shortly.","success"),v.textContent="Applied!",document.querySelectorAll(".update-dot").forEach(e=>e.remove()),!0;throw new Error(t.error||"Update failed")}catch(p){throw w("Update failed: "+p.message,"error"),v.textContent="Update Now",v.disabled=!1,p}}async function l(){try{const t=await(await fetch("/api/v1/system/update-history")).json(),e=t.success&&t.history?t.history:[];if(e.length===0){f.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4E6}</span>No self-update history.</div>';return}let s='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';s+='<tr style="border-bottom: 1px solid var(--border); color: var(--mutLine truncated
|
||||
`+e.join(`
|
||||
</select></td>`,a+=`<td style="padding: 8px;"><input type="text" class="auto-window" data-id="${escapeHtml(x)}" value="${escapeHtml(F)}" placeholder="02:00-04:00" style="width: 90px; padding: 3px 6px; font-size: 0.78rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--fg);" /></td>`,a+=`<td style="padding: 8px;"><input type="checkbox" class="auto-rollback" data-id="${escapeHtml(x)}"${_?" checked":""} /></td>`,a+=`<td style="padding: 8px; font-size: 0.78rem; color: var(--muted);">${q}</td>`,a+=`<td style="padding: 8px; text-align: right;"><button class="save-auto-btn" data-id="${escapeHtml(x)}" data-name="${escapeHtml(d)}" style="padding: 4px 10px; font-size: 0.78rem;">Save</button></td>`,a+="</tr>"}a+="</table>",D.innerHTML=a,D.querySelectorAll(".save-auto-btn").forEach(s=>{s.addEventListener("click",async()=>{const d=s.dataset.id,x=s.closest("tr"),H=x.querySelector(".auto-schedule").value,U=x.querySelector(".auto-rollback").checked,_=x.querySelector(".auto-window").value.trim();s.textContent="Saving...",s.disabled=!0;try{const q=await(await secureFetch(`/api/v1/updates/auto-update/${encodeURIComponent(d)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!!H,schedule:H||"weekly",autoRollback:U,maintenanceWindow:_||void 0})})).json();if(q.success)s.textContent="\u2713 Saved";else throw new Error(q.error)}catch(F){s.textContent="\u2717 Error",showNotification("Save error: "+F.message,"error")}setTimeout(()=>{s.textContent="Save",s.disabled=!1},2e3)})})}catch(c){D.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(c.message)}</div>`}}const $=document.getElementById("dashcaddy-current-version"),E=document.getElementById("dashcaddy-update-badge"),T=document.getElementById("dashcaddy-update-details"),P=document.getElementById("dashcaddy-new-version"),v=document.getElementById("dashcaddy-changelog"),B=document.getElementById("dashcaddy-apply-btn"),z=document.getElementById("dashcaddy-check-btn"),O=document.getElementById("dashcaddy-rollback-btn"),u=document.getElementById("dashcaddy-status-bar"),y=document.getElementById("dashcaddy-history-container");let C=null;function w(c,n){u&&(u.style.display="block",u.style.background=n==="error"?"var(--bad-bg)":n==="success"?"var(--ok-bg)":"var(--bg)",u.style.color=n==="error"?"var(--bad-fg)":n==="success"?"var(--ok-fg)":"var(--fg)",u.textContent=c)}async function S(){try{const n=await(await fetch("/api/v1/system/version")).json();if(n.success){const t=n.commit&&n.commit!=="unknown"?n.commit:null;$.textContent="v"+n.version+(t?" ("+t.substring(0,7)+")":"")}}catch{$.textContent="Unable to fetch version"}}async function i(c){c||(z.textContent="Checking...",z.disabled=!0);try{const t=await(await fetch("/api/v1/system/update-check")).json();if(C=t,t.success&&t.available&&t.remote){E.style.display="",T.style.display="",P.textContent="v"+t.remote.version,v.textContent=t.remote.changelog||"No changelog available.";const r=document.getElementById("updates-btn");if(r&&!r.querySelector(".update-dot")){const o=document.createElement("span");o.className="update-dot",o.style.cssText="position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--accent);",r.style.position="relative",r.appendChild(o)}const e=document.getElementById("updates-dashcaddy-tab");if(e&&!e.querySelector(".update-dot")){const o=document.createElement("span");o.className="update-dot",o.style.cssText="display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--accent);margin-left:4px;vertical-align:middle;",e.appendChild(o)}}else E.style.display="none",T.style.display="none",await S(),c||w("You are running the latest version.","success");c||(z.textContent="Check for Updates",z.disabled=!1)}catch(n){c||(w("Failed to check: "+n.message,"error"),z.textContent="Check for Updates",z.disabled=!1)}}async function p(){if(!confirm("Apply DashCaddy update? The API container will restart."))return!1;B.textContent="Updating...",B.disabled=!0,w("Downloading and applying update...","info");try{const n=await(await secureFetch("/api/v1/system/update-apply",{method:"POST"})).json();if(n.success)return w("Update initiated: v"+(n.fromVersion||"?")+" \u2192 v"+(n.toVersion||"?")+". The container will restart shortly.","success"),B.textContent="Applied!",document.querySelectorAll(".update-dot").forEach(t=>t.remove()),!0;throw new Error(n.error||"Update failed")}catch(c){throw w("Update failed: "+c.message,"error"),B.textContent="Update Now",B.disabled=!1,c}}async function l(){try{const n=await(await fetch("/api/v1/system/update-history")).json(),t=n.success&&n.history?n.history:[];if(t.length===0){y.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4E6}</span>No self-update history.</div>';return}let r='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';r+='<tr style="border-bottom: 1px solid var(--border); color: var(--mutLine truncated
|
||||
`+t.join(`
|
||||
`)+`
|
||||
|
||||
Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification("Invalid version: "+s,"error");return}if(!confirm("Rollback DashCaddy to v"+s+"? The container will restart."))return;w("Rolling back to v"+s+"...","info");const r=await(await secureFetch("/api/v1/system/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:s})})).json();if(r.success)w("Rollback to v"+s+" initiated. Container will restart.","success");else throw new Error(r.error||"Rollback failed")}catch(p){w("Rollback failed: "+p.message,"error")}}S?.addEventListener("click",()=>o(!1)),v?.addEventListener("click",()=>u().catch(()=>{})),O?.addEventListener("click",g),h?.addEventListener("click",k),E?.addEventListener("click",()=>{x?.classList.add("show"),y()}),wireModal(x,j),window.openUpdateModal=function(p){x?.classList.add("show"),y().then(()=>{if(!p)return;const t=P.querySelector(`[data-app-id="${p}"]`);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.style.background="rgba(249,115,22,0.15)",setTimeout(()=>{t.style.background=""},3e3))})},document.querySelector('[data-panel="updates-history"]')?.addEventListener("click",H),document.querySelector('[data-panel="updates-auto"]')?.addEventListener("click",T),document.querySelector('[data-panel="updates-dashcaddy"]')?.addEventListener("click",()=>{L(),l(),B||o(!0)}),window.dcApplyUpdate=u,window.dcCheckForUpdate=o,setTimeout(()=>o(!0),5e3)})(),(function(){injectModal("docker-resources-modal",`<div id="docker-resources-modal" class="weather-modal">
|
||||
Enter version to rollback to:`);if(!r)return;if(!t.includes(r)){showNotification("Invalid version: "+r,"error");return}if(!confirm("Rollback DashCaddy to v"+r+"? The container will restart."))return;w("Rolling back to v"+r+"...","info");const o=await(await secureFetch("/api/v1/system/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:r})})).json();if(o.success)w("Rollback to v"+r+" initiated. Container will restart.","success");else throw new Error(o.error||"Rollback failed")}catch(c){w("Rollback failed: "+c.message,"error")}}z?.addEventListener("click",()=>i(!1)),B?.addEventListener("click",()=>p().catch(()=>{})),O?.addEventListener("click",f),m?.addEventListener("click",k),h?.addEventListener("click",()=>{b?.classList.add("show"),g()}),wireModal(b,j),window.openUpdateModal=function(c){b?.classList.add("show"),g().then(()=>{if(!c)return;const n=N.querySelector(`[data-app-id="${c}"]`);n&&(n.scrollIntoView({behavior:"smooth",block:"center"}),n.style.background="rgba(249,115,22,0.15)",setTimeout(()=>{n.style.background=""},3e3))})},document.querySelector('[data-panel="updates-history"]')?.addEventListener("click",M),document.querySelector('[data-panel="updates-auto"]')?.addEventListener("click",I),document.querySelector('[data-panel="updates-dashcaddy"]')?.addEventListener("click",()=>{S(),l(),C||i(!0)}),window.dcApplyUpdate=p,window.dcCheckForUpdate=i,setTimeout(()=>i(!0),5e3)})(),(function(){injectModal("docker-resources-modal",`<div id="docker-resources-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 750px; max-width: 950px;">
|
||||
<h3>\u{1F433} Docker Resources</h3>
|
||||
<p class="modal-subtitle">Manage volumes, networks, and view disk usage.</p>
|
||||
@@ -1711,7 +1711,7 @@ Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification
|
||||
<button id="dr-close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("docker-resources-modal"),E=document.getElementById("docker-resources-btn"),j=document.getElementById("dr-close");function h(R){if(!R||R===0)return"0 B";const y=["B","KB","MB","GB","TB"],$=Math.floor(Math.log(Math.abs(R))/Math.log(1024));return(R/Math.pow(1024,$)).toFixed(1)+" "+y[$]}async function P(){const R=document.getElementById("dr-vol-list");try{const $=(await getJSON("/api/v1/docker/volumes")).volumes||[];if($.length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4E6}</span>No volumes found.</div>';return}let k='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';k+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Name</th><th style="padding: 6px;">Driver</th><th style="padding: 6px;">Scope</th><th style="padding: 6px; text-align: right;">Actions</th></tr>';for(const H of $){const T=H.name==="buildkit"||H.name.length===64;k+='<tr style="border-bottom: 1px solid var(--border);">',k+=`<td style="padding: 6px; font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="${escapeHtml(H.name)}">${escapeHtml(H.name.length>40?H.name.substring(0,37)+"...":H.name)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(H.driver)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(H.scope)}</td>`,k+='<td style="padding: 6px; text-align: right;">',T||(k+=`<button class="dr-vol-del" data-name="${escapeHtml(H.name)}" style="padding: 3px 8px; font-size: 0.75rem; color: var(--bad-fg);">Delete</button>`),k+="</td></tr>"}k+="</table>",R.innerHTML=k,R.querySelectorAll(".dr-vol-del").forEach(H=>{H.addEventListener("click",async()=>{if(confirm(`Delete volume "${H.dataset.name}"? Data will be lost.`)){H.textContent="...",H.disabled=!0;try{await deleteAPI(`/api/v1/docker/volumes/${encodeURIComponent(H.dataset.name)}?force=true`),P()}catch(T){showNotification("Delete failed: "+T.message,"error"),H.textContent="Delete",H.disabled=!1}}})})}catch(y){R.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(y.message)}</div>`}}document.getElementById("dr-vol-create")?.addEventListener("click",async()=>{const R=document.getElementById("dr-vol-name"),y=R.value.trim();if(!y){showNotification("Enter a volume name","warning");return}try{await postJSON("/api/v1/docker/volumes",{name:y}),R.value="",showNotification(`Volume "${y}" created`,"success"),P()}catch($){showNotification("Create failed: "+$.message,"error")}});async function A(){const R=document.getElementById("dr-net-list");try{const $=(await getJSON("/api/v1/docker/networks")).networks||[];if($.length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F310}</span>No networks found.</div>';return}let k='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';k+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Name</th><th style="padding: 6px;">Driver</th><th style="padding: 6px;">Scope</th><th style="padding: 6px;">Containers</th><th style="padding: 6px; text-align: right;">Actions</th></tr>';for(const H of $){const T=["bridge","host","none"].includes(H.name);k+='<tr style="border-bottom: 1px solid var(--border);">',k+=`<td style="padding: 6px; font-weight: 500;">${escapeHtml(H.name)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(H.driver)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(H.scope)}</td>`,k+=`<td style="padding: 6px; text-align: center;">${H.containers}</td>`,k+='<td style="padding: 6px; text-align: right;">',T||(k+=`<button class="dr-net-del" data-id="${escapeHtml(H.id)}" data-name="${escapeHtml(H.name)}" style="padding: 3px 8px; font-size: 0.75rem; color: var(--bad-fg);">Delete</button>`),k+="</td></tr>"}k+="</table>",R.innerHTML=k,R.querySelectorAll(".dr-net-del").forEach(H=>{H.addEventListener("click",async()=>{if(confirm(`Delete network "${H.dataset.name}"?`)){H.textContent="...",H.disabled=!0;try{await deleteAPI(`/api/v1/docker/networks/${encodeURIComponent(H.dataset.id)}`),A()}catch(T){showNotification("Delete failed: "+T.message,"error"),H.textContent="Delete",H.disabled=!1}}})})}catch(y){R.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(y.message)}</div>`}}document.getElementById("dr-net-create")?.addEventListener("click",async()=>{const R=document.getElementById("dr-net-name"),y=document.getElementById("dr-net-driver"),$=R.value.trim();if(!$){showNotification("Enter a network name","warning");return}try{await postJSON("/api/v1/docker/networks",{name:$,driver:y.value}),R.value="",showNotification(`Network "${$}" created`,"success"),A()}catch(k){showNotification("Create failed: "+k.message,"error")}});async fuLine truncated
|
||||
</div>`);const b=document.getElementById("docker-resources-modal"),h=document.getElementById("docker-resources-btn"),j=document.getElementById("dr-close");function m(R){if(!R||R===0)return"0 B";const g=["B","KB","MB","GB","TB"],L=Math.floor(Math.log(Math.abs(R))/Math.log(1024));return(R/Math.pow(1024,L)).toFixed(1)+" "+g[L]}async function N(){const R=document.getElementById("dr-vol-list");try{const L=(await getJSON("/api/v1/docker/volumes")).volumes||[];if(L.length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F4E6}</span>No volumes found.</div>';return}let k='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';k+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Name</th><th style="padding: 6px;">Driver</th><th style="padding: 6px;">Scope</th><th style="padding: 6px; text-align: right;">Actions</th></tr>';for(const M of L){const I=M.name==="buildkit"||M.name.length===64;k+='<tr style="border-bottom: 1px solid var(--border);">',k+=`<td style="padding: 6px; font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="${escapeHtml(M.name)}">${escapeHtml(M.name.length>40?M.name.substring(0,37)+"...":M.name)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(M.driver)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(M.scope)}</td>`,k+='<td style="padding: 6px; text-align: right;">',I||(k+=`<button class="dr-vol-del" data-name="${escapeHtml(M.name)}" style="padding: 3px 8px; font-size: 0.75rem; color: var(--bad-fg);">Delete</button>`),k+="</td></tr>"}k+="</table>",R.innerHTML=k,R.querySelectorAll(".dr-vol-del").forEach(M=>{M.addEventListener("click",async()=>{if(confirm(`Delete volume "${M.dataset.name}"? Data will be lost.`)){M.textContent="...",M.disabled=!0;try{await deleteAPI(`/api/v1/docker/volumes/${encodeURIComponent(M.dataset.name)}?force=true`),N()}catch(I){showNotification("Delete failed: "+I.message,"error"),M.textContent="Delete",M.disabled=!1}}})})}catch(g){R.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(g.message)}</div>`}}document.getElementById("dr-vol-create")?.addEventListener("click",async()=>{const R=document.getElementById("dr-vol-name"),g=R.value.trim();if(!g){showNotification("Enter a volume name","warning");return}try{await postJSON("/api/v1/docker/volumes",{name:g}),R.value="",showNotification(`Volume "${g}" created`,"success"),N()}catch(L){showNotification("Create failed: "+L.message,"error")}});async function A(){const R=document.getElementById("dr-net-list");try{const L=(await getJSON("/api/v1/docker/networks")).networks||[];if(L.length===0){R.innerHTML='<div class="panel-empty"><span class="empty-icon">\u{1F310}</span>No networks found.</div>';return}let k='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">';k+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);"><th style="padding: 6px; text-align: left;">Name</th><th style="padding: 6px;">Driver</th><th style="padding: 6px;">Scope</th><th style="padding: 6px;">Containers</th><th style="padding: 6px; text-align: right;">Actions</th></tr>';for(const M of L){const I=["bridge","host","none"].includes(M.name);k+='<tr style="border-bottom: 1px solid var(--border);">',k+=`<td style="padding: 6px; font-weight: 500;">${escapeHtml(M.name)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(M.driver)}</td>`,k+=`<td style="padding: 6px; text-align: center; color: var(--muted);">${escapeHtml(M.scope)}</td>`,k+=`<td style="padding: 6px; text-align: center;">${M.containers}</td>`,k+='<td style="padding: 6px; text-align: right;">',I||(k+=`<button class="dr-net-del" data-id="${escapeHtml(M.id)}" data-name="${escapeHtml(M.name)}" style="padding: 3px 8px; font-size: 0.75rem; color: var(--bad-fg);">Delete</button>`),k+="</td></tr>"}k+="</table>",R.innerHTML=k,R.querySelectorAll(".dr-net-del").forEach(M=>{M.addEventListener("click",async()=>{if(confirm(`Delete network "${M.dataset.name}"?`)){M.textContent="...",M.disabled=!0;try{await deleteAPI(`/api/v1/docker/networks/${encodeURIComponent(M.dataset.id)}`),A()}catch(I){showNotification("Delete failed: "+I.message,"error"),M.textContent="Delete",M.disabled=!1}}})})}catch(g){R.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(g.message)}</div>`}}document.getElementById("dr-net-create")?.addEventListener("click",async()=>{const R=document.getElementById("dr-net-name"),g=document.getElementById("dr-net-driver"),L=R.value.trim();if(!L){showNotification("Enter a network name","warning");return}try{await postJSON("/api/v1/docker/networks",{name:L,driver:g.value}),R.value="",showNotification(`Network "${L}" created`,"success"),A()}catch(k){showNotification("Create failed: "+k.message,"error")}});async fuLine truncated
|
||||
<div class="weather-modal-content" style="min-width: 650px; max-width: 800px;">
|
||||
<h3>\u{1F4E6} Import Docker Compose</h3>
|
||||
<p class="modal-subtitle">Paste a docker-compose.yml to import and deploy services.</p>
|
||||
@@ -1752,8 +1752,8 @@ Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification
|
||||
<div id="compose-progress-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("compose-import-modal"),E=document.getElementById("compose-import-btn"),j=document.getElementById("compose-cancel");wireModal(x,j);let h=null;function P(D){document.getElementById("compose-step-paste").style.display=D==="paste"?"":"none",document.getElementById("compose-step-preview").style.display=D==="preview"?"":"none",document.getElementById("compose-step-progress").style.display=D==="progress"?"":"none"}E?.addEventListener("click",()=>{P("paste"),h=null,document.getElementById("compose-yaml").value="",document.getElementById("compose-stack-name").value="",x?.classList.add("show")}),document.getElementById("compose-file-upload")?.addEventListener("change",D=>{const R=D.target.files[0];if(!R)return;const y=new FileReader;y.onload=()=>{document.getElementById("compose-yaml").value=y.result},y.readAsText(R)}),document.getElementById("compose-parse-btn")?.addEventListener("click",async()=>{const D=document.getElementById("compose-yaml").value.trim(),R=document.getElementById("compose-stack-name").value.trim()||"stack";if(!D){showNotification("Paste a docker-compose.yml","warning");return}const y=document.getElementById("compose-parse-btn"),$=y.textContent;y.textContent="Parsing...",y.disabled=!0;try{const k=await postJSON("/api/v1/apps/import-compose",{yaml:D,stackName:R});h=k,h.stackName=R,A(k),P("preview")}catch(k){showNotification("Parse failed: "+k.message,"error")}finally{y.textContent=$,y.disabled=!1}});function A(D){const R=document.getElementById("compose-preview-content");let y="";D.networks&&D.networks.length>0&&(y+=`<div style="margin-bottom: 12px; font-size: 0.82rem; color: var(--muted);">Networks: ${D.networks.map($=>`<code>${escapeHtml($)}</code>`).join(", ")}</div>`),D.volumes&&D.volumes.length>0&&(y+=`<div style="margin-bottom: 12px; font-size: 0.82rem; color: var(--muted);">Volumes: ${D.volumes.map($=>`<code>${escapeHtml($)}</code>`).join(", ")}</div>`),y+=`<div style="font-weight: 600; margin-bottom: 8px;">${D.services.length} service(s)</div>`,y+='<div class="scroll-container" style="max-height: 350px;">';for(const $ of D.services){const k=$.skip?"var(--bad-fg)":"var(--border)";if(y+=`<div style="padding: 10px 14px; border: 1px solid ${k}; border-radius: 8px; margin-bottom: 8px; background: var(--bg);">`,y+=`<div style="font-weight: 600; font-size: 0.9rem;">${escapeHtml($.name)}`,$.skip&&(y+=` <span style="color: var(--bad-fg); font-weight: 400; font-size: 0.78rem;">\u2014 skipped: ${escapeHtml($.reason)}</span>`),y+="</div>",!$.skip&&(y+=`<div style="font-size: 0.8rem; color: var(--muted); margin-top: 4px;">Image: <code>${escapeHtml($.image)}</code></div>`,$.ports?.length&&(y+=`<div style="font-size: 0.8rem; color: var(--muted);">Ports: ${$.ports.map(H=>`${H.host}:${H.container}`).join(", ")}</div>`),$.volumes?.length&&(y+=`<div style="font-size: 0.8rem; color: var(--muted);">Volumes: ${$.volumes.length}</div>`),Object.keys($.environment||{}).length&&(y+=`<div style="font-size: 0.8rem; color: var(--muted);">Env vars: ${Object.keys($.environment).length}</div>`),$.envFileWarning&&(y+=`<div style="font-size: 0.78rem; color: var(--bad-fg);">\u26A0 ${escapeHtml($.envFileWarning)}</div>`),$.resources?.cpus||$.resources?.memory)){const H=[];$.resources.cpus&&H.push(`CPU: ${$.resources.cpus}`),$.resources.memory&&H.push(`Mem: ${$.resources.memory}MB`),y+=`<div style="font-size: 0.8rem; color: var(--muted);">Limits: ${H.join(", ")}</div>`}y+="</div>"}y+="</div>",R.innerHTML=y}document.getElementById("compose-back-btn")?.addEventListener("click",()=>P("paste")),document.getElementById("compose-deploy-btn")?.addEventListener("click",async()=>{if(!h)return;const D=document.getElementById("compose-deploy-btn");D.textContent="Deploying...",D.disabled=!0,P("progress");const R=document.getElementById("compose-progress-content");R.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Deploying services...</div>';try{const y=await postJSON("/api/v1/apps/deploy-compose",{services:h.services,networks:h.networks,stackName:h.stackName});let $=`<div style="font-weight: 600; margin-bottom: 12px;">Stack "${escapeHtml(y.stackName)}" \u2014 Deployment Complete</div>`;$+='<div class="scroll-container" style="max-height: 350px;">';for(const k of y.results){const H=k.status==="deployed"||k.status==="created"?"\u2705":k.status==="exists"?"\u26A1":k.status==="skipped"?"\u23ED":"\u274C";$+='<div style="padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem;">',$+=`${H} <strong>${escapeHtml(k.name)}</strong> (${k.type}) \u2014 ${escapeHtml(k.status)}`,k.error&&($+=` <span style="color: var(--bad-fg);">${escapeHtml(k.error)}</span>`),k.subdomain&&($+=` \u2192 <code>${escapeHtml(k.subdomain)}</code>`),k.reason&&($+=` <span style="color: var(--muted);">(${escapeHtml(k.reason)})</span>`),$+="</div>"}$+="</div>",$+='<div class="weather-modal-buttons modal-footer-bar" style="margin-top: 16px;"><button id="compose-done-btn">Done</button></div>Line truncated
|
||||
<div class="weather-modal-buttons modal-footer-bar" style="margin-top: 16px;"><button id="compose-retry-btn">Back</button></div>`,document.getElementById("compose-retry-btn")?.addEventListener("click",()=>P("paste"))}finally{D.textContent="Deploy All",D.disabled=!1}})})(),(function(){injectModal("exec-modal",`<div id="exec-modal" class="weather-modal">
|
||||
</div>`);const b=document.getElementById("compose-import-modal"),h=document.getElementById("compose-import-btn"),j=document.getElementById("compose-cancel");wireModal(b,j);let m=null;function N(D){document.getElementById("compose-step-paste").style.display=D==="paste"?"":"none",document.getElementById("compose-step-preview").style.display=D==="preview"?"":"none",document.getElementById("compose-step-progress").style.display=D==="progress"?"":"none"}h?.addEventListener("click",()=>{N("paste"),m=null,document.getElementById("compose-yaml").value="",document.getElementById("compose-stack-name").value="",b?.classList.add("show")}),document.getElementById("compose-file-upload")?.addEventListener("change",D=>{const R=D.target.files[0];if(!R)return;const g=new FileReader;g.onload=()=>{document.getElementById("compose-yaml").value=g.result},g.readAsText(R)}),document.getElementById("compose-parse-btn")?.addEventListener("click",async()=>{const D=document.getElementById("compose-yaml").value.trim(),R=document.getElementById("compose-stack-name").value.trim()||"stack";if(!D){showNotification("Paste a docker-compose.yml","warning");return}const g=document.getElementById("compose-parse-btn"),L=g.textContent;g.textContent="Parsing...",g.disabled=!0;try{const k=await postJSON("/api/v1/apps/import-compose",{yaml:D,stackName:R});m=k,m.stackName=R,A(k),N("preview")}catch(k){showNotification("Parse failed: "+k.message,"error")}finally{g.textContent=L,g.disabled=!1}});function A(D){const R=document.getElementById("compose-preview-content");let g="";D.networks&&D.networks.length>0&&(g+=`<div style="margin-bottom: 12px; font-size: 0.82rem; color: var(--muted);">Networks: ${D.networks.map(L=>`<code>${escapeHtml(L)}</code>`).join(", ")}</div>`),D.volumes&&D.volumes.length>0&&(g+=`<div style="margin-bottom: 12px; font-size: 0.82rem; color: var(--muted);">Volumes: ${D.volumes.map(L=>`<code>${escapeHtml(L)}</code>`).join(", ")}</div>`),g+=`<div style="font-weight: 600; margin-bottom: 8px;">${D.services.length} service(s)</div>`,g+='<div class="scroll-container" style="max-height: 350px;">';for(const L of D.services){const k=L.skip?"var(--bad-fg)":"var(--border)";if(g+=`<div style="padding: 10px 14px; border: 1px solid ${k}; border-radius: 8px; margin-bottom: 8px; background: var(--bg);">`,g+=`<div style="font-weight: 600; font-size: 0.9rem;">${escapeHtml(L.name)}`,L.skip&&(g+=` <span style="color: var(--bad-fg); font-weight: 400; font-size: 0.78rem;">\u2014 skipped: ${escapeHtml(L.reason)}</span>`),g+="</div>",!L.skip&&(g+=`<div style="font-size: 0.8rem; color: var(--muted); margin-top: 4px;">Image: <code>${escapeHtml(L.image)}</code></div>`,L.ports?.length&&(g+=`<div style="font-size: 0.8rem; color: var(--muted);">Ports: ${L.ports.map(M=>`${M.host}:${M.container}`).join(", ")}</div>`),L.volumes?.length&&(g+=`<div style="font-size: 0.8rem; color: var(--muted);">Volumes: ${L.volumes.length}</div>`),Object.keys(L.environment||{}).length&&(g+=`<div style="font-size: 0.8rem; color: var(--muted);">Env vars: ${Object.keys(L.environment).length}</div>`),L.envFileWarning&&(g+=`<div style="font-size: 0.78rem; color: var(--bad-fg);">\u26A0 ${escapeHtml(L.envFileWarning)}</div>`),L.resources?.cpus||L.resources?.memory)){const M=[];L.resources.cpus&&M.push(`CPU: ${L.resources.cpus}`),L.resources.memory&&M.push(`Mem: ${L.resources.memory}MB`),g+=`<div style="font-size: 0.8rem; color: var(--muted);">Limits: ${M.join(", ")}</div>`}g+="</div>"}g+="</div>",R.innerHTML=g}document.getElementById("compose-back-btn")?.addEventListener("click",()=>N("paste")),document.getElementById("compose-deploy-btn")?.addEventListener("click",async()=>{if(!m)return;const D=document.getElementById("compose-deploy-btn");D.textContent="Deploying...",D.disabled=!0,N("progress");const R=document.getElementById("compose-progress-content");R.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Deploying services...</div>';try{const g=await postJSON("/api/v1/apps/deploy-compose",{services:m.services,networks:m.networks,stackName:m.stackName});let L=`<div style="font-weight: 600; margin-bottom: 12px;">Stack "${escapeHtml(g.stackName)}" \u2014 Deployment Complete</div>`;L+='<div class="scroll-container" style="max-height: 350px;">';for(const k of g.results){const M=k.status==="deployed"||k.status==="created"?"\u2705":k.status==="exists"?"\u26A1":k.status==="skipped"?"\u23ED":"\u274C";L+='<div style="padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem;">',L+=`${M} <strong>${escapeHtml(k.name)}</strong> (${k.type}) \u2014 ${escapeHtml(k.status)}`,k.error&&(L+=` <span style="color: var(--bad-fg);">${escapeHtml(k.error)}</span>`),k.subdomain&&(L+=` \u2192 <code>${escapeHtml(k.subdomain)}</code>`),k.reason&&(L+=` <span style="color: var(--muted);">(${escapeHtml(k.reason)})</span>`),L+="</div>"}L+="</div>",L+='<div class="weather-modal-buttons modal-footer-bar" style="margin-top: 16px;"><button id="compose-done-btn">Done</button></div>Line truncated
|
||||
<div class="weather-modal-buttons modal-footer-bar" style="margin-top: 16px;"><button id="compose-retry-btn">Back</button></div>`,document.getElementById("compose-retry-btn")?.addEventListener("click",()=>N("paste"))}finally{D.textContent="Deploy All",D.disabled=!1}})})(),(function(){injectModal("exec-modal",`<div id="exec-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 700px; max-width: 900px; padding-bottom: 0;">
|
||||
<h3 id="exec-title">Terminal</h3>
|
||||
<div id="exec-terminal" style="height: 420px; border-radius: 6px; overflow: hidden; background: #1e1e1e;"></div>
|
||||
@@ -1761,11 +1761,11 @@ Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification
|
||||
<button id="exec-close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("exec-modal"),E=document.getElementById("exec-terminal"),j=document.getElementById("exec-close");let h=null,P=null,A=null;function D(){if(P){try{P.close()}catch{}P=null}if(h){try{h.dispose()}catch{}h=null}A=null,E.innerHTML=""}function R(y,$){if(D(),document.getElementById("exec-title").textContent=`Terminal \u2014 ${$||y}`,x?.classList.add("show"),typeof Terminal>"u"){E.innerHTML='<div style="color: #f44; padding: 20px; font-family: monospace;">xterm.js not loaded</div>';return}h=new Terminal({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', 'Consolas', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#aeafad",selectionBackground:"#264f78"},scrollback:5e3}),typeof FitAddon<"u"&&(A=new FitAddon.FitAddon,h.loadAddon(A)),h.open(E),A&&setTimeout(()=>A.fit(),50);const k=location.protocol==="https:"?"wss:":"ws:";P=new WebSocket(`${k}//${location.host}/ws/exec/${encodeURIComponent(y)}`),P.binaryType="arraybuffer",P.onopen=()=>{if(h.writeln("\x1B[32mConnecting...\x1B[0m"),A){const T=A.proposeDimensions();T&&P.send(JSON.stringify({type:"resize",cols:T.cols,rows:T.rows}))}},P.onmessage=T=>{if(typeof T.data=="string"){try{const z=JSON.parse(T.data);if(z.type==="connected"){h.writeln(`\x1B[32mConnected (${z.shell})\x1B[0m\r
|
||||
`);return}if(z.type==="error"){h.writeln(`\x1B[31mError: ${z.message}\x1B[0m`);return}if(z.type==="exit"){h.writeln(`\r
|
||||
\x1B[33mSession ended.\x1B[0m`);return}}catch{}h.write(T.data)}else h.write(new Uint8Array(T.data))},P.onclose=()=>{h&&h.writeln(`\r
|
||||
\x1B[33mDisconnected.\x1B[0m`)},P.onerror=()=>{h&&h.writeln(`\r
|
||||
\x1B[31mConnection error.\x1B[0m`)},h.onData(T=>{P&&P.readyState===WebSocket.OPEN&&P.send(T)}),h.onResize(({cols:T,rows:z})=>{P&&P.readyState===WebSocket.OPEN&&P.send(JSON.stringify({type:"resize",cols:T,rows:z}))});const H=()=>{A&&A.fit()};window.addEventListener("resize",H),x._resizeHandler=H}j?.addEventListener("click",()=>{D(),x._resizeHandler&&window.removeEventListener("resize",x._resizeHandler),x?.classList.remove("show")}),x?.addEventListener("click",y=>{y.target===x&&(D(),x._resizeHandler&&window.removeEventListener("resize",x._resizeHandler),x?.classList.remove("show"))}),window.openExecModal=R})(),(function(){injectModal("audit-modal",`<div id="audit-modal" class="weather-modal">
|
||||
</div>`);const b=document.getElementById("exec-modal"),h=document.getElementById("exec-terminal"),j=document.getElementById("exec-close");let m=null,N=null,A=null;function D(){if(N){try{N.close()}catch{}N=null}if(m){try{m.dispose()}catch{}m=null}A=null,h.innerHTML=""}function R(g,L){if(D(),document.getElementById("exec-title").textContent=`Terminal \u2014 ${L||g}`,b?.classList.add("show"),typeof Terminal>"u"){h.innerHTML='<div style="color: #f44; padding: 20px; font-family: monospace;">xterm.js not loaded</div>';return}m=new Terminal({cursorBlink:!0,fontSize:14,fontFamily:"'Cascadia Code', 'Fira Code', 'Consolas', monospace",theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#aeafad",selectionBackground:"#264f78"},scrollback:5e3}),typeof FitAddon<"u"&&(A=new FitAddon.FitAddon,m.loadAddon(A)),m.open(h),A&&setTimeout(()=>A.fit(),50);const k=location.protocol==="https:"?"wss:":"ws:";N=new WebSocket(`${k}//${location.host}/ws/exec/${encodeURIComponent(g)}`),N.binaryType="arraybuffer",N.onopen=()=>{if(m.writeln("\x1B[32mConnecting...\x1B[0m"),A){const I=A.proposeDimensions();I&&N.send(JSON.stringify({type:"resize",cols:I.cols,rows:I.rows}))}},N.onmessage=I=>{if(typeof I.data=="string"){try{const $=JSON.parse(I.data);if($.type==="connected"){m.writeln(`\x1B[32mConnected (${$.shell})\x1B[0m\r
|
||||
`);return}if($.type==="error"){m.writeln(`\x1B[31mError: ${$.message}\x1B[0m`);return}if($.type==="exit"){m.writeln(`\r
|
||||
\x1B[33mSession ended.\x1B[0m`);return}}catch{}m.write(I.data)}else m.write(new Uint8Array(I.data))},N.onclose=()=>{m&&m.writeln(`\r
|
||||
\x1B[33mDisconnected.\x1B[0m`)},N.onerror=()=>{m&&m.writeln(`\r
|
||||
\x1B[31mConnection error.\x1B[0m`)},m.onData(I=>{N&&N.readyState===WebSocket.OPEN&&N.send(I)}),m.onResize(({cols:I,rows:$})=>{N&&N.readyState===WebSocket.OPEN&&N.send(JSON.stringify({type:"resize",cols:I,rows:$}))});const M=()=>{A&&A.fit()};window.addEventListener("resize",M),b._resizeHandler=M}j?.addEventListener("click",()=>{D(),b._resizeHandler&&window.removeEventListener("resize",b._resizeHandler),b?.classList.remove("show")}),b?.addEventListener("click",g=>{g.target===b&&(D(),b._resizeHandler&&window.removeEventListener("resize",b._resizeHandler),b?.classList.remove("show"))}),window.openExecModal=R})(),(function(){injectModal("audit-modal",`<div id="audit-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 950px; max-width: 1150px;">
|
||||
<h3>\u{1F4DC} Audit Log</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1811,7 +1811,7 @@ Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification
|
||||
<button id="audit-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("audit-modal"),E=document.getElementById("audit-log-btn"),j=document.getElementById("audit-cancel"),h=document.getElementById("audit-refresh-btn"),P=document.getElementById("audit-clear-btn"),A=document.getElementById("audit-filter"),D=document.getElementById("audit-outcome-filter"),R=document.getElementById("audit-since"),y=document.getElementById("audit-until"),$=document.getElementById("audit-log-container"),k=document.getElementById("audit-load-more");let H=0,T=null,z=0;const C=50;function M(S){if(!S)return null;const O=new Date(S);return isNaN(O.getTime())?null:O.toISOString()}async function b(S){try{S?(T&&T.abort(),T=new AbortController):(T&&T.abort(),T=new AbortController,H=0,z++,$.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading...</div>');const O=z,m=new URLSearchParams;m.set("limit",String(C)),m.set("offset",String(H));const f=A.value,B=D.value,w=M(R.value),L=M(y.value);f&&m.set("action",f),B&&m.set("outcome",B),w&&m.set("since",w),L&&m.set("until",L);const o=await fetch("/api/v1/audit-logs?"+m.toString(),{signal:T.signal});if(!o.ok){$.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: HTTP ${o.status}</div>`,k.style.display="none";return}const u=await o.json();if(!u.success){$.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(u.error||"unknown")}</div>`,k.style.display="none";return}if(!S&&O!==z)return;const l=Array.isArray(u.entries)?u.entries:[];if(l.length===0&&!S){const p=u.filters&&(u.filters.action||u.filters.outcome||u.filters.since||u.filters.until)?"No entries match your filters.":"No audit log entries yet. Actions will be logged automatically.";$.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4DC}</span>${escapeHtml(p)}</div>`,k.style.display="none";return}let g="";S||(g='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',g+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);">',g+='<th style="padding: 6px; text-align: left;">When</th>',g+='<th style="padding: 6px; text-align: left;">Actor</th>',g+='<th style="padding: 6px; text-align: left;">IP</th>',g+='<th style="padding: 6px; text-align: left;">Action</th>',g+='<th style="padding: 6px; text-align: left;">Resource</th>',g+='<th style="padding: 6px; text-align: left;">Result</th>',g+="</tr>");for(const p of l){const t=p.outcome==="success",e=d(p);g+='<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" class="audit-row">',g+=`<td style="padding: 6px; color: var(--muted);" title="${escapeHtml(p.timestamp||"")}">${timeAgo(p.timestamp)}</td>`,g+=`<td style="padding: 6px; font-size: 0.78rem;">${e}</td>`,g+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(p.ip||"-")}</td>`,g+=`<td style="padding: 6px; font-weight: 500;">${escapeHtml(p.action||"-")}</td>`,g+=`<td style="padding: 6px;">${escapeHtml(p.resource||"-")}</td>`,g+=`<td style="padding: 6px;"><span style="color: ${t?"var(--ok-fg)":"var(--bad-fg)"};">${t?"\u2713":"\u2717"} ${escapeHtml(p.outcome||"")}</span></td>`,g+="</tr>",p.details&&Object.keys(p.details).length>0&&(g+=`<tr class="audit-detail" style="display: none;"><td colspan="6" style="padding: 6px 6px 10px; font-size: 0.78rem; color: var(--muted);"><pre style="margin: 0; white-space: pre-wrap; font-family: monospace;">${escapeHtml(JSON.stringify(p.details,null,2))}</pre></td></tr>`)}if(!S)g+="</table>",$.innerHTML=g;else{const p=$.querySelector("table");p&&p.insertAdjacentHTML("beforeend",g)}H+=l.length,k.style.display=u.hasMore?"":"none",$.querySelectorAll(".audit-row").forEach(p=>{p.dataset.wired||(p.dataset.wired="true",p.addEventListener("click",()=>{const t=p.nextElementSibling;t&&t.classList.contains("audit-detail")&&(t.style.display=t.style.display==="none"?"":"none")}))})}catch(O){if(O&&O.name==="AbortError")return;$.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(O.message)}</div>`}}function d(S){const O=S.details||{},m=O.userEmail,f=O.userId,B=O.userRole,w=O.viaProvider;if(m){const L=B?` <span style="color: var(--muted); font-size: 0.72rem;">[${escapeHtml(B)}${w?"/"+escapeHtml(w):""}]</span>`:"";return`${escapeHtml(m)}${L}`}return f?`<span style="font-family: monospace; color: var(--muted);">${escapeHtml(f)}</span>`:S.ip?'<span style="color: var(--muted);">anon</span>':'<span style="color: var(--muted);">system</span>'}E?.addEventListener("click",()=>{x?.classList.add("show"),b(!1)}),wireModal(x,j),h?.addEventListener("click",()=>b(!1)),A?.addEventListener("change",()=>b(!1)),D?.addEventListener("change",()=>b(!1));let v;[R,y].forEach(S=>{S?.addEventListener("change",()=>{clearTimeout(v),v=setTimeout(()=>b(!1),250)})}),k?.addEventListener("click",()=>b(!0)),P?.addEventListener("click",async()=>{if(confirm("Clear the entire audit log? This cannot be undone."))try{const O=await(await secureFetch("/api/v1/audit-logs",{method:"DELETE"Line truncated
|
||||
</div>`);const b=document.getElementById("audit-modal"),h=document.getElementById("audit-log-btn"),j=document.getElementById("audit-cancel"),m=document.getElementById("audit-refresh-btn"),N=document.getElementById("audit-clear-btn"),A=document.getElementById("audit-filter"),D=document.getElementById("audit-outcome-filter"),R=document.getElementById("audit-since"),g=document.getElementById("audit-until"),L=document.getElementById("audit-log-container"),k=document.getElementById("audit-load-more");let M=0,I=null,$=0;const E=50;function T(z){if(!z)return null;const O=new Date(z);return isNaN(O.getTime())?null:O.toISOString()}async function P(z){try{z?(I&&I.abort(),I=new AbortController):(I&&I.abort(),I=new AbortController,M=0,$++,L.innerHTML='<div class="panel-empty"><span class="brand-spinner"></span> Loading...</div>');const O=$,u=new URLSearchParams;u.set("limit",String(E)),u.set("offset",String(M));const y=A.value,C=D.value,w=T(R.value),S=T(g.value);y&&u.set("action",y),C&&u.set("outcome",C),w&&u.set("since",w),S&&u.set("until",S);const i=await fetch("/api/v1/audit-logs?"+u.toString(),{signal:I.signal});if(!i.ok){L.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: HTTP ${i.status}</div>`,k.style.display="none";return}const p=await i.json();if(!p.success){L.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(p.error||"unknown")}</div>`,k.style.display="none";return}if(!z&&O!==$)return;const l=Array.isArray(p.entries)?p.entries:[];if(l.length===0&&!z){const c=p.filters&&(p.filters.action||p.filters.outcome||p.filters.since||p.filters.until)?"No entries match your filters.":"No audit log entries yet. Actions will be logged automatically.";L.innerHTML=`<div class="panel-empty"><span class="empty-icon">\u{1F4DC}</span>${escapeHtml(c)}</div>`,k.style.display="none";return}let f="";z||(f='<table style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">',f+='<tr style="border-bottom: 1px solid var(--border); color: var(--muted);">',f+='<th style="padding: 6px; text-align: left;">When</th>',f+='<th style="padding: 6px; text-align: left;">Actor</th>',f+='<th style="padding: 6px; text-align: left;">IP</th>',f+='<th style="padding: 6px; text-align: left;">Action</th>',f+='<th style="padding: 6px; text-align: left;">Resource</th>',f+='<th style="padding: 6px; text-align: left;">Result</th>',f+="</tr>");for(const c of l){const n=c.outcome==="success",t=v(c);f+='<tr style="border-bottom: 1px solid var(--border); cursor: pointer;" class="audit-row">',f+=`<td style="padding: 6px; color: var(--muted);" title="${escapeHtml(c.timestamp||"")}">${timeAgo(c.timestamp)}</td>`,f+=`<td style="padding: 6px; font-size: 0.78rem;">${t}</td>`,f+=`<td style="padding: 6px; font-family: monospace; font-size: 0.78rem;">${escapeHtml(c.ip||"-")}</td>`,f+=`<td style="padding: 6px; font-weight: 500;">${escapeHtml(c.action||"-")}</td>`,f+=`<td style="padding: 6px;">${escapeHtml(c.resource||"-")}</td>`,f+=`<td style="padding: 6px;"><span style="color: ${n?"var(--ok-fg)":"var(--bad-fg)"};">${n?"\u2713":"\u2717"} ${escapeHtml(c.outcome||"")}</span></td>`,f+="</tr>",c.details&&Object.keys(c.details).length>0&&(f+=`<tr class="audit-detail" style="display: none;"><td colspan="6" style="padding: 6px 6px 10px; font-size: 0.78rem; color: var(--muted);"><pre style="margin: 0; white-space: pre-wrap; font-family: monospace;">${escapeHtml(JSON.stringify(c.details,null,2))}</pre></td></tr>`)}if(!z)f+="</table>",L.innerHTML=f;else{const c=L.querySelector("table");c&&c.insertAdjacentHTML("beforeend",f)}M+=l.length,k.style.display=p.hasMore?"":"none",L.querySelectorAll(".audit-row").forEach(c=>{c.dataset.wired||(c.dataset.wired="true",c.addEventListener("click",()=>{const n=c.nextElementSibling;n&&n.classList.contains("audit-detail")&&(n.style.display=n.style.display==="none"?"":"none")}))})}catch(O){if(O&&O.name==="AbortError")return;L.innerHTML=`<div class="panel-empty" style="color: var(--bad-fg);">Failed: ${escapeHtml(O.message)}</div>`}}function v(z){const O=z.details||{},u=O.userEmail,y=O.userId,C=O.userRole,w=O.viaProvider;if(u){const S=C?` <span style="color: var(--muted); font-size: 0.72rem;">[${escapeHtml(C)}${w?"/"+escapeHtml(w):""}]</span>`:"";return`${escapeHtml(u)}${S}`}return y?`<span style="font-family: monospace; color: var(--muted);">${escapeHtml(y)}</span>`:z.ip?'<span style="color: var(--muted);">anon</span>':'<span style="color: var(--muted);">system</span>'}h?.addEventListener("click",()=>{b?.classList.add("show"),P(!1)}),wireModal(b,j),m?.addEventListener("click",()=>P(!1)),A?.addEventListener("change",()=>P(!1)),D?.addEventListener("change",()=>P(!1));let B;[R,g].forEach(z=>{z?.addEventListener("change",()=>{clearTimeout(B),B=setTimeout(()=>P(!1),250)})}),k?.addEventListener("click",()=>P(!0)),N?.addEventListener("click",async()=>{if(confirm("Clear the entire audit log? This cannot be undone."))try{const O=await(await secureFetch("/api/v1/audit-logs",{method:"DELETE"Line truncated
|
||||
<div class="weather-modal-content" style="min-width: 980px; max-width: 1280px;">
|
||||
<h3>\u{1F6E1}\uFE0F Security Center</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -1890,39 +1890,39 @@ Enter version to rollback to:`);if(!s)return;if(!e.includes(s)){showNotification
|
||||
<button id="sec-cancel">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("security-modal"),E=document.getElementById("security-center-btn"),j=document.getElementById("sec-cancel"),h=x.querySelectorAll(".sec-tab"),P=x.querySelectorAll(".sec-panel");let A=[],D=[],R=null;h.forEach(o=>{o.addEventListener("click",()=>{h.forEach(u=>u.classList.toggle("active",u===o)),P.forEach(u=>u.style.display=u.dataset.panel===o.dataset.tab?"":"none"),o.dataset.tab==="overview"&&H(),o.dataset.tab==="events"&&v(),o.dataset.tab==="hosts"&&f()})}),E&&E.addEventListener("click",()=>{x.classList.add("show"),H(),$()}),j.addEventListener("click",y),x.addEventListener("click",o=>{o.target===x&&y()});function y(){x.classList.remove("show"),k()}function $(){if(k(),!!document.getElementById("sec-live-tail").checked&&!(typeof EventSource>"u"))try{R=new EventSource("/api/v1/security/events/stream"),R.addEventListener("init",o=>{try{A=JSON.parse(o.data).events||[],S()}catch{}}),R.addEventListener("security",o=>{try{const u=JSON.parse(o.data);A.unshift(u),A.length>500&&(A.length=500);const l=x.querySelector(".sec-tab.active")?.dataset?.tab;l==="events"?S():l==="overview"&&H()}catch{}}),R.onerror=()=>{}}catch(o){console.warn("[security] SSE failed:",o.message)}}function k(){if(R){try{R.close()}catch{}R=null}}document.getElementById("sec-live-tail").addEventListener("change",()=>{x.classList.contains("show")&&$()});async function H(){try{const o=new Date(Date.now()-864e5).toISOString(),[u,l,g]=await Promise.all([fetch(`/api/v1/security/events/stats?since=${encodeURIComponent(o)}`),fetch("/api/v1/security/hosts"),fetch(`/api/v1/security/events?limit=1&since=${encodeURIComponent(o)}`)]),p=(await u.json()).data||{},t=(await l.json()).data?.hosts||[],e=(await g.json()).data?.total||0;document.querySelector('#sec-stats [data-key="total"]').textContent=`${e} events (24h)`,document.querySelector('#sec-stats [data-key="warn"]').textContent=`${p.by_severity?.warn||0} warnings`,document.querySelector('#sec-stats [data-key="error"]').textContent=`${p.by_severity?.error||0} errors`,document.querySelector('#sec-stats [data-key="denied"]').textContent=`${p.by_outcome?.denied||0} denied`,document.querySelector('#sec-stats [data-key="hosts"]').textContent=`${t.length} hosts`,T("sec-top-actors",p.top_actors||[]),T("sec-top-targets",p.top_targets||[])}catch(o){console.warn("[security] refreshOverview failed:",o.message)}}function T(o,u){const l=document.getElementById(o);if(!u.length){l.innerHTML='<div class="panel-empty">No data</div>';return}l.innerHTML='<table style="width:100%;font-size:0.85rem;">'+u.map(g=>`<tr><td style="padding:3px 0;word-break:break-all;">${w(String(g.key))}</td><td style="text-align:right;color:var(--muted);">${g.count}</td></tr>`).join("")+"</table>"}const z=document.getElementById("sec-filter-source"),C=document.getElementById("sec-filter-severity"),M=document.getElementById("sec-filter-host"),b=document.getElementById("sec-filter-actor"),d=document.getElementById("sec-refresh-btn");[z,C,M].forEach(o=>o.addEventListener("change",v)),b.addEventListener("input",L(v,250)),d.addEventListener("click",v);async function v(){try{const o=new URLSearchParams;o.set("limit","200"),z.value&&o.set("source_type",z.value),C.value&&o.set("severity",C.value),M.value&&o.set("source_host",M.value),b.value&&o.set("actor_prefix",b.value),A=(await(await fetch(`/api/v1/security/events?${o}`)).json()).data.events||[],S(),(!M.options.length||M.options.length===1)&&await m()}catch(o){document.getElementById("sec-events-container").innerHTML='<div class="panel-empty">Load failed: '+w(o.message)+"</div>"}}function S(){const o=document.getElementById("sec-events-container");if(!A.length){o.innerHTML='<div class="panel-empty">No events</div>';return}o.innerHTML=A.slice(0,200).map(O).join("")}function O(o){const u=o.severity||"info",l={critical:"#c0392b",error:"#e74c3c",warn:"#f39c12",notice:"#3498db",info:"#7f8c8d"}[u]||"#7f8c8d",g=o.ts?new Date(o.ts).toLocaleTimeString():"",p=o.source_type||"",t=o.actor||"\u2014",e=o.target||"",s=o.action||"",n=o.outcome||"";return`<div class="sec-event-row" style="display:grid;grid-template-columns:84px 80px 1fr 1fr 100px 90px;gap:8px;padding:5px 8px;border-bottom:1px solid var(--border);font-size:0.82rem;align-items:center;">
|
||||
<span style="color:${l};font-weight:600;">${w(u)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;">${w(p)}</span>
|
||||
<span title="${w(t)}" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${w(t)}</span>
|
||||
<span title="${w(e)}" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${w(s)} ${w(e)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;">${w(n)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;text-align:right;">${w(g)}</span>
|
||||
</div>`}async function m(){try{const u=(await(await fetch("/api/v1/security/hosts")).json()).data?.hosts||[],l=M.value;M.innerHTML='<option value="">All hosts</option>'+u.map(g=>`<option value="${w(g.id)}">${w(g.label||g.id)}</option>`).join(""),l&&(M.value=l)}catch{}}document.getElementById("sec-host-register-btn").addEventListener("click",B),document.getElementById("sec-hosts-refresh").addEventListener("click",f);async function f(){try{const u=(await(await fetch("/api/v1/security/hosts")).json()).data?.hosts||[];D=u;const l=document.getElementById("sec-hosts-container");if(!u.length){l.innerHTML='<div class="panel-empty">No hosts registered. Click \u2795 Register Host to add one.</div>';return}l.innerHTML=u.map(g=>{const p=g.enabled?g.last_seen_at?Date.now()-Date.parse(g.last_seen_at)>18e5?"\u{1F7E1} stale":"\u{1F7E2} online":"\u26AA registered":"\u{1F534} disabled";return`<div style="padding:10px 12px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center;">
|
||||
</div>`);const b=document.getElementById("security-modal"),h=document.getElementById("security-center-btn"),j=document.getElementById("sec-cancel"),m=b.querySelectorAll(".sec-tab"),N=b.querySelectorAll(".sec-panel");let A=[],D=[],R=null;m.forEach(i=>{i.addEventListener("click",()=>{m.forEach(p=>p.classList.toggle("active",p===i)),N.forEach(p=>p.style.display=p.dataset.panel===i.dataset.tab?"":"none"),i.dataset.tab==="overview"&&M(),i.dataset.tab==="events"&&B(),i.dataset.tab==="hosts"&&y()})}),h&&h.addEventListener("click",()=>{b.classList.add("show"),M(),L()}),j.addEventListener("click",g),b.addEventListener("click",i=>{i.target===b&&g()});function g(){b.classList.remove("show"),k()}function L(){if(k(),!!document.getElementById("sec-live-tail").checked&&!(typeof EventSource>"u"))try{R=new EventSource("/api/v1/security/events/stream"),R.addEventListener("init",i=>{try{A=JSON.parse(i.data).events||[],z()}catch{}}),R.addEventListener("security",i=>{try{const p=JSON.parse(i.data);A.unshift(p),A.length>500&&(A.length=500);const l=b.querySelector(".sec-tab.active")?.dataset?.tab;l==="events"?z():l==="overview"&&M()}catch{}}),R.onerror=()=>{}}catch(i){console.warn("[security] SSE failed:",i.message)}}function k(){if(R){try{R.close()}catch{}R=null}}document.getElementById("sec-live-tail").addEventListener("change",()=>{b.classList.contains("show")&&L()});async function M(){try{const i=new Date(Date.now()-864e5).toISOString(),[p,l,f]=await Promise.all([fetch(`/api/v1/security/events/stats?since=${encodeURIComponent(i)}`),fetch("/api/v1/security/hosts"),fetch(`/api/v1/security/events?limit=1&since=${encodeURIComponent(i)}`)]),c=(await p.json()).data||{},n=(await l.json()).data?.hosts||[],t=(await f.json()).data?.total||0;document.querySelector('#sec-stats [data-key="total"]').textContent=`${t} events (24h)`,document.querySelector('#sec-stats [data-key="warn"]').textContent=`${c.by_severity?.warn||0} warnings`,document.querySelector('#sec-stats [data-key="error"]').textContent=`${c.by_severity?.error||0} errors`,document.querySelector('#sec-stats [data-key="denied"]').textContent=`${c.by_outcome?.denied||0} denied`,document.querySelector('#sec-stats [data-key="hosts"]').textContent=`${n.length} hosts`,I("sec-top-actors",c.top_actors||[]),I("sec-top-targets",c.top_targets||[])}catch(i){console.warn("[security] refreshOverview failed:",i.message)}}function I(i,p){const l=document.getElementById(i);if(!p.length){l.innerHTML='<div class="panel-empty">No data</div>';return}l.innerHTML='<table style="width:100%;font-size:0.85rem;">'+p.map(f=>`<tr><td style="padding:3px 0;word-break:break-all;">${w(String(f.key))}</td><td style="text-align:right;color:var(--muted);">${f.count}</td></tr>`).join("")+"</table>"}const $=document.getElementById("sec-filter-source"),E=document.getElementById("sec-filter-severity"),T=document.getElementById("sec-filter-host"),P=document.getElementById("sec-filter-actor"),v=document.getElementById("sec-refresh-btn");[$,E,T].forEach(i=>i.addEventListener("change",B)),P.addEventListener("input",S(B,250)),v.addEventListener("click",B);async function B(){try{const i=new URLSearchParams;i.set("limit","200"),$.value&&i.set("source_type",$.value),E.value&&i.set("severity",E.value),T.value&&i.set("source_host",T.value),P.value&&i.set("actor_prefix",P.value),A=(await(await fetch(`/api/v1/security/events?${i}`)).json()).data.events||[],z(),(!T.options.length||T.options.length===1)&&await u()}catch(i){document.getElementById("sec-events-container").innerHTML='<div class="panel-empty">Load failed: '+w(i.message)+"</div>"}}function z(){const i=document.getElementById("sec-events-container");if(!A.length){i.innerHTML='<div class="panel-empty">No events</div>';return}i.innerHTML=A.slice(0,200).map(O).join("")}function O(i){const p=i.severity||"info",l={critical:"#c0392b",error:"#e74c3c",warn:"#f39c12",notice:"#3498db",info:"#7f8c8d"}[p]||"#7f8c8d",f=i.ts?new Date(i.ts).toLocaleTimeString():"",c=i.source_type||"",n=i.actor||"\u2014",t=i.target||"",r=i.action||"",e=i.outcome||"";return`<div class="sec-event-row" style="display:grid;grid-template-columns:84px 80px 1fr 1fr 100px 90px;gap:8px;padding:5px 8px;border-bottom:1px solid var(--border);font-size:0.82rem;align-items:center;">
|
||||
<span style="color:${l};font-weight:600;">${w(p)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;">${w(c)}</span>
|
||||
<span title="${w(n)}" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${w(n)}</span>
|
||||
<span title="${w(t)}" style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${w(r)} ${w(t)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;">${w(e)}</span>
|
||||
<span style="color:var(--muted);font-size:0.75rem;text-align:right;">${w(f)}</span>
|
||||
</div>`}async function u(){try{const p=(await(await fetch("/api/v1/security/hosts")).json()).data?.hosts||[],l=T.value;T.innerHTML='<option value="">All hosts</option>'+p.map(f=>`<option value="${w(f.id)}">${w(f.label||f.id)}</option>`).join(""),l&&(T.value=l)}catch{}}document.getElementById("sec-host-register-btn").addEventListener("click",C),document.getElementById("sec-hosts-refresh").addEventListener("click",y);async function y(){try{const p=(await(await fetch("/api/v1/security/hosts")).json()).data?.hosts||[];D=p;const l=document.getElementById("sec-hosts-container");if(!p.length){l.innerHTML='<div class="panel-empty">No hosts registered. Click \u2795 Register Host to add one.</div>';return}l.innerHTML=p.map(f=>{const c=f.enabled?f.last_seen_at?Date.now()-Date.parse(f.last_seen_at)>18e5?"\u{1F7E1} stale":"\u{1F7E2} online":"\u26AA registered":"\u{1F534} disabled";return`<div style="padding:10px 12px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center;">
|
||||
<div>
|
||||
<strong>${w(g.label||g.id)}</strong>
|
||||
<span style="color:var(--muted);margin-left:8px;font-size:0.8rem;">${w(g.type)}</span>
|
||||
<strong>${w(f.label||f.id)}</strong>
|
||||
<span style="color:var(--muted);margin-left:8px;font-size:0.8rem;">${w(f.type)}</span>
|
||||
<div style="color:var(--muted);font-size:0.78rem;margin-top:2px;">
|
||||
id: ${w(g.id)} \xB7
|
||||
registered ${new Date(g.registered_at).toLocaleDateString()} \xB7
|
||||
last seen ${g.last_seen_at?new Date(g.last_seen_at).toLocaleString():"never"}
|
||||
id: ${w(f.id)} \xB7
|
||||
registered ${new Date(f.registered_at).toLocaleDateString()} \xB7
|
||||
last seen ${f.last_seen_at?new Date(f.last_seen_at).toLocaleString():"never"}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<span style="font-size:0.85rem;margin-right:12px;">${p}</span>
|
||||
${g.id==="self"?"":`<button class="btn-sm sec-host-del" data-id="${w(g.id)}" style="color:var(--bad-fg);">Remove</button>`}
|
||||
<span style="font-size:0.85rem;margin-right:12px;">${c}</span>
|
||||
${f.id==="self"?"":`<button class="btn-sm sec-host-del" data-id="${w(f.id)}" style="color:var(--bad-fg);">Remove</button>`}
|
||||
</div>
|
||||
</div>`}).join(""),l.querySelectorAll(".sec-host-del").forEach(g=>{g.addEventListener("click",async()=>{confirm(`Remove host ${g.dataset.id}? Events already received will remain in the store.`)&&(await fetch(`/api/v1/security/hosts/${encodeURIComponent(g.dataset.id)}`,{method:"DELETE"}),f())})})}catch(o){document.getElementById("sec-hosts-container").innerHTML='<div class="panel-empty">Load failed: '+w(o.message)+"</div>"}}async function B(){const o=prompt("Host id (lowercase, no spaces):");if(!o)return;const u=prompt("Display label:",o)||o,l=prompt('Type ("dashcaddy", "service", or "agent"):',"agent")||"agent";try{const g=await fetch("/api/v1/security/hosts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:o,label:u,type:l})}),p=await g.json();if(!g.ok){alert("Failed: "+(p?.error?.message||g.statusText));return}alert(`\u2705 Host registered!
|
||||
</div>`}).join(""),l.querySelectorAll(".sec-host-del").forEach(f=>{f.addEventListener("click",async()=>{confirm(`Remove host ${f.dataset.id}? Events already received will remain in the store.`)&&(await fetch(`/api/v1/security/hosts/${encodeURIComponent(f.dataset.id)}`,{method:"DELETE"}),y())})})}catch(i){document.getElementById("sec-hosts-container").innerHTML='<div class="panel-empty">Load failed: '+w(i.message)+"</div>"}}async function C(){const i=prompt("Host id (lowercase, no spaces):");if(!i)return;const p=prompt("Display label:",i)||i,l=prompt('Type ("dashcaddy", "service", or "agent"):',"agent")||"agent";try{const f=await fetch("/api/v1/security/hosts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:i,label:p,type:l})}),c=await f.json();if(!f.ok){alert("Failed: "+(c?.error?.message||f.statusText));return}alert(`\u2705 Host registered!
|
||||
|
||||
id: ${p.data.host.id}
|
||||
label: ${p.data.host.label}
|
||||
type: ${p.data.host.type}
|
||||
id: ${c.data.host.id}
|
||||
label: ${c.data.host.label}
|
||||
type: ${c.data.host.type}
|
||||
|
||||
\u{1F511} API KEY (save this NOW \u2014 won't be shown again):
|
||||
|
||||
${p.data.api_key}
|
||||
${c.data.api_key}
|
||||
|
||||
Send this key as: Authorization: Bearer <api_key>
|
||||
To endpoint: POST /api/v1/security/events/ingest or /events/batch`),f()}catch(g){alert("Failed: "+g.message)}}function w(o){return String(o).replace(/[&<>"']/g,u=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[u])}function L(o,u){let l;return function(){clearTimeout(l),l=setTimeout(()=>o.apply(this,arguments),u)}}})(),window.__dc133_buildRepoOptions=function(x,E){var j=E||function(h){return String(h).replace(/[&<>"']/g,function(P){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[P]})};return'<option value="">\u2014 choose a repo \u2014</option>'+(x||[]).map(function(h){return'<option value="'+j(h.url)+'" data-id="'+j(h.id)+'">'+j(h.full_name)+(h.description?" \u2014 "+j(h.description):"")+"</option>"}).join("")},window.__dc133_requestToken=function(x,E){if(x)return"";var j=String(E||"").trim();return j||void 0},(function(){injectModal("deploys-modal",`<div id="deploys-modal" class="weather-modal">
|
||||
To endpoint: POST /api/v1/security/events/ingest or /events/batch`),y()}catch(f){alert("Failed: "+f.message)}}function w(i){return String(i).replace(/[&<>"']/g,p=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[p])}function S(i,p){let l;return function(){clearTimeout(l),l=setTimeout(()=>i.apply(this,arguments),p)}}})(),window.__dc133_buildRepoOptions=function(b,h){var j=h||function(m){return String(m).replace(/[&<>"']/g,function(N){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[N]})};return'<option value="">\u2014 choose a repo \u2014</option>'+(b||[]).map(function(m){return'<option value="'+j(m.url)+'" data-id="'+j(m.id)+'">'+j(m.full_name)+(m.description?" \u2014 "+j(m.description):"")+"</option>"}).join("")},window.__dc133_requestToken=function(b,h){if(b)return"";var j=String(h||"").trim();return j||void 0},(function(){injectModal("deploys-modal",`<div id="deploys-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width: 860px; max-width: 1200px;">
|
||||
<h3>\u{1F69A} Deploys</h3>
|
||||
<p class="modal-subtitle">
|
||||
@@ -2006,16 +2006,16 @@ To endpoint: POST /api/v1/security/events/ingest or /events/batch`),f()}catch(g)
|
||||
<button class="btn" id="dep-close">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=b=>document.getElementById(b);let E=null,j=!1;function h(b){return window.escapeHtml?window.escapeHtml(String(b)):String(b).replace(/[&<>"']/g,d=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[d])}async function P(b,d){const v=await fetch("/dashcaddy-api/api/v1/deploys"+b,Object.assign({credentials:"include"},d||{}));let S=null;try{S=await v.json()}catch{S={success:!1,error:"non-JSON response"}}return{status:v.status,body:S}}function A(b){const d=x("dep-output");d.style.display="block",d.textContent=b||"(no output)",d.scrollTop=d.scrollHeight}async function D(){const b=x("dep-services"),{body:d}=await P("/services");if(!d.success){b.innerHTML="<em>"+h(d.error||"unavailable")+"</em>";return}const v=d.services||[];if(!v.length){b.innerHTML="<em>No shipdeck deployments on record yet.</em>";return}b.innerHTML='<table class="table" style="width:100%;"><thead><tr><th>Service</th><th>Last action</th><th>When</th><th>Release</th><th></th></tr></thead><tbody>'+v.map(S=>"<tr><td><strong>"+h(S.name)+"</strong></td><td>"+h(S.last_action)+"</td><td>"+h(S.last_time)+"</td><td>"+h(S.last_epoch)+'</td><td><button class="btn btn-sm dep-rollback" data-service="'+h(S.name)+'">Rollback</button> <button class="btn btn-sm dep-status" data-service="'+h(S.name)+'">Status</button></td></tr>').join("")+"</tbody></table>"}async function R(){const b=x("dep-repo-select"),{body:d}=await P("/repos");if(!d.success){b.innerHTML="<option>"+h(d.error||"unavailable")+"</option>";return}const v=d.repos||[];b.innerHTML=v.length?v.map(S=>'<option value="'+h(S.dir)+'">'+h(S.name)+"</option>").join(""):'<option value="">(no repos with a Shipdeckfile found)</option>'}async function y(b){const d=x("dep-journal"),v=b?"?service="+encodeURIComponent(b):"",{body:S}=await P("/journal"+v),O=S.rows||[];if(!O.length){d.innerHTML="<em>No journal rows.</em>";return}d.innerHTML='<table class="table" style="width:100%;"><thead><tr><th>Time</th><th>Service</th><th>Action</th><th>Release</th><th>Duration</th></tr></thead><tbody>'+O.map(m=>"<tr><td>"+h(m.time)+"</td><td>"+h(m.service)+"</td><td>"+h(m.action)+"</td><td>"+h(m.epoch)+"</td><td>"+h(m.duration||"\u2014")+"</td></tr>").join("")+"</tbody></table>"}async function $(){const b=document.getElementById("dep-gh-gitea"),d=document.getElementById("dep-gh-gitea-host"),v=document.getElementById("dep-gh-gitea-token"),S=document.getElementById("dep-gh-anonymous"),O={};if(d&&d.value.trim()&&(O.gitea_url="https://"+d.value.trim().replace(/^https?:\/*/,"")),S&&S.checked)O.token="";else{const m=window.__dc133_requestToken(!1,v&&v.value);m!==void 0&&(O.token=m)}try{const{status:m,body:f}=await P("/gitea-repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!f.success||!(f.repos||[]).length){b.innerHTML='<option value="">'+h(f.error||"no repos found")+"</option>";return}b.innerHTML=window.__dc133_buildRepoOptions(f.repos,h)}catch{b.innerHTML='<option value="">unavailable</option>'}}async function k(){const b=document.getElementById("dep-gh-btn"),d=document.getElementById("dep-gh-url").value.trim(),v=(document.getElementById("dep-gh-service").value.trim()||"").toLowerCase(),S=document.getElementById("dep-gh-args").value.trim();if(!d||!v){A("Repo URL and name are required.");return}const O=S?S.split(/\s+/):[];H(!0,b,"Install"),A("Installing "+d+`
|
||||
Cloning, building, gating and DNS-ing... (~30-60s)`);try{const m=!!(document.getElementById("dep-gh-anonymous")||{}).checked,f=(document.getElementById("dep-gh-gitea-token")||{value:""}).value,B=window.__dc133_requestToken(m,f),{status:w,body:L}=await P("/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo_url:d,service:v,args:O,token:B})});if(!L.success){A((L.output?L.output+`
|
||||
`:"")+"FAIL "+(L.error||"HTTP "+w)),H(!1,b,"Install");return}const o=L.service||{};if(!(window.APPS||[]).some(l=>l.id===o.id)){const l={id:o.id,name:o.name||o.id,url:o.url,logo:o.logo,tailscaleOnly:!0,isCustom:!0};try{await fetch("/dashcaddy-api/api/v1/services",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),window.APPS.push(l),typeof window.renderApps=="function"&&window.renderApps(),typeof window.renderGrid=="function"&&window.renderGrid()}catch{}}A("INSTALLED "+(o.name||o.id)+" in "+(o.deploy_seconds||"?")+`s
|
||||
Card: `+(o.url||"")+`
|
||||
`+(L.output||"").slice(-800)),D()}catch(m){A("install error: "+m.message)}H(!1,b,"Install")}function H(b,d,v){d&&(d.disabled=b,v&&(d.textContent=b?"Working\u2026":v))}async function T(){const b=x("dep-deploy-btn"),d=x("dep-repo-select").value;if(d){H(!0,b,"Deploy"),A("Deploying "+d+`
|
||||
This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:d})});A((v.output||v.error||"")+(v.success?`
|
||||
</div>`);const b=P=>document.getElementById(P);let h=null,j=!1;function m(P){return window.escapeHtml?window.escapeHtml(String(P)):String(P).replace(/[&<>"']/g,v=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[v])}async function N(P,v){const B=await fetch("/dashcaddy-api/api/v1/deploys"+P,Object.assign({credentials:"include"},v||{}));let z=null;try{z=await B.json()}catch{z={success:!1,error:"non-JSON response"}}return{status:B.status,body:z}}function A(P){const v=b("dep-output");v.style.display="block",v.textContent=P||"(no output)",v.scrollTop=v.scrollHeight}async function D(){const P=b("dep-services"),{body:v}=await N("/services");if(!v.success){P.innerHTML="<em>"+m(v.error||"unavailable")+"</em>";return}const B=v.services||[];if(!B.length){P.innerHTML="<em>No shipdeck deployments on record yet.</em>";return}P.innerHTML='<table class="table" style="width:100%;"><thead><tr><th>Service</th><th>Last action</th><th>When</th><th>Release</th><th></th></tr></thead><tbody>'+B.map(z=>"<tr><td><strong>"+m(z.name)+"</strong></td><td>"+m(z.last_action)+"</td><td>"+m(z.last_time)+"</td><td>"+m(z.last_epoch)+'</td><td><button class="btn btn-sm dep-rollback" data-service="'+m(z.name)+'">Rollback</button> <button class="btn btn-sm dep-status" data-service="'+m(z.name)+'">Status</button></td></tr>').join("")+"</tbody></table>"}async function R(){const P=b("dep-repo-select"),{body:v}=await N("/repos");if(!v.success){P.innerHTML="<option>"+m(v.error||"unavailable")+"</option>";return}const B=v.repos||[];P.innerHTML=B.length?B.map(z=>'<option value="'+m(z.dir)+'">'+m(z.name)+"</option>").join(""):'<option value="">(no repos with a Shipdeckfile found)</option>'}async function g(P){const v=b("dep-journal"),B=P?"?service="+encodeURIComponent(P):"",{body:z}=await N("/journal"+B),O=z.rows||[];if(!O.length){v.innerHTML="<em>No journal rows.</em>";return}v.innerHTML='<table class="table" style="width:100%;"><thead><tr><th>Time</th><th>Service</th><th>Action</th><th>Release</th><th>Duration</th></tr></thead><tbody>'+O.map(u=>"<tr><td>"+m(u.time)+"</td><td>"+m(u.service)+"</td><td>"+m(u.action)+"</td><td>"+m(u.epoch)+"</td><td>"+m(u.duration||"\u2014")+"</td></tr>").join("")+"</tbody></table>"}async function L(){const P=document.getElementById("dep-gh-gitea"),v=document.getElementById("dep-gh-gitea-host"),B=document.getElementById("dep-gh-gitea-token"),z=document.getElementById("dep-gh-anonymous"),O={};if(v&&v.value.trim()&&(O.gitea_url="https://"+v.value.trim().replace(/^https?:\/*/,"")),z&&z.checked)O.token="";else{const u=window.__dc133_requestToken(!1,B&&B.value);u!==void 0&&(O.token=u)}try{const{status:u,body:y}=await N("/gitea-repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!y.success||!(y.repos||[]).length){P.innerHTML='<option value="">'+m(y.error||"no repos found")+"</option>";return}P.innerHTML=window.__dc133_buildRepoOptions(y.repos,m)}catch{P.innerHTML='<option value="">unavailable</option>'}}async function k(){const P=document.getElementById("dep-gh-btn"),v=document.getElementById("dep-gh-url").value.trim(),B=(document.getElementById("dep-gh-service").value.trim()||"").toLowerCase(),z=document.getElementById("dep-gh-args").value.trim();if(!v||!B){A("Repo URL and name are required.");return}const O=z?z.split(/\s+/):[];M(!0,P,"Install"),A("Installing "+v+`
|
||||
Cloning, building, gating and DNS-ing... (~30-60s)`);try{const u=!!(document.getElementById("dep-gh-anonymous")||{}).checked,y=(document.getElementById("dep-gh-gitea-token")||{value:""}).value,C=window.__dc133_requestToken(u,y),{status:w,body:S}=await N("/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({repo_url:v,service:B,args:O,token:C})});if(!S.success){A((S.output?S.output+`
|
||||
`:"")+"FAIL "+(S.error||"HTTP "+w)),M(!1,P,"Install");return}const i=S.service||{};if(!(window.APPS||[]).some(l=>l.id===i.id)){const l={id:i.id,name:i.name||i.id,url:i.url,logo:i.logo,tailscaleOnly:!0,isCustom:!0};try{await fetch("/dashcaddy-api/api/v1/services",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),window.APPS.push(l),typeof window.renderApps=="function"&&window.renderApps(),typeof window.renderGrid=="function"&&window.renderGrid()}catch{}}A("INSTALLED "+(i.name||i.id)+" in "+(i.deploy_seconds||"?")+`s
|
||||
Card: `+(i.url||"")+`
|
||||
`+(S.output||"").slice(-800)),D()}catch(u){A("install error: "+u.message)}M(!1,P,"Install")}function M(P,v,B){v&&(v.disabled=P,B&&(v.textContent=P?"Working\u2026":B))}async function I(){const P=b("dep-deploy-btn"),v=b("dep-repo-select").value;if(v){M(!0,P,"Deploy"),A("Deploying "+v+`
|
||||
This can take ~30-60s\u2026`);try{const{body:B}=await N("/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:v})});A((B.output||B.error||"")+(B.success?`
|
||||
\u2705 SUCCESS`:`
|
||||
\u274C FAILED`)),D()}catch(v){A("deploy error: "+v.message)}H(!1,b,"Deploy")}}async function z(b,d){if(confirm("Roll back "+b+" to the previous release?")){H(!0,d,"Rollback"),A("Rolling back "+b+"\u2026");try{const{body:v}=await P("/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:b})});A((v.output||v.error||"")+(v.success?`
|
||||
\u274C FAILED`)),D()}catch(B){A("deploy error: "+B.message)}M(!1,P,"Deploy")}}async function $(P,v){if(confirm("Roll back "+P+" to the previous release?")){M(!0,v,"Rollback"),A("Rolling back "+P+"\u2026");try{const{body:B}=await N("/rollback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({service:P})});A((B.output||B.error||"")+(B.success?`
|
||||
\u2705 ROLLED BACK`:`
|
||||
\u274C FAILED`)),D()}catch(v){A("rollback error: "+v.message)}H(!1,d,"Rollback")}}async function C(b,d){H(!0,d,"Status");try{const{body:v}=await P("/status?service="+encodeURIComponent(b));A(v.output||v.error||"(no output)")}catch(v){A("status error: "+v.message)}H(!1,d,"Status")}function M(){E=document.getElementById("deploys-btn"),E&&(E.addEventListener("click",async()=>{x("deploys-modal").classList.add("open"),j||(j=!0,D(),R(),y(""),$())}),x("dep-close").addEventListener("click",()=>{x("deploys-modal").classList.remove("open")}),document.querySelectorAll(".dep-tab").forEach(b=>{b.addEventListener("click",()=>{document.querySelectorAll(".dep-tab").forEach(d=>d.classList.remove("active")),b.classList.add("active"),document.querySelectorAll("#deploys-modal .dep-panel").forEach(d=>{d.style.display=d.dataset.panel===b.dataset.tab?"block":"none"})})}),x("dep-deploy-btn").addEventListener("click",T),x("dep-gh-btn").addEventListener("click",k),["dep-gh-gitea-host","dep-gh-gitea-token"].forEach(b=>{const d=document.getElementById(b);d&&d.addEventListener("change",()=>$())}),document.getElementById("dep-gh-gitea").addEventListener("change",b=>{const d=b.target.value;if(d){document.getElementById("dep-gh-url").value=d;const v=b.target.selectedOptions[0],S=v&&v.dataset?v.dataset.id:"",O=document.getElementById("dep-gh-service");S&&!O.value&&(O.value=S)}}),x("dep-journal-btn").addEventListener("click",()=>y(x("dep-journal-name").value.trim())),x("dep-status-btn").addEventListener("click",()=>{const b=x("dep-status-name").value.trim();b&&C(b)}),x("dep-services").addEventListener("click",b=>{const d=b.target.closest(".dep-rollback");if(d)return z(d.dataset.service,d);const v=b.target.closest(".dep-status");if(v)return C(v.dataset.service,v)}))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M):M()})(),(function(){const x=new ErrorHandler;injectModal("weather-modal",`<div id="weather-modal" class="weather-modal"><div class="weather-modal-content"><h3>Weather Settings</h3>
|
||||
\u274C FAILED`)),D()}catch(B){A("rollback error: "+B.message)}M(!1,v,"Rollback")}}async function E(P,v){M(!0,v,"Status");try{const{body:B}=await N("/status?service="+encodeURIComponent(P));A(B.output||B.error||"(no output)")}catch(B){A("status error: "+B.message)}M(!1,v,"Status")}function T(){h=document.getElementById("deploys-btn"),h&&(h.addEventListener("click",async()=>{b("deploys-modal").classList.add("open"),j||(j=!0,D(),R(),g(""),L())}),b("dep-close").addEventListener("click",()=>{b("deploys-modal").classList.remove("open")}),document.querySelectorAll(".dep-tab").forEach(P=>{P.addEventListener("click",()=>{document.querySelectorAll(".dep-tab").forEach(v=>v.classList.remove("active")),P.classList.add("active"),document.querySelectorAll("#deploys-modal .dep-panel").forEach(v=>{v.style.display=v.dataset.panel===P.dataset.tab?"block":"none"})})}),b("dep-deploy-btn").addEventListener("click",I),b("dep-gh-btn").addEventListener("click",k),["dep-gh-gitea-host","dep-gh-gitea-token"].forEach(P=>{const v=document.getElementById(P);v&&v.addEventListener("change",()=>L())}),document.getElementById("dep-gh-gitea").addEventListener("change",P=>{const v=P.target.value;if(v){document.getElementById("dep-gh-url").value=v;const B=P.target.selectedOptions[0],z=B&&B.dataset?B.dataset.id:"",O=document.getElementById("dep-gh-service");z&&!O.value&&(O.value=z)}}),b("dep-journal-btn").addEventListener("click",()=>g(b("dep-journal-name").value.trim())),b("dep-status-btn").addEventListener("click",()=>{const P=b("dep-status-name").value.trim();P&&E(P)}),b("dep-services").addEventListener("click",P=>{const v=P.target.closest(".dep-rollback");if(v)return $(v.dataset.service,v);const B=P.target.closest(".dep-status");if(B)return E(B.dataset.service,B)}))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",T):T()})(),(function(){const b=new ErrorHandler;injectModal("weather-modal",`<div id="weather-modal" class="weather-modal"><div class="weather-modal-content"><h3>Weather Settings</h3>
|
||||
<label for="weather-location-input">Location:</label>
|
||||
<input type="text" id="weather-location-input" placeholder="City name or ZIP (e.g., Hamburg, 90210)" maxlength="100">
|
||||
<div style="font-size: 0.78rem; color: var(--muted); margin-top: 4px;">Enter a city name, postal code, or “City, Country”</div>
|
||||
@@ -2026,23 +2026,23 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
<label class="weather-unit-option"><input type="radio" name="weather-unit-radio" value="metric"><span class="weather-unit-card">°C / km/h</span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="weather-modal-buttons"><button id="weather-cancel">Cancel</button><button id="weather-save">Save</button></div></div></div>`);const E="weather-location",j="weather-zip",h="weather-geo",P="weather-unit";!safeGet(E)&&safeGet(j)&&safeSet(E,safeGet(j));function A(){return safeGet(P)||"imperial"}function D(){return{icon:document.querySelector(".weather-icon"),temp:document.querySelector(".weather-temp"),condition:document.querySelector(".weather-condition"),location:document.querySelector(".weather-location"),wind:document.querySelector(".weather-wind")}}const R={0:"Clear sky",1:"Mainly clear",2:"Partly cloudy",3:"Overcast",45:"Fog",48:"Rime fog",51:"Light drizzle",53:"Drizzle",55:"Dense drizzle",56:"Freezing drizzle",57:"Dense freezing drizzle",61:"Light rain",63:"Moderate rain",65:"Heavy rain",66:"Light freezing rain",67:"Heavy freezing rain",71:"Light snow",73:"Moderate snow",75:"Heavy snow",77:"Snow grains",80:"Light showers",81:"Moderate showers",82:"Violent showers",85:"Light snow showers",86:"Heavy snow showers",95:"Thunderstorm",96:"Thunderstorm with hail",99:"Severe thunderstorm"},y={0:"\u2600\uFE0F",1:"\u{1F324}\uFE0F",2:"\u26C5",3:"\u2601\uFE0F",45:"\u{1F32B}\uFE0F",48:"\u{1F32B}\uFE0F",51:"\u{1F326}\uFE0F",53:"\u{1F326}\uFE0F",55:"\u{1F326}\uFE0F",56:"\u{1F328}\uFE0F",57:"\u{1F328}\uFE0F",61:"\u{1F326}\uFE0F",63:"\u{1F327}\uFE0F",65:"\u{1F327}\uFE0F",66:"\u{1F328}\uFE0F",67:"\u{1F328}\uFE0F",71:"\u{1F328}\uFE0F",73:"\u2744\uFE0F",75:"\u2744\uFE0F",77:"\u2744\uFE0F",80:"\u{1F326}\uFE0F",81:"\u{1F327}\uFE0F",82:"\u{1F327}\uFE0F",85:"\u{1F328}\uFE0F",86:"\u2744\uFE0F",95:"\u26C8\uFE0F",96:"\u26C8\uFE0F",99:"\u26C8\uFE0F"},$=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];function k(d){return $[Math.round(d/22.5)%16]}async function H(d){const v=safeGet(h);if(v)try{const B=JSON.parse(v);if(B.query===d)return B}catch{}const S=await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(d)}&count=1&language=en&format=json`);if(!S.ok)throw new Error("Geocoding failed");const O=await S.json();if(!O.results||!O.results.length)throw new Error("Location not found");const m=O.results[0],f={query:d,lat:m.latitude,lon:m.longitude,city:m.name,state:m.admin1||"",country:m.country||"",countryCode:m.country_code||""};return safeSet(h,JSON.stringify(f)),f}function T(d){return d.countryCode==="US"&&d.state?`${d.city}, ${d.state}`:d.country?`${d.city}, ${d.country}`:d.city}async function z(d){try{const v=await H(d),S=A(),O=S==="metric"?"celsius":"fahrenheit",m=S==="metric"?"kmh":"mph",f=`https://api.open-meteo.com/v1/forecast?latitude=${v.lat}&longitude=${v.lon}¤t=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m&temperature_unit=${O}&wind_speed_unit=${m}`,B=await fetch(f);if(!B.ok)throw new Error("Weather fetch failed");const L=(await B.json()).current,o=L.weather_code;return{temp:Math.round(L.temperature_2m),condition:R[o]||"Unknown",icon:y[o]||"\u{1F324}\uFE0F",locationStr:T(v),windSpeed:Math.round(L.wind_speed_10m),windDir:k(L.wind_direction_10m),unit:S}}catch(v){return console.warn("Weather fetch failed:",v),null}}async function C(){const d=D();if(!d.icon||!d.temp||!d.condition||!d.location||!d.wind){console.warn("Weather widget elements not found");return}const v=safeGet(E);if(!v){d.location.textContent="Set Location",d.temp.textContent="--\xB0",d.condition.textContent="Click \u2699\uFE0F to configure",d.wind.textContent="--",d.icon.innerHTML='<span class="weather-emoji">\u{1F324}\uFE0F</span>';return}try{const S=await z(v);if(S){const O=S.unit==="metric"?"\xB0C":"\xB0F",m=S.unit==="metric"?"km/h":"mph";d.location.textContent=S.locationStr,d.temp.textContent=`${S.temp}${O}`,d.condition.textContent=S.condition,d.wind.textContent=`Wind: ${S.windSpeed} ${m} ${S.windDir}`,d.icon.innerHTML=`<span class="weather-emoji">${escapeHtml(S.icon)}</span>`}}catch(S){x.logError("[Weather] Update Error",S,{function:"updateWeather"}),d.location.textContent="Weather Error",d.temp.textContent="Error",d.condition.textContent="Failed to load",d.wind.textContent="--"}}const M=document.getElementById("weather-modal"),b=document.getElementById("weather-location-input");document.getElementById("weather-settings")?.addEventListener("click",()=>{b.value=safeGet(E)||"";const d=A(),v=M.querySelector(`input[name="weather-unit-radio"][value="${d}"]`);v&&(v.checked=!0),M.classList.add("show"),b.focus()}),document.getElementById("weather-cancel")?.addEventListener("click",()=>{M.classList.remove("show")}),document.getElementById("weather-save")?.addEventListener("click",()=>{const d=b.value.trim();if(d){safeGet(E)!==d&&safeSet(h,""),safeSet(E,d);const S=M.querySelector('input[name="weather-unit-radio"]:checked'),O=S?S.value:"imperial",m=A();safeSet(P,O),m!==O&&safeSet(h,""),M.classList.remove("show"),C()}else showNotification("Please enter a location (e.g., Hamburg, London, 90210)","warning")}),wireModal(M),document.addEventListener("keydown",d=>{d.keyLine truncated
|
||||
<circle cx="${i}" cy="${c}" r="58" fill="none" stroke="var(--border)" stroke-width="2"/>
|
||||
<div class="weather-modal-buttons"><button id="weather-cancel">Cancel</button><button id="weather-save">Save</button></div></div></div>`);const h="weather-location",j="weather-zip",m="weather-geo",N="weather-unit";!safeGet(h)&&safeGet(j)&&safeSet(h,safeGet(j));function A(){return safeGet(N)||"imperial"}function D(){return{icon:document.querySelector(".weather-icon"),temp:document.querySelector(".weather-temp"),condition:document.querySelector(".weather-condition"),location:document.querySelector(".weather-location"),wind:document.querySelector(".weather-wind")}}const R={0:"Clear sky",1:"Mainly clear",2:"Partly cloudy",3:"Overcast",45:"Fog",48:"Rime fog",51:"Light drizzle",53:"Drizzle",55:"Dense drizzle",56:"Freezing drizzle",57:"Dense freezing drizzle",61:"Light rain",63:"Moderate rain",65:"Heavy rain",66:"Light freezing rain",67:"Heavy freezing rain",71:"Light snow",73:"Moderate snow",75:"Heavy snow",77:"Snow grains",80:"Light showers",81:"Moderate showers",82:"Violent showers",85:"Light snow showers",86:"Heavy snow showers",95:"Thunderstorm",96:"Thunderstorm with hail",99:"Severe thunderstorm"},g={0:"\u2600\uFE0F",1:"\u{1F324}\uFE0F",2:"\u26C5",3:"\u2601\uFE0F",45:"\u{1F32B}\uFE0F",48:"\u{1F32B}\uFE0F",51:"\u{1F326}\uFE0F",53:"\u{1F326}\uFE0F",55:"\u{1F326}\uFE0F",56:"\u{1F328}\uFE0F",57:"\u{1F328}\uFE0F",61:"\u{1F326}\uFE0F",63:"\u{1F327}\uFE0F",65:"\u{1F327}\uFE0F",66:"\u{1F328}\uFE0F",67:"\u{1F328}\uFE0F",71:"\u{1F328}\uFE0F",73:"\u2744\uFE0F",75:"\u2744\uFE0F",77:"\u2744\uFE0F",80:"\u{1F326}\uFE0F",81:"\u{1F327}\uFE0F",82:"\u{1F327}\uFE0F",85:"\u{1F328}\uFE0F",86:"\u2744\uFE0F",95:"\u26C8\uFE0F",96:"\u26C8\uFE0F",99:"\u26C8\uFE0F"},L=["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];function k(v){return L[Math.round(v/22.5)%16]}async function M(v){const B=safeGet(m);if(B)try{const C=JSON.parse(B);if(C.query===v)return C}catch{}const z=await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(v)}&count=1&language=en&format=json`);if(!z.ok)throw new Error("Geocoding failed");const O=await z.json();if(!O.results||!O.results.length)throw new Error("Location not found");const u=O.results[0],y={query:v,lat:u.latitude,lon:u.longitude,city:u.name,state:u.admin1||"",country:u.country||"",countryCode:u.country_code||""};return safeSet(m,JSON.stringify(y)),y}function I(v){return v.countryCode==="US"&&v.state?`${v.city}, ${v.state}`:v.country?`${v.city}, ${v.country}`:v.city}async function $(v){try{const B=await M(v),z=A(),O=z==="metric"?"celsius":"fahrenheit",u=z==="metric"?"kmh":"mph",y=`https://api.open-meteo.com/v1/forecast?latitude=${B.lat}&longitude=${B.lon}¤t=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m&temperature_unit=${O}&wind_speed_unit=${u}`,C=await fetch(y);if(!C.ok)throw new Error("Weather fetch failed");const S=(await C.json()).current,i=S.weather_code;return{temp:Math.round(S.temperature_2m),condition:R[i]||"Unknown",icon:g[i]||"\u{1F324}\uFE0F",locationStr:I(B),windSpeed:Math.round(S.wind_speed_10m),windDir:k(S.wind_direction_10m),unit:z}}catch(B){return console.warn("Weather fetch failed:",B),null}}async function E(){const v=D();if(!v.icon||!v.temp||!v.condition||!v.location||!v.wind){console.warn("Weather widget elements not found");return}const B=safeGet(h);if(!B){v.location.textContent="Set Location",v.temp.textContent="--\xB0",v.condition.textContent="Click \u2699\uFE0F to configure",v.wind.textContent="--",v.icon.innerHTML='<span class="weather-emoji">\u{1F324}\uFE0F</span>';return}try{const z=await $(B);if(z){const O=z.unit==="metric"?"\xB0C":"\xB0F",u=z.unit==="metric"?"km/h":"mph";v.location.textContent=z.locationStr,v.temp.textContent=`${z.temp}${O}`,v.condition.textContent=z.condition,v.wind.textContent=`Wind: ${z.windSpeed} ${u} ${z.windDir}`,v.icon.innerHTML=`<span class="weather-emoji">${escapeHtml(z.icon)}</span>`}}catch(z){b.logError("[Weather] Update Error",z,{function:"updateWeather"}),v.location.textContent="Weather Error",v.temp.textContent="Error",v.condition.textContent="Failed to load",v.wind.textContent="--"}}const T=document.getElementById("weather-modal"),P=document.getElementById("weather-location-input");document.getElementById("weather-settings")?.addEventListener("click",()=>{P.value=safeGet(h)||"";const v=A(),B=T.querySelector(`input[name="weather-unit-radio"][value="${v}"]`);B&&(B.checked=!0),T.classList.add("show"),P.focus()}),document.getElementById("weather-cancel")?.addEventListener("click",()=>{T.classList.remove("show")}),document.getElementById("weather-save")?.addEventListener("click",()=>{const v=P.value.trim();if(v){safeGet(h)!==v&&safeSet(m,""),safeSet(h,v);const z=T.querySelector('input[name="weather-unit-radio"]:checked'),O=z?z.value:"imperial",u=A();safeSet(N,O),u!==O&&safeSet(m,""),T.classList.remove("show"),E()}else showNotification("Please enter a location (e.g., Hamburg, London, 90210)","warning")}),wireModal(T),document.addEventListener("keydown",v=>{v.keyLine truncated
|
||||
<circle cx="${s}" cy="${d}" r="58" fill="none" stroke="var(--border)" stroke-width="2"/>
|
||||
${F}
|
||||
${_}
|
||||
<line x1="${i}" y1="${c}" x2="${i+28*Math.cos(U*Math.PI/180)}" y2="${c+28*Math.sin(U*Math.PI/180)}" stroke="var(--fg)" stroke-width="3" stroke-linecap="round"/>
|
||||
<line x1="${i}" y1="${c}" x2="${i+38*Math.cos(N*Math.PI/180)}" y2="${c+38*Math.sin(N*Math.PI/180)}" stroke="var(--fg)" stroke-width="2" stroke-linecap="round"/>
|
||||
<line x1="${i}" y1="${c}" x2="${i+42*Math.cos(I*Math.PI/180)}" y2="${c+42*Math.sin(I*Math.PI/180)}" stroke="#e74c3c" stroke-width="1" stroke-linecap="round"/>
|
||||
<circle cx="${i}" cy="${c}" r="3" fill="var(--fg)"/>
|
||||
</svg>`,J=t.getHours()>=12?"PM":"AM";E.innerHTML=`<div class="analog-clock-wrap">${q}<div class="analog-info"><span class="analog-digital">${t.getHours()%12||12}:${String(n).padStart(2,"0")} ${J}</span><span class="analog-date-sm">${z(t)}</span></div></div>`,$="analog"}function f(){const t=new Date,e=t.getHours()%12||12,s=t.getMinutes(),n=t.getSeconds(),r="clock-widget"+(A!=="default"?" "+A:"");switch(x.className!==r&&(x.className=r),A){case"lcd":d(t);break;case"lcd-blue":d(t);break;case"lcd-amber":d(t);break;case"lcd-retro":d(t);break;case"lcd-taxi":d(t);break;case"flip":v(t);break;case"binary":O(t);break;case"analog":m(t,!1);break;case"roman":m(t,!0);break;default:b(t)}s===0&&n===0&&e!==D&&(D=e,T(e)),s!==0&&(D=-1)}function B(){clearTimeout(H);const t=document.hidden?6e4:1e3,e=t-Date.now()%t+25;H=setTimeout(()=>{f(),B()},e)}document.addEventListener("visibilitychange",()=>{y="",C(),f(),B()}),f(),B();const w=[{id:"default",label:"Default",icon:"\u{1F550}"},{id:"lcd",label:"LCD Green",icon:"\u{1F49A}"},{id:"lcd-blue",label:"LCD Blue",icon:"\u{1F499}"},{id:"lcd-amber",label:"LCD Amber",icon:"\u{1F7E0}"},{id:"lcd-retro",label:"LCD Retro",icon:"\u{1F7E9}"},{id:"lcd-taxi",label:"LCD Taxi",icon:"\u{1F7E1}"},{id:"flip",label:"Flip Clock",icon:"\u{1F4DF}"},{id:"binary",label:"Binary",icon:"\u{1F4BB}"},{id:"analog",label:"Analog",icon:"\u23F0"},{id:"roman",label:"Roman",icon:"\u{1F3DB}\uFE0F"}];let L='<div class="clock-style-grid">';w.forEach(t=>{L+=`<label class="clock-style-option">
|
||||
<input type="radio" name="clock-style-radio" value="${t.id}">
|
||||
<span class="clock-style-card"><span class="clock-style-icon">${t.icon}</span><span class="clock-style-label">${t.label}</span></span>
|
||||
</label>`}),L+="</div>",injectModal("clock-settings-modal",`<div id="clock-settings-modal" class="weather-modal">
|
||||
<line x1="${s}" y1="${d}" x2="${s+28*Math.cos(U*Math.PI/180)}" y2="${d+28*Math.sin(U*Math.PI/180)}" stroke="var(--fg)" stroke-width="3" stroke-linecap="round"/>
|
||||
<line x1="${s}" y1="${d}" x2="${s+38*Math.cos(H*Math.PI/180)}" y2="${d+38*Math.sin(H*Math.PI/180)}" stroke="var(--fg)" stroke-width="2" stroke-linecap="round"/>
|
||||
<line x1="${s}" y1="${d}" x2="${s+42*Math.cos(x*Math.PI/180)}" y2="${d+42*Math.sin(x*Math.PI/180)}" stroke="#e74c3c" stroke-width="1" stroke-linecap="round"/>
|
||||
<circle cx="${s}" cy="${d}" r="3" fill="var(--fg)"/>
|
||||
</svg>`,J=n.getHours()>=12?"PM":"AM";h.innerHTML=`<div class="analog-clock-wrap">${q}<div class="analog-info"><span class="analog-digital">${n.getHours()%12||12}:${String(e).padStart(2,"0")} ${J}</span><span class="analog-date-sm">${$(n)}</span></div></div>`,L="analog"}function y(){const n=new Date,t=n.getHours()%12||12,r=n.getMinutes(),e=n.getSeconds(),o="clock-widget"+(A!=="default"?" "+A:"");switch(b.className!==o&&(b.className=o),A){case"lcd":v(n);break;case"lcd-blue":v(n);break;case"lcd-amber":v(n);break;case"lcd-retro":v(n);break;case"lcd-taxi":v(n);break;case"flip":B(n);break;case"binary":O(n);break;case"analog":u(n,!1);break;case"roman":u(n,!0);break;default:P(n)}r===0&&e===0&&t!==D&&(D=t,I(t)),r!==0&&(D=-1)}function C(){clearTimeout(M);const n=document.hidden?6e4:1e3,t=n-Date.now()%n+25;M=setTimeout(()=>{y(),C()},t)}document.addEventListener("visibilitychange",()=>{g="",E(),y(),C()}),y(),C();const w=[{id:"default",label:"Default",icon:"\u{1F550}"},{id:"lcd",label:"LCD Green",icon:"\u{1F49A}"},{id:"lcd-blue",label:"LCD Blue",icon:"\u{1F499}"},{id:"lcd-amber",label:"LCD Amber",icon:"\u{1F7E0}"},{id:"lcd-retro",label:"LCD Retro",icon:"\u{1F7E9}"},{id:"lcd-taxi",label:"LCD Taxi",icon:"\u{1F7E1}"},{id:"flip",label:"Flip Clock",icon:"\u{1F4DF}"},{id:"binary",label:"Binary",icon:"\u{1F4BB}"},{id:"analog",label:"Analog",icon:"\u23F0"},{id:"roman",label:"Roman",icon:"\u{1F3DB}\uFE0F"}];let S='<div class="clock-style-grid">';w.forEach(n=>{S+=`<label class="clock-style-option">
|
||||
<input type="radio" name="clock-style-radio" value="${n.id}">
|
||||
<span class="clock-style-card"><span class="clock-style-icon">${n.icon}</span><span class="clock-style-label">${n.label}</span></span>
|
||||
</label>`}),S+="</div>",injectModal("clock-settings-modal",`<div id="clock-settings-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="max-width: 420px;">
|
||||
<h3>Clock Settings</h3>
|
||||
<div style="margin-bottom: 16px;">
|
||||
<label style="display: block; margin-bottom: 8px; font-weight: 600; color: var(--fg);">Style</label>
|
||||
${L}
|
||||
${S}
|
||||
</div>
|
||||
<div style="margin-bottom: 16px; padding-top: 12px; border-top: 1px solid var(--border);">
|
||||
<label style="display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--fg);">
|
||||
@@ -2066,13 +2066,19 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
<button id="clock-settings-save">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const o=document.getElementById("clock-settings-modal"),u=document.getElementById("clock-chimes-toggle"),l=document.getElementById("clock-chime-volume"),g=document.getElementById("clock-volume-section");function p(){const t=safeGet("clock-style")||"default",e=o.querySelector(`input[value="${t}"]`);e&&(e.checked=!0),u.checked=safeGet("clock-chimes")==="true",l.value=safeGet("clock-chime-volume")||"50",g.style.opacity=u.checked?"1":"0.4"}u?.addEventListener("change",()=>{g.style.opacity=u.checked?"1":"0.4"}),document.getElementById("clock-settings")?.addEventListener("click",()=>{p(),o.classList.add("show")}),document.getElementById("clock-chime-test")?.addEventListener("click",()=>{const t=parseInt(l.value,10)/100,e=new Audio("/assets/sounds/church-bell.mp3");e.volume=t,e.play().catch(()=>{})}),document.getElementById("clock-settings-save")?.addEventListener("click",()=>{const t=o.querySelector('input[name="clock-style-radio"]:checked'),e=t?t.value:"default";safeSet("clock-style",e),safeSet("clock-chimes",String(u.checked)),safeSet("clock-chime-volume",l.value),A=e,y="",C(),f(),B(),o.classList.remove("show"),showNotification("Clock settings saved","success",2e3)}),document.getElementById("clock-settings-cancel")?.addEventListener("click",()=>{o.classList.remove("show")}),wireModal(o),o?.querySelectorAll('input[name="clock-style-radio"]').forEach(t=>{t.addEventListener("change",()=>{A=t.value,y="",C(),f()})})})(),(function(){const x=new ErrorHandler;injectModal("calendar-modal",`<div id="calendar-modal" class="weather-modal">
|
||||
</div>`);const i=document.getElementById("clock-settings-modal"),p=document.getElementById("clock-chimes-toggle"),l=document.getElementById("clock-chime-volume"),f=document.getElementById("clock-volume-section");function c(){const n=safeGet("clock-style")||"default",t=i.querySelector(`input[value="${n}"]`);t&&(t.checked=!0),p.checked=safeGet("clock-chimes")==="true",l.value=safeGet("clock-chime-volume")||"50",f.style.opacity=p.checked?"1":"0.4"}p?.addEventListener("change",()=>{f.style.opacity=p.checked?"1":"0.4"}),document.getElementById("clock-settings")?.addEventListener("click",()=>{c(),i.classList.add("show")}),document.getElementById("clock-chime-test")?.addEventListener("click",()=>{const n=parseInt(l.value,10)/100,t=new Audio("/assets/sounds/church-bell.mp3");t.volume=n,t.play().catch(()=>{})}),document.getElementById("clock-settings-save")?.addEventListener("click",()=>{const n=i.querySelector('input[name="clock-style-radio"]:checked'),t=n?n.value:"default";safeSet("clock-style",t),safeSet("clock-chimes",String(p.checked)),safeSet("clock-chime-volume",l.value),A=t,g="",E(),y(),C(),i.classList.remove("show"),showNotification("Clock settings saved","success",2e3)}),document.getElementById("clock-settings-cancel")?.addEventListener("click",()=>{i.classList.remove("show")}),wireModal(i),i?.querySelectorAll('input[name="clock-style-radio"]').forEach(n=>{n.addEventListener("change",()=>{A=n.value,g="",E(),y()})})})(),(function(){function b(m){const N=new Date(m.start).toISOString();return m.uid?`${m.uid}@${N}`:`${N}|${m.title||""}`}function h(){const m=new Map;return{size:()=>m.size,merge(N,A){if(A)for(const[D,R]of m){const g=new Date(R.start).getTime();g>=A.start.getTime()&&g<=A.end.getTime()&&m.delete(D)}for(const D of N&&Array.isArray(N.events)?N.events:[])m.set(b(D),D);return{events:[...m.values()].sort((D,R)=>new Date(D.start)-new Date(R.start))}}}}const j={eventKey:b,createCache:h};typeof module<"u"&&module.exports&&(module.exports=j),typeof window<"u"&&(window.CalendarCache=j)})(),(function(){const b=new ErrorHandler;injectModal("calendar-modal",`<div id="calendar-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width:560px;max-width:720px;">
|
||||
<h3>\u{1F4C5} Calendar</h3>
|
||||
<div id="calendar-upcoming" style="margin:0 0 14px;">
|
||||
<div style="font-size:0.8rem;color:var(--muted);margin-bottom:6px;">Next 14 days</div>
|
||||
<div id="calendar-upcoming-list" style="display:flex;flex-direction:column;gap:4px;max-height:180px;overflow-y:auto;">
|
||||
<div style="color:var(--muted);font-size:0.85rem;">No upcoming appointments.</div>
|
||||
<div class="cal-monthbar">
|
||||
<button id="cal-prev" class="cal-nav-btn" aria-label="Previous month">\u2039</button>
|
||||
<span id="cal-month-label" class="cal-month-label"></span>
|
||||
<button id="cal-next" class="cal-nav-btn" aria-label="Next month">\u203A</button>
|
||||
</div>
|
||||
<div id="cal-grid" class="cal-grid"></div>
|
||||
<div id="calendar-upcoming" style="margin:12px 0 14px;">
|
||||
<div style="font-size:0.8rem;color:var(--muted);margin-bottom:6px;">Upcoming appointments</div>
|
||||
<div id="calendar-upcoming-list" class="cal-list">
|
||||
<div class="cal-empty">No upcoming appointments.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:14px;padding-top:12px;border-top:1px solid var(--border);">
|
||||
@@ -2112,19 +2118,18 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
</details>
|
||||
</div>
|
||||
<div class="weather-modal-buttons"><button id="calendar-close">Close</button></div>
|
||||
</div></div>`);const E=()=>({icon:document.querySelector(".calendar-widget-icon"),text:document.querySelector(".calendar-widget-text")});function j(b,d){const v=new Date(b),S=new Date;S.setHours(0,0,0,0);const O=new Date(v);O.setHours(0,0,0,0);const m=Math.round((O-S)/864e5),f=m===0?"Today":m===1?"Tomorrow":v.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}),B=d?"all-day":v.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return`${f} ${B}`}async function h(){const b=new Date(Date.now()-864e5),d=new Date(Date.now()+14*864e5),v=await fetch(`/api/v1/calendar/events?start=${b.toISOString()}&end=${d.toISOString()}`,{cache:"no-store"});if(v.status===404)return{notConfigured:!0};if(!v.ok)throw new Error(`Calendar API HTTP ${v.status}`);return v.json()}function P(b){const d=E();if(!d.icon||!d.text)return;const v=b&&Array.isArray(b.events)?b.events:[];if(!v.length){d.icon.textContent="\u{1F4C5}",d.text.textContent="No calendar";return}const S=v[0];d.icon.textContent=S.allDay?"\u{1F5D3}\uFE0F":"\u23F0",d.text.innerHTML=`${escapeHtml(S.title||"Untitled")}
|
||||
<span style="color:var(--muted);font-size:0.78em;">\xB7 ${escapeHtml(j(S.start,S.allDay))}</span>`}function A(b){const d=document.getElementById("calendar-upcoming-list");if(!d)return;const v=b&&Array.isArray(b.events)?b.events:[];if(!v.length){d.innerHTML='<div style="color:var(--muted);font-size:0.85rem;">No upcoming appointments.</div>';return}d.innerHTML=v.slice(0,12).map(S=>`<div style="display:flex;gap:8px;align-items:baseline;">
|
||||
<span style="font-size:0.78rem;color:var(--muted);white-space:nowrap;">${escapeHtml(j(S.start,S.allDay))}</span>
|
||||
<span style="font-size:0.85rem;">${escapeHtml(S.title||"Untitled")}</span>
|
||||
${S.location?`<span style="font-size:0.75rem;color:var(--muted);">${escapeHtml(S.location)}</span>`:""}
|
||||
</div>`).join("")}async function D(){const b=document.getElementById("calendar-sources-list");if(!b)return;let d=[];try{const v=await fetch("/api/v1/calendar/sources",{cache:"no-store"});if(v.ok){const S=await v.json();d=S&&Array.isArray(S.sources)?S.sources:Array.isArray(S)?S:[]}}catch{}if(!d.length){b.innerHTML='<div style="font-size:0.82rem;color:var(--muted);">No calendars connected. Deploy Radicale from the App Selector to auto-connect one, or add a CalDAV/ICS URL below.</div>';return}b.innerHTML=d.map(v=>`
|
||||
<div style="display:flex;gap:8px;align-items:center;border:1px solid var(--border);border-radius:6px;padding:6px 10px;">
|
||||
<span style="font-size:0.85rem;flex:1;">${escapeHtml(v.name||v.id)}
|
||||
<span style="color:var(--muted);font-size:0.72rem;">\xB7 ${escapeHtml(v.type)}${v.autoProvisioned?" \xB7 auto-wired":""}</span></span>
|
||||
<button class="cal-src-toggle" data-id="${escapeHtml(v.id)}" data-enabled="${v.enabled!==!1?"1":"0"}"
|
||||
style="font-size:0.75rem;padding:2px 8px;">${v.enabled!==!1?"\u2713 on":"off"}</button>
|
||||
<button class="cal-src-del" data-id="${escapeHtml(v.id)}" style="font-size:0.75rem;padding:2px 8px;color:var(--err-fg);">remove</button>
|
||||
</div>`).join(""),b.querySelectorAll(".cal-src-toggle").forEach(v=>v.addEventListener("click",async()=>{const S=v.dataset.id,O=v.dataset.enabled!=="1";await fetch(`/api/v1/calendar/sources/${encodeURIComponent(S)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:O})}),D(),R()})),b.querySelectorAll(".cal-src-del").forEach(v=>v.addEventListener("click",async()=>{const S=v.dataset.id;await fetch(`/api/v1/calendar/sources/${encodeURIComponent(S)}`,{method:"DELETE"}),D(),R()}))}async function R(){if(!R._inFlight){R._inFlight=!0;try{const b=await h();P(b),document.getElementById("calendar-modal").style.display==="flex"&&A(b)}catch(b){x.log(b,"calendar-widget");const d=E();d.text&&(d.text.textContent="Calendar offline")}finally{R._inFlight=!1}}}function y(){document.getElementById("calendar-modal").style.display="flex",D(),R()}function $(){document.getElementById("calendar-modal").style.display="none"}function k(){return{type:document.getElementById("cal-add-type").value,name:document.getElementById("cal-add-name").value.trim(),url:document.getElementById("cal-add-url").value.trim(),user:document.getElementById("cal-add-user").value.trim(),pass:document.getElementById("cal-add-pass").value}}function H(b){document.getElementById("cal-add-status").textContent=b}document.getElementById("cal-add-test").addEventListener("click",async()=>{const b=k();if(!b.url){H("Enter a URL first.");return}H("Testing\u2026");try{const v=await(await fetch("/api/v1/calendar/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:b.url,user:b.user,pass:b.pass})})).json(),S=v&&v.probe;S&&S.ok?H(`\u2713 Reachable (${S.server||"server"})${S.looksLikeCalendar?" \u2014 looks like a calendar":""}`):H(`\u2717 ${S&&S.error?S.error:"Not reachable"}`)}catch(d){H(`\u2717 ${d.message}`)}}),document.getElementById("cal-add-save").addEventListener("click",async()=>{const b=k();if(!b.name||!b.url){H("Name and URL are required.");return}try{const d=await fetch("/api/v1/calendar/sources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,type:b.type,url:b.url,user:b.user,pass:b.pass})});if(!d.ok){const v=await d.json().catch(()=>({}));H(`\u2717 ${v.error||v.message||`HTTP ${d.status}`}`);return}H("Saved."),document.getElementById("cal-add-details").open=!1,["cal-add-name","cal-add-url","cal-add-user","cal-add-pass"].forEach(v=>{document.getElementById(v).value=""}),D(),R()}catch(d){H(`\u2717 ${d.message}`)}});const T=document.getElementById("calendar-widget");T&&T.addEventListener("click",y);const z=document.getElementById("calendar-settings");z&&z.addEventListener("click",b=>{b.stopPropagation(),y()});const C=document.getElementById("calendar-close");C&&C.addEventListener("click",$),window.refreshCalendarWidget=R;const M=typeof DC<"u"&&DC.POLL&&DC.POLL.CALENDAR||3e5;setInterval(R,M),setTimeout(R,400)})(),(function(){const x=new ErrorHandler;injectModal("ai-connect-modal",`<div id="ai-connect-modal" class="weather-modal">
|
||||
</div></div>`);function h(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const j=()=>({icon:document.querySelector(".calendar-widget-icon"),text:document.querySelector(".calendar-widget-text")});function m(e,o){const a=new Date(e),s=new Date;s.setHours(0,0,0,0);const d=new Date(a);d.setHours(0,0,0,0);const x=Math.round((d-s)/864e5),H=x===0?"Today":x===1?"Tomorrow":a.toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"}),U=o?"all-day":a.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return`${H} ${U}`}function N(e,o){return o?"all-day":new Date(e).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}function A(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}const D=typeof window<"u"&&window.CalendarCache?window.CalendarCache.createCache():null;function R(e,o){return D?D.merge(e,o):e}let g=null,L=null;function k(e){const o=e||new Date,a=new Date(o.getFullYear(),o.getMonth()-1,1,0,0,0,0),s=new Date(o.getFullYear(),o.getMonth()+2,0,23,59,59,999);return{start:a,end:s}}function M(e){return g&&L&&g.getTime()<=e.start.getTime()&&L.getTime()>=e.end.getTime()}function I(e){if(!g){g=e.start,L=e.end;return}e.start<g&&(g=e.start),e.end>L&&(L=e.end)}let $=null,E={events:[]};async function T(e){const o=k($);if(!e&&M(o))return E;const a=await fetch(`/api/v1/calendar/events?start=${o.start.toISOString()}&end=${o.end.toISOString()}`,{cache:"no-store"});if(a.status===404)return{notConfigured:!0};if(!a.ok)throw new Error(`Calendar API HTTP ${a.status}`);const s=await a.json();return E=R(s,o),I(o),E}function P(e){const o=j();if(!o.icon||!o.text)return;const a=e&&Array.isArray(e.events)?e.events:[],s=Date.now(),d=a.filter(H=>(H.end?new Date(H.end).getTime():new Date(H.start).getTime())>=s).sort((H,U)=>new Date(H.start)-new Date(U.start));if(!d.length){o.icon.textContent="\u{1F4C5}",o.text.innerHTML='<span class="cal-chip-muted">No upcoming appointments</span>';return}const x=d[0];o.icon.textContent=x.allDay?"\u{1F5D3}\uFE0F":"\u23F0",o.text.innerHTML=`<span class="cal-chip-title">${h(x.title||"Untitled")}</span><span class="cal-chip-when">\xB7 ${h(m(x.start,x.allDay))}</span>`}function v(e){const o={};for(const a of e&&Array.isArray(e.events)?e.events:[]){const s=A(new Date(a.start));(o[s]=o[s]||[]).push(a)}return o}function B(e){const o=document.getElementById("cal-grid"),a=document.getElementById("cal-month-label");if(!o||!a)return;$||($=new Date,$.setDate(1));const s=$.getFullYear(),d=$.getMonth();a.textContent=$.toLocaleDateString(void 0,{month:"long",year:"numeric"});const x=v(e),H=A(new Date),U=new Date(s,d,1).getDay(),_=new Date(s,d+1,0).getDate();let F=["S","M","T","W","T","F","S"].map(q=>`<div class="cal-dow">${q}</div>`).join("");for(let q=0;q<U;q++)F+='<div class="cal-day cal-pad"></div>';for(let q=1;q<=_;q++){const J=`${s}-${String(d+1).padStart(2,"0")}-${String(q).padStart(2,"0")}`,V=x[J]||[],X=["cal-day"];J===H&&X.push("cal-today"),V.length&&X.push("cal-has-events");const ne=V.slice(0,3).map(Z=>`<span class="cal-dot" title="${h(N(Z.start,Z.allDay))}"></span>`).join(""),oe=V.map(Z=>`${N(Z.start,Z.allDay)} \u2014 ${Z.title||"Untitled"}`).join(`
|
||||
`);F+=`<div class="${X.join(" ")}" title="${h(oe||J)}"><span class="cal-daynum">${q}</span>${ne?`<span class="cal-dots">${ne}</span>`:""}</div>`}o.innerHTML=F}function z(e){const o=document.getElementById("calendar-upcoming-list");if(!o)return;const a=e&&Array.isArray(e.events)?e.events:[];if(!a.length){o.innerHTML='<div class="cal-empty">No upcoming appointments.</div>';return}o.innerHTML=a.slice(0,12).map(s=>`<div class="cal-row">
|
||||
<span class="cal-when">${h(m(s.start,s.allDay))}</span>
|
||||
<span class="cal-evtitle">${h(s.title||"Untitled")}</span>
|
||||
${s.location?`<span class="cal-loc">${h(s.location)}</span>`:""}
|
||||
</div>`).join("")}async function O(){const e=document.getElementById("calendar-sources-list");if(!e)return;let o=[];try{const a=await fetch("/api/v1/calendar/sources",{cache:"no-store"});if(a.ok){const s=await a.json();o=s&&Array.isArray(s.sources)?s.sources:Array.isArray(s)?s:[]}}catch{}if(!o.length){e.innerHTML='<div class="cal-empty">No calendars connected. Deploy Radicale from the App Selector to auto-connect one, or add a CalDAV/ICS URL below.</div>';return}e.innerHTML=o.map(a=>`
|
||||
<div class="cal-row cal-src-row">
|
||||
<span class="cal-evtitle">${h(a.name||a.id)}
|
||||
<span class="cal-loc">\xB7 ${h(a.type)}${a.autoProvisioned?" \xB7 auto-wired":""}</span></span>
|
||||
<button class="cal-src-toggle cal-btn" data-id="${h(a.id)}" data-enabled="${a.enabled!==!1?"1":"0"}">${a.enabled!==!1?"\u2713 on":"off"}</button>
|
||||
<button class="cal-src-del cal-btn cal-btn-danger" data-id="${h(a.id)}">remove</button>
|
||||
</div>`).join(""),e.querySelectorAll(".cal-src-toggle").forEach(a=>a.addEventListener("click",async()=>{const s=a.dataset.id,d=a.dataset.enabled!=="1";await fetch(`/api/v1/calendar/sources/${encodeURIComponent(s)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:d})}),O(),y()})),e.querySelectorAll(".cal-src-del").forEach(a=>a.addEventListener("click",async()=>{const s=a.dataset.id;await fetch(`/api/v1/calendar/sources/${encodeURIComponent(s)}`,{method:"DELETE"}),O(),y()}))}let u=null;async function y(){if(!y._inFlight){y._inFlight=!0;try{const e=await T(!1);u=e,P(e),document.getElementById("calendar-modal").style.display==="flex"&&(B(e),z(e))}catch(e){b.log(e,"calendar-widget");const o=j();o.text&&(o.text.innerHTML='<span class="cal-chip-muted">Calendar offline</span>')}finally{y._inFlight=!1}}}function C(){document.getElementById("calendar-modal").style.display="flex",B(u||{events:[]}),z(u||{events:[]}),O(),y(),T(!1).then(e=>{e&&(B(e),z(e))}).catch(()=>{})}function w(){document.getElementById("calendar-modal").style.display="none"}function S(){return{type:document.getElementById("cal-add-type").value,name:document.getElementById("cal-add-name").value.trim(),url:document.getElementById("cal-add-url").value.trim(),user:document.getElementById("cal-add-user").value.trim(),pass:document.getElementById("cal-add-pass").value}}function i(e){document.getElementById("cal-add-status").textContent=e}document.getElementById("cal-add-test").addEventListener("click",async()=>{const e=S();if(!e.url){i("Enter a URL first.");return}i("Testing\u2026");try{const a=await(await fetch("/api/v1/calendar/discover",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e.url,user:e.user,pass:e.pass})})).json(),s=a&&a.probe;s&&s.ok?i(`\u2713 Reachable (${s.server||"server"})${s.looksLikeCalendar?" \u2014 looks like a calendar":""}`):i(`\u2717 ${s&&s.error?s.error:"Not reachable"}`)}catch(o){i(`\u2717 ${o.message}`)}}),document.getElementById("cal-add-save").addEventListener("click",async()=>{const e=S();if(!e.name||!e.url){i("Name and URL are required.");return}try{const o=await fetch("/api/v1/calendar/sources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,type:e.type,url:e.url,user:e.user,pass:e.pass})});if(!o.ok){const a=await o.json().catch(()=>({}));i(`\u2717 ${a.error||a.message||`HTTP ${o.status}`}`);return}i("Saved."),document.getElementById("cal-add-details").open=!1,["cal-add-name","cal-add-url","cal-add-user","cal-add-pass"].forEach(a=>{document.getElementById(a).value=""}),O(),y()}catch(o){i(`\u2717 ${o.message}`)}});const p=document.getElementById("calendar-widget");p&&p.addEventListener("click",C);const l=document.getElementById("calendar-settings");l&&l.addEventListener("click",e=>{e.stopPropagation(),C()});const f=document.getElementById("calendar-close");f&&f.addEventListener("click",w);async function c(e){$||($=new Date,$.setDate(1)),$=new Date($.getFullYear(),$.getMonth()+e,1);const o=await T(!1).catch(()=>u);B(o||{events:[]})}const n=document.getElementById("cal-prev");n&&n.addEventListener("click",()=>{c(-1)});const t=document.getElementById("cal-next");t&&t.addEventListener("click",()=>{c(1)}),window.refreshCalendarWidget=y;const r=typeof DC<"u"&&DC.POLL&&DC.POLL.CALENDAR||3e5;setInterval(y,r),setTimeout(y,400)})(),(function(){const b=new ErrorHandler;injectModal("ai-connect-modal",`<div id="ai-connect-modal" class="weather-modal">
|
||||
<div class="weather-modal-content" style="min-width:560px;max-width:720px;">
|
||||
<h3>\u{1F916} Connect your AI assistant</h3>
|
||||
<div id="aiconn-intro" style="font-size:0.85rem;color:var(--muted);margin-bottom:12px;">
|
||||
@@ -2178,12 +2183,12 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
<span id="aiconn-status" style="flex:1;font-size:0.78rem;color:var(--muted);align-self:center;"></span>
|
||||
<button id="aiconn-close">Close</button>
|
||||
</div>
|
||||
</div></div>`);const E=y=>document.getElementById(y);let j=null;function h(y){E("aiconn-status").textContent=y}async function P(){try{const y=await secureFetch("/api/v1/mcp/info");if(!y.ok)throw new Error(`HTTP ${y.status}`);const $=await y.json();j=$,E("aiconn-endpoint").style.display="block",E("aiconn-endpoint-url").textContent=$.endpoint,E("aiconn-tools").textContent=`${$.toolCount} tools \xB7 MCP ${$.protocolVersion} \xB7 DashCaddy v${$.serverVersion}`}catch(y){x.log(y,"ai-connect-info"),h("MCP endpoint unavailable on this build.")}}async function A(){const y=E("aiconn-connections");try{const k=await(await secureFetch("/api/v1/mcp/connections")).json().catch(()=>({})),H=k&&Array.isArray(k.connections)?k.connections:[];if(!H.length){y.innerHTML='<div style="font-size:0.8rem;color:var(--muted);">No connections yet \u2014 choose an assistant above.</div>';return}y.innerHTML=H.map(T=>`
|
||||
</div></div>`);const h=g=>document.getElementById(g);let j=null;function m(g){h("aiconn-status").textContent=g}async function N(){try{const g=await secureFetch("/api/v1/mcp/info");if(!g.ok)throw new Error(`HTTP ${g.status}`);const L=await g.json();j=L,h("aiconn-endpoint").style.display="block",h("aiconn-endpoint-url").textContent=L.endpoint,h("aiconn-tools").textContent=`${L.toolCount} tools \xB7 MCP ${L.protocolVersion} \xB7 DashCaddy v${L.serverVersion}`}catch(g){b.log(g,"ai-connect-info"),m("MCP endpoint unavailable on this build.")}}async function A(){const g=h("aiconn-connections");try{const k=await(await secureFetch("/api/v1/mcp/connections")).json().catch(()=>({})),M=k&&Array.isArray(k.connections)?k.connections:[];if(!M.length){g.innerHTML='<div style="font-size:0.8rem;color:var(--muted);">No connections yet \u2014 choose an assistant above.</div>';return}g.innerHTML=M.map(I=>`
|
||||
<div style="display:flex;gap:8px;align-items:center;font-size:0.8rem;">
|
||||
<span style="flex:1;">${escapeHtml(T.name)}
|
||||
<span style="color:var(--muted);">\xB7 ${(T.scopes||[]).join(",")} \xB7 since ${escapeHtml((T.createdAt||"").slice(0,10))}${T.lastUsed?" \xB7 last used "+escapeHtml(String(T.lastUsed).slice(0,10)):""}</span></span>
|
||||
<button class="aiconn-revoke" data-id="${escapeHtml(T.id)}" style="font-size:0.75rem;color:var(--err-fg);">Revoke</button>
|
||||
</div>`).join(""),y.querySelectorAll(".aiconn-revoke").forEach(T=>T.addEventListener("click",async()=>{T.disabled=!0;try{const z=await secureFetch(`/api/v1/auth/keys/${encodeURIComponent(T.dataset.id)}`,{method:"DELETE"});if(z.ok)h("Connection revoked."),A();else{const C=await z.json().catch(()=>({}));h(C.error||"Revoke failed."),T.disabled=!1}}catch(z){h("Revoke failed: "+z.message),T.disabled=!1}}))}catch{y.innerHTML='<div style="font-size:0.8rem;color:var(--muted);">Could not load connections.</div>'}}async function D(y){h(`Creating ${y} connection\u2026`);try{const $=await secureFetch("/api/v1/mcp/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client:y})}),k=await $.json().catch(()=>({}));if(!$.ok||!k.key){h(k.error||`Failed (HTTP ${$.status})`);return}E("aiconn-key").textContent=k.key;const H=k.httpConfig?JSON.stringify(k.httpConfig,null,2):"";E("aiconn-snippet").textContent=H||"(see note below)",E("aiconn-client-note").textContent=k.note||"",E("aiconn-config-title").textContent=y==="chatgpt"?"Access key (ChatGPT note below):":"Your access key (shown once):",E("aiconn-step-pick").style.display="none",E("aiconn-step-config").style.display="block",h(""),A()}catch($){x.log($,"ai-connect-create"),h("Failed: "+$.message)}}function R(y,$){navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(y).then(()=>h($)).catch(()=>h("Copy failed \u2014 select manually.")):h("Clipboard unavailable \u2014 select manually.")}E("ai-connect-btn").addEventListener("click",()=>{E("ai-connect-modal").style.display="flex",E("aiconn-step-pick").style.display="block",E("aiconn-step-config").style.display="none",h(""),P(),A()}),E("aiconn-close").addEventListener("click",()=>{E("ai-connect-modal").style.display="none"}),E("aiconn-back").addEventListener("click",()=>{E("aiconn-step-config").style.display="none",E("aiconn-step-pick").style.display="block"}),document.querySelectorAll(".aiconn-client-btn").forEach(y=>y.addEventListener("click",()=>D(y.dataset.client))),E("aiconn-copy-key").addEventListener("click",()=>R(E("aiconn-key").textContent,"Key copied \u2014 paste it into your client.")),E("aiconn-copy-snippet").addEventListener("click",()=>R(E("aiconn-snippet").textContent,"Config copied.")),E("aiconn-copy-endpoint").addEventListener("click",()=>R(j?j.endpoint:E("aiconn-endpoint-url").textContent,"Endpoint copied."))})(),(function(){async function x(){try{const R=await(await fetch("/api/v1/health-checks/status")).json();if(!R.success||!R.status)return;for(const[y,$]of Object.entries(R.status)){const k=document.getElementById("uptime-"+y),H=document.getElementById("uptime-bar-"+y);if(!k)continue;const T=$.uptime?.["24h"];if(T!=null){const z=T.toFixed(1);k.textContent=`${z}% uptime`,k.className="uptime-chip",T>=99.9?k.classList.add("excellent"):T>=99?k.classList.add("good"):T>=95?k.classList.add("degraded"):k.classList.add("poor"),H&&(H.style.width=z+"%")}}}catch{console.warn("[Card Badges] Health check API unavailable")}}let E;try{E=new Set(JSON.parse(safeSessionGet("dismissed-updates")||"[]"))}catch{E=new Set}let j=[];async function h(D){try{const y=await(await fetch("/api/v1/updates/available")).json();if(!y.success)return;document.querySelectorAll(".update-available-badge").forEach(k=>k.classList.remove("visible"));const $=y.updates||[];if(j=$,D&&$.length>0){const k=window._lastKnownUpdateCount||0;k>0&&$.length>k&&showNotification(`${$.length} container update(s) available \u2014 click Update Management to review.`,"info"),window._lastKnownUpdateCount=$.length}if(!$.length)return;for(const k of $){const H=window.APPS||[];for(const T of H)if(T.containerId===k.containerId||T.id===k.containerName||T.name===k.containerName){if(E.has(T.id))break;const z=document.getElementById("update-badge-"+T.id),C=document.getElementById("update-btn-"+T.id);z&&(z.classList.add("visible"),z.title="Update available \u2014 click to open Update Management.",z.style.cursor="pointer",z.onclick=M=>{M.stopPropagation(),window.openUpdateModal&&window.openUpdateModal(T.id)}),C&&(C.style.background="#f97316",C.style.borderColor="#f97316",C.style.boxShadow="0 0 6px #f9731688",C.title="Update available \u2014 click to open Update Management.");break}}}catch{console.warn("[Card Badges] Updates API unavailable")}}function P(){setTimeout(()=>{x(),h()},5e3),setInterval(()=>{x(),h(!0)},6e4)}const A=window.refreshAll;A&&(window.refreshAll=async function(){try{await A(),setTimeout(x,1e3)}catch(D){console.warn("[Card Badges] Error in refreshAll hook:",D.message)}}),P()})(),(function(){var x=null,E=null,j={},h={dark:"Dark",light:"Light",blue:"Blue",black:"Black",nord:"Nord",dracula:"Dracula","solarized-dark":"Solarized Dark","solarized-light":"Solarized Light",taxi:"Taxi",ocean:"Ocean"},P=[["bg","Background","base"],["card-base","Card","base"],["fg","Text","base"],["muted","Muted Text","base"],["border","Border","base"],["accent","Accent","accent"],["accent-strong","Accent Strong","accent"]Line truncated
|
||||
<span style="flex:1;">${escapeHtml(I.name)}
|
||||
<span style="color:var(--muted);">\xB7 ${(I.scopes||[]).join(",")} \xB7 since ${escapeHtml((I.createdAt||"").slice(0,10))}${I.lastUsed?" \xB7 last used "+escapeHtml(String(I.lastUsed).slice(0,10)):""}</span></span>
|
||||
<button class="aiconn-revoke" data-id="${escapeHtml(I.id)}" style="font-size:0.75rem;color:var(--err-fg);">Revoke</button>
|
||||
</div>`).join(""),g.querySelectorAll(".aiconn-revoke").forEach(I=>I.addEventListener("click",async()=>{I.disabled=!0;try{const $=await secureFetch(`/api/v1/auth/keys/${encodeURIComponent(I.dataset.id)}`,{method:"DELETE"});if($.ok)m("Connection revoked."),A();else{const E=await $.json().catch(()=>({}));m(E.error||"Revoke failed."),I.disabled=!1}}catch($){m("Revoke failed: "+$.message),I.disabled=!1}}))}catch{g.innerHTML='<div style="font-size:0.8rem;color:var(--muted);">Could not load connections.</div>'}}async function D(g){m(`Creating ${g} connection\u2026`);try{const L=await secureFetch("/api/v1/mcp/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client:g})}),k=await L.json().catch(()=>({}));if(!L.ok||!k.key){m(k.error||`Failed (HTTP ${L.status})`);return}h("aiconn-key").textContent=k.key;const M=k.httpConfig?JSON.stringify(k.httpConfig,null,2):"";h("aiconn-snippet").textContent=M||"(see note below)",h("aiconn-client-note").textContent=k.note||"",h("aiconn-config-title").textContent=g==="chatgpt"?"Access key (ChatGPT note below):":"Your access key (shown once):",h("aiconn-step-pick").style.display="none",h("aiconn-step-config").style.display="block",m(""),A()}catch(L){b.log(L,"ai-connect-create"),m("Failed: "+L.message)}}function R(g,L){navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(g).then(()=>m(L)).catch(()=>m("Copy failed \u2014 select manually.")):m("Clipboard unavailable \u2014 select manually.")}h("ai-connect-btn").addEventListener("click",()=>{h("ai-connect-modal").style.display="flex",h("aiconn-step-pick").style.display="block",h("aiconn-step-config").style.display="none",m(""),N(),A()}),h("aiconn-close").addEventListener("click",()=>{h("ai-connect-modal").style.display="none"}),h("aiconn-back").addEventListener("click",()=>{h("aiconn-step-config").style.display="none",h("aiconn-step-pick").style.display="block"}),document.querySelectorAll(".aiconn-client-btn").forEach(g=>g.addEventListener("click",()=>D(g.dataset.client))),h("aiconn-copy-key").addEventListener("click",()=>R(h("aiconn-key").textContent,"Key copied \u2014 paste it into your client.")),h("aiconn-copy-snippet").addEventListener("click",()=>R(h("aiconn-snippet").textContent,"Config copied.")),h("aiconn-copy-endpoint").addEventListener("click",()=>R(j?j.endpoint:h("aiconn-endpoint-url").textContent,"Endpoint copied."))})(),(function(){async function b(){try{const R=await(await fetch("/api/v1/health-checks/status")).json();if(!R.success||!R.status)return;for(const[g,L]of Object.entries(R.status)){const k=document.getElementById("uptime-"+g),M=document.getElementById("uptime-bar-"+g);if(!k)continue;const I=L.uptime?.["24h"];if(I!=null){const $=I.toFixed(1);k.textContent=`${$}% uptime`,k.className="uptime-chip",I>=99.9?k.classList.add("excellent"):I>=99?k.classList.add("good"):I>=95?k.classList.add("degraded"):k.classList.add("poor"),M&&(M.style.width=$+"%")}}}catch{console.warn("[Card Badges] Health check API unavailable")}}let h;try{h=new Set(JSON.parse(safeSessionGet("dismissed-updates")||"[]"))}catch{h=new Set}let j=[];async function m(D){try{const g=await(await fetch("/api/v1/updates/available")).json();if(!g.success)return;document.querySelectorAll(".update-available-badge").forEach(k=>k.classList.remove("visible"));const L=g.updates||[];if(j=L,D&&L.length>0){const k=window._lastKnownUpdateCount||0;k>0&&L.length>k&&showNotification(`${L.length} container update(s) available \u2014 click Update Management to review.`,"info"),window._lastKnownUpdateCount=L.length}if(!L.length)return;for(const k of L){const M=window.APPS||[];for(const I of M)if(I.containerId===k.containerId||I.id===k.containerName||I.name===k.containerName){if(h.has(I.id))break;const $=document.getElementById("update-badge-"+I.id),E=document.getElementById("update-btn-"+I.id);$&&($.classList.add("visible"),$.title="Update available \u2014 click to open Update Management.",$.style.cursor="pointer",$.onclick=T=>{T.stopPropagation(),window.openUpdateModal&&window.openUpdateModal(I.id)}),E&&(E.style.background="#f97316",E.style.borderColor="#f97316",E.style.boxShadow="0 0 6px #f9731688",E.title="Update available \u2014 click to open Update Management.");break}}}catch{console.warn("[Card Badges] Updates API unavailable")}}function N(){setTimeout(()=>{b(),m()},5e3),setInterval(()=>{b(),m(!0)},6e4)}const A=window.refreshAll;A&&(window.refreshAll=async function(){try{await A(),setTimeout(b,1e3)}catch(D){console.warn("[Card Badges] Error in refreshAll hook:",D.message)}}),N()})(),(function(){var b=null,h=null,j={},m={dark:"Dark",light:"Light",blue:"Blue",black:"Black",nord:"Nord",dracula:"Dracula","solarized-dark":"Solarized Dark","solarized-light":"Solarized Light",taxi:"Taxi",ocean:"Ocean"},N=[["bg","Background","base"],["card-base","Card","base"],["fg","Text","base"],["muted","Muted Text","base"],["border","Border","base"],["accent","Accent","accent"],["accent-strong","Accent Strong","accent"]Line truncated
|
||||
<div class="weather-modal-content" style="min-width: 420px; max-width: 520px;">
|
||||
<h3>DashCaddy License</h3>
|
||||
<p style="font-size: 0.85rem; color: var(--muted); margin: 0 0 16px;">
|
||||
@@ -2220,16 +2225,16 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
<button id="license-activate" class="btn-accent">Activate</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`);const x=document.getElementById("license-modal"),E=document.getElementById("license-code-input"),j=document.getElementById("license-activate"),h=document.getElementById("license-deactivate"),P=document.getElementById("license-error"),A=document.getElementById("license-success"),D=document.getElementById("license-badge-icon"),R=document.getElementById("license-badge-text"),y=document.getElementById("license-badge"),$=document.getElementById("license-details"),k=document.getElementById("license-feature-list"),H=document.getElementById("license-activate-section");let T=null;function z(){P.style.display="none",A.style.display="none"}function C(B){z(),P.textContent=B,P.style.display="block"}function M(B){z(),A.textContent=B,A.style.display="block"}function b(B){if(T=B,B.active){y.style.background="rgba(46,204,113,0.15)",y.style.color="var(--ok-fg)",D.textContent="\u2605",R.textContent="Premium Active";const o=B.lifetime?"<div>License: <strong>LIFETIME</strong></div>":`<div>Expires: <strong>${new Date(B.expiresAt).toLocaleDateString()}</strong> (${B.daysRemaining} days remaining)</div>`;$.innerHTML=`
|
||||
<div>Code: <code style="font-family: monospace;">${B.code||"***"}</code></div>
|
||||
${o}
|
||||
`,H.style.display="none",j.style.display="none",h.style.display=""}else y.style.background="rgba(149,165,166,0.15)",y.style.color="var(--muted)",D.textContent="\u2606",R.textContent=B.expired?"License Expired":"Free Tier",$.innerHTML=B.expired?"<div>Your license has expired. Enter a new code to renew.</div>":"<div>Enter a license code to unlock premium features.</div>",H.style.display="",j.style.display="",h.style.display="none";const w=B.premiumFeatures||{},L=new Set(B.features||[]);k.innerHTML=Object.entries(w).map(([o,u])=>`<div style="display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; background: var(--card-bg); border: 1px solid var(--border);">
|
||||
<span style="font-size: 1.1rem;">${L.has(o)?"\u2705":"\u{1F512}"}</span>
|
||||
</div>`);const b=document.getElementById("license-modal"),h=document.getElementById("license-code-input"),j=document.getElementById("license-activate"),m=document.getElementById("license-deactivate"),N=document.getElementById("license-error"),A=document.getElementById("license-success"),D=document.getElementById("license-badge-icon"),R=document.getElementById("license-badge-text"),g=document.getElementById("license-badge"),L=document.getElementById("license-details"),k=document.getElementById("license-feature-list"),M=document.getElementById("license-activate-section");let I=null;function $(){N.style.display="none",A.style.display="none"}function E(C){$(),N.textContent=C,N.style.display="block"}function T(C){$(),A.textContent=C,A.style.display="block"}function P(C){if(I=C,C.active){g.style.background="rgba(46,204,113,0.15)",g.style.color="var(--ok-fg)",D.textContent="\u2605",R.textContent="Premium Active";const i=C.lifetime?"<div>License: <strong>LIFETIME</strong></div>":`<div>Expires: <strong>${new Date(C.expiresAt).toLocaleDateString()}</strong> (${C.daysRemaining} days remaining)</div>`;L.innerHTML=`
|
||||
<div>Code: <code style="font-family: monospace;">${C.code||"***"}</code></div>
|
||||
${i}
|
||||
`,M.style.display="none",j.style.display="none",m.style.display=""}else g.style.background="rgba(149,165,166,0.15)",g.style.color="var(--muted)",D.textContent="\u2606",R.textContent=C.expired?"License Expired":"Free Tier",L.innerHTML=C.expired?"<div>Your license has expired. Enter a new code to renew.</div>":"<div>Enter a license code to unlock premium features.</div>",M.style.display="",j.style.display="",m.style.display="none";const w=C.premiumFeatures||{},S=new Set(C.features||[]);k.innerHTML=Object.entries(w).map(([i,p])=>`<div style="display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; background: var(--card-bg); border: 1px solid var(--border);">
|
||||
<span style="font-size: 1.1rem;">${S.has(i)?"\u2705":"\u{1F512}"}</span>
|
||||
<div>
|
||||
<div style="font-weight: 600; font-size: 0.9rem;">${u.name}</div>
|
||||
<div style="font-size: 0.78rem; color: var(--muted);">${u.description}</div>
|
||||
<div style="font-weight: 600; font-size: 0.9rem;">${p.name}</div>
|
||||
<div style="font-size: 0.78rem; color: var(--muted);">${p.description}</div>
|
||||
</div>
|
||||
</div>`).join("")}async function d(){try{const w=await(await fetch("/api/v1/license/status")).json();w.success&&(b(w.license),O(w.license))}catch(B){console.warn("Failed to load license status:",B.message)}}async function v(){const B=E.value.trim();if(!B){C("Please enter a license code.");return}z(),j.disabled=!0,j.textContent="Activating...";try{const L=await(await secureFetch("/api/v1/license/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:B})})).json();L.success?(M(L.message),E.value="",b(L.license),showNotification("License activated! Premium features unlocked.","success",5e3),O(L.license)):C(L.error||"Activation failed")}catch(w){C("Network error: "+w.message)}finally{j.disabled=!1,j.textContent="Activate"}}async function S(){if(confirm("Deactivate your license? You can reuse the code on another machine.")){h.disabled=!0,h.textContent="Deactivating...";try{const w=await(await secureFetch("/api/v1/license/deactivate",{method:"POST"})).json();w.success?(M(w.message),await d(),showNotification("License deactivated.","info",3e3),O({active:!1})):C(w.error||"Deactivation failed")}catch(B){C("Network error: "+B.message)}finally{h.disabled=!1,h.textContent="Deactivate"}}}function O(B){const w=document.getElementById("license-status-topbar"),L=document.getElementById("license-topbar-icon"),o=document.getElementById("license-topbar-text"),u=document.getElementById("license-topbar-time");if(w)if(w.className="license-status-topbar "+(B.active?"premium":"free"),B.active)if(L.textContent="\u2605",o.textContent="PREMIUM",B.lifetime)u.textContent="\xB7 LIFETIME";else{const l=B.daysRemaining;u.textContent=l!=null?"\xB7 "+l+"d remaining":""}else L.textContent="\u2606",o.textContent=B.expired?"EXPIRED":"FREE TIER",u.textContent=""}function m(){z(),d(),x.classList.add("show")}E.addEventListener("input",function(){let B=this.value.toUpperCase().replace(/[^A-Z0-9-]/g,"");if(B.length>this._prevLength&&(B=B.replace(/-/g,""),B.length>2&&!B.startsWith("DC")&&(B="DC"+B),B.startsWith("DC")&&B.length>2)){const w=["DC"],L=B.substring(2);for(let o=0;o<L.length;o+=5)w.push(L.substring(o,o+5));B=w.join("-")}this._prevLength=B.length,this.value=B}),j.addEventListener("click",v),h.addEventListener("click",S),E.addEventListener("keydown",B=>{B.key==="Enter"&&v()}),wireModal(x,document.getElementById("license-cancel"));const f=document.getElementById("license-status-topbar");f&&f.addEventListener("click",()=>window.openLicenseModal&&window.openLicenseModal()),window.openLicenseModal=m,window.checkPremiumFeature=async function(B){try{return(await(await fetch(`/api/v1/license/feature/${B}`)).json()).available}catch{return!1}},d().then(B=>{T&&O(T)})})(),(function(){"use strict";if(window.__dc_058_share_modal_loaded)return;window.__dc_058_share_modal_loaded=!0;const x=[{ms:3600*1e3,label:"1 hour"},{ms:1440*60*1e3,label:"24 hours"},{ms:10080*60*1e3,label:"7 days"}];injectModal("share-modal",`
|
||||
</div>`).join("")}async function v(){try{const w=await(await fetch("/api/v1/license/status")).json();w.success&&(P(w.license),O(w.license))}catch(C){console.warn("Failed to load license status:",C.message)}}async function B(){const C=h.value.trim();if(!C){E("Please enter a license code.");return}$(),j.disabled=!0,j.textContent="Activating...";try{const S=await(await secureFetch("/api/v1/license/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:C})})).json();S.success?(T(S.message),h.value="",P(S.license),showNotification("License activated! Premium features unlocked.","success",5e3),O(S.license)):E(S.error||"Activation failed")}catch(w){E("Network error: "+w.message)}finally{j.disabled=!1,j.textContent="Activate"}}async function z(){if(confirm("Deactivate your license? You can reuse the code on another machine.")){m.disabled=!0,m.textContent="Deactivating...";try{const w=await(await secureFetch("/api/v1/license/deactivate",{method:"POST"})).json();w.success?(T(w.message),await v(),showNotification("License deactivated.","info",3e3),O({active:!1})):E(w.error||"Deactivation failed")}catch(C){E("Network error: "+C.message)}finally{m.disabled=!1,m.textContent="Deactivate"}}}function O(C){const w=document.getElementById("license-status-topbar"),S=document.getElementById("license-topbar-icon"),i=document.getElementById("license-topbar-text"),p=document.getElementById("license-topbar-time");if(w)if(w.className="license-status-topbar "+(C.active?"premium":"free"),C.active)if(S.textContent="\u2605",i.textContent="PREMIUM",C.lifetime)p.textContent="\xB7 LIFETIME";else{const l=C.daysRemaining;p.textContent=l!=null?"\xB7 "+l+"d remaining":""}else S.textContent="\u2606",i.textContent=C.expired?"EXPIRED":"FREE TIER",p.textContent=""}function u(){$(),v(),b.classList.add("show")}h.addEventListener("input",function(){let C=this.value.toUpperCase().replace(/[^A-Z0-9-]/g,"");if(C.length>this._prevLength&&(C=C.replace(/-/g,""),C.length>2&&!C.startsWith("DC")&&(C="DC"+C),C.startsWith("DC")&&C.length>2)){const w=["DC"],S=C.substring(2);for(let i=0;i<S.length;i+=5)w.push(S.substring(i,i+5));C=w.join("-")}this._prevLength=C.length,this.value=C}),j.addEventListener("click",B),m.addEventListener("click",z),h.addEventListener("keydown",C=>{C.key==="Enter"&&B()}),wireModal(b,document.getElementById("license-cancel"));const y=document.getElementById("license-status-topbar");y&&y.addEventListener("click",()=>window.openLicenseModal&&window.openLicenseModal()),window.openLicenseModal=u,window.checkPremiumFeature=async function(C){try{return(await(await fetch(`/api/v1/license/feature/${C}`)).json()).available}catch{return!1}},v().then(C=>{I&&O(I)})})(),(function(){"use strict";if(window.__dc_058_share_modal_loaded)return;window.__dc_058_share_modal_loaded=!0;const b=[{ms:3600*1e3,label:"1 hour"},{ms:1440*60*1e3,label:"24 hours"},{ms:10080*60*1e3,label:"7 days"}];injectModal("share-modal",`
|
||||
<div id="share-modal" class="weather-modal" role="dialog" aria-labelledby="share-modal-title">
|
||||
<div class="weather-modal-content" style="min-width: 460px; max-width: 580px;">
|
||||
<h3 id="share-modal-title">Share <span id="share-modal-service-name">\u2026</span></h3>
|
||||
@@ -2251,7 +2256,7 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
<div class="share-tab-panel" data-panel="public">
|
||||
<label class="form-label-bold" for="share-public-ttl">Link duration:</label>
|
||||
<select id="share-public-ttl" style="width: 100%; padding: 8px 10px; margin: 6px 0 12px; background: var(--input-bg); color: var(--fg); border: 1px solid var(--border); border-radius: 4px;">
|
||||
${x.map(t=>`<option value="${t.ms}">${t.label}</option>`).join("")}
|
||||
${b.map(n=>`<option value="${n.ms}">${n.label}</option>`).join("")}
|
||||
</select>
|
||||
<button id="share-public-create" class="btn-accent" type="button"
|
||||
style="width: 100%; padding: 10px; background: var(--accent); color: #04141f; border: 0; border-radius: 4px; font-weight: 600; cursor: pointer;">
|
||||
@@ -2298,17 +2303,17 @@ This can take ~30-60s\u2026`);try{const{body:v}=await P("/deploy",{method:"POST"
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`);const E=document.getElementById("share-modal"),j=document.getElementById("share-modal-service-name"),h=document.getElementById("share-issued"),P=document.getElementById("share-issued-url"),A=document.getElementById("share-issued-copy"),D=document.getElementById("share-issued-meta"),R=document.getElementById("share-error"),y=document.getElementById("share-success"),$=document.getElementById("share-outstanding-list"),k=document.getElementById("share-cancel"),H=document.getElementById("share-public-create"),T=document.getElementById("share-ts-create"),z=document.getElementById("share-ts-email"),C=document.getElementById("share-public-ttl");let M=null,b="public";function d(){R.style.display="none",y.style.display="none",h.style.display="none"}function v(t){y.style.display="none",h.style.display="none",R.textContent=t,R.style.display="block"}function S(t){R.style.display="none",y.textContent=t,y.style.display="block"}function O(){return window.location.origin}function m(t){return t.startsWith("http")?t:O()+t}function f(t){if(!t)return"";const e=new Date(t);return Number.isNaN(e.getTime())?"":e.toLocaleString()}function B(t){if(t<=0)return"expired";const e=Math.floor(t/36e5);if(e>=24)return`${Math.floor(e/24)}d ${e%24}h left`;const s=Math.floor(t%36e5/6e4);return`${e}h ${s}m left`}function w(t){b=t,d(),E.querySelectorAll(".share-tab").forEach(e=>{const s=e.dataset.tab===t;e.classList.toggle("active",s),e.style.borderBottomColor=s?"var(--accent)":"transparent",e.style.color=s?"var(--fg)":"var(--muted)",e.style.fontWeight=s?"600":"400"}),E.querySelectorAll(".share-tab-panel").forEach(e=>{e.style.display=e.dataset.panel===t?"":"none"})}async function L(){$.innerHTML='<span style="color: var(--muted);">Loading\u2026</span>';try{const t=await fetch("/api/v1/share",{credentials:"same-origin"});if(!t.ok){$.innerHTML='<span style="color: var(--muted);">No shares listed.</span>';return}const e=await t.json(),n=(e&&e.data||[]).filter(r=>r.serviceId===M.id);if(n.length===0){$.innerHTML='<span style="color: var(--muted);">No outstanding shares for this service.</span>';return}$.innerHTML=n.map(r=>{const a=r.expiresAt?B(new Date(r.expiresAt).getTime()-Date.now()):"";return`
|
||||
<div class="share-row" data-share-id="${escapeHtml(r.id)}"
|
||||
`);const h=document.getElementById("share-modal"),j=document.getElementById("share-modal-service-name"),m=document.getElementById("share-issued"),N=document.getElementById("share-issued-url"),A=document.getElementById("share-issued-copy"),D=document.getElementById("share-issued-meta"),R=document.getElementById("share-error"),g=document.getElementById("share-success"),L=document.getElementById("share-outstanding-list"),k=document.getElementById("share-cancel"),M=document.getElementById("share-public-create"),I=document.getElementById("share-ts-create"),$=document.getElementById("share-ts-email"),E=document.getElementById("share-public-ttl");let T=null,P="public";function v(){R.style.display="none",g.style.display="none",m.style.display="none"}function B(n){g.style.display="none",m.style.display="none",R.textContent=n,R.style.display="block"}function z(n){R.style.display="none",g.textContent=n,g.style.display="block"}function O(){return window.location.origin}function u(n){return n.startsWith("http")?n:O()+n}function y(n){if(!n)return"";const t=new Date(n);return Number.isNaN(t.getTime())?"":t.toLocaleString()}function C(n){if(n<=0)return"expired";const t=Math.floor(n/36e5);if(t>=24)return`${Math.floor(t/24)}d ${t%24}h left`;const r=Math.floor(n%36e5/6e4);return`${t}h ${r}m left`}function w(n){P=n,v(),h.querySelectorAll(".share-tab").forEach(t=>{const r=t.dataset.tab===n;t.classList.toggle("active",r),t.style.borderBottomColor=r?"var(--accent)":"transparent",t.style.color=r?"var(--fg)":"var(--muted)",t.style.fontWeight=r?"600":"400"}),h.querySelectorAll(".share-tab-panel").forEach(t=>{t.style.display=t.dataset.panel===n?"":"none"})}async function S(){L.innerHTML='<span style="color: var(--muted);">Loading\u2026</span>';try{const n=await fetch("/api/v1/share",{credentials:"same-origin"});if(!n.ok){L.innerHTML='<span style="color: var(--muted);">No shares listed.</span>';return}const t=await n.json(),e=(t&&t.data||[]).filter(o=>o.serviceId===T.id);if(e.length===0){L.innerHTML='<span style="color: var(--muted);">No outstanding shares for this service.</span>';return}L.innerHTML=e.map(o=>{const a=o.expiresAt?C(new Date(o.expiresAt).getTime()-Date.now()):"";return`
|
||||
<div class="share-row" data-share-id="${escapeHtml(o.id)}"
|
||||
style="display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border);">
|
||||
<span style="flex: 1;">
|
||||
<strong>${r.kind==="tailscale"?"Tailscale":"Public"}</strong>
|
||||
<span style="color: var(--muted);"> \xB7 expires ${escapeHtml(f(r.expiresAt))} (${a})</span>
|
||||
<strong>${o.kind==="tailscale"?"Tailscale":"Public"}</strong>
|
||||
<span style="color: var(--muted);"> \xB7 expires ${escapeHtml(y(o.expiresAt))} (${a})</span>
|
||||
</span>
|
||||
<button class="share-revoke" data-share-id="${escapeHtml(r.id)}" type="button"
|
||||
<button class="share-revoke" data-share-id="${escapeHtml(o.id)}" type="button"
|
||||
style="padding: 4px 10px; background: transparent; color: var(--bad-fg); border: 1px solid var(--bad-fg); border-radius: 4px; cursor: pointer; font-size: 0.8rem;">
|
||||
Revoke
|
||||
</button>
|
||||
</div>
|
||||
`}).join(""),$.querySelectorAll(".share-revoke").forEach(r=>{r.addEventListener("click",()=>o(r.dataset.shareId))})}catch{$.innerHTML='<span style="color: var(--muted);">Could not load outstanding shares.</span>'}}async function o(t){try{const e=await fetch(`/api/v1/share/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"same-origin"});if(!e.ok){const s=await e.json().catch(()=>({}));v(s&&s.error||`Revoke failed (HTTP ${e.status}).`);return}S("Share revoked."),L()}catch{v("Network error while revoking.")}}async function u(){if(!M)return;d(),H.disabled=!0;const t=H.textContent;H.textContent="Creating\u2026";try{const e=parseInt(C.value,10),s=await fetch("/api/v1/share",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:M.id,ttlMs:e})}),n=await s.json().catch(()=>({}));if(!s.ok||!n.success){g(s.status,n);return}const r=n.data.urlPath;P.value=m(r),D.textContent=`Public link \xB7 expires ${f(n.data.expiresAt)}`,h.style.display="block",S("Share link created."),L()}catch{v("Network error while creating share.")}finally{H.disabled=!1,H.textContent=t}}async function l(){if(!M)return;const t=(z.value||"").trim();if(!t||!t.includes("@")){v("A valid recipient email is required.");return}d(),T.disabled=!0;const e=T.textContent;T.textContent="Creating\u2026";try{const s=await fetch("/api/v1/share/tailscale",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:M.id,email:t})}),n=await s.json().catch(()=>({}));if(!s.ok||!n.success){g(s.status,n);return}const r=n.data&&n.data.urlPath;r?(P.value=m(r),D.textContent=`Tailscale invite \xB7 emailed to ${t} (or use this URL manually if delivery failed).`):(P.value="",D.textContent=`Tailscale invite sent to ${t}.`),h.style.display="block",S("Tailscale invite created."),z.value="",L()}catch{v("Network error while creating Tailscale invite.")}finally{T.disabled=!1,T.textContent=e}}function g(t,e){const s=e&&e.error||"";if(t===402){v("Share is a Pro feature. Activate a license to unlock.");return}if(t===400&&/tailscale/i.test(s)){v("Tailscale is not configured on this host. Set up Tailscale in the dashboard first.");return}if(t===403){v("You do not have permission to share services.");return}if(t===404){v("Service not found. It may have been deleted.");return}v(s||`Request failed (HTTP ${t}).`)}function p(t){!t||!t.id||(M={id:t.id,name:t.name||t.id},j.textContent=M.name,d(),w("public"),z.value="",C.value=String(x[1].ms),E.classList.add("show"),L())}E.querySelectorAll(".share-tab").forEach(t=>{t.addEventListener("click",()=>w(t.dataset.tab))}),H.addEventListener("click",u),T.addEventListener("click",l),k.addEventListener("click",()=>E.classList.remove("show")),wireModal(E,k),A.addEventListener("click",async()=>{const t=P.value;if(t)try{navigator.clipboard&&navigator.clipboard.writeText?await navigator.clipboard.writeText(t):(P.select(),document.execCommand("copy"));const e=A.textContent;A.textContent="Copied!",setTimeout(()=>{A.textContent=e},1200)}catch{v("Could not copy to clipboard. Select the URL manually.")}}),window.openShareModal=p})();
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiPHN0ZGluPiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLy8gTG9nbyBDdXN0b21pemF0aW9uIFN5c3RlbVxuKGZ1bmN0aW9uKCkge1xuICAvLyBJbmplY3QgbW9kYWwgSFRNTFxuICBpbmplY3RNb2RhbCgnbG9nby1tb2RhbCcsIGA8ZGl2IGlkPVwibG9nby1tb2RhbFwiIGNsYXNzPVwid2VhdGhlci1tb2RhbFwiPlxuICAgIDxkaXYgY2xhc3M9XCJ3ZWF0aGVyLW1vZGFsLWNvbnRlbnRcIiBzdHlsZT1cIm1pbi13aWR0aDogNDAwcHg7IG1heC13aWR0aDogNTIwcHg7XCI+XG4gICAgICA8aDM+RGFzaGJvYXJkIFNldHRpbmdzPC9oMz5cbiAgICAgIDxwIHN0eWxlPVwiZm9udC1zaXplOiAwLjg1cmVtOyBjb2xvcjogdmFyKC0tbXV0ZWQpOyBtYXJnaW46IDAgMCAxNnB4O1wiPlxuICAgICAgICBDdXN0b21pemUgeW91ciBkYXNoYm9hcmQncyBhcHBlYXJhbmNlIGFuZCBzeXN0ZW0gcHJlZmVyZW5jZXMuXG4gICAgICA8L3A+XG5cbiAgICAgIDxkaXYgY2xhc3M9XCJtYi0xNlwiPlxuICAgICAgICA8bGFiZWwgZm9yPVwiZGFzaGJvYXJkLXRpdGxlXCIgY2xhc3M9XCJmb3JtLWxhYmVsLWJvbGRcIj5EYXNoYm9hcmQgVGl0bGU6PC9sYWJlbD5cbiAgICAgICAgPGlucHV0IHR5cGU9XCJ0ZXh0XCIgaWQ9XCJkYXNoYm9hcmQtdGl0bGVcIiBwbGFjZWhvbGRlcj1cIkRhc2hDYWRkeVwiIG1heGxlbmd0aD1cIjUwXCIgc3R5bGU9XCJ3aWR0aDogMTAwJTsgcGFkZGluZzogMTBweCAxMnB4OyBib3JkZXI6IDFweCBzb2xpZCB2YXIoLS1ib3JkZXIpOyBib3JkZXItcmFkaXVzOiA0cHg7IGJhY2tncm91bmQ6IHZhcigtLWNhcmQtYmcpOyBjb2xvcjogdmFyKC0tZmcpOyBmb250LXNpemU6IDFyZW07XCIgLz5cbiAgICAgICAgPHAgY2xhc3M9XCJ0aW55LWhpbnRcIj5TaG93biBpbiBicm93c2VyIHRhYiBhbmQgaGVhZGVyIChtYXggNTAgY2hhcmFjdGVycyk8L3A+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGhyIGNsYXNzPVwiaHItZGl2aWRlclwiIC8+XG5cbiAgICAgIDxkaXYgY2xhc3M9XCJtYi0xNlwiPlxuICAgICAgICA8bGFiZWwgY2xhc3M9XCJmb3JtLWxhYmVsLWJvbGRcIj5Mb2dvOjwvbGFiZWw+XG4gICAgICAgIDxwIGNsYXNzPVwidGlueS1oaW50XCIgc3R5bGU9XCJtYXJnaW4tdG9wOiAycHg7XCI+U2VwYXJhdGUgbG9nb3MgZm9yIGRhcmsgYW5kIGxpZ2h0IHRoZW1lcywgb3IgdXNlIHRoZSBzYW1lIGZvciBib3RoLjwvcD5cbiAgICAgIDwvZGl2PlxuXG4gICAgICA8ZGl2IHN0eWxlPVwiZGlzcGxheTogZmxleDsgZ2FwOiAxMnB4OyBtYXJnaW4tYm90dG9tOiAxMnB4O1wiPlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTsgdGV4dC1hbGlnbjogY2VudGVyOyBwYWRkaW5nOiAxNnB4IDEwcHg7IGJvcmRlci1yYWRpdXM6IDhweDsgYmFja2dyb3VuZDogIzFhMWEyZTsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgyNTUsMjU1LDI1NSwuMSk7XCI+XG4gICAgICAgICAgPGltZyBpZD1cImxvZ28tcHJldmlldy1kYXJrXCIgc3JjPVwiL2Fzc2V0cy9kYXNoY2FkZHktbG9nby1kYXJrLnBuZ1wiIGFsdD1cIkRhcmsgdGhlbWUgbG9nb1wiIHN0eWxlPVwibWF4LWhlaWdodDogNjBweDsgbWF4LXdpZHRoOiAxMDAlO1wiIC8+XG4gICAgICAgICAgPHAgc3R5bGU9XCJmb250LXNpemU6IDAuNjVyZW07IGNvbG9yOiAjOWFhNmJmOyBtYXJnaW4tdG9wOiA2cHg7XCI+RGFyayB0aGVtZXM8L3A+XG4gICAgICAgIDwvZGl2PlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTsgdGV4dC1hbGlnbjogY2VudGVyOyBwYWRkaW5nOiAxNnB4IDEwcHg7IGJvcmRlci1yYWRpdXM6IDhweDsgYmFja2dyb3VuZDogI2YwZjBmMDsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgwLDAsMCwuMSk7XCI+XG4gICAgICAgICAgPGltZyBpZD1cImxvZ28tcHJldmlldy1saWdodFwiIHNyYz1cIi9hc3NldHMvZGFzaGNhZGR5LWxvZ28tbGlnaHQucG5nXCIgYWx0PVwiTGlnaHQgdGhlbWUgbG9nb1wiIHN0eWxlPVwibWF4LWhlaWdodDogNjBweDsgbWF4LXdpZHRoOiAxMDAlO1wiIC8+XG4gICAgICAgICAgPHAgc3R5bGU9XCJmb250LXNpemU6IDAuNjVyZW07IGNvbG9yOiAjNWY2YjdhOyBtYXJnaW4tdG9wOiA2cHg7XCI+TGlnaHQgdGhlbWVzPC9wPlxuICAgICAgICA8L2Rpdj5cbiAgICAgIDwvZGl2PlxuICAgICAgPHAgaWQ9XCJsb2dvLXN0YXR1c1wiIHN0eWxlPVwiZm9udC1zaXplOiAwLjc1cmVtOyBjb2xvcjogdmFyKC0tbXV0ZWQpOyBtYXJnaW4tYm90dG9tOiAxMnB4OyB0ZXh0LWFsaWduOiBjZW50ZXI7XCI+VXNpbmcgZGVmYXVsdCBsb2dvczwvcD5cblxuICAgICAgPGRpdiBjbGFzcz1cIm1iLTE2XCI+XG4gICAgICAgIDxsYWJlbCBzdHlsZT1cImRpc3BsYXk6IGZsZXg7IGFsaWduLWl0ZW1zOiBjZW50ZXI7IGdhcDogOHB4OyBmb250LXNpemU6IDAuODJyZW07IGN1cnNvcjogcG9pbnRlcjsgdXNlci1zZWxlY3Q6IG5vbmU7XCI+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJjaGVja2JveFwiIGlkPVwibG9nby1zYW1lLWJvdGhcIiAvPiBVc2Ugc2FtZSBsb2dvIGZvciBib3RoXG4gICAgICAgIDwvbGFiZWw+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGRpdiBpZD1cImxvZ28tZHVhbC11cGxvYWRzXCIgY2xhc3M9XCJtYi0xNlwiIHN0eWxlPVwiZGlzcGxheTogZmxleDsgZ2FwOiAxMnB4O1wiPlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTtcIj5cbiAgICAgICAgICA8bGFiZWwgZm9yPVwibG9nby11cGxvYWQtZGFya1wiIHN0eWxlPVwiZGlzcGxheTogYmxvY2s7IG1hcmdpbi1ib3R0b206IDZweDsgZm9udC1zaXplOiAwLjhyZW07XCI+RGFyayB0aGVtZSBsb2dvOjwvbGFiZWw+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJmaWxlXCIgaWQ9XCJsb2dvLXVwbG9hZC1kYXJrXCIgYWNjZXB0PVwiaW1hZ2UvKlwiIGNsYXNzPVwiaW5wdXQtY2FyZC1hbHRcIiBzdHlsZT1cImZvbnQtc2l6ZTogMC43NXJlbTtcIiAvPlxuICAgICAgICA8L2Rpdj5cbiAgICAgICAgPGRpdiBzdHlsZT1cImZsZXg6IDE7XCI+XG4gICAgICAgICAgPGxhYmVsIGZvcj1cImxvZ28tdXBsb2FkLWxpZ2h0XCIgc3R5bGU9XCJkaXNwbGF5OiBibG9jazsgbWFyZ2luLWJvdHRvbTogNnB4OyBmb250LXNpemU6IDAuOHJlbTtcIj5MaWdodCB0aGVtZSBsb2dvOjwvbGFiZWw+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJmaWxlXCIgaWQ9XCJsb2dvLXVwbG9hZC1saWdodFwiIGFjY2VwdD1cImltYWdlLypcIiBjbGFzcz1cImlucHV0LWNhcmQtYWx0XCIgc3R5bGU9XCJmb250LXNpemU6IDAuNzVyZW07XCIgLz5cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGRpdiBpZD1cImxvZ28tc2luZ2xlLXVwbG9hZFwiIGNsYXNzPVwibWItMTZcIiBzdHlsZT1cImRpc3BsYXk6IG5vbmU7XCI+XG4gICAgICAgIDxsYWJlbCBmb3I9XCJsb2dvLXVwbG9hZC1zaW5nbGVcIiBzdHlsZT1cImRpc3BsYXk6IGJsb2NrOyBtYXJnaW4tYm90dG9tOiA2cHg7IGZvbnQtc2l6ZTogMC44cmVtO1wiPlVwbG9hZCBsb2dvOjwvbGFiZWw+XG4gICAgICAgIDxpbnB1dCB0eXBlPVwiZmlsZVwiIGlkPVwibG9nby11cGxvYWQtc2luZ2xlXCIgYWNjZXB0PVwiaW1hZ2UvKlwiIGNsYXNzPVwiaW5wdXQtY2FyZC1hbHRcIiAvPlxuICAgICAgICA8cCBjbGFzcz1cInRpbnktaGludFwiPlRoaXMgbG9nbyB3aWxsIGJlIHVzZWQgb24gYWxsIHRoZW1lc
Line truncated
|
||||
`}).join(""),L.querySelectorAll(".share-revoke").forEach(o=>{o.addEventListener("click",()=>i(o.dataset.shareId))})}catch{L.innerHTML='<span style="color: var(--muted);">Could not load outstanding shares.</span>'}}async function i(n){try{const t=await fetch(`/api/v1/share/${encodeURIComponent(n)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok){const r=await t.json().catch(()=>({}));B(r&&r.error||`Revoke failed (HTTP ${t.status}).`);return}z("Share revoked."),S()}catch{B("Network error while revoking.")}}async function p(){if(!T)return;v(),M.disabled=!0;const n=M.textContent;M.textContent="Creating\u2026";try{const t=parseInt(E.value,10),r=await fetch("/api/v1/share",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:T.id,ttlMs:t})}),e=await r.json().catch(()=>({}));if(!r.ok||!e.success){f(r.status,e);return}const o=e.data.urlPath;N.value=u(o),D.textContent=`Public link \xB7 expires ${y(e.data.expiresAt)}`,m.style.display="block",z("Share link created."),S()}catch{B("Network error while creating share.")}finally{M.disabled=!1,M.textContent=n}}async function l(){if(!T)return;const n=($.value||"").trim();if(!n||!n.includes("@")){B("A valid recipient email is required.");return}v(),I.disabled=!0;const t=I.textContent;I.textContent="Creating\u2026";try{const r=await fetch("/api/v1/share/tailscale",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({serviceId:T.id,email:n})}),e=await r.json().catch(()=>({}));if(!r.ok||!e.success){f(r.status,e);return}const o=e.data&&e.data.urlPath;o?(N.value=u(o),D.textContent=`Tailscale invite \xB7 emailed to ${n} (or use this URL manually if delivery failed).`):(N.value="",D.textContent=`Tailscale invite sent to ${n}.`),m.style.display="block",z("Tailscale invite created."),$.value="",S()}catch{B("Network error while creating Tailscale invite.")}finally{I.disabled=!1,I.textContent=t}}function f(n,t){const r=t&&t.error||"";if(n===402){B("Share is a Pro feature. Activate a license to unlock.");return}if(n===400&&/tailscale/i.test(r)){B("Tailscale is not configured on this host. Set up Tailscale in the dashboard first.");return}if(n===403){B("You do not have permission to share services.");return}if(n===404){B("Service not found. It may have been deleted.");return}B(r||`Request failed (HTTP ${n}).`)}function c(n){!n||!n.id||(T={id:n.id,name:n.name||n.id},j.textContent=T.name,v(),w("public"),$.value="",E.value=String(b[1].ms),h.classList.add("show"),S())}h.querySelectorAll(".share-tab").forEach(n=>{n.addEventListener("click",()=>w(n.dataset.tab))}),M.addEventListener("click",p),I.addEventListener("click",l),k.addEventListener("click",()=>h.classList.remove("show")),wireModal(h,k),A.addEventListener("click",async()=>{const n=N.value;if(n)try{navigator.clipboard&&navigator.clipboard.writeText?await navigator.clipboard.writeText(n):(N.select(),document.execCommand("copy"));const t=A.textContent;A.textContent="Copied!",setTimeout(()=>{A.textContent=t},1200)}catch{B("Could not copy to clipboard. Select the URL manually.")}}),window.openShareModal=c})();
|
||||
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiPHN0ZGluPiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLy8gTG9nbyBDdXN0b21pemF0aW9uIFN5c3RlbVxuKGZ1bmN0aW9uKCkge1xuICAvLyBJbmplY3QgbW9kYWwgSFRNTFxuICBpbmplY3RNb2RhbCgnbG9nby1tb2RhbCcsIGA8ZGl2IGlkPVwibG9nby1tb2RhbFwiIGNsYXNzPVwid2VhdGhlci1tb2RhbFwiPlxuICAgIDxkaXYgY2xhc3M9XCJ3ZWF0aGVyLW1vZGFsLWNvbnRlbnRcIiBzdHlsZT1cIm1pbi13aWR0aDogNDAwcHg7IG1heC13aWR0aDogNTIwcHg7XCI+XG4gICAgICA8aDM+RGFzaGJvYXJkIFNldHRpbmdzPC9oMz5cbiAgICAgIDxwIHN0eWxlPVwiZm9udC1zaXplOiAwLjg1cmVtOyBjb2xvcjogdmFyKC0tbXV0ZWQpOyBtYXJnaW46IDAgMCAxNnB4O1wiPlxuICAgICAgICBDdXN0b21pemUgeW91ciBkYXNoYm9hcmQncyBhcHBlYXJhbmNlIGFuZCBzeXN0ZW0gcHJlZmVyZW5jZXMuXG4gICAgICA8L3A+XG5cbiAgICAgIDxkaXYgY2xhc3M9XCJtYi0xNlwiPlxuICAgICAgICA8bGFiZWwgZm9yPVwiZGFzaGJvYXJkLXRpdGxlXCIgY2xhc3M9XCJmb3JtLWxhYmVsLWJvbGRcIj5EYXNoYm9hcmQgVGl0bGU6PC9sYWJlbD5cbiAgICAgICAgPGlucHV0IHR5cGU9XCJ0ZXh0XCIgaWQ9XCJkYXNoYm9hcmQtdGl0bGVcIiBwbGFjZWhvbGRlcj1cIkRhc2hDYWRkeVwiIG1heGxlbmd0aD1cIjUwXCIgc3R5bGU9XCJ3aWR0aDogMTAwJTsgcGFkZGluZzogMTBweCAxMnB4OyBib3JkZXI6IDFweCBzb2xpZCB2YXIoLS1ib3JkZXIpOyBib3JkZXItcmFkaXVzOiA0cHg7IGJhY2tncm91bmQ6IHZhcigtLWNhcmQtYmcpOyBjb2xvcjogdmFyKC0tZmcpOyBmb250LXNpemU6IDFyZW07XCIgLz5cbiAgICAgICAgPHAgY2xhc3M9XCJ0aW55LWhpbnRcIj5TaG93biBpbiBicm93c2VyIHRhYiBhbmQgaGVhZGVyIChtYXggNTAgY2hhcmFjdGVycyk8L3A+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGhyIGNsYXNzPVwiaHItZGl2aWRlclwiIC8+XG5cbiAgICAgIDxkaXYgY2xhc3M9XCJtYi0xNlwiPlxuICAgICAgICA8bGFiZWwgY2xhc3M9XCJmb3JtLWxhYmVsLWJvbGRcIj5Mb2dvOjwvbGFiZWw+XG4gICAgICAgIDxwIGNsYXNzPVwidGlueS1oaW50XCIgc3R5bGU9XCJtYXJnaW4tdG9wOiAycHg7XCI+U2VwYXJhdGUgbG9nb3MgZm9yIGRhcmsgYW5kIGxpZ2h0IHRoZW1lcywgb3IgdXNlIHRoZSBzYW1lIGZvciBib3RoLjwvcD5cbiAgICAgIDwvZGl2PlxuXG4gICAgICA8ZGl2IHN0eWxlPVwiZGlzcGxheTogZmxleDsgZ2FwOiAxMnB4OyBtYXJnaW4tYm90dG9tOiAxMnB4O1wiPlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTsgdGV4dC1hbGlnbjogY2VudGVyOyBwYWRkaW5nOiAxNnB4IDEwcHg7IGJvcmRlci1yYWRpdXM6IDhweDsgYmFja2dyb3VuZDogIzFhMWEyZTsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgyNTUsMjU1LDI1NSwuMSk7XCI+XG4gICAgICAgICAgPGltZyBpZD1cImxvZ28tcHJldmlldy1kYXJrXCIgc3JjPVwiL2Fzc2V0cy9kYXNoY2FkZHktbG9nby1kYXJrLnBuZ1wiIGFsdD1cIkRhcmsgdGhlbWUgbG9nb1wiIHN0eWxlPVwibWF4LWhlaWdodDogNjBweDsgbWF4LXdpZHRoOiAxMDAlO1wiIC8+XG4gICAgICAgICAgPHAgc3R5bGU9XCJmb250LXNpemU6IDAuNjVyZW07IGNvbG9yOiAjOWFhNmJmOyBtYXJnaW4tdG9wOiA2cHg7XCI+RGFyayB0aGVtZXM8L3A+XG4gICAgICAgIDwvZGl2PlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTsgdGV4dC1hbGlnbjogY2VudGVyOyBwYWRkaW5nOiAxNnB4IDEwcHg7IGJvcmRlci1yYWRpdXM6IDhweDsgYmFja2dyb3VuZDogI2YwZjBmMDsgYm9yZGVyOiAxcHggc29saWQgcmdiYSgwLDAsMCwuMSk7XCI+XG4gICAgICAgICAgPGltZyBpZD1cImxvZ28tcHJldmlldy1saWdodFwiIHNyYz1cIi9hc3NldHMvZGFzaGNhZGR5LWxvZ28tbGlnaHQucG5nXCIgYWx0PVwiTGlnaHQgdGhlbWUgbG9nb1wiIHN0eWxlPVwibWF4LWhlaWdodDogNjBweDsgbWF4LXdpZHRoOiAxMDAlO1wiIC8+XG4gICAgICAgICAgPHAgc3R5bGU9XCJmb250LXNpemU6IDAuNjVyZW07IGNvbG9yOiAjNWY2YjdhOyBtYXJnaW4tdG9wOiA2cHg7XCI+TGlnaHQgdGhlbWVzPC9wPlxuICAgICAgICA8L2Rpdj5cbiAgICAgIDwvZGl2PlxuICAgICAgPHAgaWQ9XCJsb2dvLXN0YXR1c1wiIHN0eWxlPVwiZm9udC1zaXplOiAwLjc1cmVtOyBjb2xvcjogdmFyKC0tbXV0ZWQpOyBtYXJnaW4tYm90dG9tOiAxMnB4OyB0ZXh0LWFsaWduOiBjZW50ZXI7XCI+VXNpbmcgZGVmYXVsdCBsb2dvczwvcD5cblxuICAgICAgPGRpdiBjbGFzcz1cIm1iLTE2XCI+XG4gICAgICAgIDxsYWJlbCBzdHlsZT1cImRpc3BsYXk6IGZsZXg7IGFsaWduLWl0ZW1zOiBjZW50ZXI7IGdhcDogOHB4OyBmb250LXNpemU6IDAuODJyZW07IGN1cnNvcjogcG9pbnRlcjsgdXNlci1zZWxlY3Q6IG5vbmU7XCI+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJjaGVja2JveFwiIGlkPVwibG9nby1zYW1lLWJvdGhcIiAvPiBVc2Ugc2FtZSBsb2dvIGZvciBib3RoXG4gICAgICAgIDwvbGFiZWw+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGRpdiBpZD1cImxvZ28tZHVhbC11cGxvYWRzXCIgY2xhc3M9XCJtYi0xNlwiIHN0eWxlPVwiZGlzcGxheTogZmxleDsgZ2FwOiAxMnB4O1wiPlxuICAgICAgICA8ZGl2IHN0eWxlPVwiZmxleDogMTtcIj5cbiAgICAgICAgICA8bGFiZWwgZm9yPVwibG9nby11cGxvYWQtZGFya1wiIHN0eWxlPVwiZGlzcGxheTogYmxvY2s7IG1hcmdpbi1ib3R0b206IDZweDsgZm9udC1zaXplOiAwLjhyZW07XCI+RGFyayB0aGVtZSBsb2dvOjwvbGFiZWw+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJmaWxlXCIgaWQ9XCJsb2dvLXVwbG9hZC1kYXJrXCIgYWNjZXB0PVwiaW1hZ2UvKlwiIGNsYXNzPVwiaW5wdXQtY2FyZC1hbHRcIiBzdHlsZT1cImZvbnQtc2l6ZTogMC43NXJlbTtcIiAvPlxuICAgICAgICA8L2Rpdj5cbiAgICAgICAgPGRpdiBzdHlsZT1cImZsZXg6IDE7XCI+XG4gICAgICAgICAgPGxhYmVsIGZvcj1cImxvZ28tdXBsb2FkLWxpZ2h0XCIgc3R5bGU9XCJkaXNwbGF5OiBibG9jazsgbWFyZ2luLWJvdHRvbTogNnB4OyBmb250LXNpemU6IDAuOHJlbTtcIj5MaWdodCB0aGVtZSBsb2dvOjwvbGFiZWw+XG4gICAgICAgICAgPGlucHV0IHR5cGU9XCJmaWxlXCIgaWQ9XCJsb2dvLXVwbG9hZC1saWdodFwiIGFjY2VwdD1cImltYWdlLypcIiBjbGFzcz1cImlucHV0LWNhcmQtYWx0XCIgc3R5bGU9XCJmb250LXNpemU6IDAuNzVyZW07XCIgLz5cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L2Rpdj5cblxuICAgICAgPGRpdiBpZD1cImxvZ28tc2luZ2xlLXVwbG9hZFwiIGNsYXNzPVwibWItMTZcIiBzdHlsZT1cImRpc3BsYXk6IG5vbmU7XCI+XG4gICAgICAgIDxsYWJlbCBmb3I9XCJsb2dvLXVwbG9hZC1zaW5nbGVcIiBzdHlsZT1cImRpc3BsYXk6IGJsb2NrOyBtYXJnaW4tYm90dG9tOiA2cHg7IGZvbnQtc2l6ZTogMC44cmVtO1wiPlVwbG9hZCBsb2dvOjwvbGFiZWw+XG4gICAgICAgIDxpbnB1dCB0eXBlPVwiZmlsZVwiIGlkPVwibG9nby11cGxvYWQtc2luZ2xlXCIgYWNjZXB0PVwiaW1hZ2UvKlwiIGNsYXNzPVwiaW5wdXQtY2FyZC1hbHRcIiAvPlxuICAgICAgICA8cCBjbGFzcz1cInRpbnktaGludFwiPlRoaXMgbG9nbyB3aWxsIGJlIHVzZWQgb24gYWxsIHRoZW1lc
Line truncated
|
||||
Reference in new issue
Block a user