-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
178 lines (160 loc) · 6.77 KB
/
app.R
File metadata and controls
178 lines (160 loc) · 6.77 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#######################################################
"app.R is the user specific code that runs to create
each session. User Roles are set and specific modules
are called"
#######################################################
source("global.R")
ui <- fluidPage(theme = "css/custom-bootstrap3.css",
e_theme_register('{"color":["#440154FF,481B6DFF" ,"#46337EFF" ,"#3F4889FF",
"#365C8DFF", "#2E6E8EFF", "#277F8EFF","#21908CFF" ,"#1FA187FF", "#2DB27DFF",
"#4AC16DFF", "#71CF57FF", "#9FDA3AFF","#CFE11CFF",
"#FDE725FF"]}', name = "myTheme"),
tags$head(#navbarPage("djfa",
# #theme = "css/pulse.css",
# header = tags$img(src = "https://d1fd34dzzl09j.cloudfront.net/Images/CFACOM/Stories%20Images/2018/11/door%20dash/2web.jpg?h=960&w=1440&la=en"),
# navbarMenu("More",
# tabPanel("Summary"),
# "----",
# "Section header",
# tabPanel("Table")
# ),
# Custom CSS and JavaScript
tags$script(src = "js/custom.js"),
#tags$link(rel = "stylesheet", type = "text/css", href = "css/custom-bootstrap.css"),
tags$link(rel = "stylesheet", type = "text/css", href = "css/customyeti.css"),
tags$link(rel="stylesheet",type = "text/css",
href="highlight/styles/atom-one-dark.css"),
tags$script(src="highlight/highlight.pack.js"),
tags$script("hljs.initHighlightingOnLoad();")
),
#Shiny.setInputValue(id, value);
#https://shiny.rstudio.com/articles/communicating-with-js.html
# The Possible Navigation Menus To Exist
use_waiter(),
tags$body(
custNavBar(custBrand(label = "ShinyMeNot",module_name = 'landing'),
uiOutput("home"),
uiOutput("landing"),
uiOutput("reports"),
uiOutput("case_studies"),
uiOutput('admin'),
tags$span(logoutButton(id="logout","Logout",style = "background-color:#9fd89f"))
#custNav(id = "user_info")
),
shinyjs::useShinyjs(debug = FALSE),
# This determines what page is being used
hidden(selectInput("pageID", label = "",choices = c(), selected = "")),
# For Any Modules that simply display a markdown file.
hidden(selectInput("moduleFile", label = "",choices = c(), selected = NULL)),
# Main Output That Is Then Switched Between
# Maybe something to change the style of this for some modules
withSpinner(div(id = "mainOutput", class = "shiny-html-output",
style = 'margin-top:60px;background-color:#ccc;'),type = 8,color = "darkblue"
),
tags$div(
HTML('<footer class="footer dark mt-auto py-3">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
</footer>')
)
),
# Loading Page
#waiter_show_on_load(html = spin_fading_circles())
)
#ui <- secure_app(ui,enable_admin = TRUE)
# Define server logic required to draw a histogram
server <- function(input, output,session) {
session$userData[['id']] <- stringr::str_to_lower(Sys.getenv("USER"))
session$userData[['con']] <- AppConfig$make_con(RSQLite::SQLite(),cfg$sql_lite_con, NULL, NULL)
refresh_con <- function(con=NULL){
if (is.null(con)){
con <- AppConfig$make_con(RSQLite::SQLite(),cfg$sql_lite_con, NULL, NULL)
}
else if (!dbIsValid(con)){
con <- AppConfig$make_con(RSQLite::SQLite(),cfg$sql_lite_con, NULL, NULL)
}
return(con)
}
con <- refresh_con()
AppUser <- User$new(name = str_to_lower(Sys.getenv('USER')))
AppUser$set_role(con) # Sets the role of the AppUserObject
# Home Page
output$home <- renderUI({
#<span class="fa fa-home"></span>
custNav(id = "home",module_name = 'home')
})
rt_home <- callModule(home,id="home")
waiter_hide()
user_roles <- TRUE
admin_tab <- TRUE
report_tab <- TRUE
case_tab <- TRUE
home_tab <- TRUE
landing_tab <- TRUE
# Module Access - Only shows if user has permission
if (report_tab){
output$reports <- renderUI({
customNavDown(id = "navDropdown3","Reports",
moduleDropdownLink(label = "Echarts",moduleName = "reports_echarts"))
})
rt_echarts <- callModule(reports_echarts,id = "reports_echarts")
}
if(case_tab){
output$case_studies <- renderUI({
custNav(id = "navDropdown1",label = "Case Studies",module_name = "reports_caseStudies")
})
rt_caseStudies <- callModule(reports_caseStudies,id = "reports_caseStudies")
}
if(home_tab){
output$home <- renderUI({
custNav(id = "navDropdown0",label = "About",module_name = "home")
})
}
##9fd89f
if (admin_tab) {
output$admin <- renderUI({
customNavDown(id = "navDropdownAdmin","Admin",
moduleDropdownLink("Data Sources","admin_dataPreview"),
moduleDropdownLink("User Info","admin_userInfo"))
})
rt_dataPreview <- callModule(admin_dataPreview, id = "admin_dataPreview")
rt_userInfro <- callModule(admin_userInfo,id = "admin_userInfo")
}
page <- reactive({ input$pageID })
parm1 <- reactive({ input$app_parm1 })
# Watch for parms to be changed and set in user data
observe({
session$userData$parm1 <- parm1()
})
# Shiny Book Marking
# Use Shiny To Book Mark the page
output$mainOutput <- renderUI({
if (page() != '') {
Sys.sleep(.25)
ui <- do.call(paste0(page(),"UI"), list(page()))
#Sys.sleep(.25)
} else {
runjs("setPage('home');")
#Sys.sleep(.25)
#do.call(paste0("home","UI"), list("home"))
}
})
onStop(function() {
cat("Application stopped\n")
})
onSessionEnded(function() {
cat("Session stopped\n")
})
}
# Conditional logic to deploy to shinyapps.io
# remote url needs to be '' when local.
if (active_config == "shinyapps"){
cat(active_config)
auth0::shinyAppAuth0(ui = ui, server = server)
}else{
cat(active_config)
options(shiny.port = 8080)
auth0::shinyAppAuth0(ui = ui, server = server)
#shinyApp(ui = ui, server = server)
}