treeNavigator-module | R Documentation |
A Shiny module allowing to render a files and folders navigator in the server side file system.
treeNavigatorUI(id, width = "100%", height = "auto")
treeNavigatorServer(
id,
rootFolder,
search = TRUE,
wholerow = FALSE,
contextMenu = FALSE,
theme = "proton",
pattern = NULL,
all.files = TRUE,
...
)
id |
an ID string; the one passed to |
width , height |
arguments passed to |
rootFolder |
path to the root folder in which you want to navigate |
search , wholerow , contextMenu |
arguments passed to |
theme |
the jsTree theme, |
pattern , all.files |
arguments passed to |
... |
values passed to |
The treeNavigatorUI
function returns a shiny.tag.list
object to be included in a Shiny UI definition, and the function
treeNavigatorServer
, to be included in a Shiny server definition,
returns a reactive value containing the selected file paths of the tree
navigator.
library(shiny)
library(jsTreeR)
css <- HTML("
.flexcol {
display: flex;
flex-direction: column;
width: 100%;
margin: 0;
}
.stretch {
flex-grow: 1;
height: 1px;
}
.bottomright {
position: fixed;
bottom: 0;
right: 15px;
min-width: calc(50% - 15px);
}
")
ui <- fixedPage(
tags$head(
tags$style(css)
),
class = "flexcol",
br(),
fixedRow(
column(
width = 6,
treeNavigatorUI("explorer")
),
column(
width = 6,
tags$div(class = "stretch"),
tags$fieldset(
class = "bottomright",
tags$legend(
tags$h1("Selections:", style = "float: left;"),
downloadButton(
"dwnld",
class = "btn-primary btn-lg",
style = "float: right;",
icon = icon("save")
)
),
verbatimTextOutput("selections")
)
)
)
)
server <- function(input, output, session){
Paths <- treeNavigatorServer(
"explorer", rootFolder = getwd(),
search = list( # (search in the visited folders only)
show_only_matches = TRUE,
case_sensitive = TRUE,
search_leaves_only = TRUE
)
)
output[["selections"]] <- renderPrint({
cat(Paths(), sep = "\n")
})
output[["dwnld"]] <- downloadHandler(
filename = "myArchive.zip",
content = function(file){
zip(file, files = Paths())
}
)
}
if(interactive()) shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.