262 lines
14 KiB
JavaScript
262 lines
14 KiB
JavaScript
// ---------- Launch calendar ----------
|
|
// RNDSystems launches every 2nd & 4th Tuesday · BT launches every 3rd Tuesday.
|
|
// Code freeze: Friday at 10:00 AM, the week of the launch (Friday before launch day).
|
|
const UAT_NOW = new Date(); UAT_NOW.setHours(0, 0, 0, 0);
|
|
function nthTuesday(y, m, n) {
|
|
const d = new Date(y, m, 1);
|
|
const first = ((2 - d.getDay()) + 7) % 7; // offset to first Tuesday
|
|
return new Date(y, m, 1 + first + (n - 1) * 7);
|
|
}
|
|
function upcomingLaunches(ordinals, count) {
|
|
const out = [];
|
|
for (let i = 0; i < 18 && out.length < count; i++) {
|
|
const m = UAT_NOW.getMonth() + i;
|
|
const y = UAT_NOW.getFullYear() + Math.floor(m / 12);
|
|
const mm = m % 12;
|
|
for (const n of ordinals) {
|
|
const launch = nthTuesday(y, mm, n);
|
|
if (launch >= UAT_NOW) out.push({ launch, freeze: new Date(launch.getTime() - 4 * 86400000) });
|
|
}
|
|
}
|
|
return out.sort((a, b) => a.launch - b.launch).slice(0, count);
|
|
}
|
|
const RDNS_LAUNCHES = upcomingLaunches([2, 4], 3);
|
|
const BT_LAUNCHES = upcomingLaunches([3], 3);
|
|
const fmtD = d => d.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" });
|
|
const fmtDy = d => d.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" });
|
|
const daysUntil = d => Math.round((d - UAT_NOW) / 86400000);
|
|
// global next freeze (whichever comes first)
|
|
const NEXT_FREEZE = RDNS_LAUNCHES[0].freeze < BT_LAUNCHES[0].freeze
|
|
? { ...RDNS_LAUNCHES[0], site: "RNDSystems" }
|
|
: { ...BT_LAUNCHES[0], site: "BT" };
|
|
|
|
// ---------- Grouping (by launch cycle) ----------
|
|
function siteOf(t) {
|
|
const first = ((t.desc || "").split("|")[0] || "").trim().toLowerCase();
|
|
if (/^rnd|^r&d/.test(first)) return "RNDSystems";
|
|
if (/^bt\b|^bio/.test(first)) return "BT";
|
|
if (/^wms/.test(first)) return "WMS";
|
|
if (/^sbd|^spd|^spatial/.test(first)) return "SBD";
|
|
return "Other";
|
|
}
|
|
const SITE_ORDER = { "RNDSystems": 10, "BT": 11, "WMS": 12, "SBD": 13 };
|
|
const STATE_OPTIONS = ["Draft", "Ready", "Work in Progress", "Peer Review", "QA Testing", "UAT Testing", "Approved", "Awaiting Deployment", "Complete", "Cancelled"];
|
|
// priority within a launch section: outreach action needed first, then state readiness
|
|
const ACTION_ORDER = { 0: 0, 1: 1, 2: 2, 4: 3, 3: 4 };
|
|
const STATE_ORDER = { "UAT Testing": 0, "Work in Progress": 1, "Peer Review": 2, "QA Testing": 3, "Draft": 4, "Ready": 5 };
|
|
|
|
// "sent to bottom" memory (order matters — the order you sent them down)
|
|
const BOTTOM_KEY = "uat-outreach-bottom-v1";
|
|
let bottomOrder = [];
|
|
try { bottomOrder = JSON.parse(localStorage.getItem(BOTTOM_KEY) || "[]"); } catch { bottomOrder = []; }
|
|
function saveBottom() { localStorage.setItem(BOTTOM_KEY, JSON.stringify(bottomOrder)); }
|
|
function moveBottom(id) {
|
|
if (bottomOrder.includes(id)) bottomOrder = bottomOrder.filter(x => x !== id);
|
|
else bottomOrder.push(id);
|
|
saveBottom();
|
|
uatRender();
|
|
}
|
|
|
|
// ---------- Filters ----------
|
|
const els = {
|
|
statusFilter: document.getElementById("statusFilter"),
|
|
stateFilter: document.getElementById("stateFilter"),
|
|
epicFilter: document.getElementById("epicFilter"),
|
|
search: document.getElementById("search"),
|
|
showDone: document.getElementById("showDoneToggle"),
|
|
list: document.getElementById("list"),
|
|
};
|
|
let hideApproved = false;
|
|
let showHidden = false;
|
|
const isVisibleState = t => !HARD_EXCLUDED.has(t.state) && (showHidden || !IGNORED_STATES.has(t.state));
|
|
|
|
function populateFilters() {
|
|
const states = [...new Set(tickets.map(t => t.state).filter(s => s && !HARD_EXCLUDED.has(s) && (showHidden || !IGNORED_STATES.has(s))))].sort();
|
|
const epics = [...new Set(tickets.map(t => t.epic).filter(Boolean))].sort();
|
|
const prevState = els.stateFilter.value;
|
|
const prevEpic = els.epicFilter.value;
|
|
els.stateFilter.innerHTML = '<option value="">All ticket states</option>' +
|
|
states.map(s => `<option>${s}</option>`).join("");
|
|
els.epicFilter.innerHTML = '<option value="">All epics</option>' +
|
|
epics.map(s => `<option>${s}</option>`).join("");
|
|
if (states.includes(prevState)) els.stateFilter.value = prevState;
|
|
if (epics.includes(prevEpic)) els.epicFilter.value = prevEpic;
|
|
}
|
|
|
|
function visibleTickets() {
|
|
const sf = els.statusFilter.value;
|
|
const ts = els.stateFilter.value;
|
|
const ep = els.epicFilter.value;
|
|
const q = els.search.value.trim().toLowerCase();
|
|
return tickets.filter(t => {
|
|
if (!isVisibleState(t)) return false;
|
|
if (hideApproved && uatStatusOf(t) === 3 && sf === "") return false;
|
|
if (sf !== "" && uatStatusOf(t) !== Number(sf)) return false;
|
|
if (ts && t.state !== ts) return false;
|
|
if (ep && t.epic !== ep) return false;
|
|
if (q && !(t.ticket + " " + t.desc + " " + t.assigned_to + " " + t.opened_by + " " + t.epic + " " + (t.watch_list || "")).toLowerCase().includes(q)) return false;
|
|
return true;
|
|
});
|
|
}
|
|
|
|
// ---------- Render (organized by next launch per site) ----------
|
|
function escUat(s) {
|
|
return (s || "").replace(/[&<>"']/g, c =>
|
|
({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c]));
|
|
}
|
|
|
|
function uatRender() {
|
|
const vis = visibleTickets();
|
|
vis.forEach(t => { t.site = siteOf(t); });
|
|
|
|
// summary (counts over all tickets)
|
|
const counts = [0, 0, 0, 0, 0];
|
|
const active = tickets.filter(t => isVisibleState(t));
|
|
active.forEach(t => counts[uatStatusOf(t)]++);
|
|
for (let i = 0; i < 5; i++) document.getElementById("cnt" + i).textContent = counts[i];
|
|
const done = counts[3], total = active.length;
|
|
const pct = total ? Math.round((done / total) * 100) : 0;
|
|
document.getElementById("prog").style.width = pct + "%";
|
|
document.getElementById("progLabel").textContent =
|
|
total ? `${done} of ${total} approved (${pct}%) · ${counts[2]} waiting on a response` : "";
|
|
|
|
// freeze banner (top of page)
|
|
const bf = document.getElementById("uatBanner");
|
|
if (bf) {
|
|
const n = daysUntil(NEXT_FREEZE.freeze);
|
|
if (n >= 0 && n <= 7) {
|
|
bf.style.display = "flex";
|
|
bf.innerHTML = `⚠️ <span>Code freeze: <b>${fmtD(NEXT_FREEZE.freeze)} at 10:00 AM</b> (${n === 0 ? "TODAY" : n + " day" + (n === 1 ? "" : "s") + " from now"})</span>
|
|
<span class="b-sub">→ launch ${escUat(NEXT_FREEZE.site)} on ${fmtD(NEXT_FREEZE.launch)} · make sure testers are booked & approved stories are ready</span>`;
|
|
} else bf.style.display = "none";
|
|
}
|
|
|
|
// launch calendar cards
|
|
const lc = document.getElementById("launchCards");
|
|
if (lc) {
|
|
const siteCount = s => vis.filter(t => t.site === s).length;
|
|
const card = (name, rule, launches, count) => {
|
|
const hot = daysUntil(launches[0].freeze) <= 7;
|
|
return `<div class="lcard${hot ? " hot" : ""}">
|
|
<h3>${name}</h3>
|
|
<div class="rule">${rule}</div>
|
|
<div class="lnext">🚀 ${fmtDy(launches[0].launch)} · <span class="fz">🧊 freeze ${fmtD(launches[0].freeze)} 10 AM</span></div>
|
|
<div class="lcount"><b>${count}</b> open ticket${count === 1 ? "" : "s"} in queue · next in ${daysUntil(launches[0].launch)} days</div>
|
|
<div class="lmore">then ${launches.slice(1).map(l => fmtD(l.launch)).join(" · ")}</div>
|
|
</div>`;
|
|
};
|
|
const both = [ { name: "🖥 RNDSystems", rule: "launches 2nd & 4th Tuesday", launches: RDNS_LAUNCHES, count: siteCount("RNDSystems") },
|
|
{ name: "🧬 BT", rule: "launches 3rd Tuesday", launches: BT_LAUNCHES, count: siteCount("BT") } ]
|
|
.sort((a, b) => a.launches[0].launch - b.launches[0].launch);
|
|
lc.innerHTML = both.map(c => card(c.name, c.rule, c.launches, c.count)).join("");
|
|
}
|
|
|
|
if (!vis.length) {
|
|
els.list.innerHTML = tickets.length
|
|
? '<div class="uempty">No tickets match the current filters.</div>'
|
|
: '<div class="uempty">📂 No data loaded yet.<br>Click <b>"📂 Load weekly CSV"</b> in the toolbar (or drag & drop your weekly ServiceNow export anywhere on this tab) to get started.</div>';
|
|
updateUatBadge();
|
|
return;
|
|
}
|
|
|
|
// priority sort inside a section: normal order first, "sent to bottom" tickets last
|
|
const cmp = (a, b) => {
|
|
const ab = bottomOrder.indexOf(a.ticket), bb = bottomOrder.indexOf(b.ticket);
|
|
const aB = ab === -1 ? 1 : 0, bB = bb === -1 ? 1 : 0;
|
|
if (aB !== bB) return aB - bB;
|
|
if (ab !== -1 && bb !== -1) return ab - bb;
|
|
const sa = ACTION_ORDER[uatStatusOf(a)], sb = ACTION_ORDER[uatStatusOf(b)];
|
|
if (sa !== sb) return sa - sb;
|
|
const ta = STATE_ORDER[a.state] ?? 99, tb = STATE_ORDER[b.state] ?? 99;
|
|
if (ta !== tb) return ta - tb;
|
|
return a.ticket.localeCompare(b.ticket);
|
|
};
|
|
|
|
const bucketLaunch = site =>
|
|
site === "RNDSystems" ? RDNS_LAUNCHES[0] : (site === "BT" ? BT_LAUNCHES[0] : null);
|
|
const siteRule = { RNDSystems: "2nd & 4th Tuesday", BT: "3rd Tuesday" };
|
|
|
|
const withLaunch = [], without = [];
|
|
for (const s of new Set(vis.map(t => t.site))) (bucketLaunch(s) ? withLaunch : without).push(s);
|
|
// nearest launch first — the section you have to worry about now comes on top
|
|
withLaunch.sort((a, b) => daysUntil(bucketLaunch(a).launch) - daysUntil(bucketLaunch(b).launch) || (SITE_ORDER[a] ?? 98) - (SITE_ORDER[b] ?? 98));
|
|
without.sort((a, b) => (SITE_ORDER[a] ?? 98) - (SITE_ORDER[b] ?? 98) || a.localeCompare(b));
|
|
const keys = [...withLaunch, ...without];
|
|
const nextSite = withLaunch[0] || null;
|
|
|
|
const colhead = `<div class="colhead"><span>Ticket</span><span>Description</span><span>State</span><span>Tester (watch list)</span><span>Dev</span><span style="text-align:right">Outreach status</span></div>`;
|
|
const row = t => {
|
|
const s = uatStatusOf(t);
|
|
const btnLabels = ["Reached out", "Waiting", "Approved"];
|
|
const isUAT = /^UAT/i.test(t.state || "");
|
|
const isBottom = bottomOrder.includes(t.ticket);
|
|
return `<div class="rowwrap">
|
|
<button class="holdbtn${s === 4 ? " on" : ""}" data-hold="${escUat(t.ticket)}" title="On hold — not ready for UAT yet (waiting on something). Click again to clear.">⏸</button>
|
|
<button class="bottombtn${isBottom ? " on" : ""}" data-bottom="${escUat(t.ticket)}" title="${isBottom ? "Bring back to priority order" : "Send to bottom of this section"}">${isBottom ? "⬆" : "⬇"}</button>
|
|
<div class="row st-${s}${isBottom ? " dimmed" : ""}" data-ticket="${escUat(t.ticket)}">
|
|
<span class="ticket" title="${escUat(t.ticket)}">${escUat(t.ticket)}</span>
|
|
<span class="desc" title="${escUat(t.desc)}">${escUat(t.desc) || "—"}</span>
|
|
<span class="cell editable" data-field="state" title="Click to edit"><span class="tag">${escUat(t.state) || "—"}</span></span>
|
|
<span class="cell tester editable" data-field="watch_list" title="${escUat(t.watch_list)} — click to edit">${t.watch_list ? `<span class="tag tester">${escUat(t.watch_list)}</span>` : "—"}</span>
|
|
<span class="cell editable" data-field="assigned_to" title="${escUat(t.assigned_to)} — click to edit">${t.assigned_to ? `→ ${escUat(t.assigned_to)}` : "—"}</span>
|
|
<span class="status-btns">
|
|
${[1, 2, 3].map(i =>
|
|
`<button class="sbtn${i === s ? " on" : ""}" data-s="${i}" data-ticket="${escUat(t.ticket)}">${btnLabels[i - 1]}</button>`
|
|
).join("")}
|
|
</span>
|
|
</div>
|
|
${(isUAT || t.note) ? `
|
|
<div class="uat-line">
|
|
<button class="mini" data-note="${escUat(t.ticket)}">📝 ${t.note ? "Edit feedback note" : "Add feedback note"}</button>
|
|
${isUAT ? `<button class="mini wip" data-wip="${escUat(t.ticket)}" title="Sets the state to Work in Progress">↩ Send back to Work in Progress</button>` : ""}
|
|
${t.note ? `<span class="notetext" title="${escUat(t.note)}">“${escUat(t.note)}”</span>` : ""}
|
|
</div>` : ""}
|
|
</div>`;
|
|
};
|
|
|
|
const section = site => {
|
|
const list = vis.filter(t => t.site === site).sort(cmp);
|
|
if (!list.length) return "";
|
|
const launch = bucketLaunch(site);
|
|
let head = `<div class="section-head">
|
|
<div class="bsec"><span style="font-size:15px">${site === "RNDSystems" ? "🖥" : (site === "BT" ? "🧬" : "📦")}</span>
|
|
<span style="font-size:13px;font-weight:700;letter-spacing:.05em;text-transform:uppercase">${escUat(site)}</span>${site === nextSite ? '<span class="bnext">⏭ NEXT UP</span>' : ""}`;
|
|
if (launch) {
|
|
const n = daysUntil(launch.launch);
|
|
const cls = n <= 7 ? "urgent" : (n <= 21 ? "soon" : "later");
|
|
head += `<span class="blaunch">→ launch ${fmtDy(launch.launch)}</span>
|
|
<span class="bfreeze">🧊 freeze ${fmtD(launch.freeze)} · 10 AM</span>
|
|
<span class="bdays ${cls}">${n === 0 ? "LAUNCH TODAY" : n + " day" + (n === 1 ? "" : "s") + " out"}</span>
|
|
<span class="bsub">${siteRule[site]}</span>`;
|
|
} else {
|
|
head += `<span class="bsub">no launch cycle tracked here — keep as a separate queue</span>`;
|
|
}
|
|
head += `<span class="count">${list.length} ticket${list.length === 1 ? "" : "s"}</span></div></div>`;
|
|
const main = list.filter(t => !bottomOrder.includes(t.ticket)).map(row).join("");
|
|
const bots = list.filter(t => bottomOrder.includes(t.ticket));
|
|
const bot = bots.length
|
|
? `<div class="bottom-zone"><div class="bz-label">⬇ sent to bottom · ${bots.length}</div>${bots.map(row).join("")}</div>`
|
|
: "";
|
|
return `<div class="section secbody${site === nextSite ? " next" : ""}">
|
|
${head}
|
|
${colhead}
|
|
${main}
|
|
${bot}
|
|
</div>`;
|
|
};
|
|
|
|
els.list.innerHTML = keys.map(section).join("");
|
|
updateUatBadge();
|
|
}
|
|
|
|
function updateUatBadge() {
|
|
const b = document.getElementById("uatBadge");
|
|
if (!b) return;
|
|
if (!tickets.length) { b.textContent = "🚀"; return; }
|
|
const action = tickets.filter(t => {
|
|
const s = siteOf(t);
|
|
return isVisibleState(t) && (s === "RNDSystems" || s === "BT") && uatStatusOf(t) === 0;
|
|
}).length;
|
|
b.textContent = action > 0 ? `⚠ ${action}` : "🚀";
|
|
}
|