|
|
In the IDE, modules are used to encapsulate sets of related functionalities and correspond to workspaces accessible through entries in the menu on the left-hand side bar.
|
|
|
|
|
|
### Module structure
|
|
|
|
|
|
Each module is composed of a ui and a server function. The ui function takes as input the session id while the server function needs additional inputs. Below are the templates for both functions:
|
|
|
|
|
|
```{r}
|
|
|
ui_<module_name> <- function(id) {
|
|
|
ns <- NS(id)
|
|
|
|
|
|
}
|
|
|
|
|
|
<module_name>_server <- function(input, output, session [, rv, session_parent]) {
|
|
|
|
|
|
req(rv$data)
|
|
|
ns <- session$ns
|
|
|
|
|
|
[return(rv)]
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
Global reactive values are stored in the rv object which is defined in datafile.R. If a module needs a new variable in rv, this variable must be added to the rv definition in datafile.R (starting at line 125).
|
|
|
The session_parent variable is currently only needed when automatically switching to another workspace.
|
|
|
|
|
|
### Adding a module to the app
|
|
|
|
|
|
To add a new module to the sidebar menu, add a new entry to the sideBarMenu() function in the server function in image\_data\_explorer.R (line 141). Below is a template for a new menuItem entry:
|
|
|
```
|
|
|
menuItem(HTML(" <Name to display>"), tabName = "<Workspace name>", icon = icon("<icon name>")),
|
|
|
```
|
|
|
|
|
|
The corresponding workspace is created as a new tabItem() entry in the dashboardBody() function in the ui() function in image\_data\_explorer.R. Below is a template for a new tabItem entry:
|
|
|
```
|
|
|
tabItem( tabName = "<Workspace name>",
|
|
|
fluidRow(
|
|
|
ui_<module>("<module name>_module")
|
|
|
)),
|
|
|
```
|
|
|
|
|
|
To trigger the switch to the workspace when it is selected in the sidebar menu, add an observeEvent entry to the server function(). Below is a template for a new observeEvent entry:
|
|
|
```
|
|
|
observeEvent(input$tabs_menu,{
|
|
|
if(input$tabs_menu=="<Workspace name"){
|
|
|
callModule(<module>_server, "<module name>_module", global_data, session)
|
|
|
}
|
|
|
}, ignoreNULL = TRUE, ignoreInit = TRUE)
|
|
|
``` |