cryogenic22 commited on
Commit
4152a02
·
verified ·
1 Parent(s): dd96f4e

Create components/document_preview.py

Browse files
Files changed (1) hide show
  1. components/document_preview.py +49 -0
components/document_preview.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # components/document_preview.py
3
+ def enhanced_document_preview(doc: Dict):
4
+ """Enhanced document preview component."""
5
+ with st.container():
6
+ # Header with metadata
7
+ col1, col2 = st.columns([3, 1])
8
+
9
+ with col1:
10
+ st.subheader(doc['name'])
11
+ st.text(f"Uploaded: {doc['upload_date']}")
12
+ if doc.get('collections'):
13
+ st.text(f"Collections: {', '.join(doc['collections'])}")
14
+
15
+ with col2:
16
+ st.button("Download PDF", key=f"download_{doc['id']}",
17
+ use_container_width=True)
18
+ st.button("Add to Collection", key=f"add_col_{doc['id']}",
19
+ use_container_width=True)
20
+
21
+ # Document preview tabs
22
+ tab1, tab2, tab3 = st.tabs(["Preview", "Text Content", "Metadata"])
23
+
24
+ with tab1:
25
+ if doc.get('thumbnail'):
26
+ st.image(doc['thumbnail'])
27
+ else:
28
+ st.write("Preview not available")
29
+
30
+ with tab2:
31
+ st.text_area(
32
+ "",
33
+ value=doc['content'],
34
+ height=400,
35
+ disabled=True
36
+ )
37
+
38
+ with tab3:
39
+ col1, col2 = st.columns(2)
40
+ with col1:
41
+ st.write("**Document Info**")
42
+ st.write(f"Size: {len(doc['content'])/1024:.1f} KB")
43
+ st.write(f"Upload Date: {doc['upload_date']}")
44
+ st.write(f"Document ID: {doc['id']}")
45
+
46
+ with col2:
47
+ st.write("**Collections**")
48
+ for collection in doc.get('collections', []):
49
+ st.write(f"• {collection}")