Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,26 @@ with open("mtdna_tool_explainer_updated.html", "r", encoding="utf-8") as f:
|
|
19 |
flow_chart = f.read()
|
20 |
|
21 |
### NEW: CSS for NPS modal overlay
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
custom_css = """
|
23 |
#nps-overlay {
|
24 |
position: fixed;
|
@@ -26,11 +46,13 @@ custom_css = """
|
|
26 |
width: 100%; height: 100%;
|
27 |
background: rgba(0,0,0,0.6);
|
28 |
z-index: 9999;
|
29 |
-
display:
|
|
|
30 |
justify-content: center;
|
31 |
align-items: center;
|
32 |
}
|
33 |
#nps-box {
|
|
|
34 |
background: white;
|
35 |
padding: 20px;
|
36 |
border-radius: 12px;
|
@@ -38,9 +60,22 @@ custom_css = """
|
|
38 |
max-width: 90%;
|
39 |
text-align: center;
|
40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
"""
|
42 |
|
43 |
|
|
|
44 |
with gr.Blocks() as interface:
|
45 |
# with gr.Tab("CURIOUS ABOUT THIS PRODUCT?"):
|
46 |
# gr.HTML(value=pricing_html)
|
@@ -67,20 +102,27 @@ with gr.Blocks() as interface:
|
|
67 |
|
68 |
with gr.Row():
|
69 |
run_button = gr.Button("π Submit and Classify", elem_id="run-btn")
|
70 |
-
stop_button = gr.Button("β Stop Batch", visible=
|
71 |
reset_button = gr.Button("π Reset", elem_id="reset-btn")
|
72 |
|
73 |
|
74 |
status = gr.Markdown(visible=False)
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
|
77 |
with gr.Column(elem_id="nps-box"):
|
|
|
78 |
gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
|
79 |
nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Your NPS Score (0-10)")
|
80 |
nps_text = gr.Textbox(label="Any feedback?", lines=3)
|
81 |
-
|
82 |
-
nps_submit = gr.Button("Submit")
|
83 |
-
nps_close = gr.Button("X", elem_id="nps-close")
|
84 |
|
85 |
|
86 |
with gr.Group(visible=False) as results_group:
|
@@ -479,14 +521,21 @@ with gr.Blocks() as interface:
|
|
479 |
|
480 |
# Minimal blank yield to trigger UI rendering
|
481 |
yield (
|
482 |
-
make_html_table([]),
|
483 |
-
gr.update(visible=True),
|
484 |
-
gr.update(visible=False),
|
485 |
-
gr.update(value="", visible=True),
|
486 |
-
"βοΈ Quota limit",
|
487 |
-
"βοΈ Quota limit"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
)
|
489 |
-
|
490 |
# Actual warning frame
|
491 |
yield (
|
492 |
make_html_table([]),
|
@@ -494,7 +543,14 @@ with gr.Blocks() as interface:
|
|
494 |
gr.update(visible=False),
|
495 |
gr.update(value="β You have reached your quota. Please contact us to unlock more.", visible=True),
|
496 |
"β Quota Exceeded",
|
497 |
-
"\n".join(log_lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
)
|
499 |
return
|
500 |
limited_acc = int(max_allowed-usage_count)
|
@@ -509,7 +565,7 @@ with gr.Blocks() as interface:
|
|
509 |
"", # usage_display
|
510 |
"β³ Processing...", # status
|
511 |
"", # progess_box
|
512 |
-
gr.update(visible=
|
513 |
gr.update(visible=True), # show stop button
|
514 |
gr.update(visible=True), # show reset button
|
515 |
gr.update(visible=False), # hide raw_text
|
@@ -523,14 +579,22 @@ with gr.Blocks() as interface:
|
|
523 |
print("π§ͺ Accessions received:", accessions)
|
524 |
if error:
|
525 |
yield (
|
526 |
-
"",
|
527 |
-
gr.update(visible=False),
|
528 |
-
gr.update(visible=False),
|
529 |
-
"",
|
530 |
-
"β Error",
|
531 |
-
str(error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
)
|
533 |
return
|
|
|
534 |
|
535 |
total = len(accessions)
|
536 |
if total > limited_acc:
|
@@ -632,7 +696,7 @@ with gr.Blocks() as interface:
|
|
632 |
"", # usage_display
|
633 |
"β³ Processing...", # status
|
634 |
"\n".join(log_lines), # progress_box
|
635 |
-
gr.update(visible=
|
636 |
gr.update(visible=True), # stop_button
|
637 |
gr.update(visible=True), # reset_button
|
638 |
gr.update(visible=False), # hide raw_text
|
@@ -944,6 +1008,8 @@ with gr.Blocks() as interface:
|
|
944 |
gr.update(value="", visible=False), # status_report
|
945 |
gr.update(value="", visible=False), # processed_info
|
946 |
gr.update(visible=False) # hide NPS modal
|
|
|
|
|
947 |
)
|
948 |
|
949 |
|
@@ -1069,7 +1135,9 @@ with gr.Blocks() as interface:
|
|
1069 |
submit_report_button,
|
1070 |
status_report,
|
1071 |
processed_info,
|
1072 |
-
nps_modal
|
|
|
|
|
1073 |
]
|
1074 |
)
|
1075 |
|
@@ -1181,5 +1249,14 @@ with gr.Blocks() as interface:
|
|
1181 |
|
1182 |
with gr.Tab("PRICING"):
|
1183 |
gr.HTML(value=pricing_html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1184 |
|
1185 |
interface.launch(share=True,debug=True)
|
|
|
19 |
flow_chart = f.read()
|
20 |
|
21 |
### NEW: CSS for NPS modal overlay
|
22 |
+
# custom_css = """
|
23 |
+
# #nps-overlay {
|
24 |
+
# position: fixed;
|
25 |
+
# top: 0; left: 0;
|
26 |
+
# width: 100%; height: 100%;
|
27 |
+
# background: rgba(0,0,0,0.6);
|
28 |
+
# z-index: 9999;
|
29 |
+
# display: none; /* hidden by default */
|
30 |
+
# justify-content: center;
|
31 |
+
# align-items: center;
|
32 |
+
# }
|
33 |
+
# #nps-box {
|
34 |
+
# background: white;
|
35 |
+
# padding: 20px;
|
36 |
+
# border-radius: 12px;
|
37 |
+
# width: 400px;
|
38 |
+
# max-width: 90%;
|
39 |
+
# text-align: center;
|
40 |
+
# }
|
41 |
+
# """
|
42 |
custom_css = """
|
43 |
#nps-overlay {
|
44 |
position: fixed;
|
|
|
46 |
width: 100%; height: 100%;
|
47 |
background: rgba(0,0,0,0.6);
|
48 |
z-index: 9999;
|
49 |
+
display: flex;
|
50 |
+
flex-direction: column;
|
51 |
justify-content: center;
|
52 |
align-items: center;
|
53 |
}
|
54 |
#nps-box {
|
55 |
+
position: relative;
|
56 |
background: white;
|
57 |
padding: 20px;
|
58 |
border-radius: 12px;
|
|
|
60 |
max-width: 90%;
|
61 |
text-align: center;
|
62 |
}
|
63 |
+
#nps-close {
|
64 |
+
position: absolute;
|
65 |
+
top: 8px;
|
66 |
+
right: 8px;
|
67 |
+
cursor: pointer;
|
68 |
+
font-size: 18px;
|
69 |
+
font-weight: bold;
|
70 |
+
color: #666;
|
71 |
+
}
|
72 |
+
#nps-close:hover {
|
73 |
+
color: black;
|
74 |
+
}
|
75 |
"""
|
76 |
|
77 |
|
78 |
+
|
79 |
with gr.Blocks() as interface:
|
80 |
# with gr.Tab("CURIOUS ABOUT THIS PRODUCT?"):
|
81 |
# gr.HTML(value=pricing_html)
|
|
|
102 |
|
103 |
with gr.Row():
|
104 |
run_button = gr.Button("π Submit and Classify", elem_id="run-btn")
|
105 |
+
stop_button = gr.Button("β Stop Batch", visible=False, elem_id="stop-btn")
|
106 |
reset_button = gr.Button("π Reset", elem_id="reset-btn")
|
107 |
|
108 |
|
109 |
status = gr.Markdown(visible=False)
|
110 |
|
111 |
+
# with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
|
112 |
+
# with gr.Column(elem_id="nps-box"):
|
113 |
+
# gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
|
114 |
+
# nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Your NPS Score (0-10)")
|
115 |
+
# nps_text = gr.Textbox(label="Any feedback?", lines=3)
|
116 |
+
# with gr.Row():
|
117 |
+
# nps_submit = gr.Button("Submit")
|
118 |
+
# nps_close = gr.Button("X", elem_id="nps-close")
|
119 |
with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
|
120 |
with gr.Column(elem_id="nps-box"):
|
121 |
+
gr.HTML('<span id="nps-close">β</span>') # Small top-right X
|
122 |
gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
|
123 |
nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Your NPS Score (0-10)")
|
124 |
nps_text = gr.Textbox(label="Any feedback?", lines=3)
|
125 |
+
nps_submit = gr.Button("Submit")
|
|
|
|
|
126 |
|
127 |
|
128 |
with gr.Group(visible=False) as results_group:
|
|
|
521 |
|
522 |
# Minimal blank yield to trigger UI rendering
|
523 |
yield (
|
524 |
+
make_html_table([]), # 1 output_table
|
525 |
+
gr.update(visible=True), # 2 results_group
|
526 |
+
gr.update(visible=False), # 3 download_file
|
527 |
+
gr.update(value="", visible=True), # 4 usage_display
|
528 |
+
"βοΈ Quota limit", # 5 status
|
529 |
+
"βοΈ Quota limit", # 6 progress_box
|
530 |
+
gr.update(visible=True), # 7 run_button
|
531 |
+
gr.update(visible=False), # 8 stop_button
|
532 |
+
gr.update(visible=True), # 9 reset_button
|
533 |
+
gr.update(visible=True), # 10 raw_text
|
534 |
+
gr.update(visible=True), # 11 file_upload
|
535 |
+
gr.update(value="", visible=False), # 12 processed_info
|
536 |
+
gr.update(visible=False) # 13 nps_modal
|
537 |
)
|
538 |
+
|
539 |
# Actual warning frame
|
540 |
yield (
|
541 |
make_html_table([]),
|
|
|
543 |
gr.update(visible=False),
|
544 |
gr.update(value="β You have reached your quota. Please contact us to unlock more.", visible=True),
|
545 |
"β Quota Exceeded",
|
546 |
+
"\n".join(log_lines),
|
547 |
+
gr.update(visible=True),
|
548 |
+
gr.update(visible=False),
|
549 |
+
gr.update(visible=True),
|
550 |
+
gr.update(visible=True),
|
551 |
+
gr.update(visible=True),
|
552 |
+
gr.update(value="", visible=False),
|
553 |
+
gr.update(visible=False)
|
554 |
)
|
555 |
return
|
556 |
limited_acc = int(max_allowed-usage_count)
|
|
|
565 |
"", # usage_display
|
566 |
"β³ Processing...", # status
|
567 |
"", # progess_box
|
568 |
+
gr.update(visible=False), # run_button,
|
569 |
gr.update(visible=True), # show stop button
|
570 |
gr.update(visible=True), # show reset button
|
571 |
gr.update(visible=False), # hide raw_text
|
|
|
579 |
print("π§ͺ Accessions received:", accessions)
|
580 |
if error:
|
581 |
yield (
|
582 |
+
"", # 1 output_table
|
583 |
+
gr.update(visible=False), # 2 results_group
|
584 |
+
gr.update(visible=False), # 3 download_file
|
585 |
+
"", # 4 usage_display
|
586 |
+
"β Error", # 5 status
|
587 |
+
str(error), # 6 progress_box
|
588 |
+
gr.update(visible=True), # 7 run_button
|
589 |
+
gr.update(visible=False), # 8 stop_button
|
590 |
+
gr.update(visible=True), # 9 reset_button
|
591 |
+
gr.update(visible=True), # 10 raw_text
|
592 |
+
gr.update(visible=True), # 11 file_upload
|
593 |
+
gr.update(value="", visible=False), # 12 processed_info
|
594 |
+
gr.update(visible=False) # 13 nps_modal
|
595 |
)
|
596 |
return
|
597 |
+
|
598 |
|
599 |
total = len(accessions)
|
600 |
if total > limited_acc:
|
|
|
696 |
"", # usage_display
|
697 |
"β³ Processing...", # status
|
698 |
"\n".join(log_lines), # progress_box
|
699 |
+
gr.update(visible=False), # run_button
|
700 |
gr.update(visible=True), # stop_button
|
701 |
gr.update(visible=True), # reset_button
|
702 |
gr.update(visible=False), # hide raw_text
|
|
|
1008 |
gr.update(value="", visible=False), # status_report
|
1009 |
gr.update(value="", visible=False), # processed_info
|
1010 |
gr.update(visible=False) # hide NPS modal
|
1011 |
+
gr.update(visible=True), # run_button β
restore
|
1012 |
+
gr.update(visible=False) # stop button
|
1013 |
)
|
1014 |
|
1015 |
|
|
|
1135 |
submit_report_button,
|
1136 |
status_report,
|
1137 |
processed_info,
|
1138 |
+
nps_modal,
|
1139 |
+
run_button,
|
1140 |
+
stop_button
|
1141 |
]
|
1142 |
)
|
1143 |
|
|
|
1249 |
|
1250 |
with gr.Tab("PRICING"):
|
1251 |
gr.HTML(value=pricing_html)
|
1252 |
+
interface.load(
|
1253 |
+
_js="""
|
1254 |
+
() => {
|
1255 |
+
document.getElementById('nps-close').onclick = function() {
|
1256 |
+
document.querySelector('#nps-overlay').style.display = 'none';
|
1257 |
+
};
|
1258 |
+
}
|
1259 |
+
"""
|
1260 |
+
)
|
1261 |
|
1262 |
interface.launch(share=True,debug=True)
|