ui.R 6.7 KB
Newer Older
Sylvain Falala's avatar
Sylvain Falala committed
1
################### PURPOSE OF THE APP ###################
2
3
# Interface for mapMCDA project
# April 2019, by Sylvain Falala, Unit CIRAD-INRA ASTRE
Sylvain Falala's avatar
Sylvain Falala committed
4

Sylvain Falala's avatar
Sylvain Falala committed
5
6
7

################### UI ###################

8
9
#### SIDEBAR ####

Sylvain Falala's avatar
Sylvain Falala committed
10
11
sidebar <- dashboardSidebar(
  
12
13
14
15
16
17
18
19
  # Radio buttons to select language
  radioButtons(inputId = "rbLanguage",
               label = NULL,
               choiceNames = langChoiceNames,
               choiceValues = langChoiceVal,
               selected = as.character(indLang),
               inline = FALSE),
  
Sylvain Falala's avatar
Sylvain Falala committed
20
  sidebarMenu(id = "tabs",
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
              
              # Menu for input files
              menuItem(uiOutput("fileMenuTextUI"), tabName = "fileTab"),
              
              # Menu for epidemiological units
              menuItem(uiOutput("unitMenuTextUI"), tabName = "unitTab"),
              
              # Menu for risk factors
              menuItem(uiOutput("riskMenuTextUI"), tabName = "riskTab"),
              
              # Menu for weight table
              menuItem(uiOutput("weightMenuTextUI"), tabName = "weightTab"),
              
              # Menu for results
              menuItem(uiOutput("resultMenuTextUI"), tabName = "resultTab")
              
Sylvain Falala's avatar
Sylvain Falala committed
37
38
39
  )
)

40
#### BODY ####
Sylvain Falala's avatar
Sylvain Falala committed
41
42
43

