OliverKeyes has submitted this change and it was merged. Change subject: Enables sharing dash settings via URL ......................................................................
Enables sharing dash settings via URL This adds a requested feature of allowing users to link to the dashboard and including settings (selections, choices) in the URL. This uses Andrzej OleÅ›'s shinyURL package to store params in the URL and then restore the dashboard parameters from URL. Change-Id: Ic5a768ffa62a01a2ded7e66667ccdc83ec12b126 --- M server.R M ui.R M utils.R 3 files changed, 15 insertions(+), 6 deletions(-) Approvals: OliverKeyes: Verified; Looks good to me, approved diff --git a/server.R b/server.R index 14edc05..f1e87db 100644 --- a/server.R +++ b/server.R @@ -3,7 +3,7 @@ existing_date <- Sys.Date() - 1 # Actual server code. -shinyServer(function(input, output) { +shinyServer(function(input, output, session) { if(Sys.Date() != existing_date){ read_actions() @@ -11,6 +11,8 @@ suppressWarnings(read_tiles()) existing_date <<- Sys.Date() } + + shinyURL.server(session) # Wrap time_frame_range to provide global settings time_frame_range <- function(input_local_timeframe, input_local_daterange) { @@ -47,7 +49,7 @@ output$tiles_style_series <- renderDygraph({ polloi::data_select(input$tile_style_automata_check, new_tiles_automata, new_tiles_no_automata) %>% ddply(.(date, style), summarize, `total tiles` = sum(total)) %>% - tidyr::spread(style, `total tiles`) %>% + tidyr::spread(style, `total tiles`, fill = 0) %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_tiles_style_series)) %>% polloi::subset_by_date_range(time_frame_range(input$tiles_style_series_timeframe, input$tiles_style_series_timeframe_daterange)) %>% polloi::make_dygraph("Date", "Tiles", "Total tiles by style", legend_name = "Style") %>% @@ -60,7 +62,7 @@ output$tiles_users_series <- renderDygraph({ polloi::data_select(input$tile_users_automata_check, new_tiles_automata, new_tiles_no_automata) %>% ddply(.(date, style), summarize, `total users` = sum(users)) %>% - tidyr::spread(style, `total users`) %>% + tidyr::spread(style, `total users`, fill = 0) %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_tiles_users_series)) %>% polloi::subset_by_date_range(time_frame_range(input$tiles_users_series_timeframe, input$tiles_users_series_timeframe_daterange)) %>% polloi::make_dygraph("Date", "Users", "Total users by style") %>% @@ -80,7 +82,7 @@ polloi::data_select(input$tile_zoom_automata_check, new_tiles_automata, new_tiles_no_automata) %>% subset(zoom %in% as.numeric(input$zoom_level_selector)) %>% ddply(.(date, zoom), summarize, `total tiles` = sum(total)) %>% - tidyr::spread(zoom, `total tiles`) %>% + tidyr::spread(zoom, `total tiles`, fill = 0) %>% polloi::smoother(smooth_level = polloi::smooth_switch(input$smoothing_global, input$smoothing_tiles_zoom_series)) %>% polloi::subset_by_date_range(time_frame_range(input$tiles_zoom_series_timeframe, input$tiles_zoom_series_timeframe_daterange)) %>% polloi::make_dygraph("Date", "Tiles", "Total tiles by zoom level") %>% diff --git a/ui.R b/ui.R index 1b19d10..adec0f2 100644 --- a/ui.R +++ b/ui.R @@ -1,6 +1,7 @@ library(shiny) library(shinydashboard) library(dygraphs) +library(shinyURL) header <- dashboardHeader(title = "Wikimedia Maps", dropdownMenuOutput("message_menu"), disable = FALSE) @@ -30,7 +31,11 @@ conditionalPanel("input.timeframe_global == 'custom'", dateRangeInput("daterange_global", label = "Custom Date Range", start = Sys.Date()-11, end = Sys.Date()-1, min = "2015-04-14")), - icon = icon("cog", lib = "glyphicon")) + icon = icon("cog", lib = "glyphicon")), + menuItem(text = "Sharing Options", + shinyURL.ui(tinyURL = FALSE), + p("Dashboard settings stored in URL.", style = "padding-bottom: 10px;"), + icon = icon("share-alt", lib = "glyphicon")) ) ) diff --git a/utils.R b/utils.R index 633806e..028d186 100644 --- a/utils.R +++ b/utils.R @@ -1,10 +1,12 @@ # Dependencies library(plyr) -library(dplyr) library(magrittr) +library(dplyr) +library(tidyr) library(reshape2) library(polloi) library(data.table) +library(shinyURL) # devtools::install_github("aoles/shinyURL") # Read in action data and write it into the global scope with sufficient formatting to be trivially # used in dygraphs. -- To view, visit https://gerrit.wikimedia.org/r/268027 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic5a768ffa62a01a2ded7e66667ccdc83ec12b126 Gerrit-PatchSet: 2 Gerrit-Project: wikimedia/discovery/wetzel Gerrit-Branch: master Gerrit-Owner: Bearloga <mpo...@wikimedia.org> Gerrit-Reviewer: Bearloga <mpo...@wikimedia.org> Gerrit-Reviewer: OliverKeyes <oke...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits