Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beekeeper page add year selector for simulation + limit number of simulation run days #68

Merged
merged 10 commits into from
Jun 26, 2024
6 changes: 4 additions & 2 deletions app/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ ui <- function(id) {
nav_panel(
title = i18n$translate("Honeybee"),
class = "p-0",
honeybee_ui(ns("honeybee_main"),
theme = biodt_theme
honeybee_ui(
ns("honeybee_main"),
theme = biodt_theme,
i18n
)
),
if (env_active == "dev") {
Expand Down
2 changes: 1 addition & 1 deletion app/static/css/app.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
}
/* END slider inputs color fix (for awesome inputs which were removed) */

.no-minor-ticks{
.irs-grid-pol.small {
height: 0px;
}
}
/* shiny checkbox color fix */
.shiny-input-checkbox {
background-color: #DDA15E !important;
Expand Down
4 changes: 4 additions & 0 deletions app/translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
{
"en": "[EN] Lorem ipsum...",
"cz": "[CZ] Lorem ipsum..."
},
{
"en": "Simulation length (in years):",
"cz": "Délka simulace (počet let):"
}
]
}
68 changes: 42 additions & 26 deletions app/view/honeybee/beekeeper_param.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
box::use(
shiny[moduleServer, NS, tagList, sliderInput, tags, numericInput, bootstrapPage, reactiveVal, observeEvent, reactive, updateSliderInput, checkboxInput],
shiny[moduleServer, NS, tagList, sliderInput, tags, div, numericInput, bootstrapPage, reactiveVal, observeEvent, reactive, updateSliderInput, checkboxInput],
bslib[card, card_header, card_body],
shinyWidgets[airYearpickerInput],
)

#' @export
honeybee_param_ui <- function(id,
theme) {
honeybee_param_ui <- function(id, theme, i18n) {
ns <- NS(id)
# tagList(
bootstrapPage(
Expand Down Expand Up @@ -57,26 +57,26 @@ honeybee_param_ui <- function(id,
label = "Drone Brood Removal",
value = TRUE
),
# shinyWidgets::airDatepickerInput(
# inputId = ns("SimulationDateStart"),
# label = "Start the simulation from:",
# value = "2016-01-01",
# multiple = FALSE,
# placeholder = "What starting date of your simulation run do you want to?",
# minDate = "2016-01-01",
# startView = "2020-01-01",
# clearButton = TRUE,
# update_on = "close",
# addon = "none"
# ),
numericInput(
inputId = ns("SimulationDays"),
label = "Simulation length (days):",
div(
class = "no-minor-ticks",
sliderInput(
ns("SimulationYearStart"),
label = "Choose start year of the simulation:",
value = 2016L,
min = 2016L,
#ticks = FALSE,
max = (Sys.Date() - 395) |> format("%Y") |> as.integer(), # 395 -> year plus one month
step = 1
)
),
sliderInput(
ns("DaysLimit"),
label = "For how many days:",
value = 365,
min = 365,
max = 3650,
step = 365
)
max = as.integer((Sys.Date() - 31) - as.Date("2016-01-01")),
step = 30
),
)
)
)
Expand Down Expand Up @@ -108,7 +108,8 @@ honeybee_param_server <- function(id) {
input$HoneyHarvesting,
input$VarroaTreatment,
input$DroneBroodRemoval,
input$SimulationDays
input$SimulationYearStart,
input$DaysLimit
)
})

Expand All @@ -120,22 +121,37 @@ honeybee_param_server <- function(id) {
"N_INITIAL_MITES_INFECTED",
"HoneyHarvesting",
"VarroaTreatment",
"DroneBroodRemoval"
"DroneBroodRemoval",
"SimulationYearStart",
"DaysLimit"
),
Value = c(
input$N_INITIAL_BEES,
input$N_INITIAL_MITES_HEALTHY,
input$N_INITIAL_MITES_INFECTED,
input$HoneyHarvesting,
input$VarroaTreatment,
input$DroneBroodRemoval
input$DroneBroodRemoval,
input$SimulationYearStart,
input$DaysLimit
),
Default.Value = NA
)

observeEvent(
input$SimulationYearStart,
ignoreInit = TRUE,
{
updateSliderInput(
inputId = "DaysLimit",
max = as.integer((Sys.Date() - 31) - as.Date(paste0(input$SimulationYearStart, "-01-01")))
)
}
)

simulation <- data.frame(
sim_days = input$SimulationDays,
start_day = "2016-01-01"
sim_days = input$DaysLimit,
start_day = input$SimulationYearStart
)

list(
Expand Down
6 changes: 3 additions & 3 deletions app/view/honeybee/honeybee_beekeeper.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ box::use(
)

#' @export
honeybee_beekeeper_ui <- function(id,
theme) {
honeybee_beekeeper_ui <- function(id, theme, i18n) {
ns <- NS(id)
tagList(
tags$div(
Expand All @@ -31,7 +30,8 @@ honeybee_beekeeper_ui <- function(id,
honeybee_map_ui(ns("beekeeper_map")),
honeybee_param_ui(
ns("beekeeper_param"),
theme
theme,
i18n
)
),
honeybee_lookup_ui(ns("beekeeper_lookup")),
Expand Down
6 changes: 3 additions & 3 deletions app/view/honeybee/honeybee_main.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ box::use(
app/view/honeybee/beekeeper_contributors[bee_contributors_ui],
)
#' @export
honeybee_ui <- function(id,
theme) {
honeybee_ui <- function(id, theme, i18n) {
ns <- NS(id)
# tagList(
navset_tab(
Expand All @@ -28,7 +27,8 @@ honeybee_ui <- function(id,
icon = icon("forumbee"),
honeybee_beekeeper_ui(
ns("honeybee_beekeeper"),
theme
theme,
i18n
)
),
# Beekeper Contributors ----
Expand Down
Loading