body <- dashboardBody(
  
44
45
  tabItems(
    
46
    # Files
47
48
    tabItem("fileTab", 
            
Sylvain Falala's avatar
Sylvain Falala committed
49
            fluidRow(
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
              
              box(title = uiOutput("fileBoxTextUI"), status = "primary", width = 5, solidHeader = TRUE,
                  footer = uiOutput("fileBoxHelpTextUI"),
                  
                  # Button from shinyFiles package
                  # To upload vector, raster and igraph files
                  shinyFilesButton(id = "file", 
                                   label = uiOutput("fileInputButtonLblTextUI"),
                                   title = "Please select a file",
                                   multiple = TRUE),
                  
                  # # Shiny basic fileInput
                  # # To upload vector, raster and igraph files
                  # fileInput(inputId = "fiLayer", 
                  #           label = uiOutput("fileInputTextUI"),
                  #           multiple = TRUE, 
                  #           accept = NULL, #acceptLayerType, 
                  #           width = NULL,
                  #           buttonLabel = uiOutput("fileInputButtonLblTextUI"),
                  #           placeholder = "No file"),
                  
                  # List of accepted files
                  tableOutput("accFileTable")
                  
74
75
              ),
              
76
77
78
79
80
81
82
              
              box(title = uiOutput("layerBoxTextUI"), status = "success", width = 7, solidHeader = TRUE,
                  footer = uiOutput("layerBoxHelpTextUI"),
                  
                  # List of layers. Name is editable
                  rHandsontableOutput("rhLayerTable")
                  
83
84
              )
              
Sylvain Falala's avatar
Sylvain Falala committed
85
            )
Sylvain Falala's avatar
Sylvain Falala committed
86
            
Sylvain Falala's avatar
Sylvain Falala committed
87
88
    ),
    
89
90
    # Epidemiological units
    tabItem("unitTab", 
Sylvain Falala's avatar
Sylvain Falala committed
91
            
92
93
94
            uiOutput("unitNameText"),
            
            box(title = uiOutput("unitMapTextUI"), status = "primary", width = 6, solidHeader = TRUE,
Sylvain Falala's avatar
Sylvain Falala committed
95
                
96
97
                # Display map
                plotOutput("unitMapDisplay")
Sylvain Falala's avatar
Sylvain Falala committed
98
                
99
100
101
102
            ),
            
            
            box(title = uiOutput("unitStatTextUI"), status = "success", width = 6, solidHeader = TRUE,
Sylvain Falala's avatar
Sylvain Falala committed
103
                
104
105
                # Display statistics
                textOutput("unitStatText"),
Sylvain Falala's avatar
Sylvain Falala committed
106
                
107
                plotOutput("unitStatDisplay")
Sylvain Falala's avatar
Sylvain Falala committed
108
                
109
110
111
112
113
114
115
116
117
118
119
120
121
            )
            
    ),
    
    # Risk factors
    tabItem("riskTab", 
            
            uiOutput("uiRiskLayerList"),
            
            box(title = uiOutput("riskRawMapTextUI"), status = "primary", width = 6, solidHeader = TRUE,
                
                # Original raw layer
                plotOutput("rawLayerDisplay")
Sylvain Falala's avatar
Sylvain Falala committed
122
123
124
                
            ),
            
125
126
            
            box(title = uiOutput("riskStandRasterTextUI"), status = "success", width = 6, solidHeader = TRUE,
127
                
128
129
                # Standardized raster
                plotOutput("standRasterDisplay")
Sylvain Falala's avatar
Sylvain Falala committed
130
                
131
132
133
134
            ),
            
            
            box(status = "info", width = 6, solidHeader = FALSE,
Sylvain Falala's avatar
Sylvain Falala committed
135
              
136
137
138
              uiOutput("riskHelpTextUI")
              
            ),
Sylvain Falala's avatar
Sylvain Falala committed
139
            
140
            actionButton(inputId = "abInvert", label = langDF["ABRiskRasterInvert", indLang])
Sylvain Falala's avatar
Sylvain Falala committed
141
            
142
143
144
145
146
147
148
149
150
151
    ),
    
    
    # Weight table
    tabItem("weightTab", 
            
            fluidRow(
              
              box(title = uiOutput("weightMatrixTextUI"), status = "primary", width = 12, solidHeader = TRUE,
                  footer = uiOutput("weightHelpTextUI"),
Sylvain Falala's avatar
Sylvain Falala committed
152
                  
153
154
155
156
157
158
159
160
161
162
                  # Editable table of weights
                  rHandsontableOutput("rhWeightTable")

              )
              
            ),
            
            fluidRow(
              
              box(title = uiOutput("weightBarTextUI"), status = "success", width = 12, solidHeader = TRUE,
163
                  
164
165
                  # Weights bar plot
                  plotOutput("weightBarDisplay")
Sylvain Falala's avatar
Sylvain Falala committed
166
167
                  
              )
168
169
170
171
172
173
174
175
176
              
            )
            
            
            
    ),
    
    # Results
    tabItem("resultTab",
Sylvain Falala's avatar
Sylvain Falala committed
177
            
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
            box(title = uiOutput("resultTextUI"), status = "primary", width = 6, solidHeader = TRUE,
                
                plotOutput("resultDisplay"),
                
                #Button to generate and download raster
                downloadButton(outputId = "exportResultRaster", 
                               label = uiOutput("resultExportTextUI"))
                
            ),
            
            box(title = uiOutput("resultPerUnitTextUI"), status = "success", width = 6, solidHeader = TRUE,
                
                selectInput(inputId = "siLevelRisk", 
                            label = uiOutput("levelRiskTextUI"),
                            choices = 1:12,
                            selected = 4),
                
                plotOutput("resultUnitDisplay"),
                
                #Button to generate and download raster
                downloadButton(outputId = "exportResultVector", 
                               label = uiOutput("resultPUExportTextUI")),
                
                #Button to generate and download csv table
                downloadButton(outputId = "exportResultCSV", 
                               label = "Export table")
                
Sylvain Falala's avatar
Sylvain Falala committed
205
            )
206
207
208
            
            
    )
209
210
211
212
    
  )
  
  
Sylvain Falala's avatar
Sylvain Falala committed
213
214
215
  
)

216
#### PAGE ####
Sylvain Falala's avatar
Sylvain Falala committed
217
218
219
220
221
222
223

dashboardPage(
  dashboardHeader(title = appTitle),
  sidebar,
  body
)