-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.R
86 lines (72 loc) · 2.32 KB
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
source("global.R")
ui <- dashboardPage(
dashboardHeader(disable = TRUE),
dashboardSidebar(
tags$h4(strong("Knowledge Repo")),
sidebarSearchForm(label = "Search Repos", "searchText", "searchButton"),
tags$h4("Repositories"),
uiOutput("repos"),
actionLink("remove", "Remove repo tabs", icon = icon("remove"))
),
dashboardBody(
skin = "black",
tags$script(
HTML( "var openTab = function(tabName){ $('a', $('.sidebar')).each(function() {if(this.getAttribute('data-value') == tabName) { this.click()};});}")),
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "https://fonts.googleapis.com/css?family=Muli|Work+Sans"),
tags$link(rel = "stylesheet", type = "text/css", href = "theme.css")
),
tabsetPanel(
id = "tabs",
tabPanel(
title = "README",
value = "intro",
uiOutput("intro"))),
getdeps())
)
server <- function(input, output, session) {
tab_list <- NULL
output$ui_line <- renderUI({
## using renderUI here because Knitr will not create a slider
tagList(
sliderInput("nr_points", "", min = 10, max = 100, value = 50),
renderPlot({
nr <- if (is.null(input$nr_points)) 2 else input$nr_points
plot(1:nr, rnorm(nr))
})
)
})
output$repos <- renderUI({
sidebarMenu(id = "repotabs",
lapply(names(files), function(i) {
menuItem(i,
tabName = i,
icon = icon('chevron-right'))
}))
})
output$res <- renderText({
paste("You've selected:", input$repotabs)
})
output$intro <- renderUI({
includeMarkdown("README.md")
})
observeEvent(input$repotabs, {
mdinput <- input$repotabs
mdfile <- file_list$file[file_list$title == mdinput]
tab_title <- file_list$title[file_list$title == mdinput]
#tab_title <- readLines(mdfile, n = 1)
if (!(tab_title %in% tab_list)) {
appendTab(inputId = "tabs",
tabPanel(tab_title,
renderUI(get_details(mdfile))))
tab_list <<- c(tab_list, tab_title)
}
updateTabsetPanel(session, "tabs", selected = tab_title)
})
observeEvent(input$remove, {
tab_list %>%
walk(~ removeTab("tabs", .x))
tab_list <<- NULL
})
}
shinyApp(ui = ui, server = server)