nesticot commited on
Commit
40a227a
·
verified ·
1 Parent(s): 78f9d2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -8
app.py CHANGED
@@ -203,7 +203,11 @@ main_ui = ui.page_sidebar(
203
 
204
  ),
205
  # Row for selecting the date range
206
- ui.row(ui.column(12, ui.output_ui('date_id_1', 'Select Date'))),
 
 
 
 
207
  ui.row(
208
  ui.column(6, ui.input_switch("switch_1", "Custom Team?", False)),
209
  ui.column(6, ui.input_select('logo_select_1', 'Select Custom Logo', image_dict_flip, multiple=False))
@@ -257,7 +261,7 @@ main_ui = ui.page_sidebar(
257
 
258
  ),
259
  )
260
-
261
  # Combined UI with conditional panel
262
  app_ui = ui.page_fluid(
263
  ui.tags.head(
@@ -376,13 +380,34 @@ def server(input, output, session):
376
  @render.ui
377
  @reactive.event(input.player_button_1, input.year_input_1, ignore_none=False)
378
  def date_id_1():
379
- # Create a date range input for selecting the date range within the selected year
380
- return ui.input_date_range("date_id_1", "Select Date Range",
381
- start=f"{int(input.year_input_1())}-01-01",
382
- end=f"{int(input.year_input_1())}-12-31",
383
- min=f"{int(input.year_input_1())}-01-01",
384
- max=f"{int(input.year_input_1())}-12-31")
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  @render.ui
387
  @reactive.event(input.player_button_2, input.year_input_2, ignore_none=False)
388
  def date_id_2():
 
203
 
204
  ),
205
  # Row for selecting the date range
206
+ ui.row(ui.column(8, ui.output_ui('date_id_1', 'Select Date')),
207
+ ui.column(4, ui.input_select('select_date_time1', 'Quick Time',['','Season','Last 10 Days','Last 30 Days'])),
208
+
209
+
210
+ ),
211
  ui.row(
212
  ui.column(6, ui.input_switch("switch_1", "Custom Team?", False)),
213
  ui.column(6, ui.input_select('logo_select_1', 'Select Custom Logo', image_dict_flip, multiple=False))
 
261
 
262
  ),
263
  )
264
+ from datetime import datetime, timedelta
265
  # Combined UI with conditional panel
266
  app_ui = ui.page_fluid(
267
  ui.tags.head(
 
380
  @render.ui
381
  @reactive.event(input.player_button_1, input.year_input_1, ignore_none=False)
382
  def date_id_1():
 
 
 
 
 
 
383
 
384
+ if input.select_date_time1() == 'Season':
385
+ # Create a date range input for selecting the date range within the selected year
386
+ return ui.input_date_range("date_id_1", "Select Date Range",
387
+ start=f"{int(input.year_input_1())}-01-01",
388
+ end=f"{int(input.year_input_1())}-12-31",
389
+ min=f"{int(input.year_input_1())}-01-01",
390
+ max=f"{int(input.year_input_1())}-12-31")
391
+ elif input.select_date_time1() == 'Last 10 Days':
392
+ today = datetime.today().date()
393
+ last_10_days = today - timedelta(days=10)
394
+
395
+ return ui.input_date_range("date_id_1", "Select Date Range",
396
+ start=last_10_days.strftime("%Y-%m-%d"),
397
+ end=today.strftime("%Y-%m-%d"),
398
+ min=last_10_days.strftime("%Y-%m-%d"),
399
+ max=today.strftime("%Y-%m-%d"))
400
+
401
+ elif input.select_date_time1() == 'Last 30 Days':
402
+ today = datetime.today().date()
403
+ last_10_days = today - timedelta(days=30)
404
+
405
+ return ui.input_date_range("date_id_1", "Select Date Range",
406
+ start=last_10_days.strftime("%Y-%m-%d"),
407
+ end=today.strftime("%Y-%m-%d"),
408
+ min=last_10_days.strftime("%Y-%m-%d"),
409
+ max=today.strftime("%Y-%m-%d"))
410
+
411
  @render.ui
412
  @reactive.event(input.player_button_2, input.year_input_2, ignore_none=False)
413
  def date_id_2():