index.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>imagedl API Health Dashboard</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <style>
  8. :root {
  9. --bg: #020617;
  10. --bg-elevated: rgba(15, 23, 42, 0.9);
  11. --border-subtle: rgba(148, 163, 184, 0.2);
  12. --accent: #facc15; /* 皮卡丘黄 */
  13. --accent-soft: rgba(250, 204, 21, 0.16);
  14. --danger: #fb7185;
  15. --text: #e5e7eb;
  16. --text-muted: #9ca3af;
  17. --radius-lg: 1.5rem;
  18. --radius-md: 0.9rem;
  19. --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.75);
  20. }
  21. *,
  22. *::before,
  23. *::after {
  24. box-sizing: border-box;
  25. }
  26. html,
  27. body {
  28. margin: 0;
  29. padding: 0;
  30. min-height: 100%;
  31. font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
  32. "Segoe UI", sans-serif;
  33. color: var(--text);
  34. background: radial-gradient(circle at top, #0f172a 0, #020617 55%, #000 100%);
  35. }
  36. body {
  37. display: flex;
  38. justify-content: center;
  39. position: relative;
  40. overflow-x: hidden;
  41. }
  42. /* 粒子背景画布:放在内容后面但在背景前面 */
  43. #bg-canvas {
  44. position: fixed;
  45. inset: 0;
  46. width: 100%;
  47. height: 100%;
  48. z-index: 0;
  49. pointer-events: none;
  50. }
  51. .app {
  52. width: 100%;
  53. max-width: 1200px;
  54. padding: 24px 18px 40px;
  55. opacity: 0;
  56. transform: translateY(8px);
  57. transition: opacity 0.4s ease, transform 0.4s ease;
  58. position: relative;
  59. z-index: 1;
  60. }
  61. .app-loaded {
  62. opacity: 1;
  63. transform: translateY(0);
  64. }
  65. .header {
  66. display: flex;
  67. flex-wrap: wrap;
  68. justify-content: space-between;
  69. gap: 16px;
  70. padding: 18px 22px;
  71. margin-bottom: 24px;
  72. border-radius: var(--radius-lg);
  73. background: linear-gradient(
  74. 135deg,
  75. rgba(15, 23, 42, 0.96),
  76. rgba(24, 24, 27, 0.95)
  77. );
  78. border: 1px solid var(--border-subtle);
  79. box-shadow: var(--shadow-soft);
  80. backdrop-filter: blur(18px);
  81. }
  82. .header-title h1 {
  83. margin: 0 0 6px;
  84. font-size: 1.75rem;
  85. display: flex;
  86. align-items: center;
  87. gap: 8px;
  88. }
  89. .pika-badge {
  90. padding: 3px 10px;
  91. border-radius: 999px;
  92. font-size: 0.8rem;
  93. background: rgba(250, 204, 21, 0.12);
  94. border: 1px solid rgba(250, 204, 21, 0.4);
  95. color: #facc15;
  96. display: inline-flex;
  97. align-items: center;
  98. gap: 4px;
  99. }
  100. .header-title p {
  101. margin: 0;
  102. color: var(--text-muted);
  103. font-size: 0.95rem;
  104. }
  105. .header-meta {
  106. display: flex;
  107. align-items: center;
  108. gap: 10px;
  109. }
  110. .meta-pill {
  111. padding: 6px 12px;
  112. border-radius: 999px;
  113. font-size: 0.8rem;
  114. border: 1px solid var(--border-subtle);
  115. background: rgba(15, 23, 42, 0.9);
  116. color: var(--text-muted);
  117. }
  118. /* Overall 状态徽章,基于 meta-pill 再覆盖颜色 */
  119. .badge {
  120. border-width: 1px;
  121. border-style: solid;
  122. font-weight: 600;
  123. }
  124. /* 真·全部正常 = 绿色 */
  125. .badge-ok {
  126. background: rgba(34, 197, 94, 0.18); /* 绿 */
  127. color: #bbf7d0;
  128. border-color: rgba(34, 197, 94, 0.6);
  129. }
  130. /* 有模块挂了 = 红色 */
  131. .badge-fail {
  132. background: rgba(248, 113, 113, 0.18); /* 红 */
  133. color: #fecaca;
  134. border-color: rgba(248, 113, 113, 0.6);
  135. }
  136. .section {
  137. margin-bottom: 32px;
  138. }
  139. .section-header {
  140. margin-bottom: 14px;
  141. }
  142. .section-header h2 {
  143. margin: 0 0 4px;
  144. font-size: 1.3rem;
  145. }
  146. .section-header p {
  147. margin: 0;
  148. font-size: 0.9rem;
  149. color: var(--text-muted);
  150. }
  151. .cards-grid {
  152. display: grid;
  153. grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  154. gap: 16px;
  155. }
  156. .card {
  157. position: relative;
  158. padding: 14px 16px 14px;
  159. border-radius: var(--radius-md);
  160. background:
  161. radial-gradient(circle at top left, rgba(250, 204, 21, 0.04), transparent 45%),
  162. radial-gradient(circle at bottom right, rgba(253, 224, 71, 0.05), transparent 55%),
  163. var(--bg-elevated);
  164. border: 1px solid var(--border-subtle);
  165. box-shadow: 0 14px 35px rgba(15, 23, 42, 0.7);
  166. backdrop-filter: blur(12px);
  167. transform: translateY(0);
  168. transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  169. }
  170. .card::before {
  171. content: "";
  172. position: absolute;
  173. inset: 0;
  174. border-radius: inherit;
  175. border: 1px solid rgba(250, 204, 21, 0.2);
  176. opacity: 0;
  177. pointer-events: none;
  178. transition: opacity 0.2s ease;
  179. }
  180. .card:hover {
  181. transform: translateY(-4px);
  182. box-shadow: 0 22px 50px rgba(15, 23, 42, 0.85);
  183. border-color: rgba(250, 204, 21, 0.45);
  184. }
  185. .card:hover::before {
  186. opacity: 1;
  187. }
  188. .card-header {
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. gap: 8px;
  193. margin-bottom: 10px;
  194. }
  195. /* 模块名过长省略号显示,并用 title 提示完整内容 */
  196. .card-header h3 {
  197. margin: 0;
  198. font-size: 1rem;
  199. max-width: 70%;
  200. white-space: nowrap;
  201. overflow: hidden;
  202. text-overflow: ellipsis;
  203. }
  204. .status-pill {
  205. padding: 2px 9px;
  206. border-radius: 999px;
  207. font-size: 0.72rem;
  208. text-transform: uppercase;
  209. letter-spacing: 0.06em;
  210. }
  211. .status-ok {
  212. background: rgba(45, 212, 191, 0.2);
  213. color: #5eead4;
  214. }
  215. .status-fail {
  216. background: rgba(248, 113, 113, 0.16);
  217. color: #fecaca;
  218. }
  219. .card-body {
  220. font-size: 0.86rem;
  221. }
  222. .metric-row {
  223. display: flex;
  224. justify-content: space-between;
  225. margin-bottom: 4px;
  226. }
  227. .metric-row .query-value {
  228. flex: 1;
  229. text-align: right;
  230. margin-left: 8px;
  231. white-space: nowrap;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. }
  235. .metric-row.small {
  236. font-size: 0.8rem;
  237. color: var(--text-muted);
  238. }
  239. .tag-ok,
  240. .tag-fail {
  241. padding: 2px 6px;
  242. border-radius: 999px;
  243. font-size: 0.7rem;
  244. }
  245. .tag-ok {
  246. background: rgba(45, 212, 191, 0.15);
  247. color: #6ee7b7;
  248. }
  249. .tag-fail {
  250. background: rgba(248, 113, 113, 0.16);
  251. color: #fecaca;
  252. }
  253. /* Sample 文本自动换行,避免太长的 URL 撑爆布局 */
  254. .sample-text {
  255. margin: 6px 0 0;
  256. font-size: 0.75rem;
  257. color: var(--text-muted);
  258. overflow-wrap: anywhere;
  259. word-break: break-all;
  260. }
  261. .query-text {
  262. margin: 6px 0 0;
  263. font-size: 0.75rem;
  264. color: var(--text-muted);
  265. overflow-wrap: anywhere;
  266. word-break: break-all;
  267. opacity: 0.95;
  268. }
  269. .error-text {
  270. margin: 6px 0 0;
  271. font-size: 0.78rem;
  272. color: var(--danger);
  273. }
  274. .gallery-grid {
  275. display: grid;
  276. grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  277. gap: 14px;
  278. }
  279. .gallery-item {
  280. border-radius: var(--radius-md);
  281. overflow: hidden;
  282. background: var(--bg-elevated);
  283. border: 1px solid var(--border-subtle);
  284. box-shadow: 0 12px 30px rgba(15, 23, 42, 0.7);
  285. transform: translateY(0);
  286. transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  287. }
  288. .gallery-image-wrapper {
  289. aspect-ratio: 4 / 3;
  290. overflow: hidden;
  291. }
  292. .gallery-image-wrapper img {
  293. width: 100%;
  294. height: 100%;
  295. object-fit: cover;
  296. display: block;
  297. transition: transform 0.22s ease;
  298. }
  299. .gallery-item:hover {
  300. transform: translateY(-3px);
  301. box-shadow: 0 18px 40px rgba(15, 23, 42, 0.85);
  302. border-color: rgba(250, 204, 21, 0.45);
  303. }
  304. .gallery-item:hover img {
  305. transform: scale(1.05);
  306. }
  307. .gallery-meta {
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. padding: 6px 10px 8px;
  312. font-size: 0.8rem;
  313. }
  314. .gallery-module {
  315. color: var(--text-muted);
  316. max-width: 70%;
  317. white-space: nowrap;
  318. overflow: hidden;
  319. text-overflow: ellipsis;
  320. }
  321. .gallery-status {
  322. padding: 2px 6px;
  323. border-radius: 999px;
  324. font-size: 0.72rem;
  325. }
  326. .gallery-status-ok {
  327. background: rgba(45, 212, 191, 0.16);
  328. color: #6ee7b7;
  329. }
  330. .gallery-status-fail {
  331. background: rgba(248, 113, 113, 0.16);
  332. color: #fecaca;
  333. }
  334. .footer {
  335. margin-top: 12px;
  336. font-size: 0.8rem;
  337. color: var(--text-muted);
  338. text-align: right;
  339. }
  340. .footer a {
  341. color: var(--accent);
  342. text-decoration: none;
  343. }
  344. .footer a:hover {
  345. text-decoration: underline;
  346. }
  347. @media (max-width: 720px) {
  348. .header {
  349. padding: 14px 14px;
  350. }
  351. .header-title h1 {
  352. font-size: 1.35rem;
  353. flex-wrap: wrap;
  354. }
  355. .header-meta {
  356. width: 100%;
  357. justify-content: flex-start;
  358. flex-wrap: wrap;
  359. }
  360. }
  361. </style>
  362. </head>
  363. <body>
  364. <!-- 粒子背景画布 -->
  365. <canvas id="bg-canvas"></canvas>
  366. <div class="app">
  367. <header class="header">
  368. <div class="header-title">
  369. <span>
  370. imagedl API Health
  371. </span>
  372. <span class="pika-badge" title="Pikachu-powered monitoring">
  373. ⚡ CharlesPikachu
  374. </span>
  375. <p style="margin: 4px 0 0; font-size: 0.78rem; color: var(--text-muted);">
  376. Author: <strong>Zhenchao Jin + GPT 5.1</strong>
  377. </p>
  378. </div>
  379. <div class="header-meta">
  380. <span id="last-run" class="meta-pill">Last run: --</span>
  381. <span id="overall-status" class="meta-pill badge">Loading...</span>
  382. </div>
  383. </header>
  384. <main>
  385. <section id="summary-section" class="section">
  386. <div class="section-header">
  387. <h2>Module Status</h2>
  388. <p>Each card shows the latest search &amp; download health for a module.</p>
  389. </div>
  390. <div id="cards-container" class="cards-grid">
  391. <!-- JS 动态填充 -->
  392. </div>
  393. </section>
  394. <section id="gallery-section" class="section">
  395. <div class="section-header">
  396. <h2>Latest Image Gallery</h2>
  397. <p>Real images downloaded in the most recent run, directly from this repo.</p>
  398. </div>
  399. <div id="gallery-grid" class="gallery-grid">
  400. <!-- JS 动态填充 -->
  401. </div>
  402. </section>
  403. </main>
  404. <footer class="footer">
  405. Built with ⚡ by <strong>Zhenchao Jin + GPT 5.1</strong> ·
  406. <a href="https://github.com/your-name/imagedl-monitor" target="_blank" rel="noreferrer">
  407. View on GitHub
  408. </a>
  409. </footer>
  410. </div>
  411. <script>
  412. const SUMMARY_URL = "daily_test_results/summary_latest.json";
  413. let GLOBAL_QUERY = null;
  414. async function fetchSummary() {
  415. const res = await fetch(SUMMARY_URL + "?cache-bust=" + Date.now());
  416. if (!res.ok) {
  417. throw new Error("Failed to load summary.json");
  418. }
  419. return res.json();
  420. }
  421. function setOverallStatus(data) {
  422. const badge = document.getElementById("overall-status");
  423. const lastRunEl = document.getElementById("last-run");
  424. const modules = data.modules || [];
  425. const allOk = modules.length > 0 && modules.every((m) => m.ok);
  426. const okCount = modules.filter((m) => m.ok).length;
  427. if (badge) {
  428. badge.textContent = allOk ? "ALL GREEN" : `${okCount}/${modules.length} OK`;
  429. badge.classList.toggle("badge-ok", allOk);
  430. badge.classList.toggle("badge-fail", !allOk);
  431. }
  432. if (lastRunEl) {
  433. lastRunEl.textContent = `Last run: ${data.timestamp_utc || data.date}`;
  434. }
  435. }
  436. function escapeHtml(str) {
  437. return String(str)
  438. .replace(/&/g, "&amp;")
  439. .replace(/</g, "&lt;")
  440. .replace(/>/g, "&gt;")
  441. .replace(/"/g, "&quot;")
  442. .replace(/'/g, "&#39;");
  443. }
  444. function truncate(str, maxLen) {
  445. if (!str || str.length <= maxLen) return str;
  446. return str.slice(0, maxLen - 1) + "…";
  447. }
  448. function createModuleCard(mod) {
  449. const card = document.createElement("div");
  450. card.className = "card";
  451. const statusClass = mod.ok ? "status-ok" : "status-fail";
  452. const statusText = mod.ok ? "Healthy" : "Issue";
  453. // 这里优先用每个模块自己的 mod.query,没有的话用全局 GLOBAL_QUERY
  454. const querySource = mod.query != null ? mod.query : GLOBAL_QUERY;
  455. const queryRaw = querySource != null ? String(querySource) : null;
  456. const queryShort = queryRaw ? truncate(queryRaw, 80) : null;
  457. const sampleRaw =
  458. mod.search_samples && mod.search_samples[0]
  459. ? String(mod.search_samples[0])
  460. : null;
  461. const sampleShort = sampleRaw ? truncate(sampleRaw, 80) : null;
  462. card.innerHTML = `
  463. <div class="card-header">
  464. <h3 title="${escapeHtml(mod.name)}">${escapeHtml(mod.name)}</h3>
  465. <span class="status-pill ${statusClass}">${statusText}</span>
  466. </div>
  467. <div class="card-body">
  468. ${
  469. // ✅ 这一块就是插在最上面的一行 Query
  470. queryShort
  471. ? `<div class="metric-row">
  472. <span>Query</span>
  473. <span class="query-value" title="${escapeHtml(queryRaw)}">
  474. ${escapeHtml(queryShort)}
  475. </span>
  476. </div>`
  477. : ""
  478. }
  479. <div class="metric-row">
  480. <span>Search results</span>
  481. <span>${mod.n_results}</span>
  482. </div>
  483. <div class="metric-row">
  484. <span>Images downloaded</span>
  485. <span>${mod.n_downloaded}</span>
  486. </div>
  487. <div class="metric-row small">
  488. <span>Search</span>
  489. <span class="${mod.search_ok ? "tag-ok" : "tag-fail"}">
  490. ${mod.search_ok ? "OK" : "FAIL"}
  491. </span>
  492. </div>
  493. <div class="metric-row small">
  494. <span>Download</span>
  495. <span class="${mod.download_ok ? "tag-ok" : "tag-fail"}">
  496. ${mod.download_ok ? "OK" : "FAIL"}
  497. </span>
  498. </div>
  499. ${
  500. sampleShort
  501. ? `<p class="sample-text" title="${escapeHtml(sampleRaw)}">
  502. Sample: ${escapeHtml(sampleShort)}
  503. </p>`
  504. : ""
  505. }
  506. ${mod.error ? `<p class="error-text">${escapeHtml(mod.error)}</p>` : ""}
  507. </div>
  508. `;
  509. return card;
  510. }
  511. function createGalleryItem(mod, imgPath) {
  512. const div = document.createElement("div");
  513. div.className = "gallery-item";
  514. div.innerHTML = `
  515. <div class="gallery-image-wrapper">
  516. <img src="${imgPath}" alt="${escapeHtml(mod.name)} image" loading="lazy">
  517. </div>
  518. <div class="gallery-meta">
  519. <span class="gallery-module" title="${escapeHtml(mod.name)}">
  520. ${escapeHtml(mod.name)}
  521. </span>
  522. <span class="gallery-status ${
  523. mod.ok ? "gallery-status-ok" : "gallery-status-fail"
  524. }">
  525. ${mod.ok ? "OK" : "Issue"}
  526. </span>
  527. </div>
  528. `;
  529. return div;
  530. }
  531. async function initDashboard() {
  532. const cardsContainer = document.getElementById("cards-container");
  533. const galleryGrid = document.getElementById("gallery-grid");
  534. const app = document.querySelector(".app");
  535. try {
  536. const data = await fetchSummary();
  537. setOverallStatus(data);
  538. // 把顶层的 query 存到全局变量
  539. GLOBAL_QUERY = data.query || null;
  540. const modules = data.modules || [];
  541. modules.forEach((mod) => {
  542. if (cardsContainer) {
  543. cardsContainer.appendChild(createModuleCard(mod));
  544. }
  545. if (galleryGrid) {
  546. (mod.downloaded_images || []).forEach((imgPath) => {
  547. galleryGrid.appendChild(createGalleryItem(mod, imgPath));
  548. });
  549. }
  550. });
  551. if (app) {
  552. app.classList.add("app-loaded");
  553. }
  554. } catch (err) {
  555. console.error(err);
  556. if (cardsContainer) {
  557. cardsContainer.innerHTML =
  558. '<p class="error-text">Failed to load latest results. Check if the workflow has run.</p>';
  559. }
  560. }
  561. }
  562. /* 粒子背景:更亮、更明显的电光效果 */
  563. function initParticles() {
  564. const canvas = document.getElementById("bg-canvas");
  565. if (!canvas) return;
  566. const ctx = canvas.getContext("2d");
  567. let width = window.innerWidth;
  568. let height = window.innerHeight;
  569. const dpr = window.devicePixelRatio || 1;
  570. function resize() {
  571. width = window.innerWidth;
  572. height = window.innerHeight;
  573. canvas.width = width * dpr;
  574. canvas.height = height * dpr;
  575. canvas.style.width = width + "px";
  576. canvas.style.height = height + "px";
  577. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  578. }
  579. resize();
  580. window.addEventListener("resize", resize);
  581. const particles = [];
  582. const maxParticles = Math.min(110, Math.floor(width / 12));
  583. for (let i = 0; i < maxParticles; i++) {
  584. particles.push({
  585. x: Math.random() * width,
  586. y: Math.random() * height,
  587. vx: (Math.random() - 0.5) * 0.5,
  588. vy: (Math.random() - 0.5) * 0.5,
  589. r: 1.5 + Math.random() * 2.5,
  590. alpha: 0.5 + Math.random() * 0.5,
  591. flicker: Math.random() * Math.PI * 2,
  592. });
  593. }
  594. function step() {
  595. ctx.clearRect(0, 0, width, height);
  596. // 粒子移动
  597. for (const p of particles) {
  598. p.x += p.vx;
  599. p.y += p.vy;
  600. p.flicker += 0.03;
  601. if (p.x < -20) p.x = width + 20;
  602. if (p.x > width + 20) p.x = -20;
  603. if (p.y < -20) p.y = height + 20;
  604. if (p.y > height + 20) p.y = -20;
  605. }
  606. // 画点 + 连线
  607. for (let i = 0; i < particles.length; i++) {
  608. const p1 = particles[i];
  609. const flickerFactor = 0.6 + Math.sin(p1.flicker) * 0.4;
  610. // 画点(偏黄的电光)
  611. ctx.beginPath();
  612. ctx.fillStyle = `rgba(250, 204, 21, ${p1.alpha * flickerFactor})`;
  613. ctx.shadowColor = "rgba(250, 204, 21, 0.5)";
  614. ctx.shadowBlur = 8;
  615. ctx.arc(p1.x, p1.y, p1.r, 0, Math.PI * 2);
  616. ctx.fill();
  617. ctx.shadowBlur = 0;
  618. // 和附近粒子连线
  619. for (let j = i + 1; j < particles.length; j++) {
  620. const p2 = particles[j];
  621. const dx = p1.x - p2.x;
  622. const dy = p1.y - p2.y;
  623. const dist = Math.sqrt(dx * dx + dy * dy);
  624. if (dist < 180) {
  625. const lineAlpha = (1 - dist / 180) * 0.55 * flickerFactor;
  626. ctx.beginPath();
  627. ctx.strokeStyle = `rgba(250, 250, 210, ${lineAlpha})`;
  628. ctx.lineWidth = 0.7;
  629. ctx.moveTo(p1.x, p1.y);
  630. ctx.lineTo(p2.x, p2.y);
  631. ctx.stroke();
  632. }
  633. }
  634. }
  635. requestAnimationFrame(step);
  636. }
  637. step();
  638. }
  639. document.addEventListener("DOMContentLoaded", () => {
  640. initDashboard();
  641. initParticles();
  642. });
  643. </script>
  644. </body>
  645. </html>