Spaces:
Paused
Paused
Update app.py via AI Editor
Browse files
app.py
CHANGED
@@ -56,7 +56,11 @@ def get_right_col_content(selected_type):
|
|
56 |
controls.append(dbc.Button("Download Document", id="btn-download", color="success", className="mt-3"))
|
57 |
controls.append(dcc.Download(id="download-document"))
|
58 |
controls.append(html.Hr())
|
59 |
-
if selected_type
|
|
|
|
|
|
|
|
|
60 |
controls.append(html.Div([
|
61 |
html.Label(f"Upload {selected_type} Document"),
|
62 |
dcc.Upload(
|
@@ -248,12 +252,10 @@ def remove_file(n_clicks, existing_files):
|
|
248 |
ctx = dash.callback_context
|
249 |
if not ctx.triggered:
|
250 |
raise dash.exceptions.PreventUpdate
|
251 |
-
# Only proceed if a remove button was actually clicked
|
252 |
triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
253 |
if not triggered_id.startswith("{\"type\":\"remove-file\""):
|
254 |
raise dash.exceptions.PreventUpdate
|
255 |
try:
|
256 |
-
# Parse the file name from the triggered id
|
257 |
import json
|
258 |
triggered_dict = json.loads(triggered_id)
|
259 |
removed_file = triggered_dict['index']
|
@@ -263,11 +265,9 @@ def remove_file(n_clicks, existing_files):
|
|
263 |
uploaded_files.pop(removed_file, None)
|
264 |
shredded_document = None
|
265 |
logging.info(f"Removed file: {removed_file}")
|
266 |
-
# Filter out the removed file from the list
|
267 |
filtered_files = []
|
268 |
if existing_files:
|
269 |
for file in existing_files:
|
270 |
-
# Defensive: file['props']['children'][1]['props']['children'] is the filename
|
271 |
try:
|
272 |
file_name = file['props']['children'][1]['props']['children']
|
273 |
if file_name != removed_file:
|
|
|
56 |
controls.append(dbc.Button("Download Document", id="btn-download", color="success", className="mt-3"))
|
57 |
controls.append(dcc.Download(id="download-document"))
|
58 |
controls.append(html.Hr())
|
59 |
+
if selected_type == "Shred":
|
60 |
+
controls.append(
|
61 |
+
dbc.Button("Generate Document", id={'type': 'btn-generate-doc', 'index': selected_type}, color="primary", className="mb-3")
|
62 |
+
)
|
63 |
+
elif selected_type != "Shred":
|
64 |
controls.append(html.Div([
|
65 |
html.Label(f"Upload {selected_type} Document"),
|
66 |
dcc.Upload(
|
|
|
252 |
ctx = dash.callback_context
|
253 |
if not ctx.triggered:
|
254 |
raise dash.exceptions.PreventUpdate
|
|
|
255 |
triggered_id = ctx.triggered[0]['prop_id'].split('.')[0]
|
256 |
if not triggered_id.startswith("{\"type\":\"remove-file\""):
|
257 |
raise dash.exceptions.PreventUpdate
|
258 |
try:
|
|
|
259 |
import json
|
260 |
triggered_dict = json.loads(triggered_id)
|
261 |
removed_file = triggered_dict['index']
|
|
|
265 |
uploaded_files.pop(removed_file, None)
|
266 |
shredded_document = None
|
267 |
logging.info(f"Removed file: {removed_file}")
|
|
|
268 |
filtered_files = []
|
269 |
if existing_files:
|
270 |
for file in existing_files:
|
|
|
271 |
try:
|
272 |
file_name = file['props']['children'][1]['props']['children']
|
273 |
if file_name != removed_file:
|