Update page_files/Home.py
Browse files- page_files/Home.py +2 -49
page_files/Home.py
CHANGED
|
@@ -198,32 +198,7 @@ elif _nav == "search":
|
|
| 198 |
st.query_params.clear()
|
| 199 |
st.switch_page("page_files/Categorized_Search.py")
|
| 200 |
|
| 201 |
-
|
| 202 |
-
components.html("""
|
| 203 |
-
<script>
|
| 204 |
-
window.addEventListener('message', function(e) {
|
| 205 |
-
if (e.data && e.data.type === 'streamlit:setComponentValue') {
|
| 206 |
-
// Write to a hidden input Streamlit can read via query params
|
| 207 |
-
const val = e.data.value;
|
| 208 |
-
window.parent.location.href = window.parent.location.href.split('?')[0] + '?card=' + val;
|
| 209 |
-
}
|
| 210 |
-
});
|
| 211 |
-
</script>
|
| 212 |
-
""", height=0)
|
| 213 |
-
|
| 214 |
-
# Check query param for card navigation
|
| 215 |
-
import urllib.parse
|
| 216 |
-
try:
|
| 217 |
-
_qp = st.query_params
|
| 218 |
-
if "card" in _qp:
|
| 219 |
-
_card_val = _qp["card"]
|
| 220 |
-
st.query_params.clear()
|
| 221 |
-
if _card_val == "upload":
|
| 222 |
-
st.switch_page("page_files/Upload_Data.py")
|
| 223 |
-
elif _card_val == "search":
|
| 224 |
-
st.switch_page("page_files/Categorized_Search.py")
|
| 225 |
-
except Exception:
|
| 226 |
-
pass
|
| 227 |
|
| 228 |
# Helper
|
| 229 |
def go_categorized(material=None, search=None):
|
|
@@ -600,29 +575,7 @@ def _build_showcase_html(extract_b64, search_b64):
|
|
| 600 |
"</body></html>"
|
| 601 |
)
|
| 602 |
|
| 603 |
-
|
| 604 |
-
# Hidden Streamlit buttons wired to the card clicks via JS
|
| 605 |
-
_btn_col1, _btn_col2 = st.columns(2)
|
| 606 |
-
with _btn_col1:
|
| 607 |
-
if st.button("Go to Extract Data", key="_nav_upload", help="", use_container_width=True):
|
| 608 |
-
st.switch_page("page_files/Upload_Data.py")
|
| 609 |
-
with _btn_col2:
|
| 610 |
-
if st.button("Go to Search", key="_nav_search", help="", use_container_width=True):
|
| 611 |
-
st.switch_page("page_files/Categorized_Search.py")
|
| 612 |
-
|
| 613 |
-
# Hide the nav buttons visually — they are only triggered by JS
|
| 614 |
-
st.markdown("""
|
| 615 |
-
<style>
|
| 616 |
-
.st-key-_nav_upload, .st-key-_nav_search {
|
| 617 |
-
position: absolute !important;
|
| 618 |
-
opacity: 0 !important;
|
| 619 |
-
pointer-events: none !important;
|
| 620 |
-
height: 0 !important;
|
| 621 |
-
overflow: hidden !important;
|
| 622 |
-
}
|
| 623 |
-
</style>
|
| 624 |
-
""", unsafe_allow_html=True)
|
| 625 |
-
|
| 626 |
|
| 627 |
|
| 628 |
|
|
|
|
| 198 |
st.query_params.clear()
|
| 199 |
st.switch_page("page_files/Categorized_Search.py")
|
| 200 |
|
| 201 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
# Helper
|
| 204 |
def go_categorized(material=None, search=None):
|
|
|
|
| 575 |
"</body></html>"
|
| 576 |
)
|
| 577 |
|
| 578 |
+
components.html(_build_showcase_html(extract_card_img, search_card_img), height=480, scrolling=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
|
| 580 |
|
| 581 |
|