bluenevus commited on
Commit
c3e6348
·
verified ·
1 Parent(s): c54cfd8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -17
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("download-g-review-doc", "data"),
469
- Input("download-g-review", "n_clicks"),
470
- State('g-review-output', 'children'),
471
- prevent_initial_call=True,
 
472
  )
473
- def download_g_review(n_clicks, g_review_output):
474
- if g_review_output is None:
475
- return dash.no_update
476
- return dict(content=g_review_output, filename="g_review_report.md")
 
 
 
 
 
 
477
 
 
478
  @app.callback(
479
- Output("download-loe-doc", "data"),
480
- Input("download-loe", "n_clicks"),
481
- State('loe-output', 'children'),
482
- prevent_initial_call=True,
483
  )
484
- def download_loe(n_clicks, loe_output):
485
- if loe_output is None:
486
- return dash.no_update
487
- loe_text = loe_output[0]['props']['children']
488
- return dict(content=loe_text, filename="loe_report.md")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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...")