nesticot commited on
Commit
f0d6574
·
verified ·
1 Parent(s): 91d00ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -8
app.py CHANGED
@@ -232,8 +232,9 @@ main_ui = ui.page_sidebar(
232
 
233
  ),
234
  # Row for selecting the date range
235
- ui.row(ui.column(12, ui.output_ui('date_id_2', 'Select Date'))),
236
-
 
237
  ui.row(
238
  ui.column(6, ui.input_switch("switch_2", "Custom Team?", False)),
239
  ui.column(6, ui.input_select('logo_select_2', 'Select Custom Logo', image_dict_flip, multiple=False))
@@ -412,12 +413,32 @@ def server(input, output, session):
412
  @reactive.event(input.player_button_2, input.year_input_2, ignore_none=False)
413
  def date_id_2():
414
  # Create a date range input for selecting the date range within the selected year
415
- return ui.input_date_range("date_id_2", "Select Date Range",
416
- start=f"{int(input.year_input_2())}-01-01",
417
- end=f"{int(input.year_input_2())}-12-31",
418
- min=f"{int(input.year_input_2())}-01-01",
419
- max=f"{int(input.year_input_2())}-12-31")
420
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
 
422
  @output
423
  @render.text
 
232
 
233
  ),
234
  # Row for selecting the date range
235
+ ui.row(ui.column(8, ui.output_ui('date_id_2', 'Select Date')),
236
+ ui.column(4, ui.input_select('select_date_time2', 'Quick Time',['Season','Last 10 Days','Last 30 Days'])),
237
+
238
  ui.row(
239
  ui.column(6, ui.input_switch("switch_2", "Custom Team?", False)),
240
  ui.column(6, ui.input_select('logo_select_2', 'Select Custom Logo', image_dict_flip, multiple=False))
 
413
  @reactive.event(input.player_button_2, input.year_input_2, ignore_none=False)
414
  def date_id_2():
415
  # Create a date range input for selecting the date range within the selected year
416
+ if input.select_date_time2() == 'Season':
417
+ # Create a date range input for selecting the date range within the selected year
418
+ return ui.input_date_range("date_id_2", "Select Date Range",
419
+ start=f"{int(input.year_input_1())}-01-01",
420
+ end=f"{int(input.year_input_1())}-12-31",
421
+ min=f"{int(input.year_input_1())}-01-01",
422
+ max=f"{int(input.year_input_1())}-12-31")
423
+ elif input.select_date_time2() == 'Last 10 Days':
424
+ today = datetime.today().date()
425
+ last_10_days = today - timedelta(days=10)
426
+
427
+ return ui.input_date_range("date_id_2", "Select Date Range",
428
+ start=last_10_days.strftime("%Y-%m-%d"),
429
+ end=today.strftime("%Y-%m-%d"),
430
+ min=last_10_days.strftime("%Y-%m-%d"),
431
+ max=today.strftime("%Y-%m-%d"))
432
+
433
+ elif input.select_date_time2() == 'Last 30 Days':
434
+ today = datetime.today().date()
435
+ last_10_days = today - timedelta(days=30)
436
+
437
+ return ui.input_date_range("date_id_2", "Select Date Range",
438
+ start=last_10_days.strftime("%Y-%m-%d"),
439
+ end=today.strftime("%Y-%m-%d"),
440
+ min=last_10_days.strftime("%Y-%m-%d"),
441
+ max=today.strftime("%Y-%m-%d"))
442
 
443
  @output
444
  @render.text