window.pageBoot = async (me) => { /* ---------------- shared state ---------------- */ let OPT = null; // wizard options let mode = "list"; // list | monitor let editingId = null; // editing existing campaign const ST_BADGE = { draft: "b-gray", queued: "b-blue", running: "b-amber", paused: "b-violet", completed: "b-green", cancelled: "b-gray", failed: "b-red" }; const C = {}; // wizard state (CampaignIn mirror) const DEF = () => ({ name: "", recipient_list_id: null, subject_set_ids: [], template_ids: [], message_type: "html", attach_mode: "none", attach_pdf: false, attach_pdf_template_id: null, attachment_id: null, variable_config: {}, account_ids: [], rotation_strategy: "sequential", rotation_weights: {}, subject_rotation: "round_robin", template_sequence_mode: "repeat", phone_selection: "round_robin", max_per_account: 200, send_interval_seconds: 1.0, rate_per_minute: 60, max_retries: 3, retry_delay_seconds: 60, unsubscribe_enabled: true, preview_sample_size: 5, }); Object.assign(C, DEF()); let step = 1; const STEPS = [ "Campaign name", "Recipient list", "Subject lines", "Templates", "Attachments", "Variables & amounts", "Gmail accounts", "Rotation & weights", "Limits & pacing", "Company phone", "Unsubscribe", "Confirm & start", ]; const STEPS_KEYS = ["name", "recipients", "subjects", "templates", "attachments", "variables", "accounts", "rotation", "limits", "phone", "unsubscribe", "confirm"]; async function loadOptions() { const d = await GET("/campaigns/wizard/options"); OPT = d; return d; } function stBadge(s) { return `${esc(s || "—")}`; } /* ==================== LIST PANE ==================== */ let lst = { page: 1, status: "", q: "" }; async function loadList() { const box = $("#campTable"); box.innerHTML = `
`; try { const p = new URLSearchParams({ status: lst.status, search: lst.q, page: lst.page, page_size: 20 }); const d = await GET("/campaigns/list?" + p); const rows = d.campaigns || []; box.innerHTML = rows.length ? `| ID | Name | Status | Recipients | Sent | Failed | Suppressed | Skipped | Started | Actions |
|---|---|---|---|---|---|---|---|---|---|
| ${c.id} | ${esc(c.name)} | ${stBadge(c.status)} | ${c.total_recipients ?? 0} | ${c.sent_count ?? 0} | ${c.failed_count ?? 0} | ${c.suppressed_count ?? 0} | ${c.skipped_count ?? 0} | ${fmtDT(c.started_at)} | ${["draft", "paused"].includes(c.status) ? `` : ""} |
No campaigns yet. Use the wizard to create your first campaign.