-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
141 lines (126 loc) · 4.62 KB
/
Copy pathapp.R
File metadata and controls
141 lines (126 loc) · 4.62 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
#-Packages----------------------------------------------------------------------
library(shiny)
library(bslib)
library(shinyjs)
#-Source UI and server functions for each tab-----------------------------------
source("global/source-ui-server-code.R")
source("global/global.R")
source("global/helpers.R")
source("global/figure-download.R")
# Disable scientific notation globally
options(scipen = 999)
#-Define UI---------------------------------------------------------------------
ui <- page_fluid(
theme = bs_theme(version = 5, bootswatch = "minty"),
useShinyjs(),
# Add custom CSS for fixed full-height sidebar
tags$head(
tags$style(HTML("
.sidebar-container {
height: 100vh; /* Full height */
position: fixed; /* Fix it to the side */
top: 0;
left: 0;
width: 250px; /* Sidebar width */
overflow-y: auto; /* Scrollable if content overflows */
background-color: #f8f9fa; /* Light background color */
border-right: 1px solid #ddd; /* Optional border */
padding: 15px;
}
.main-content {
margin-left: 250px; /* Adjust margin to match sidebar width */
padding: 20px;
}
.logo-container {
position: absolute;
bottom: 10px;
width: 100%;
text-align: center;
}
.logo-container img {
max-height: 50px;
}
/* Fix dropdown menus getting cut off */
.dropdown-menu {
max-height: 400px;
overflow-y: auto;
}
/* Ensure dropdowns aren't constrained by parent containers */
.dropdown-menu.show {
position: absolute !important;
transform: translate3d(0px, 38px, 0px) !important;
top: 0px !important;
left: 0px !important;
will-change: transform !important;
}
"))
),
#-Sidebar Navigation------------------------------------
div(
class = "sidebar-container",
h3("Malaria Budget Comparison Tool"),
tags$a(
href = 'https://www.path.org/who-we-are/programs/malaria/malaria-control-and-elimination-partnership-in-africa-macepa/',
icon("house"),
title = "Go to PATH Malaria Page"
),
br(),
actionLink("info", label = "", icon = icon("info"), title = "Info"),
br(),
tags$a(
href = "mailto:hthompson@path.org",
icon("comments"),
title = "Message Team"
),
br(), br(),
navset_pill_list(
id = "sidebar_menu",
widths = c(12, 1),
nav_panel(title = tagList(icon("house"), "Overview"), value = "tab0"),
nav_panel(title = tagList(icon("pen"), "User Inputs"), value = "tab1a"),
nav_panel(title = tagList(icon("check"), "Check Scenario"), value = "tab2"),
nav_panel(title = tagList(icon("chart-bar"), "Plan Visualization"), value = "tab3"),
nav_panel(title = tagList(icon("table-columns"), "Plan Comparisons"), value = "tab4"),
nav_panel(title = tagList(icon("file-pdf"), "Report Generation"), value = "tab5"),
nav_panel(title = tagList(icon("book"), "Methods"), value = "tab6")
),
# Add logo at the bottom
div(style = "position: absolute; bottom: 10px; width: 100%; text-align: center;",
img(src = "NMEP_logo.png", height = "60px", style = "margin-bottom: 10px;"),
img(src = "PATH_Logo_Color.png", height = "60px")
)
),
#-Main Content---------------------------------
div(
class = "main-content",
uiOutput("page_content")
)
)
#-Define Server-----------------------------------------------------------------
server <- function(input, output, session) {
#-Dynamically render content for each tab------------
output$page_content <- renderUI({
switch(input$sidebar_menu,
"tab0" = tab0UI("tab0"),
"tab1a" = tab1aUI("tab1a"),
# "tab1b" = tab1bUI("tab1b"),
"tab2" = tab2UI("tab2"),
"tab3" = tab3UI("tab3"),
"tab4" = tab4UI("tab4"),
"tab5" = tab5UI("tab5"),
"tab6" = tab6UI("tab6")
)
})
#=Call modules for each tab------------------------
callModule(tab0Server, id = "tab0")
callModule(tab1aServer, id = "tab1a", template_file_path, SCENARIO_COLS, COST_COLS, TEMPLATE_ADMIN_DATA)
# tab1aServer("tab1a")
# callModule(tab1bServer, id = "tab1b")
callModule(tab2Server, id = "tab2", static_mix_maps)
callModule(tab3Server, "tab3", lga_outline, state_outline, country_outline, intervention_mix_maps, static_mix_maps)
callModule(tab4Server, id = "tab4", lga_outline, state_outline, country_outline, intervention_mix_maps)
callModule(tab5Server, id = "tab5")
callModule(tab6Server, id = "tab6")
}
#-Run the App------------------------------------------
shinyApp(ui, server)