faisalsns commited on
Commit
f8dc2b9
·
verified ·
1 Parent(s): a261a9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -57,14 +57,17 @@ def fetch_feedback(app_filter, pwd):
57
 
58
  with gr.Blocks() as demo:
59
  with gr.Tab("Feedback Form"):
60
- gr.Markdown("### Rate this app")
61
- app_id = gr.Textbox(label="App ID")
 
 
 
62
  rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating")
63
  comment = gr.Textbox(label="Comment", lines=4)
64
  output = gr.Textbox(label="Status", interactive=False)
65
  submit_btn = gr.Button("Submit")
66
  submit_btn.click(fn=submit_feedback, inputs=[app_id, rating, comment], outputs=[output])
67
-
68
  with gr.Tab("Admin Panel"):
69
  gr.Markdown("### View Feedback (Admin Only)")
70
  pwd = gr.Textbox(label="Admin Password", type="password")
@@ -73,5 +76,24 @@ with gr.Blocks() as demo:
73
  table = gr.Dataframe(headers=["App ID", "Rating", "Comment", "Timestamp"], interactive=False)
74
  view_btn = gr.Button("Load Feedback")
75
  view_btn.click(fn=fetch_feedback, inputs=[app_filter, pwd], outputs=[status, table])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  demo.launch()
 
57
 
58
  with gr.Blocks() as demo:
59
  with gr.Tab("Feedback Form"):
60
+ gr.Markdown("### Rate this App")
61
+
62
+ app_id = gr.Textbox(label="App ID", visible=False)
63
+ app_id_display = gr.Markdown("") # optional display
64
+
65
  rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating")
66
  comment = gr.Textbox(label="Comment", lines=4)
67
  output = gr.Textbox(label="Status", interactive=False)
68
  submit_btn = gr.Button("Submit")
69
  submit_btn.click(fn=submit_feedback, inputs=[app_id, rating, comment], outputs=[output])
70
+
71
  with gr.Tab("Admin Panel"):
72
  gr.Markdown("### View Feedback (Admin Only)")
73
  pwd = gr.Textbox(label="Admin Password", type="password")
 
76
  table = gr.Dataframe(headers=["App ID", "Rating", "Comment", "Timestamp"], interactive=False)
77
  view_btn = gr.Button("Load Feedback")
78
  view_btn.click(fn=fetch_feedback, inputs=[app_filter, pwd], outputs=[status, table])
79
+ gr.HTML("""
80
+ <script>
81
+ window.addEventListener("load", function () {
82
+ const params = new URLSearchParams(window.location.search);
83
+ const appId = params.get("app_id");
84
+ if (appId) {
85
+ const inputBox = document.querySelector('input[type="text"][aria-label="App ID"]');
86
+ if (inputBox) {
87
+ inputBox.value = appId;
88
+ inputBox.dispatchEvent(new Event('input', { bubbles: true }));
89
+ }
90
+ const display = document.querySelector("div.markdown");
91
+ if (display) {
92
+ display.innerHTML = "**App ID:** " + appId;
93
+ }
94
+ }
95
+ });
96
+ </script>
97
+ """)
98
 
99
  demo.launch()