ydshieh HF Staff commited on
Commit
a188ad3
·
verified ·
1 Parent(s): 9fcc877

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -38
app.py CHANGED
@@ -188,44 +188,7 @@ def refresh_dataset() -> str:
188
  return "Cleared cached manifest. Data will be reloaded on next search."
189
 
190
 
191
- with gr.Blocks(head="""
192
- <script>
193
- document.addEventListener('DOMContentLoaded', function() {
194
- // Parse URL parameters
195
- const params = new URLSearchParams(window.location.search);
196
- const repo = params.get('repo') || '';
197
- const pr = params.get('pr') || '';
198
- const sha = params.get('sha') || '';
199
-
200
- if (repo || pr || sha) {
201
- // Wait for Gradio to initialize
202
- setTimeout(() => {
203
- // Find and populate the input fields
204
- const inputs = document.querySelectorAll('input[type="text"]');
205
- if (inputs.length >= 3) {
206
- if (repo) inputs[0].value = repo;
207
- if (pr) inputs[1].value = pr;
208
- if (sha) inputs[2].value = sha;
209
-
210
- // Trigger input events to update Gradio's state
211
- inputs.forEach(input => {
212
- input.dispatchEvent(new Event('input', { bubbles: true }));
213
- });
214
-
215
- // Auto-click search if PR is provided
216
- if (pr) {
217
- setTimeout(() => {
218
- const buttons = document.querySelectorAll('button');
219
- const searchBtn = Array.from(buttons).find(btn => btn.textContent.includes('Search'));
220
- if (searchBtn) searchBtn.click();
221
- }, 500);
222
- }
223
- }
224
- }, 1000);
225
- }
226
- });
227
- </script>
228
- """) as demo:
229
  gr.Markdown(
230
  """
231
  # CircleCI Test Collection Helper
@@ -263,6 +226,46 @@ document.addEventListener('DOMContentLoaded', function() {
263
 
264
  search_btn.click(query, inputs=[repo_box, pr_box, sha_box], outputs=[table, json_view, status])
265
  refresh_btn.click(refresh_dataset, outputs=status)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
 
267
  if __name__ == "__main__":
268
  demo.queue(max_size=20).launch(ssr_mode=False)
 
188
  return "Cleared cached manifest. Data will be reloaded on next search."
189
 
190
 
191
+ with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  gr.Markdown(
193
  """
194
  # CircleCI Test Collection Helper
 
226
 
227
  search_btn.click(query, inputs=[repo_box, pr_box, sha_box], outputs=[table, json_view, status])
228
  refresh_btn.click(refresh_dataset, outputs=status)
229
+
230
+ # Add JavaScript to handle URL parameters
231
+ gr.HTML("""
232
+ <script>
233
+ (function() {
234
+ const params = new URLSearchParams(window.location.search);
235
+ const repo = params.get('repo') || '';
236
+ const pr = params.get('pr') || '';
237
+ const sha = params.get('sha') || '';
238
+
239
+ if (repo || pr || sha) {
240
+ setTimeout(() => {
241
+ const inputs = document.querySelectorAll('input[type="text"]');
242
+ if (inputs.length >= 3) {
243
+ if (repo) {
244
+ inputs[0].value = repo;
245
+ inputs[0].dispatchEvent(new Event('input', { bubbles: true }));
246
+ }
247
+ if (pr) {
248
+ inputs[1].value = pr;
249
+ inputs[1].dispatchEvent(new Event('input', { bubbles: true }));
250
+ }
251
+ if (sha) {
252
+ inputs[2].value = sha;
253
+ inputs[2].dispatchEvent(new Event('input', { bubbles: true }));
254
+ }
255
+
256
+ if (pr) {
257
+ setTimeout(() => {
258
+ const buttons = document.querySelectorAll('button');
259
+ const searchBtn = Array.from(buttons).find(btn => btn.textContent.includes('Search'));
260
+ if (searchBtn) searchBtn.click();
261
+ }, 500);
262
+ }
263
+ }
264
+ }, 1000);
265
+ }
266
+ })();
267
+ </script>
268
+ """)
269
 
270
  if __name__ == "__main__":
271
  demo.queue(max_size=20).launch(ssr_mode=False)