-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #928 Added possibility to upload a snapshot file to the snapshot manager module. The snapshot manager control bar (top row in table) receives a third button. Clicking it opens a modal dialog that allows for selecting a `.json` file to upload and naming the snapshot. The new snapshot is added to the snapshot list and the filter manager dialog is reopened so that the user may immediately apply the new snapshot. To ensure that the uploaded snapshot matches the app, `teal_slices` class receives the `app_id` attribute, which can be set with the `app_id` argument to `teal::teal_slices`. The attribute will be set by `init` to stamp a `teal_slices`. The attribute will be stored along with other attributes. Upon uploading a snapshot, the app id of the upload will be compared to that of the app. `slices_restore` had to be re-defined in the `teal` namespace because it calls `teal_slices` and that must be the one from `teal`. #### TESTING ``` options(teal.log_level = "WARN", teal.show_js_log = FALSE) library(teal.modules.general) pkgload::load_all("../teal.slice") pkgload::load_all("../teal") rm(list = ls()) funny_module <- function (label = "Filter states", datanames = "all") { checkmate::assert_string(label) module( label = label, datanames = datanames, ui = function(id, ...) { ns <- NS(id) div( h2("The following filter calls are generated:"), verbatimTextOutput(ns("filter_states")), verbatimTextOutput(ns("filter_calls")), actionButton(ns("reset"), "reset_to_default") ) }, server = function(input, output, session, data, filter_panel_api) { checkmate::assert_class(data, "tdata") observeEvent(input$reset, set_filter_state(filter_panel_api, default_filters)) output$filter_states <- renderPrint({ logger::log_trace("rendering text1") filter_panel_api %>% get_filter_state() }) output$filter_calls <- renderText({ logger::log_trace("rendering text2") attr(data, "code")() }) } ) } dead_module <- function(label = "empty module", datanames = NULL) { module(label = label, datanames = datanames, ui = function(id) { ns <- NS(id) tagList( h4("this is just text") ) }, server = function(id, filter_panel_api, reporter) { message("hello") } ) } default_filters <- teal::teal_slices( teal_slice("iris", "Sepal.Length"), teal_slice("iris", "Sepal.Width"), teal_slice("iris", "Species", fixed = TRUE), teal_slice("mtcars", "mpg"), exclude_varnames = list( iris = c("Petal.Length"), mtcars = c("qsec", "drat") ), module_specific = TRUE, mapping = list( table = "iris Species", funny1 = c("iris Sepal.Length", "iris Sepal.Width", "iris Species"), funny2 = "iris Species", global_filters = "mtcars mpg" ) ) app <- init( data = teal_data( dataset("iris", iris), dataset("mtcars", mtcars) ), modules = modules( tm_data_table( "table", variables_selected = list(), dt_args = list() ), modules( label = "tab1", funny_module("funny1", datanames = NULL), funny_module("funny2", datanames = "iris"), dead_module("empty", datanames = NULL) ) ), filter = default_filters ) shinyApp(app$ui, app$server, options = list(launch.browser = TRUE)) ``` --------- Signed-off-by: Aleksander Chlebowski <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
031fc30
commit 8df71ba
Showing
9 changed files
with
203 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
linters: linters_with_defaults( | ||
line_length_linter = line_length_linter(120), | ||
cyclocomp_linter = NULL, | ||
object_usage_linter = NULL | ||
object_usage_linter = NULL, | ||
indentation_linter = NULL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.