-
Notifications
You must be signed in to change notification settings - Fork 16
/
ui.R
364 lines (351 loc) · 9.53 KB
/
ui.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
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
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# Components --------------------------------------------------------------
components <- list(toolbar = list())
# Components - Clickpad ----
components$toolbar$clickpad_action <- tags$div(
radioSwitchButtons(
"clickpad_click_action",
HTML(paste(icon("mouse-pointer"), "Click a node to...")),
choices = c("Select" = "parent", "Draw/Remove Edge" = "child"),
selected = "parent",
selected_background = "#D3751C"
)
)
# Components - Node List ----
components$toolbar$node_list_actions <- tags$div(
class = "btn-toolbar",
role = "toolbar",
tags$form(
class = "form-inline",
tags$div(
class = "form-group",
tags$div(
class = "btn-group",
role = "group",
actionButton(
input = "node_list_node_add",
label = "Add New Node",
icon = icon("plus"),
alt = "Add New Node to Workspace",
`data-toggle` = "tooltip",
`data-placement` = "bottom",
title = "Add New Node to Workspace"
),
shinyjs::hidden(
actionButton(
"node_list_node_delete", "Delete Node", icon("trash"),
alt = "Delete Node",
`data-toggle` = "tooltip",
`data-placement` = "bottom",
title = "Delete Node")
)
)
)
)
)
components$toolbar$node_list_name <- tags$div(
style = "padding-top: 15px; min-height: 90px;",
shinyjs::hidden(
tags$div(
id = "node_list_node_name_container",
class = "col-xs-12",
textInput("node_list_node_name", "Node Name", width = "100%")
)
)
)
# Components - About ----
components$about <- list()
components$about$gerkelab <- tagList(
h3("Development Team"),
tags$ul(
tags$li("Jordan Creed"),
tags$li(tags$a(href = "https://www.garrickadebuie.com", "Garrick Aden-Buie")),
tags$li(tags$a(href = "https://travisgerke.com", "Travis Gerke"))
),
p(
"For more information about our lab and other projects please check",
"out our website at",
tags$a(href = "http://gerkelab.com", "gerkelab.com")
),
p(
"All code and detailed instructions for usage is available on GitHub at",
tags$a(
href = "https://github.com/GerkeLab/shinyDAG",
"GerkeLab/shinyDag"
)
),
p(
"If you have any questions or comments, we would love to hear them.",
"You can email us at",
tags$a(href = "mailto:[email protected]", "[email protected]"),
"or",
HTML(paste0(
tags$a(href = "mailto:[email protected]", "[email protected]"),
"."
)),
"Or feel free to",
tags$a(
href = "https://github.com/GerkeLab/shinyDAG/issues",
"open an issue"
),
"in our GitHub repository."
)
)
# components$about$usage <- tagList(
# tags$h3("Using shinyDAG"),
# tags$p(
# "For more details on using shinyDAG please check out our",
# tags$a(
# href = "https://github.com/GerkeLab/shinyDAG/blob/master/README.md",
# "README."
# ))
# )
# Components - Build ----
components$build <- box(
title = "Build",
id = "build-box",
width = 12,
fluidRow(
id = "shinydag-toolbar",
tags$div(
class = "col-xs-12 col-md-5 shinydag-toolbar-actions",
tags$div(
class = "col-xs-12 col-sm-6 col-md-12",
id = "shinydag-toolbar-node-list-action",
components$toolbar$node_list_action
),
tags$div(
class = "col-xs-12 col-sm-6 col-md-12",
style = "padding: 10px",
id = "shinydag-toolbar-clickpad-action",
components$toolbar$clickpad_action
)
),
tags$div(
class = "col-xs-12 col-md-7",
components$toolbar$node_list_name
)
),
fluidRow(
column(
width = 12,
tags$div(
class = "pull-left",
uiOutput("node_list_helptext")
),
shinyThings::undoHistoryUI(
id = "undo_rv",
class = "pull-right",
back_text = "Undo",
fwd_text = "Redo"
)
)
),
fluidRow(
column(
width = 12,
clickpad_UI("clickpad", height = "600px", width = "100%")
)
),
if (getOption("shinydag.debug", FALSE)) fluidRow(
column(width = 12, shinyThings::undoHistoryUI_debug("undo_rv"))
),
fluidRow(
tags$div(
class = class_3_col,
selectInput("exposureNode", "Exposure", choices = c("None" = ""), width = "100%")
),
tags$div(
class = class_3_col,
selectInput("outcomeNode", "Outcome", choices = c("None" = ""), width = "100%")
),
tags$div(
class = class_3_col,
selectizeInput("adjustNode", "Adjust for...", choices = c("None" = ""), width = "100%", multiple = TRUE)
)
),
fluidRow(
tags$div(
class = "col-sm-12 col-md-9 col-lg-6",
uiOutput("dagExposureOutcomeDiagnositcs")
)
)
)
# Components - LaTeX ----
components$latex <- tagList(
tags$p(
"Use this tab to manually edit the TikZ generated by shinyDAG."
),
helpText(
"Note that changes made to the TikZ code below will not affect",
"the DAG settings in the app. Changes made to the DAG elsewhere",
"in shinyDAG will overwrite any changes made to the manually",
"edited TikZ code below."
),
uiOutput("texEdit")
)
# Components - Tweak ----
components$tweak <- tabBox(
title = "Edit DAG",
id = "tab_control",
# ---- Tab: Edit Aesthetics
tabPanel(
"Edges",
value = "edit_edge_aesthetics",
selectInput(
"arrowShape",
"Select arrow head",
choices = c(
"stealth",
"stealth'",
"diamond",
"triangle 90",
"hooks",
"triangle 45",
"triangle 60",
"hooks reversed",
"*"
),
selected = "stealth"
),
uiOutput("edge_aes_ui")
),
tabPanel(
"Nodes",
value = "edit_node_aesthetics",
uiOutput("node_aes_ui")
),
tabPanel(
"Page",
value = "edit_page_aesthetics",
tags$h3("Margins"),
fluidRow(
col_4(
numericInput("tex_opts_margin_top", "Top", value = 0L, min = 0L, max = 500L, step = 1L)
),
col_4(
numericInput("tex_opts_margin_right", "Right", value = 0L, min = 0L, max = 500L, step = 1L)
),
col_4(
numericInput("tex_opts_margin_bottom", "Bottom", value = 0L, min = 0L, max = 500L, step = 1L)
),
col_4(
numericInput("tex_opts_margin_left", "Left", value = 0L, min = 0L, max = 500L, step = 1L)
)
)
)
)
# UI - shinyDAG -----------------------------------------------------------
function(request) {
dashboardPage(
title = "shinyDAG",
skin = "black",
dashboardHeader(
title = "shinyDAG",
tags$li(
class = "dropdown",
actionLink(
inputId = "._bookmark_",
label = "Bookmark",
icon = icon("link", lib = "glyphicon"),
title = "Bookmark shinyDAG's state and get a URL for sharing.",
`data-toggle` = "tooltip",
`data-placement` = "bottom"
)
),
tags$li(
class = "dropdown",
tags$a(
href = "https://github.com/gerkelab/shinyDAG/",
title = "shinyDAG on GitHub",
target = "_blank",
icon("github")
)
),
tags$li(
class = "dropdown",
tags$a(
href = "https://gerkelab.com/project/shinyDAG/",
title = "GerkeLab Project Page",
target = "_blank",
icon("flask")
)
)
),
dashboardSidebar(
sidebarMenu(
id = "shinydag_page",
menuItem("Sketch", tabName = "sketch", icon = icon("share-alt")),
menuItem("Tweak", tabName = "tweak", icon = icon("sliders")),
menuItem("LaTeX", tabName = "latex", icon = icon("file-text-o")),
menuItem("About", tabName = "about", icon = icon("info"))
)
),
dashboardBody(
shinyjs::useShinyjs(),
tags$script(src = "shinydag.js", async = TRUE),
includeCSS("www/AdminLTE.gerkelab.min.css"),
includeCSS("www/_all-skins.gerkelab.min.css"),
includeCSS("www/shinydag.css"),
chooseSliderSkin("Flat", "#418c7a"),
tags$a(
href = "https://gerkelab.com",
target = "_blank",
tags$div(class = "gerkelab-logo")
),
if (isTRUE(getOption("shinydag.debug", FALSE))) tagList(
div(
class = 'btn-group debug-buttons',
actionButton("debug_browse", "Browse"),
actionButton("debug_trigger", label = "Trigger Debug")
)
),
tabItems(
tabItem(
tabName = "sketch",
components$build
),
tabItem(
tabName = "tweak",
two_column_flips_on_mobile(
components$tweak,
box(
title = "Preview DAG",
dagPreviewUI("tweak_preview", include_graph_downloads = TRUE)
)
)
),
tabItem(
tabName = "latex",
two_column_flips_on_mobile(
box(
title = "Edit LaTeX",
components$latex
),
box(
title = "Preview LaTeX",
dagPreviewUI("latex_preview", include_graph_downloads = FALSE)
)
)
),
tabItem(
tabName = "about",
box(
title = "Examples",
width = "12 col-md-6",
examples_UI("example")
),
box(
title = "About shinyDAG",
width = "12 col-md-6",
components$about$gerkelab
)#,
# box(
# title = "About shinyDAG",
# width = "12 col-md-6",
# components$about$usage
# )
)
)
)
)
}