import { fmtUptime, engActiveRows, engQueuedRows, engRecentRows } from "../fmt.js";
document.addEventListener("alpine:init", () => {
Alpine.data("deployEngine", () => ({
get store() {
return Alpine.store("app");
},
get engine() {
return this.store.snap?.engine || null;
},
get active() {
return engActiveRows(this.engine?.active);
},
detailId: null,
get detail() {
return this.detailId ? this.active.find((a) => a.serviceId === this.detailId) || null : null;
},
openDetail(id) {
this.detailId = id;
},
closeDetail() {
this.detailId = null;
},
get queued() {
return engQueuedRows(this.engine?.queued);
},
get recent() {
return engRecentRows(this.engine?.recent);
},
get paused() {
return !!this.engine?.paused;
},
get uptime() {
return this.engine ? fmtUptime(this.engine.uptime_secs) : "…";
},
get successCount() {
return this.engine?.successful_24h ?? 0;
},
get failedCount() {
return this.engine?.failed_24h ?? 0;
},
get totalCount() {
return this.engine?.total_24h ?? 0;
},
}));
});