add homekeeper stack
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
server <- function(input, output, session, db) {
|
||||
|
||||
nav <- reactiveValues(
|
||||
screen = "apiaries",
|
||||
apiary_id = NULL,
|
||||
colony_id = NULL
|
||||
)
|
||||
|
||||
# ---- Module initialization ------------------------------------------------
|
||||
screen_apiaries_server("s_apiaries", db = db, nav = nav)
|
||||
screen_colonies_server("s_colonies", db = db, nav = nav)
|
||||
screen_colony_server("s_colony", db = db, nav = nav)
|
||||
screen_inspection_server("s_insp", db = db, nav = nav)
|
||||
screen_varroa_server("s_varroa", db = db, nav = nav)
|
||||
screen_harvest_server("s_harvest", db = db, nav = nav)
|
||||
screen_queen_server("s_queen", db = db, nav = nav)
|
||||
screen_checklists_server("s_chklst", db = db, nav = nav)
|
||||
screen_actions_server("s_actions", db = db, nav = nav)
|
||||
screen_lineage_server("s_lineage", db = db, nav = nav)
|
||||
screen_quick_insp_server("s_qinsp", db = db, nav = nav)
|
||||
screen_bulk_action_server("s_bulk", db = db, nav = nav)
|
||||
|
||||
# ---- Navigation header ---------------------------------------------------
|
||||
BACK <- c(
|
||||
colonies = "apiaries",
|
||||
colony = "colonies",
|
||||
inspection = "colony",
|
||||
varroa = "colony",
|
||||
harvest = "colony",
|
||||
queens = "colony",
|
||||
checklists = "colony",
|
||||
actions = "colony",
|
||||
lineage = "colonies",
|
||||
quick_inspection = "colonies",
|
||||
bulk_action = "colonies"
|
||||
)
|
||||
|
||||
output$nav_header <- renderUI({
|
||||
screen <- nav$screen
|
||||
if (screen == "apiaries") {
|
||||
return(shiny::div(
|
||||
class = "bk-header d-flex justify-content-between align-items-center",
|
||||
shiny::tags$h4("Beekeeper"),
|
||||
shiny::actionButton("btn_settings", shiny::icon("gear"),
|
||||
class = "btn btn-link bk-header-icon", title = "Einstellungen")
|
||||
))
|
||||
}
|
||||
title <- switch(screen,
|
||||
colonies = {
|
||||
ap <- db_apiaries_get(db, nav$apiary_id)
|
||||
if (nrow(ap) > 0) ap$name[1] else "Stand"
|
||||
},
|
||||
colony = {
|
||||
co <- db_colonies_get(db, nav$colony_id)
|
||||
if (nrow(co) > 0) co$name[1] else "Volk"
|
||||
},
|
||||
inspection = "Neue Durchsicht",
|
||||
quick_inspection = "Schnelldurchsicht",
|
||||
bulk_action = "Sammelmaßnahme",
|
||||
varroa = "Varroa",
|
||||
harvest = "Honigernte",
|
||||
queens = "Königin",
|
||||
checklists = "Checkliste",
|
||||
actions = "Maßnahmen",
|
||||
lineage = "Stammbaum",
|
||||
""
|
||||
)
|
||||
shiny::div(
|
||||
class = "bk-header d-flex align-items-center gap-2",
|
||||
shiny::actionButton("nav_back", shiny::icon("arrow-left"),
|
||||
class = "btn btn-link bk-header-icon"
|
||||
),
|
||||
shiny::tags$h5(class = "mb-0 flex-grow-1", title)
|
||||
)
|
||||
})
|
||||
|
||||
observeEvent(input$nav_back, {
|
||||
target <- BACK[nav$screen]
|
||||
if (!is.na(target)) nav$screen <- target
|
||||
})
|
||||
|
||||
observeEvent(input$keepalive_ping, {}, ignoreNULL = TRUE, ignoreInit = TRUE)
|
||||
|
||||
# ---- Content switcher ----------------------------------------------------
|
||||
output$screen_content <- renderUI({
|
||||
switch(nav$screen,
|
||||
apiaries = screen_apiaries_ui("s_apiaries"),
|
||||
colonies = screen_colonies_ui("s_colonies"),
|
||||
colony = screen_colony_ui("s_colony"),
|
||||
inspection = screen_inspection_ui("s_insp"),
|
||||
varroa = screen_varroa_ui("s_varroa"),
|
||||
harvest = screen_harvest_ui("s_harvest"),
|
||||
queens = screen_queen_ui("s_queen"),
|
||||
checklists = screen_checklists_ui("s_chklst"),
|
||||
actions = screen_actions_ui("s_actions"),
|
||||
lineage = screen_lineage_ui("s_lineage"),
|
||||
quick_inspection = screen_quick_insp_ui("s_qinsp"),
|
||||
bulk_action = screen_bulk_action_ui("s_bulk")
|
||||
)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user