Skip to content

Commit 7f4242a

Browse files
committed
update file index page
1 parent 7627639 commit 7f4242a

File tree

1 file changed

+57
-40
lines changed
  • libs/ktem/ktem/index/file

1 file changed

+57
-40
lines changed

libs/ktem/ktem/index/file/ui.py

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -97,49 +97,66 @@ def upload_instruction(self) -> str:
9797

9898
def on_building_ui(self):
9999
"""Build the UI of the app"""
100-
with gr.Accordion(label="File upload", open=True) as self.upload:
101-
msg = self.upload_instruction()
102-
if msg:
103-
gr.Markdown(msg)
104-
105-
self.files = File(
106-
file_types=self._supported_file_types,
107-
file_count="multiple",
108-
container=False,
109-
)
110-
with gr.Accordion("Advanced indexing options", open=False):
111-
with gr.Row():
112-
self.reindex = gr.Checkbox(
113-
value=False, label="Force reindex file", container=False
100+
with gr.Row():
101+
with gr.Column(scale=1):
102+
gr.Markdown("## File Upload")
103+
with gr.Column() as self.upload:
104+
msg = self.upload_instruction()
105+
if msg:
106+
gr.Markdown(msg)
107+
108+
self.files = File(
109+
file_types=self._supported_file_types,
110+
file_count="multiple",
111+
container=True,
112+
)
113+
with gr.Accordion("Advanced indexing options", open=True):
114+
with gr.Row():
115+
self.reindex = gr.Checkbox(
116+
value=False, label="Force reindex file", container=False
117+
)
118+
119+
self.upload_button = gr.Button(
120+
"Upload and Index", variant="primary"
121+
)
122+
self.file_output = gr.File(
123+
visible=False, label="Output files (debug purpose)"
114124
)
115125

116-
self.upload_button = gr.Button("Upload and Index")
117-
self.file_output = gr.File(
118-
visible=False, label="Output files (debug purpose)"
119-
)
120-
121-
gr.Markdown("## File list")
122-
self.file_list_state = gr.State(value=None)
123-
self.file_list = gr.DataFrame(
124-
headers=["id", "name", "size", "text_length", "date_created"],
125-
interactive=False,
126-
)
127-
128-
with gr.Row() as self.selection_info:
129-
self.selected_file_id = gr.State(value=None)
130-
self.selected_panel = gr.Markdown(self.selected_panel_false)
131-
self.deselect_button = gr.Button("Deselect", visible=False)
126+
with gr.Column(scale=4):
127+
gr.Markdown("## File List")
128+
self.file_list_state = gr.State(value=None)
129+
self.file_list = gr.DataFrame(
130+
headers=["id", "name", "size", "text_length", "date_created"],
131+
interactive=False,
132+
)
132133

133-
with gr.Row() as self.tools:
134-
with gr.Column():
135-
self.view_button = gr.Button("View Text (WIP)")
136-
with gr.Column():
137-
self.delete_button = gr.Button("Delete")
138-
with gr.Row():
139-
self.delete_yes = gr.Button(
140-
"Confirm Delete", variant="primary", visible=False
141-
)
142-
self.delete_no = gr.Button("Cancel", visible=False)
134+
with gr.Row() as self.selection_info:
135+
self.selected_file_id = gr.State(value=None)
136+
with gr.Column(scale=2):
137+
self.selected_panel = gr.Markdown(self.selected_panel_false)
138+
with gr.Column(scale=1):
139+
self.deselect_button = gr.Button(
140+
"Deselect",
141+
scale=1,
142+
visible=False,
143+
elem_classes=["right-button"],
144+
)
145+
146+
self.delete_button = gr.Button(
147+
"Delete", variant="stop", elem_classes=["right-button"]
148+
)
149+
self.delete_yes = gr.Button(
150+
"Confirm Delete",
151+
variant="stop",
152+
visible=False,
153+
elem_classes=["right-button"],
154+
)
155+
self.delete_no = gr.Button(
156+
"Cancel",
157+
visible=False,
158+
elem_classes=["right-button"],
159+
)
143160

144161
def on_subscribe_public_events(self):
145162
"""Subscribe to the declared public event of the app"""

0 commit comments

Comments
 (0)