Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -464,28 +464,103 @@ def download_red(n_clicks, red_output):
|
|
464 |
return dash.no_update
|
465 |
return dict(content=red_output, filename="red_team_document.md")
|
466 |
|
|
|
467 |
@app.callback(
|
468 |
-
Output(
|
469 |
-
Input(
|
470 |
-
State('g-review
|
471 |
-
|
|
|
472 |
)
|
473 |
-
def
|
474 |
-
if
|
475 |
-
return
|
476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
|
|
|
478 |
@app.callback(
|
479 |
-
Output("
|
480 |
-
|
481 |
-
|
482 |
-
prevent_initial_call=True,
|
483 |
)
|
484 |
-
def
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
|
490 |
if __name__ == '__main__':
|
491 |
print("Starting the Dash application...")
|
|
|
464 |
return dash.no_update
|
465 |
return dict(content=red_output, filename="red_team_document.md")
|
466 |
|
467 |
+
# Update the g-review callback
|
468 |
@app.callback(
|
469 |
+
Output('g-review-output', 'children'),
|
470 |
+
Input('evaluate-g-review', 'n_clicks'),
|
471 |
+
State('upload-g-review', 'contents'),
|
472 |
+
State('upload-g-review', 'filename'),
|
473 |
+
State('shred-output', 'children')
|
474 |
)
|
475 |
+
def update_g_review_output(n_clicks, contents, filename, requirements):
|
476 |
+
if n_clicks is None:
|
477 |
+
return "Click 'Evaluate Compliance' to begin."
|
478 |
+
|
479 |
+
if contents is None:
|
480 |
+
return "Please upload a document first."
|
481 |
+
|
482 |
+
document = process_document(contents, filename)
|
483 |
+
compliance_report = evaluate_compliance(document, requirements)
|
484 |
+
return dcc.Markdown(compliance_report)
|
485 |
|
486 |
+
# Update the tab disabling callback
|
487 |
@app.callback(
|
488 |
+
[Output(f"tabs", "active_tab")] +
|
489 |
+
[Output(f"tabs", "children") for _ in range(6)],
|
490 |
+
Input('shred-output', 'children')
|
|
|
491 |
)
|
492 |
+
def update_tab_status(shred_output):
|
493 |
+
tabs = [
|
494 |
+
dbc.Tab(label="Shred", tab_id="shred"),
|
495 |
+
dbc.Tab(label="Pink", tab_id="pink"),
|
496 |
+
dbc.Tab(label="P.Review", tab_id="p-review"),
|
497 |
+
dbc.Tab(label="Red", tab_id="red"),
|
498 |
+
dbc.Tab(label="R.Review", tab_id="r-review"),
|
499 |
+
dbc.Tab(label="G.Review", tab_id="g-review"),
|
500 |
+
dbc.Tab(label="LOE", tab_id="loe")
|
501 |
+
]
|
502 |
+
|
503 |
+
if shred_output is None:
|
504 |
+
for tab in tabs[1:]:
|
505 |
+
tab.disabled = True
|
506 |
+
else:
|
507 |
+
for tab in tabs[1:]:
|
508 |
+
tab.disabled = False
|
509 |
+
|
510 |
+
return ["shred"] + tabs
|
511 |
+
|
512 |
+
# Update the app layout
|
513 |
+
app.layout = dbc.Container([
|
514 |
+
html.H1("MicroHealth PWS Analysis and Response Generator", className="my-4"),
|
515 |
+
dbc.Tabs(id="tabs", active_tab="shred"),
|
516 |
+
html.Div(id='tab-content')
|
517 |
+
])
|
518 |
+
|
519 |
+
# Add a callback to update tab content
|
520 |
+
@app.callback(
|
521 |
+
Output('tab-content', 'children'),
|
522 |
+
Input('tabs', 'active_tab')
|
523 |
+
)
|
524 |
+
def render_tab_content(active_tab):
|
525 |
+
if active_tab == "shred":
|
526 |
+
return [
|
527 |
+
dbc.Textarea(
|
528 |
+
id='shred-instructions',
|
529 |
+
placeholder="Enter any additional instructions for shredding the document...",
|
530 |
+
style={'height': '100px', 'marginBottom': '10px'}
|
531 |
+
),
|
532 |
+
dcc.Upload(
|
533 |
+
id='upload-document',
|
534 |
+
children=html.Div(['Drag and Drop or ', html.A('Select Files')]),
|
535 |
+
style={
|
536 |
+
'width': '100%',
|
537 |
+
'height': '60px',
|
538 |
+
'lineHeight': '60px',
|
539 |
+
'borderWidth': '1px',
|
540 |
+
'borderStyle': 'dashed',
|
541 |
+
'borderRadius': '5px',
|
542 |
+
'textAlign': 'center',
|
543 |
+
'margin': '10px'
|
544 |
+
},
|
545 |
+
multiple=False
|
546 |
+
),
|
547 |
+
dbc.Spinner(html.Div(id='shred-output')),
|
548 |
+
dbc.Button("Download Outline", id="download-shred", className="mt-3"),
|
549 |
+
dcc.Download(id="download-shred-doc")
|
550 |
+
]
|
551 |
+
elif active_tab == "pink":
|
552 |
+
return [
|
553 |
+
dbc.Textarea(
|
554 |
+
id='pink-instructions',
|
555 |
+
placeholder="Enter any additional instructions for generating the Pink Team document...",
|
556 |
+
style={'height': '100px', 'marginBottom': '10px'}
|
557 |
+
),
|
558 |
+
dbc.Button("Generate Pink Team Document", id="generate-pink", className="mt-3"),
|
559 |
+
dbc.Spinner(html.Div(id='pink-output')),
|
560 |
+
dbc.Button("Download Pink Team Document", id="download-pink", className="mt-3"),
|
561 |
+
dcc.Download(id="download-pink-doc")
|
562 |
+
]
|
563 |
+
# Add similar content for other tabs...
|
564 |
|
565 |
if __name__ == '__main__':
|
566 |
print("Starting the Dash application...")
|