Browse Source

Formatting

master
Maxime Wack 3 years ago
parent
commit
92bf28b5e7
2 changed files with 11 additions and 13 deletions
  1. +4
    -2
      helper_functions.R
  2. +7
    -11
      server.R

+ 4
- 2
helper_functions.R View File

@@ -195,7 +195,9 @@ get_line <- function(df, node_path)
# request children with a fullname that contains the path of the current node and with a level 1 above
request_children <- function(metadata, node_path, node_level)
{
metadata %>% filter(C_HLEVEL == node_level + 1, str_detect(C_FULLNAME2, fixed(node_path)))
metadata %>%
filter(C_HLEVEL == node_level + 1,
str_detect(C_FULLNAME2, fixed(node_path)))
}

search_in_df <- function(metadata, search_term, search_on="C_NAME", use_regex = F)
@@ -203,7 +205,7 @@ search_in_df <- function(metadata, search_term, search_on="C_NAME", use_regex =
if (use_regex)
{
metadata %>% filter(str_detect(!!as.symbol(search_on), regex(search_term, ignore_case=T)))
}else{
} else {
metadata %>% filter(str_detect(!!as.symbol(search_on), fixed(search_term, ignore_case=T)))
}
}

+ 7
- 11
server.R View File

@@ -15,11 +15,11 @@ read_csv("metadata.csv") %>%
C_HLEVEL = if_else(C_VISUALATTRIBUTES == "RA", str_count(C_FULLNAME, "\\\\") - 2, C_HLEVEL), # C_HLEVEL of modifiers are all 1, changing it to the correct number (either 2 or 3)
C_FULLNAME2 = str_replace_all(C_FULLNAME, regex("\\\\( ){1,3}"), "\\\\"), # remove leading whitespace on nodes in the full path
C_FULLNAME2 = str_replace_all(C_FULLNAME2, regex("( ){1,11}\\\\"), "\\\\"), # remove trailing whitespace on nodes in the full path
sticon = recode(C_VISUALATTRIBUTES,
sticon = recode(C_VISUALATTRIBUTES, # to delete ?
"FA"="glyphicon glyphicon-folder-close",
"LA"="glyphicon glyphicon-file",
"RA"="glyphicon glyphicon-file blue"),
type = C_VISUALATTRIBUTES) -> metadata
type = C_VISUALATTRIBUTES) -> metadata # to delete too ?

# Generate base trees
metadata %>%
@@ -38,17 +38,16 @@ server <- shinyServer(function(input, output, session)
{
v <- reactiveValues()
v$df <- explore_tree_df
v$df2 <- search_tree_df
v$requests <- c() # store previous requests for children to prevent doing them twice

v$selected <- NULL

v$df2 <- search_tree_df

output$explore_tree <- renderTree(explore_tree)

# Controls conditional panel
output$selected <- reactive(length(v$selected) > 0)

# When a node is selected, display information
observeEvent(input$explore_tree,
{
v$selected <- get_selected(input$explore_tree)
@@ -89,12 +88,9 @@ server <- shinyServer(function(input, output, session)
#Append children
observeEvent(v$selected,
{
#print(v$selected)
if (all(
## input$fetch_children, # controls if children should be appended on selection
length(v$selected) > 0, # a node was selected
nrow(v$node_line) == 1, # node was found in the dataframe
v$is_leaf == F, # node is not a leaf
if (all(length(v$selected) > 0, # a node was selected
nrow(v$node_line) == 1, # node was found in the dataframe
v$is_leaf == F, # node is not a leaf
!(v$node_path %in% v$requests))) # request was not already done
{
v$requests <- c(v$requests, v$node_path) # store the request


Loading…
Cancel
Save