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

239 logger::log_shiny_input_change #590

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Imports:
htmltools (>= 0.5.4),
jsonlite,
lifecycle (>= 0.2.0),
logger (>= 0.2.0),
logger (>= 0.3.0),
methods,
plotly (>= 4.9.2.2),
R6 (>= 2.2.0),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Bug fixes
* Fix error while creating the filter choices when the data has a factor with a level containing an empty string ("").

### Enhancements
* Added `logger` functionality for logging changes in shiny inputs. `logger` was added to Imports.

# teal.slice 0.5.1

### Bug fixes
Expand Down
2 changes: 2 additions & 0 deletions R/FilterState.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ FilterState <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("FilterState$server initializing module for slice: { private$get_id() } ")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
private$server_summary("summary")
if (private$is_fixed()) {
private$server_inputs_fixed("inputs")
Expand Down Expand Up @@ -745,6 +746,7 @@ FilterState <- R6::R6Class( # nolint
# @return `NULL`, invisibly.
keep_na_srv = function(id) {
moduleServer(id, function(input, output, session) {
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
# 1. renderUI is used here as an observer which triggers only if output is visible
# and if the reactive changes - reactive triggers only if the output is visible.
# 2. We want to trigger change of the labels only if reactive count changes (not underlying data)
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateChoices.R
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ ChoicesFilterState <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("ChoicesFilterState$server_inputs initializing, id: { private$get_id() }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

# 1. renderUI is used here as an observer which triggers only if output is visible
# and if the reactive changes - reactive triggers only if the output is visible.
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateDate.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ DateFilterState <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("DateFilterState$server initializing, id: { private$get_id() }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

# this observer is needed in the situation when teal_slice$selected has been
# changed directly by the api - then it's needed to rerender UI element
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateDatettime.R
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ DatetimeFilterState <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("DatetimeFilterState$server initializing, id: { private$get_id() }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
# this observer is needed in the situation when teal_slice$selected has been
# changed directly by the api - then it's needed to rerender UI element
# to show relevant values
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateExpr.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ FilterStateExpr <- R6::R6Class( # nolint
moduleServer(
id = id,
function(input, output, session) {
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
private$server_summary("summary")

private$destroy_shiny <- function() {
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateLogical.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ LogicalFilterState <- R6::R6Class( # nolint
non_missing_values <- reactive(Filter(Negate(is.na), private$x_reactive()))
output$trigger_visible <- renderUI({
logger::log_trace("LogicalFilterState$server@1 updating count labels, id: { private$get_id() }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

countsnow <- if (!is.null(private$x_reactive())) {
unname(table(factor(non_missing_values(), levels = private$get_choices())))
Expand Down
1 change: 1 addition & 0 deletions R/FilterStateRange.R
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ RangeFilterState <- R6::R6Class( # nolint
# @return `NULL`.
keep_inf_srv = function(id) {
moduleServer(id, function(input, output, session) {
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
# 1. renderUI is used here as an observer which triggers only if output is visible
# and if the reactive changes - reactive triggers only if the output is visible.
# 2. We want to trigger change of the labels only if reactive count changes (not underlying data)
Expand Down
1 change: 1 addition & 0 deletions R/FilterStates.R
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ FilterStates <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("FilterStates$srv_add initializing, dataname: { private$dataname }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

# available choices to display
avail_column_choices <- reactive({
Expand Down
1 change: 1 addition & 0 deletions R/FilterStatesSE.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ SEFilterStates <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("SEFilterState$srv_add initializing, dataname: { private$dataname }")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

row_data <- SummarizedExperiment::rowData(data)
col_data <- SummarizedExperiment::colData(data)
Expand Down
4 changes: 4 additions & 0 deletions R/FilteredData.R
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ FilteredData <- R6::R6Class( # nolint
checkmate::assert_function(active_datanames)
moduleServer(id, function(input, output, session) {
logger::log_trace("FilteredData$srv_active initializing")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

private$srv_available_filters("available_filters")

Expand Down Expand Up @@ -717,6 +718,7 @@ FilteredData <- R6::R6Class( # nolint
checkmate::assert_class(active_datanames, "reactive")
moduleServer(id, function(input, output, session) {
logger::log_trace("FilteredData$srv_add initializing")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
observeEvent(input$minimise_filter_add_vars, {
shinyjs::toggle("filter_add_vars_contents")
toggle_icon(session$ns("minimise_filter_add_vars"), c("fa-angle-right", "fa-angle-down"))
Expand Down Expand Up @@ -808,6 +810,7 @@ FilteredData <- R6::R6Class( # nolint
id = id,
function(input, output, session) {
logger::log_trace("FilteredData$srv_filter_overview initializing")
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")

observeEvent(input$minimise_filter_overview, {
shinyjs::toggle("filters_overview_contents")
Expand Down Expand Up @@ -989,6 +992,7 @@ FilteredData <- R6::R6Class( # nolint
# the appropriate filter state id.
srv_available_filters = function(id) {
moduleServer(id, function(input, output, session) {
if (shiny::isRunning()) logger::log_shiny_input_changes(input, namespace = "teal.slice")
slices_available <- self$get_available_teal_slices()
slices_interactive <- reactive(
Filter(function(slice) isFALSE(slice$fixed), slices_available())
Expand Down
Loading