Spaces:
Sleeping
Sleeping
Pointf5ive commited on
Commit Β·
c32b0f6
1
Parent(s): 2e8c90b
Sync wizard underline with selected pipeline tab
Browse files- smoke_signal_tab.py +40 -22
smoke_signal_tab.py
CHANGED
|
@@ -1608,14 +1608,24 @@ def _export_status_html(last_export=0) -> str:
|
|
| 1608 |
</div>"""
|
| 1609 |
|
| 1610 |
|
| 1611 |
-
|
| 1612 |
-
|
| 1613 |
-
|
| 1614 |
-
|
| 1615 |
-
|
| 1616 |
-
|
| 1617 |
-
|
| 1618 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1619 |
<div style="background:linear-gradient(135deg,#0d1117,#161b22);padding:24px 28px 0;border-bottom:1px solid #30363d">
|
| 1620 |
<div style="display:flex;align-items:center;gap:16px;margin-bottom:20px">
|
| 1621 |
<div style="font-size:38px;line-height:1">β</div>
|
|
@@ -1625,23 +1635,25 @@ def smoke_signal_tab():
|
|
| 1625 |
</div>
|
| 1626 |
</div>
|
| 1627 |
<div class="ss-wizard">
|
| 1628 |
-
|
| 1629 |
-
<div class="ss-connector"></div>
|
| 1630 |
-
<div class="ss-step"><span class="ss-num">2</span>PROFILE (OPTIONAL)</div>
|
| 1631 |
-
<div class="ss-connector"></div>
|
| 1632 |
-
<div class="ss-step"><span class="ss-num">3</span>OCR</div>
|
| 1633 |
-
<div class="ss-connector"></div>
|
| 1634 |
-
<div class="ss-step"><span class="ss-num">4</span>REVIEW</div>
|
| 1635 |
-
<div class="ss-connector"></div>
|
| 1636 |
-
<div class="ss-step"><span class="ss-num">5</span>EXPORT</div>
|
| 1637 |
</div>
|
| 1638 |
</div>
|
| 1639 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1640 |
|
| 1641 |
with gr.Tabs() as wizard:
|
| 1642 |
|
| 1643 |
# ββ STEP 1: INGEST ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1644 |
-
with gr.TabItem("β Ingest", id="ss-ingest"):
|
| 1645 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1646 |
<div class="ss-panel-icon">π₯</div>
|
| 1647 |
<div><p class="ss-panel-title">Source Registry</p>
|
|
@@ -1701,7 +1713,7 @@ def smoke_signal_tab():
|
|
| 1701 |
# Auto-load removed β use Refresh button instead to avoid SSR hang
|
| 1702 |
|
| 1703 |
# ββ STEP 2: PROFILE βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1704 |
-
with gr.TabItem("β‘ Profile (Optional)", id="ss-profile"):
|
| 1705 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1706 |
<div class="ss-panel-icon">π</div>
|
| 1707 |
<div><p class="ss-panel-title">PDF Profiler</p>
|
|
@@ -1715,7 +1727,7 @@ def smoke_signal_tab():
|
|
| 1715 |
profile_btn.click(run_profile, outputs=[profile_status, profile_log])
|
| 1716 |
|
| 1717 |
# ββ STEP 3: OCR βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1718 |
-
with gr.TabItem("β’ OCR", id="ss-ocr"):
|
| 1719 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1720 |
<div class="ss-panel-icon">π</div>
|
| 1721 |
<div><p class="ss-panel-title">OCR Engine</p>
|
|
@@ -1848,7 +1860,7 @@ def smoke_signal_tab():
|
|
| 1848 |
# Review now auto-loads on tab select and after OCR run completion.
|
| 1849 |
|
| 1850 |
# ββ STEP 5: EXPORT ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1851 |
-
with gr.TabItem("β€ Export", id="ss-export"):
|
| 1852 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1853 |
<div class="ss-panel-icon">β¬</div>
|
| 1854 |
<div><p class="ss-panel-title">Codex Export</p>
|
|
@@ -1878,3 +1890,9 @@ def smoke_signal_tab():
|
|
| 1878 |
run_export,
|
| 1879 |
outputs=[export_status, export_log, codex_download, gold_download],
|
| 1880 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
</div>"""
|
| 1609 |
|
| 1610 |
|
| 1611 |
+
def _wizard_header_html(active_step: int = 1) -> str:
|
| 1612 |
+
step_labels = [
|
| 1613 |
+
"INGEST+PROFILE",
|
| 1614 |
+
"PROFILE (OPTIONAL)",
|
| 1615 |
+
"OCR",
|
| 1616 |
+
"REVIEW",
|
| 1617 |
+
"EXPORT",
|
| 1618 |
+
]
|
| 1619 |
+
active_step = max(1, min(5, int(active_step or 1)))
|
| 1620 |
+
|
| 1621 |
+
step_html = []
|
| 1622 |
+
for idx, label in enumerate(step_labels, start=1):
|
| 1623 |
+
cls = "ss-step active" if idx == active_step else "ss-step"
|
| 1624 |
+
step_html.append(f'<div class="{cls}"><span class="ss-num">{idx}</span>{label}</div>')
|
| 1625 |
+
if idx < len(step_labels):
|
| 1626 |
+
step_html.append('<div class="ss-connector"></div>')
|
| 1627 |
+
|
| 1628 |
+
return """
|
| 1629 |
<div style="background:linear-gradient(135deg,#0d1117,#161b22);padding:24px 28px 0;border-bottom:1px solid #30363d">
|
| 1630 |
<div style="display:flex;align-items:center;gap:16px;margin-bottom:20px">
|
| 1631 |
<div style="font-size:38px;line-height:1">β</div>
|
|
|
|
| 1635 |
</div>
|
| 1636 |
</div>
|
| 1637 |
<div class="ss-wizard">
|
| 1638 |
+
""" + "".join(step_html) + """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1639 |
</div>
|
| 1640 |
</div>
|
| 1641 |
+
"""
|
| 1642 |
+
|
| 1643 |
+
|
| 1644 |
+
# ββ Main tab builder βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1645 |
+
def smoke_signal_tab():
|
| 1646 |
+
"""Call this inside your gr.Blocks() Tabs to add the Smoke Signal tab."""
|
| 1647 |
+
|
| 1648 |
+
with gr.TabItem("β Smoke Signal", elem_id="ss-tab"):
|
| 1649 |
+
|
| 1650 |
+
# ββ Wizard header ββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1651 |
+
wizard_header = gr.HTML(_wizard_header_html(1))
|
| 1652 |
|
| 1653 |
with gr.Tabs() as wizard:
|
| 1654 |
|
| 1655 |
# ββ STEP 1: INGEST ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1656 |
+
with gr.TabItem("β Ingest", id="ss-ingest") as ingest_tab:
|
| 1657 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1658 |
<div class="ss-panel-icon">π₯</div>
|
| 1659 |
<div><p class="ss-panel-title">Source Registry</p>
|
|
|
|
| 1713 |
# Auto-load removed β use Refresh button instead to avoid SSR hang
|
| 1714 |
|
| 1715 |
# ββ STEP 2: PROFILE βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1716 |
+
with gr.TabItem("β‘ Profile (Optional)", id="ss-profile") as profile_tab:
|
| 1717 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1718 |
<div class="ss-panel-icon">π</div>
|
| 1719 |
<div><p class="ss-panel-title">PDF Profiler</p>
|
|
|
|
| 1727 |
profile_btn.click(run_profile, outputs=[profile_status, profile_log])
|
| 1728 |
|
| 1729 |
# ββ STEP 3: OCR βββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1730 |
+
with gr.TabItem("β’ OCR", id="ss-ocr") as ocr_tab:
|
| 1731 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1732 |
<div class="ss-panel-icon">π</div>
|
| 1733 |
<div><p class="ss-panel-title">OCR Engine</p>
|
|
|
|
| 1860 |
# Review now auto-loads on tab select and after OCR run completion.
|
| 1861 |
|
| 1862 |
# ββ STEP 5: EXPORT ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1863 |
+
with gr.TabItem("β€ Export", id="ss-export") as export_tab:
|
| 1864 |
gr.HTML("""<div class="ss-panel-header" style="padding:20px 0 0 0">
|
| 1865 |
<div class="ss-panel-icon">β¬</div>
|
| 1866 |
<div><p class="ss-panel-title">Codex Export</p>
|
|
|
|
| 1890 |
run_export,
|
| 1891 |
outputs=[export_status, export_log, codex_download, gold_download],
|
| 1892 |
)
|
| 1893 |
+
|
| 1894 |
+
ingest_tab.select(lambda: _wizard_header_html(1), outputs=[wizard_header])
|
| 1895 |
+
profile_tab.select(lambda: _wizard_header_html(2), outputs=[wizard_header])
|
| 1896 |
+
ocr_tab.select(lambda: _wizard_header_html(3), outputs=[wizard_header])
|
| 1897 |
+
review_tab.select(lambda: _wizard_header_html(4), outputs=[wizard_header])
|
| 1898 |
+
export_tab.select(lambda: _wizard_header_html(5), outputs=[wizard_header])
|