@@ -412,65 +412,126 @@ def render_description(self):
412
412
"""
413
413
)
414
414
415
- def render_run_url_inputs (self , key : str , del_key : str , d : dict ):
416
- from daras_ai_v2 .all_pages import all_home_pages
415
+ def _render_url_input_only (self , key : str , del_key : str , d : dict , is_mobile : bool ):
416
+ columns = [8 , 4 ] if is_mobile else [9 , 3 ]
417
+ col1 , col2 = gui .columns (
418
+ columns , responsive = False , style = {"--bs-gutter-x" : "0.25rem" }
419
+ )
417
420
418
- init_workflow_selector (d , key )
421
+ with col1 :
422
+ url = gui .text_input (
423
+ "" ,
424
+ key = key ,
425
+ value = d .get ("url" ),
426
+ placeholder = "https://gooey.ai/.../?run_id=..." ,
427
+ )
419
428
420
- col1 , col2 , col3 , col4 = gui .columns ([9 , 1 , 1 , 1 ], responsive = False )
421
- if not d .get ("workflow" ) and d .get ("url" ):
422
- with col1 :
423
- url = gui .text_input (
424
- "" ,
425
- key = key ,
426
- value = d .get ("url" ),
427
- placeholder = "https://gooey.ai/.../?run_id=..." ,
428
- )
429
- with col2 :
429
+ with col2 :
430
+ with gui .div (className = "d-flex justify-content-between" ):
430
431
edit_done_button (key )
431
- else :
432
- with col1 :
433
- scol1 , scol2 = gui .columns ([1 , 1 ], responsive = False )
432
+ gui .url_button (url )
433
+ del_button (del_key )
434
+
435
+ return url
436
+
437
+ def _render_workflow_selector (self , key : str , d : dict ):
438
+ from daras_ai_v2 .all_pages import all_home_pages
439
+
440
+ options = {
441
+ page_cls .workflow : page_cls .get_recipe_short_title ()
442
+ for page_cls in all_home_pages
443
+ }
444
+ last_workflow_key = "__last_run_url_workflow"
445
+ workflow = gui .selectbox (
446
+ "" ,
447
+ key = key + ":workflow" ,
448
+ value = (d .get ("workflow" ) or gui .session_state .get (last_workflow_key )),
449
+ options = options ,
450
+ format_func = lambda x : options [x ],
451
+ )
452
+ d ["workflow" ] = workflow
453
+ # use this to set default for next time
454
+ gui .session_state [last_workflow_key ] = workflow
455
+ return workflow
456
+
457
+ def _render_url_selector (self , key : str , d : dict , workflow ):
458
+ page_cls = Workflow (workflow ).page_cls
459
+ url_options = get_published_run_options (
460
+ page_cls , current_user = self .request .user
461
+ )
462
+ url_options .update (d .get ("--added_workflows" , {}))
463
+
464
+ url = gui .selectbox (
465
+ "" ,
466
+ key = key ,
467
+ options = url_options ,
468
+ value = d .get ("url" ),
469
+ format_func = lambda x : url_options [x ],
470
+ )
471
+ return url
472
+
473
+ def _render_workflow_mode_mobile (self , key : str , del_key : str , d : dict ):
474
+ wcol1 , wcol2 = gui .columns (
475
+ [8 , 4 ], responsive = False , style = {"--bs-gutter-x" : "0.25rem" }
476
+ )
477
+
478
+ with wcol1 :
479
+ with gui .div (className = "pt-1" ):
480
+ workflow = self ._render_workflow_selector (key , d )
481
+
482
+ with wcol2 :
483
+ with gui .div (className = "d-flex justify-content-between" ):
484
+ edit_button (key )
485
+ gui .url_button (d .get ("url" , "" ))
486
+ del_button (del_key )
487
+
488
+ with gui .div (className = "pt-2" ):
489
+ url = self ._render_url_selector (key , d , workflow )
490
+
491
+ return url
492
+
493
+ def _render_workflow_mode_desktop (self , key : str , del_key : str , d : dict ):
494
+ col1 , col2 = gui .columns (
495
+ [9 , 3 ], responsive = False , style = {"--bs-gutter-x" : "0.25rem" }
496
+ )
497
+
498
+ with col1 :
499
+ scol1 , scol2 = gui .columns (
500
+ [3 , 9 ], responsive = False , style = {"--bs-gutter-x" : "0.5rem" }
501
+ )
502
+
434
503
with scol1 :
435
504
with gui .div (className = "pt-1" ):
436
- options = {
437
- page_cls .workflow : page_cls .get_recipe_title ()
438
- for page_cls in all_home_pages
439
- }
440
- last_workflow_key = "__last_run_url_workflow"
441
- workflow = gui .selectbox (
442
- "" ,
443
- key = key + ":workflow" ,
444
- value = (
445
- d .get ("workflow" )
446
- or gui .session_state .get (last_workflow_key )
447
- ),
448
- options = options ,
449
- format_func = lambda x : options [x ],
450
- )
451
- d ["workflow" ] = workflow
452
- # use this to set default for next time
453
- gui .session_state [last_workflow_key ] = workflow
505
+ workflow = self ._render_workflow_selector (key , d )
506
+
454
507
with scol2 :
455
- page_cls = Workflow (workflow ).page_cls
456
- options = get_published_run_options (
457
- page_cls , current_user = self .request .user
458
- )
459
- options .update (d .get ("--added_workflows" , {}))
460
508
with gui .div (className = "pt-1" ):
461
- url = gui .selectbox (
462
- "" ,
463
- key = key ,
464
- options = options ,
465
- value = d .get ("url" ),
466
- format_func = lambda x : options [x ],
467
- )
468
- with col2 :
509
+ url = self ._render_url_selector (key , d , workflow )
510
+
511
+ with col2 :
512
+ with gui .div (className = "d-flex justify-content-between" ):
469
513
edit_button (key )
470
- with col3 :
471
- gui .url_button (url )
472
- with col4 :
473
- del_button (del_key )
514
+ gui .url_button (url )
515
+ del_button (del_key )
516
+
517
+ return url
518
+
519
+ def render_run_url_inputs (self , key : str , del_key : str , d : dict ):
520
+ init_workflow_selector (d , key )
521
+
522
+ if not d .get ("workflow" ) and d .get ("url" ):
523
+ with gui .div (className = "d-block d-lg-none" ):
524
+ url = self ._render_url_input_only (key , del_key , d , is_mobile = True )
525
+
526
+ with gui .div (className = "d-none d-lg-block" ):
527
+ url = self ._render_url_input_only (key , del_key , d , is_mobile = False )
528
+
529
+ else :
530
+ with gui .div (className = "d-block d-lg-none" ):
531
+ url = self ._render_workflow_mode_mobile (key , del_key , d )
532
+
533
+ with gui .div (className = "d-none d-lg-block" ):
534
+ url = self ._render_workflow_mode_desktop (key , del_key , d )
474
535
475
536
try :
476
537
url_to_runs (url )
0 commit comments