feat: Pipeline board M5 — Mission Brief (list + right-rail inspector) (#175, v0.27.0)
Reworks the board into Direction C Mission Brief: status-grouped run list + persistent inspector reusing M4 Stage I/O; stage-list-driven; preserves New Article + polling + filters; column-limit setting restored. QA APPROVE 1034e19; CI green. Agent-Session: pipeline-board-m5-merge
This commit is contained in:
@@ -1,249 +1,550 @@
|
||||
/**
|
||||
* PRAutoBlogger — Kanban Board Styles
|
||||
* PRAutoBlogger — Mission Brief Board Styles (M5, v0.27.0)
|
||||
*
|
||||
* Warm editorial style (Proposal C / Direction C).
|
||||
* Inside wp-admin chrome; uses WP admin vars where available.
|
||||
* No build step — plain CSS, no preprocessor.
|
||||
* Replaces the four-column kanban with a vertical run-list + right-rail
|
||||
* inspector layout (Option C / "Mission Brief").
|
||||
*
|
||||
* Palette:
|
||||
* Teal #1B8A92 (brand primary — Generating pill, spinner)
|
||||
* Cream #FAF6EE (card background)
|
||||
* Ink #0D0D0D (primary text)
|
||||
* Orange #FF8A3D (In Review pill)
|
||||
* Lime #7FD600 (Published pill — success)
|
||||
* Red #D94F4F (Failed pill)
|
||||
* Mid-grey #8A8A8A (meta text, border)
|
||||
* Design language (locked by CMO consult 2026-06-20):
|
||||
* Surface: #FFFFFF (bg-page / bg-surface)
|
||||
* Inset: #F5F5F5 (bg-inset — sections, inspector bg)
|
||||
* Primary: #1B8A92 (teal-500 — Generating chip, focus ring, CTA)
|
||||
* Hover: #147178 (teal-600)
|
||||
* Lime: #7FD600 (lime-500 — Published chip)
|
||||
* Orange: #FF8A3D (orange-500 — In Review chip)
|
||||
* Error: #C0392B (cautionary — Failed chip, failed row border)
|
||||
* Text: #0D0D0D / #3D3D3D / #808080
|
||||
* Border: #E8E8E8
|
||||
*
|
||||
* @see templates/admin/board-page.php — Rendered HTML structure.
|
||||
* @see assets/js/board.js — DOM updates that match these selectors.
|
||||
* Fonts: Poppins (display), Inter (body/UI), IBM Plex Mono (all numerics).
|
||||
*
|
||||
* No dark mode. No glassmorphism. No glow effects.
|
||||
* Namespace: .prab-board-wrap and .prab-* selectors only.
|
||||
*
|
||||
* @see templates/admin/board-page.php -- Rendered HTML structure.
|
||||
* @see assets/js/board.js -- DOM updates that match these selectors.
|
||||
*/
|
||||
|
||||
/* ── Google Fonts load (same subset as theme — no second copy if already loaded) */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;600&display=swap');
|
||||
|
||||
/* ── Page wrapper ──────────────────────────────────────────────────────── */
|
||||
.prab-board-wrap {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* ── Top bar: heading + New Article CTA ───────────────────────────────── */
|
||||
.prab-board-topbar {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
padding: 18px 20px 12px;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
.prab-board-heading {
|
||||
font-size: 1.4rem;
|
||||
font-weight: 700;
|
||||
color: #0d0d0d;
|
||||
margin: 20px 0 18px 0;
|
||||
padding: 0 20px;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #0D0D0D;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.prab-board-heading-sub {
|
||||
font-size: 1rem;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
color: #8a8a8a;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
/* ── Four-column board grid ────────────────────────────────────────────── */
|
||||
.prab-board {
|
||||
.prab-board-new-article-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 7px 16px;
|
||||
background: #1B8A92;
|
||||
color: #FFFFFF;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
.prab-board-new-article-btn:hover,
|
||||
.prab-board-new-article-btn:focus {
|
||||
background: #147178;
|
||||
color: #FFFFFF;
|
||||
outline: 2px solid #1B8A92;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* ── Two-pane Mission Brief layout ────────────────────────────────────── */
|
||||
.prab-board--mission-brief {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 16px;
|
||||
padding: 0 20px 24px;
|
||||
grid-template-columns: 60% 40%;
|
||||
align-items: start;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.prab-board {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.prab-board {
|
||||
@media (max-width: 900px) {
|
||||
.prab-board--mission-brief {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Column ────────────────────────────────────────────────────────────── */
|
||||
.prab-board-column {
|
||||
background: #f8f7f5;
|
||||
border: 1px solid #e2ddd6;
|
||||
border-radius: 8px;
|
||||
min-height: 180px;
|
||||
/* ── Run list (left pane) ─────────────────────────────────────────────── */
|
||||
.prab-run-list {
|
||||
border-right: 1px solid #E8E8E8;
|
||||
min-height: 400px;
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.prab-col-header {
|
||||
/* ── Section ──────────────────────────────────────────────────────────── */
|
||||
.prab-section {
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
.prab-section:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.prab-section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 14px 10px;
|
||||
border-bottom: 1px solid #e2ddd6;
|
||||
padding: 10px 16px 8px;
|
||||
background: #F5F5F5;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
.prab-col-title {
|
||||
font-size: 0.82rem;
|
||||
.prab-section-label {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: #4a4540;
|
||||
letter-spacing: 0.08em;
|
||||
color: #3D3D3D;
|
||||
}
|
||||
|
||||
.prab-col-cards {
|
||||
padding: 10px 10px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
.prab-section-rows {
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.prab-col-empty {
|
||||
font-size: 0.82rem;
|
||||
color: #b0a898;
|
||||
text-align: center;
|
||||
padding: 20px 0;
|
||||
.prab-section-empty {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
color: #808080;
|
||||
padding: 14px 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ── Status pills ──────────────────────────────────────────────────────── */
|
||||
.prab-pill {
|
||||
/* ── Verdict-style status chips ───────────────────────────────────────── */
|
||||
.prab-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
color: #fff;
|
||||
min-width: 24px;
|
||||
line-height: 1.6;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.prab-pill--generating {
|
||||
background: #1b8a92;
|
||||
.prab-chip--generating {
|
||||
background: #1B8A92;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.prab-pill--review {
|
||||
background: #ff8a3d;
|
||||
.prab-chip--in_review {
|
||||
background: #FF8A3D;
|
||||
color: #0D0D0D;
|
||||
}
|
||||
|
||||
.prab-pill--published {
|
||||
background: #5a9e28;
|
||||
.prab-chip--published {
|
||||
background: #7FD600;
|
||||
color: #0D0D0D;
|
||||
}
|
||||
|
||||
.prab-pill--failed {
|
||||
background: #d94f4f;
|
||||
.prab-chip--failed {
|
||||
background: #C0392B;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* ── Card ──────────────────────────────────────────────────────────────── */
|
||||
.prab-board-card {
|
||||
background: #faf6ee;
|
||||
border: 1px solid #e0d8cc;
|
||||
border-radius: 6px;
|
||||
padding: 11px 12px 10px;
|
||||
position: relative;
|
||||
transition: box-shadow 0.15s ease, border-color 0.15s ease;
|
||||
.prab-chip--human {
|
||||
background: #1B8A92;
|
||||
color: #FFFFFF;
|
||||
font-size: 9px;
|
||||
padding: 1px 6px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.prab-board-card:hover {
|
||||
box-shadow: 0 2px 8px rgba(27, 138, 146, 0.12);
|
||||
border-color: #b8cfd2;
|
||||
/* ── Run row ──────────────────────────────────────────────────────────── */
|
||||
.prab-run-row {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 16px;
|
||||
border-left: 3px solid transparent;
|
||||
cursor: pointer;
|
||||
transition: background 0.1s ease, border-color 0.1s ease;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
.prab-board-card--generating {
|
||||
border-left: 3px solid #1b8a92;
|
||||
.prab-run-row:hover,
|
||||
.prab-run-row:focus {
|
||||
background: #F5F5F5;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.prab-card-title {
|
||||
font-size: 0.875rem;
|
||||
.prab-run-row.is-selected {
|
||||
background: #F0F9FA;
|
||||
border-left-color: #1B8A92;
|
||||
}
|
||||
|
||||
.prab-run-row--failed {
|
||||
border-left-color: #C0392B;
|
||||
}
|
||||
|
||||
.prab-run-row--failed.is-selected {
|
||||
border-left-color: #C0392B;
|
||||
background: #FFF5F5;
|
||||
}
|
||||
|
||||
/* Chip column */
|
||||
.prab-row-chip-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Title + stage label column */
|
||||
.prab-row-main {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.prab-row-title {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #0d0d0d;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 6px;
|
||||
padding-right: 20px; /* room for spinner */
|
||||
color: #0D0D0D;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.prab-card-meta {
|
||||
.prab-run-row--failed .prab-row-title {
|
||||
color: #C0392B;
|
||||
}
|
||||
|
||||
.prab-row-stage-label {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 11px;
|
||||
color: #808080;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.prab-row-error {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 11px;
|
||||
color: #C0392B;
|
||||
margin-top: 2px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* Cost + elapsed column */
|
||||
.prab-row-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.prab-row-cost,
|
||||
.prab-row-elapsed {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 12px;
|
||||
color: #3D3D3D;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.prab-row-elapsed {
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
/* ── Inspector rail (right pane) ─────────────────────────────────────── */
|
||||
.prab-inspector {
|
||||
background: #F5F5F5;
|
||||
min-height: 400px;
|
||||
position: sticky;
|
||||
top: 32px; /* WP admin bar height */
|
||||
max-height: calc(100vh - 60px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.prab-inspector-inner {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.prab-inspector-placeholder {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
color: #808080;
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Inspector header */
|
||||
.prab-inspector-title {
|
||||
font-family: 'Poppins', sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #0D0D0D;
|
||||
margin: 10px 0 4px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.prab-inspector-chip-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 5px;
|
||||
margin-bottom: 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.prab-card-cost {
|
||||
font-size: 0.75rem;
|
||||
color: #5a8a50;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
/* Inspector stage breakdown */
|
||||
.prab-inspector-stages {
|
||||
margin: 0 0 16px;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.prab-card-stage {
|
||||
font-size: 0.74rem;
|
||||
color: #1b8a92;
|
||||
font-weight: 500;
|
||||
margin-bottom: 5px;
|
||||
.prab-inspector-stage {
|
||||
display: grid;
|
||||
grid-template-columns: 12px 1fr auto;
|
||||
align-items: start;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
.prab-card-error {
|
||||
font-size: 0.74rem;
|
||||
color: #d94f4f;
|
||||
margin-bottom: 5px;
|
||||
font-style: italic;
|
||||
.prab-inspector-stage:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.prab-card-actions {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.prab-card-link {
|
||||
display: inline-block;
|
||||
font-size: 0.75rem;
|
||||
color: #1b8a92;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
border: 1px solid #b8d8db;
|
||||
border-radius: 4px;
|
||||
padding: 2px 8px;
|
||||
transition: background 0.1s ease;
|
||||
}
|
||||
|
||||
.prab-card-link:hover {
|
||||
background: #e8f4f5;
|
||||
color: #136870;
|
||||
border-color: #8ac4c9;
|
||||
}
|
||||
|
||||
/* ── Generating spinner ────────────────────────────────────────────────── */
|
||||
.prab-card-spinner {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 11px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 2px solid #c8e6e8;
|
||||
border-top-color: #1b8a92;
|
||||
.prab-stage-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
animation: prab-spin 0.9s linear infinite;
|
||||
margin-top: 3px;
|
||||
flex-shrink: 0;
|
||||
background: #D0D0D0;
|
||||
}
|
||||
|
||||
@keyframes prab-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
.prab-stage-dot--done { background: #1B8A92; }
|
||||
.prab-stage-dot--active { background: #1B8A92; animation: prab-pulse 2s ease-in-out infinite; }
|
||||
.prab-stage-dot--failed { background: #C0392B; }
|
||||
.prab-stage-dot--pending { background: #D0D0D0; }
|
||||
|
||||
@keyframes prab-pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
/* ── Board footer ──────────────────────────────────────────────────────── */
|
||||
.prab-board-footer {
|
||||
padding: 0 20px 16px;
|
||||
font-size: 0.78rem;
|
||||
color: #a0998f;
|
||||
.prab-stage-info {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.prab-stage-name {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #3D3D3D;
|
||||
}
|
||||
|
||||
.prab-stage-model {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 11px;
|
||||
color: #808080;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.prab-stage-error-msg {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 11px;
|
||||
color: #C0392B;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.prab-stage-io-toggle {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 10px;
|
||||
color: #1B8A92;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.prab-stage-io {
|
||||
grid-column: 2 / 4;
|
||||
margin-top: 6px;
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E8E8E8;
|
||||
border-radius: 4px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.prab-stage-io-label {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
color: #808080;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.prab-stage-io-text {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 11px;
|
||||
color: #0D0D0D;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.prab-stage-cost {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-size: 12px;
|
||||
color: #3D3D3D;
|
||||
flex-shrink: 0;
|
||||
align-self: start;
|
||||
padding-top: 3px;
|
||||
}
|
||||
|
||||
/* Inspector receipt */
|
||||
.prab-inspector-receipt {
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E8E8E8;
|
||||
border-radius: 8px;
|
||||
padding: 12px 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.prab-receipt-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
color: #3D3D3D;
|
||||
}
|
||||
|
||||
.prab-receipt-label {
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.prab-receipt-value {
|
||||
font-family: 'IBM Plex Mono', monospace;
|
||||
font-weight: 600;
|
||||
color: #0D0D0D;
|
||||
}
|
||||
|
||||
/* Inspector CTA buttons */
|
||||
.prab-inspector-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.prab-inspector-dossier-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 7px 16px;
|
||||
background: #1B8A92;
|
||||
color: #FFFFFF;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
.prab-inspector-dossier-btn:hover,
|
||||
.prab-inspector-dossier-btn:focus {
|
||||
background: #147178;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* ── Poll-error banner ─────────────────────────────────────────────────── */
|
||||
.prab-board-error {
|
||||
background: #fff4f4;
|
||||
border: 1px solid #f5c4c4;
|
||||
color: #8b2020;
|
||||
background: #FFF4F4;
|
||||
border: 1px solid #F5C4C4;
|
||||
color: #8B2020;
|
||||
border-radius: 6px;
|
||||
padding: 8px 14px;
|
||||
margin: 0 20px 12px;
|
||||
font-size: 0.82rem;
|
||||
padding: 8px 16px;
|
||||
margin: 8px 20px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.prab-board-error.is-visible {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ── Board footer ──────────────────────────────────────────────────────── */
|
||||
.prab-board-footer {
|
||||
padding: 10px 20px 16px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 12px;
|
||||
color: #808080;
|
||||
border-top: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
/* ── Inspector loading / error states ─────────────────────────────────── */
|
||||
.prab-inspector-loading,
|
||||
.prab-inspector-error {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
color: #808080;
|
||||
text-align: center;
|
||||
padding: 30px 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.prab-inspector-error {
|
||||
color: #C0392B;
|
||||
}
|
||||
|
||||
/* ── Narrow viewport: inspector becomes full-width below list ─────────── */
|
||||
@media (max-width: 900px) {
|
||||
.prab-run-list {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #E8E8E8;
|
||||
}
|
||||
|
||||
.prab-inspector {
|
||||
position: static;
|
||||
max-height: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* PRAutoBlogger Board -- "New Article" generate button handler (v0.21.0, M4).
|
||||
*
|
||||
* Loaded on the board page alongside board.js. Depends on the prabBoard config
|
||||
* object and jQuery, both already present when board.js loads.
|
||||
*
|
||||
* @see assets/js/board.js -- Board poller (loads first).
|
||||
* @see includes/admin/class-board-page.php -- Enqueues + localizes prabBoard.
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var cfg = window.prabBoard || {};
|
||||
|
||||
/**
|
||||
* Handle click on the "New Article" button. Fires the existing generate_now
|
||||
* AJAX action and triggers board backoff reset so the new card appears fast.
|
||||
*/
|
||||
function onBoardGenerateNow() {
|
||||
var $btn = $( '#prab-board-generate-now' );
|
||||
if ( ! $btn.length || $btn.prop( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
$btn.prop( 'disabled', true ).text( cfg.strings && cfg.strings.generatingBtn || 'Generating\u2026' );
|
||||
var $status = $( '#prab-board-gen-status' );
|
||||
$status.text( '' ).hide();
|
||||
|
||||
$.ajax( {
|
||||
url: cfg.ajaxUrl,
|
||||
method: 'POST',
|
||||
data: { action: 'prautoblogger_generate_now', nonce: cfg.generateNonce },
|
||||
success: function ( response ) {
|
||||
if ( response && response.success ) {
|
||||
$status.text( cfg.strings && cfg.strings.genStarted || 'Generation started.' ).show();
|
||||
// Notify board poller to reset backoff (run is now active).
|
||||
$( document ).trigger( 'prab:generation-started' );
|
||||
} else {
|
||||
$status.text( cfg.strings && cfg.strings.genError || 'Generation failed.' ).show();
|
||||
$btn.prop( 'disabled', false ).text( cfg.strings && cfg.strings.newArticle || 'New Article' );
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
$status.text( cfg.strings && cfg.strings.genError || 'Generation failed.' ).show();
|
||||
$btn.prop( 'disabled', false ).text( cfg.strings && cfg.strings.newArticle || 'New Article' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( function () {
|
||||
$( document ).on( 'click', '#prab-board-generate-now', onBoardGenerateNow );
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
||||
@@ -1,42 +1,41 @@
|
||||
/**
|
||||
* PRAutoBlogger — Kanban Board Poller
|
||||
* PRAutoBlogger — Mission Brief Board (M5, v0.27.0)
|
||||
*
|
||||
* Live-polls the board status AJAX endpoint and updates the four columns
|
||||
* (Generating | In Review | Published | Failed) in-place without a full
|
||||
* page reload.
|
||||
* Replaces the four-column kanban with a vertical run-list + right-rail
|
||||
* inspector layout. Responsibilities:
|
||||
*
|
||||
* Poll behaviour:
|
||||
* - Polls at `prabBoard.pollInterval` ms when any article is generating.
|
||||
* - Doubles the interval (backoff) when `has_active_runs` is false, capping
|
||||
* at 4× the base interval — prevents needless AJAX on an idle board.
|
||||
* - Resets to base interval as soon as an active run is detected again.
|
||||
* 1. AJAX polling (prautoblogger_board_status) — same backoff logic as M4.
|
||||
* Updates the four status sections in-place without flicker.
|
||||
* 2. Row-click inspector — fetches per-run stage I/O via
|
||||
* prautoblogger_board_inspector and renders the right rail.
|
||||
* 3. Stage I/O expand — toggles per-stage prompt/response text inline
|
||||
* inside the inspector.
|
||||
*
|
||||
* Click-throughs (M1):
|
||||
* - Generating → Activity Log
|
||||
* - In Review → Review Queue
|
||||
* - Published → Post edit screen
|
||||
* - Failed → Activity Log
|
||||
* (M2 rewires all to Article Dossier)
|
||||
* Security: All server data rendered via textContent (never innerHTML for
|
||||
* prompt/response text). escHtml() guards any dynamic HTML concatenation.
|
||||
*
|
||||
* Localised config: `prabBoard` object (ajaxUrl, nonce, pollInterval, action,
|
||||
* strings) injected by PRAutoBlogger_Board_Page::on_enqueue_assets().
|
||||
* Localised config: `prabBoard` object (ajaxUrl, nonce, pollInterval,
|
||||
* action, inspectorAction, strings) injected by Board_Page::on_enqueue_assets().
|
||||
*
|
||||
* @see includes/admin/class-board-page.php — AJAX handler + localise.
|
||||
* @see assets/css/board.css — Card and column styles.
|
||||
* @see templates/admin/board-page.php — Initial server-rendered HTML.
|
||||
* @see includes/admin/class-board-page.php -- AJAX handler + localize.
|
||||
* @see includes/ajax/class-board-inspector-handler.php -- Inspector AJAX.
|
||||
* @see assets/css/board.css -- Styles.
|
||||
* @see templates/admin/board-page.php -- Server-rendered HTML.
|
||||
*/
|
||||
( function ( $ ) {
|
||||
'use strict';
|
||||
|
||||
var cfg = window.prabBoard || {};
|
||||
var baseInterval = cfg.pollInterval || 5000;
|
||||
var maxBackoff = 4;
|
||||
var backoffFactor = 1;
|
||||
var pollTimer = null;
|
||||
var $board = null;
|
||||
var $errorBanner = null;
|
||||
var cfg = window.prabBoard || {};
|
||||
var baseInterval = cfg.pollInterval || 5000;
|
||||
var maxBackoff = 4;
|
||||
var backoffFactor = 1;
|
||||
var pollTimer = null;
|
||||
var $board = null;
|
||||
var $errorBanner = null;
|
||||
var selectedRunId = null;
|
||||
var inspFetching = false;
|
||||
|
||||
/** Escape HTML for safe DOM insertion. */
|
||||
/** Escape HTML for safe DOM insertion via innerHTML. */
|
||||
function escHtml( str ) {
|
||||
return $( '<div>' ).text( String( str ) ).html();
|
||||
}
|
||||
@@ -47,136 +46,369 @@
|
||||
return '$' + n.toFixed( 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a card HTML string from a card data object.
|
||||
*
|
||||
* @param {Object} card Card data from server.
|
||||
* @param {string} columnKey Column identifier.
|
||||
* @returns {string} HTML string.
|
||||
*/
|
||||
function buildCardHtml( card, columnKey ) {
|
||||
var isGenerating = ( columnKey === 'generating' );
|
||||
var cls = 'prab-board-card' + ( isGenerating ? ' prab-board-card--generating' : '' );
|
||||
var html = '';
|
||||
|
||||
html += '<div class="' + escHtml( cls ) + '"';
|
||||
html += ' data-run-id="' + escHtml( card.run_id || '' ) + '"';
|
||||
html += ' data-post-id="' + escHtml( card.post_id || 0 ) + '">';
|
||||
|
||||
if ( isGenerating ) {
|
||||
html += '<div class="prab-card-spinner" aria-label="' + escHtml( cfg.strings.generating ) + '"></div>';
|
||||
}
|
||||
|
||||
html += '<div class="prab-card-title">' + escHtml( card.title || cfg.strings.empty ) + '</div>';
|
||||
|
||||
// v0.20.0: human-modified runs are visually distinct at run-list level.
|
||||
if ( card.human_modified ) {
|
||||
html += '<span class="prab-card-human-chip">' + escHtml( cfg.strings.humanModified || 'Human-modified' ) + '</span>';
|
||||
}
|
||||
|
||||
if ( card.cost_total ) {
|
||||
html += '<div class="prab-card-meta"><span class="prab-card-cost">';
|
||||
html += escHtml( formatCost( card.cost_total ) );
|
||||
html += '</span></div>';
|
||||
}
|
||||
|
||||
if ( isGenerating && card.stage_current ) {
|
||||
html += '<div class="prab-card-stage">';
|
||||
/* translators: stage name */
|
||||
html += escHtml( cfg.strings.generating + ': ' + card.stage_current );
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
if ( card.error_message ) {
|
||||
var errShort = String( card.error_message ).split( ' ' ).slice( 0, 12 ).join( ' ' );
|
||||
if ( card.error_message.split( ' ' ).length > 12 ) {
|
||||
errShort += '…';
|
||||
}
|
||||
html += '<div class="prab-card-error">' + escHtml( errShort ) + '</div>';
|
||||
}
|
||||
|
||||
// Click-through link.
|
||||
var linkUrl = '';
|
||||
var linkText = '';
|
||||
if ( card.click_action === 'dossier' && card.dossier_url ) {
|
||||
linkUrl = card.dossier_url;
|
||||
linkText = cfg.strings.view;
|
||||
} else if ( card.click_action === 'review' && card.review_url ) {
|
||||
linkUrl = card.review_url;
|
||||
linkText = cfg.strings.view;
|
||||
} else if ( card.click_action === 'edit' && card.edit_url ) {
|
||||
linkUrl = card.edit_url;
|
||||
linkText = cfg.strings.edit;
|
||||
} else if ( card.click_action === 'logs' && card.log_url ) {
|
||||
linkUrl = card.log_url;
|
||||
linkText = cfg.strings.viewLog;
|
||||
}
|
||||
|
||||
if ( linkUrl ) {
|
||||
html += '<div class="prab-card-actions">';
|
||||
html += '<a href="' + escHtml( linkUrl ) + '" class="prab-card-link">';
|
||||
html += escHtml( linkText );
|
||||
html += '</a></div>';
|
||||
}
|
||||
|
||||
html += '</div>';
|
||||
return html;
|
||||
/** Elapsed seconds → human label. */
|
||||
function formatElapsed( startedAt ) {
|
||||
if ( ! startedAt ) { return ''; }
|
||||
var diff = Math.max( 0, Math.floor( Date.now() / 1000 ) - parseInt( startedAt, 10 ) );
|
||||
if ( diff < 60 ) { return diff + 's'; }
|
||||
if ( diff < 3600 ) { return Math.floor( diff / 60 ) + 'm'; }
|
||||
return Math.floor( diff / 3600 ) + 'h';
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-render a single column from the server snapshot.
|
||||
* Map a section key to chip CSS modifier + label.
|
||||
*/
|
||||
function sectionMeta( key ) {
|
||||
var map = {
|
||||
generating: { mod: 'generating', label: cfg.strings.generating || 'Generating' },
|
||||
in_review: { mod: 'in_review', label: cfg.strings.inReview || 'In review' },
|
||||
published: { mod: 'published', label: cfg.strings.published || 'Published' },
|
||||
failed: { mod: 'failed', label: cfg.strings.failed || 'Failed' },
|
||||
};
|
||||
return map[ key ] || { mod: key, label: key };
|
||||
}
|
||||
|
||||
/**
|
||||
* Build one run-row HTML string from card data.
|
||||
*
|
||||
* Updates the pill count and replaces card HTML. Avoids full DOM teardown
|
||||
* to prevent flicker on the running spinner.
|
||||
* @param {Object} card Card data from server.
|
||||
* @param {string} sectionKey Section identifier.
|
||||
* @returns {string} HTML string.
|
||||
*/
|
||||
function buildRowHtml( card, sectionKey ) {
|
||||
var meta = sectionMeta( sectionKey );
|
||||
var isFailed = ( 'failed' === sectionKey );
|
||||
var rowClass = 'prab-run-row' + ( isFailed ? ' prab-run-row--failed' : '' );
|
||||
var title = card.title || cfg.strings.empty || '';
|
||||
var cost = card.cost_total ? formatCost( card.cost_total ) : '';
|
||||
var elapsed = formatElapsed( card.started_at || card.created_at || 0 );
|
||||
var runId = card.run_id || '';
|
||||
var postId = card.post_id || 0;
|
||||
|
||||
var html = '<div class="' + escHtml( rowClass ) + '"';
|
||||
html += ' role="listitem" tabindex="0"';
|
||||
html += ' data-run-id="' + escHtml( runId ) + '"';
|
||||
html += ' data-post-id="' + escHtml( postId ) + '"';
|
||||
html += ' aria-label="' + escHtml( title ) + '">';
|
||||
|
||||
// Chip column.
|
||||
html += '<div class="prab-row-chip-wrap">';
|
||||
html += '<span class="prab-chip prab-chip--' + escHtml( meta.mod ) + '">';
|
||||
html += escHtml( meta.label );
|
||||
html += '</span>';
|
||||
if ( card.human_modified ) {
|
||||
html += '<span class="prab-chip prab-chip--human" title="' + escHtml( cfg.strings.humanModified || 'Human-modified' ) + '">H</span>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
// Main column.
|
||||
html += '<div class="prab-row-main">';
|
||||
html += '<div class="prab-row-title"></div>'; // textContent-set below
|
||||
if ( card.stage_current ) {
|
||||
html += '<div class="prab-row-stage-label"></div>'; // textContent-set below
|
||||
}
|
||||
if ( card.error_message ) {
|
||||
html += '<div class="prab-row-error"></div>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
// Meta column.
|
||||
html += '<div class="prab-row-meta">';
|
||||
if ( cost ) {
|
||||
html += '<span class="prab-row-cost"></span>'; // textContent-set below
|
||||
}
|
||||
if ( elapsed ) {
|
||||
html += '<span class="prab-row-elapsed"></span>';
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
// Use a detached jQuery element to set text safely (avoids any XSS
|
||||
// even if card.title contained markup).
|
||||
var $row = $( html );
|
||||
$row.find( '.prab-row-title' ).text( title );
|
||||
if ( card.stage_current ) {
|
||||
$row.find( '.prab-row-stage-label' ).text( card.stage_current );
|
||||
}
|
||||
if ( card.error_message ) {
|
||||
var errShort = String( card.error_message ).split( ' ' ).slice( 0, 12 ).join( ' ' );
|
||||
if ( String( card.error_message ).split( ' ' ).length > 12 ) { errShort += '…'; }
|
||||
$row.find( '.prab-row-error' ).text( errShort );
|
||||
}
|
||||
if ( cost ) { $row.find( '.prab-row-cost' ).text( cost ); }
|
||||
if ( elapsed ) { $row.find( '.prab-row-elapsed' ).text( elapsed ); }
|
||||
|
||||
return $( '<div>' ).append( $row ).html();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-render one status section from server snapshot.
|
||||
*
|
||||
* @param {string} colKey Column identifier.
|
||||
* @param {Array} cards Array of card objects.
|
||||
* @param {string} secKey Section identifier.
|
||||
* @param {Array} cards Card objects for this section.
|
||||
* @returns {void}
|
||||
*/
|
||||
function renderColumn( colKey, cards ) {
|
||||
var $col = $board.find( '[data-column="' + colKey + '"]' );
|
||||
var $cards = $col.find( '[data-column-cards]' );
|
||||
var $pill = $col.find( '.prab-col-count' );
|
||||
function renderSection( secKey, cards ) {
|
||||
var $sec = $board.find( '[data-section="' + secKey + '"]' );
|
||||
var $rows = $sec.find( '[data-section-rows]' );
|
||||
var $count = $sec.find( '.prab-section-count' );
|
||||
|
||||
$pill.text( cards.length );
|
||||
$count.text( cards.length );
|
||||
|
||||
if ( ! cards.length ) {
|
||||
$cards.html( '<p class="prab-col-empty">' + escHtml( cfg.strings.empty ) + '</p>' );
|
||||
$rows.html( '<p class="prab-section-empty">' + escHtml( cfg.strings.empty || '' ) + '</p>' );
|
||||
return;
|
||||
}
|
||||
|
||||
// Build new card HTML.
|
||||
var newHtml = '';
|
||||
var html = '';
|
||||
for ( var i = 0; i < cards.length; i++ ) {
|
||||
newHtml += buildCardHtml( cards[ i ], colKey );
|
||||
html += buildRowHtml( cards[ i ], secKey );
|
||||
}
|
||||
$cards.html( newHtml );
|
||||
$rows.html( html );
|
||||
|
||||
// Re-highlight selected row if it reappears after poll.
|
||||
if ( selectedRunId ) {
|
||||
$rows.find( '[data-run-id="' + selectedRunId + '"]' ).addClass( 'is-selected' );
|
||||
}
|
||||
|
||||
// Re-bind row-click for freshly rendered rows.
|
||||
bindRowClicks( $rows );
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a server snapshot to all four columns.
|
||||
* Apply snapshot to all four sections.
|
||||
*
|
||||
* @param {Object} snapshot Board snapshot from AJAX.
|
||||
* @param {Object} snapshot Board snapshot from AJAX.
|
||||
* @returns {void}
|
||||
*/
|
||||
function applySnapshot( snapshot ) {
|
||||
renderColumn( 'generating', snapshot.generating || [] );
|
||||
renderColumn( 'in_review', snapshot.in_review || [] );
|
||||
renderColumn( 'published', snapshot.published || [] );
|
||||
renderColumn( 'failed', snapshot.failed || [] );
|
||||
// Re-enable board Generate button once no active runs remain.
|
||||
if ( ! snapshot.has_active_runs ) {
|
||||
$( '#prab-board-generate-now' ).prop( 'disabled', false )
|
||||
.text( ( cfg.strings && cfg.strings.newArticle ) || 'New Article' );
|
||||
renderSection( 'generating', snapshot.generating || [] );
|
||||
renderSection( 'in_review', snapshot.in_review || [] );
|
||||
renderSection( 'published', snapshot.published || [] );
|
||||
renderSection( 'failed', snapshot.failed || [] );
|
||||
}
|
||||
|
||||
// ── Inspector rail ────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Render the inspector rail with a loaded run's data.
|
||||
*
|
||||
* @param {Object} data Response data from Board_Inspector_Handler.
|
||||
* @returns {void}
|
||||
*/
|
||||
function renderInspector( data ) {
|
||||
var run = data.run || {};
|
||||
var stages = data.stages || [];
|
||||
var total = data.cost_total || 0;
|
||||
|
||||
var $inner = $( '#prab-inspector-inner' );
|
||||
$inner.empty();
|
||||
|
||||
// Title + chip.
|
||||
var titleText = run.post_title || run.run_id || '';
|
||||
var $title = $( '<div class="prab-inspector-title"></div>' ).text( titleText );
|
||||
$inner.append( $title );
|
||||
|
||||
var statusMod = run.status || 'generating';
|
||||
var statusMap = {
|
||||
running: 'generating',
|
||||
complete: 'published',
|
||||
error: 'failed',
|
||||
draft: 'in_review',
|
||||
};
|
||||
var chipMod = statusMap[ statusMod ] || statusMod;
|
||||
var chipLabel = sectionMeta( chipMod ).label;
|
||||
var $chipRow = $( '<div class="prab-inspector-chip-row"></div>' );
|
||||
$chipRow.append( $( '<span class="prab-chip prab-chip--' + escHtml( chipMod ) + '"></span>' ).text( chipLabel ) );
|
||||
$inner.append( $chipRow );
|
||||
|
||||
// Stage breakdown.
|
||||
var $stageList = $( '<ul class="prab-inspector-stages"></ul>' );
|
||||
for ( var i = 0; i < stages.length; i++ ) {
|
||||
$stageList.append( buildStageItem( stages[ i ] ) );
|
||||
}
|
||||
$inner.append( $stageList );
|
||||
|
||||
// Total cost receipt.
|
||||
var $receipt = $( '<div class="prab-inspector-receipt"></div>' );
|
||||
var $receiptRow = $( '<div class="prab-receipt-row"></div>' );
|
||||
$receiptRow.append( $( '<span class="prab-receipt-label"></span>' ).text( cfg.strings.totalCost || 'Total cost' ) );
|
||||
$receiptRow.append( $( '<span class="prab-receipt-value"></span>' ).text( formatCost( total ) ) );
|
||||
$receipt.append( $receiptRow );
|
||||
$inner.append( $receipt );
|
||||
|
||||
// Dossier link.
|
||||
if ( run.dossier_url ) {
|
||||
var $actions = $( '<div class="prab-inspector-actions"></div>' );
|
||||
var $btn = $( '<a class="prab-inspector-dossier-btn"></a>' );
|
||||
$btn.attr( 'href', run.dossier_url );
|
||||
$btn.text( cfg.strings.openDossier || 'Open dossier →' );
|
||||
$actions.append( $btn );
|
||||
$inner.append( $actions );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the next poll delay based on whether there are active runs.
|
||||
* Build a single inspector stage list-item jQuery element.
|
||||
*
|
||||
* @param {boolean} hasActiveRuns
|
||||
* @returns {number} Milliseconds until next poll.
|
||||
* @param {Object} stage Stage object from inspector AJAX response.
|
||||
* @returns {jQuery}
|
||||
*/
|
||||
function buildStageItem( stage ) {
|
||||
var status = stage.response_status === 'error' ? 'failed' : 'done';
|
||||
var dotClass = 'prab-stage-dot prab-stage-dot--' + status;
|
||||
var cost = stage.estimated_cost ? formatCost( stage.estimated_cost ) : '';
|
||||
|
||||
var $li = $( '<li class="prab-inspector-stage"></li>' );
|
||||
|
||||
// Status dot.
|
||||
$li.append( $( '<span class="' + escHtml( dotClass ) + '"></span>' ) );
|
||||
|
||||
// Stage info (label + model).
|
||||
var $info = $( '<div class="prab-stage-info"></div>' );
|
||||
$info.append( $( '<div class="prab-stage-name"></div>' ).text( stage.label || stage.stage ) );
|
||||
if ( stage.model ) {
|
||||
$info.append( $( '<div class="prab-stage-model"></div>' ).text( stage.model ) );
|
||||
}
|
||||
if ( stage.error_message ) {
|
||||
$info.append( $( '<div class="prab-stage-error-msg"></div>' ).text( stage.error_message ) );
|
||||
}
|
||||
|
||||
// I/O toggle (only when there is input or output to show).
|
||||
if ( stage.input_user || stage.output || stage.output_pruned ) {
|
||||
var $toggle = $( '<button class="prab-stage-io-toggle">I/O</button>' );
|
||||
$toggle.on( 'click', ( function ( s ) {
|
||||
return function () {
|
||||
toggleStageIO( $( this ).closest( 'li' ), s );
|
||||
};
|
||||
}( stage ) ) );
|
||||
$info.append( $toggle );
|
||||
}
|
||||
|
||||
$li.append( $info );
|
||||
|
||||
// Cost.
|
||||
if ( cost ) {
|
||||
$li.append( $( '<span class="prab-stage-cost"></span>' ).text( cost ) );
|
||||
}
|
||||
|
||||
return $li;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle stage I/O panel inside an inspector stage item.
|
||||
*
|
||||
* Text is set via textContent (jQuery .text()) — structurally safe.
|
||||
*
|
||||
* @param {jQuery} $li Stage list item element.
|
||||
* @param {Object} stage Stage data with input_system/input_user/output.
|
||||
* @returns {void}
|
||||
*/
|
||||
function toggleStageIO( $li, stage ) {
|
||||
var $existing = $li.find( '.prab-stage-io' );
|
||||
if ( $existing.length ) {
|
||||
$existing.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var $io = $( '<div class="prab-stage-io"></div>' );
|
||||
|
||||
if ( stage.input_user ) {
|
||||
$io.append( $( '<div class="prab-stage-io-label"></div>' ).text( cfg.strings.input || 'Input' ) );
|
||||
$io.append( $( '<pre class="prab-stage-io-text"></pre>' ).text( stage.input_user ) );
|
||||
}
|
||||
|
||||
if ( stage.output ) {
|
||||
$io.append( $( '<div class="prab-stage-io-label"></div>' ).text( cfg.strings.output || 'Output' ) );
|
||||
$io.append( $( '<pre class="prab-stage-io-text"></pre>' ).text( stage.output ) );
|
||||
} else if ( stage.output_pruned ) {
|
||||
$io.append( $( '<div class="prab-stage-io-label"></div>' ).text( cfg.strings.output || 'Output' ) );
|
||||
$io.append( $( '<p class="prab-stage-io-text"></p>' ).text( cfg.strings.pruned || '[pruned]' ) );
|
||||
} else if ( stage.input_user ) {
|
||||
// Has input but no output — log-only stage or still running.
|
||||
$io.append( $( '<div class="prab-stage-io-label"></div>' ).text( cfg.strings.output || 'Output' ) );
|
||||
$io.append( $( '<p class="prab-stage-io-text"></p>' ).text( cfg.strings.noOutput || '[no output recorded]' ) );
|
||||
}
|
||||
|
||||
// Insert after the stage-info div.
|
||||
$li.append( $io );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load inspector data for a run_id via AJAX.
|
||||
*
|
||||
* @param {string} runId Pipeline run UUID.
|
||||
* @returns {void}
|
||||
*/
|
||||
function loadInspector( runId ) {
|
||||
if ( ! runId || inspFetching ) { return; }
|
||||
inspFetching = true;
|
||||
|
||||
var $inner = $( '#prab-inspector-inner' );
|
||||
$inner.html( '<p class="prab-inspector-loading">' + escHtml( cfg.strings.inspectorLoad || 'Loading…' ) + '</p>' );
|
||||
|
||||
$.ajax( {
|
||||
url: cfg.ajaxUrl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: cfg.inspectorAction,
|
||||
nonce: cfg.nonce,
|
||||
run_id: runId
|
||||
},
|
||||
success: function ( response ) {
|
||||
inspFetching = false;
|
||||
if ( response && response.success && response.data ) {
|
||||
renderInspector( response.data );
|
||||
} else {
|
||||
$inner.html( '<p class="prab-inspector-error">' + escHtml( cfg.strings.inspectorError || 'Could not load run details.' ) + '</p>' );
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
inspFetching = false;
|
||||
$inner.html( '<p class="prab-inspector-error">' + escHtml( cfg.strings.inspectorError || 'Could not load run details.' ) + '</p>' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// ── Row click binding ─────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Bind click + keyboard-activate on run rows within a container.
|
||||
*
|
||||
* @param {jQuery} $container Container to search within.
|
||||
* @returns {void}
|
||||
*/
|
||||
function bindRowClicks( $container ) {
|
||||
$container.find( '.prab-run-row' ).on( 'click keydown', function ( e ) {
|
||||
if ( e.type === 'keydown' && e.which !== 13 && e.which !== 32 ) { return; }
|
||||
e.preventDefault();
|
||||
|
||||
var $row = $( this );
|
||||
var runId = $row.data( 'run-id' );
|
||||
if ( ! runId ) { return; }
|
||||
|
||||
// Toggle off if already selected.
|
||||
if ( selectedRunId === String( runId ) ) {
|
||||
selectedRunId = null;
|
||||
$row.removeClass( 'is-selected' );
|
||||
$( '#prab-inspector-inner' ).html(
|
||||
'<p class="prab-inspector-placeholder">' + escHtml( cfg.strings.inspectorEmpty || 'Select an article to preview its pipeline.' ) + '</p>'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Deselect all rows, select this one.
|
||||
$board.find( '.prab-run-row' ).removeClass( 'is-selected' );
|
||||
$row.addClass( 'is-selected' );
|
||||
selectedRunId = String( runId );
|
||||
loadInspector( selectedRunId );
|
||||
} );
|
||||
}
|
||||
|
||||
// ── Polling ───────────────────────────────────────────────────────────
|
||||
|
||||
/** Compute next poll delay. */
|
||||
function nextDelay( hasActiveRuns ) {
|
||||
if ( hasActiveRuns ) {
|
||||
backoffFactor = 1;
|
||||
@@ -186,22 +418,13 @@
|
||||
return baseInterval * backoffFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the next poll after a given delay.
|
||||
*
|
||||
* @param {number} delay Milliseconds.
|
||||
* @returns {void}
|
||||
*/
|
||||
/** Schedule the next poll. */
|
||||
function schedulePoll( delay ) {
|
||||
clearTimeout( pollTimer );
|
||||
pollTimer = setTimeout( doPoll, delay );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute one board poll: AJAX POST → apply snapshot → reschedule.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
/** Execute one poll cycle. */
|
||||
function doPoll() {
|
||||
$.ajax( {
|
||||
url: cfg.ajaxUrl,
|
||||
@@ -211,9 +434,7 @@
|
||||
nonce: cfg.nonce
|
||||
},
|
||||
success: function ( response ) {
|
||||
if ( $errorBanner ) {
|
||||
$errorBanner.removeClass( 'is-visible' );
|
||||
}
|
||||
if ( $errorBanner ) { $errorBanner.removeClass( 'is-visible' ); }
|
||||
if ( response && response.success && response.data ) {
|
||||
applySnapshot( response.data );
|
||||
schedulePoll( nextDelay( !! response.data.has_active_runs ) );
|
||||
@@ -222,15 +443,29 @@
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
if ( $errorBanner ) {
|
||||
$errorBanner.addClass( 'is-visible' );
|
||||
}
|
||||
if ( $errorBanner ) { $errorBanner.addClass( 'is-visible' ); }
|
||||
schedulePoll( nextDelay( false ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// ── Init ──────────────────────────────────────────────────────────────
|
||||
|
||||
$( function () {
|
||||
$board = $( '#prab-board' );
|
||||
if ( ! $board.length ) { return; }
|
||||
|
||||
// Error banner.
|
||||
$errorBanner = $( '<div class="prab-board-error" role="alert"></div>' );
|
||||
$errorBanner.text( cfg.strings.pollError || '' );
|
||||
$board.before( $errorBanner );
|
||||
|
||||
// Bind clicks on server-rendered rows.
|
||||
bindRowClicks( $board );
|
||||
|
||||
// Start poller.
|
||||
var hasActive = ( $board.find( '[data-section="generating"] .prab-run-row' ).length > 0 );
|
||||
schedulePoll( nextDelay( hasActive ) );
|
||||
} );
|
||||
|
||||
}( jQuery ) );
|
||||
|
||||
Reference in New Issue
Block a user