Skip to content

Commit a213cf9

Browse files
authored
Version 1.0.0 (#13)
Version 1.0.0
2 parents 3192810 + 5d77ebd commit a213cf9

42 files changed

Lines changed: 3715 additions & 639 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,79 @@
1+
# ---- Project files ----
2+
shiny_bookmarks/
3+
www/errors/*
4+
5+
# ---- Default .gitignore From grkmisc ----
6+
.Rproj.user
7+
.Rhistory
8+
.RData
19
.DS_Store
10+
11+
# Directories that start with _
12+
_*/
13+
14+
## https://github.com/github/gitignore/blob/master/R.gitignore
15+
# History files
16+
.Rhistory
17+
.Rapp.history
18+
19+
# Session Data files
20+
.RData
21+
22+
# Example code in package build process
23+
*-Ex.R
24+
25+
# Output files from R CMD build
26+
/*.tar.gz
27+
28+
# Output files from R CMD check
29+
/*.Rcheck/
30+
31+
# RStudio files
32+
.Rproj.user/
33+
34+
# produced vignettes
35+
vignettes/*.html
36+
vignettes/*.pdf
37+
38+
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
39+
.httr-oauth
40+
41+
# knitr and R markdown default cache directories
42+
/*_cache/
43+
/cache/
44+
45+
# Temporary files created by R markdown
46+
*.utf8.md
47+
*.knit.md
48+
49+
# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
50+
rsconnect/
51+
52+
## https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
53+
# General
54+
.DS_Store
55+
.AppleDouble
56+
.LSOverride
57+
58+
# Icon must end with two \r
59+
Icon
60+
61+
62+
# Thumbnails
63+
._*
64+
65+
# Files that might appear in the root of a volume
66+
.DocumentRevisions-V100
67+
.fseventsd
68+
.Spotlight-V100
69+
.TemporaryItems
70+
.Trashes
71+
.VolumeIcon.icns
72+
.com.apple.timemachine.donotpresent
73+
74+
# Directories potentially created on remote AFP share
75+
.AppleDB
76+
.AppleDesktop
77+
Network Trash Folder
78+
Temporary Items
79+
.apdisk

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
sudo: required
2+
services:
3+
- docker
4+
5+
env:
6+
global:
7+
- DOCKER_USER="grrrck"
8+
- DOCKER_ORG="gerkelab"
9+
- secure: "cHdDyac1V5loCeGFS9k+hTejr2cRUWHm5vDB+7vXajkw4ile4mcn+E5vdoy9ExXlaHYuqjrOqURyBAI/HY1U0O06Brif9W8cKlUn7SGwaM6coBgqAxjeOiFDVD9Xg8IOI7wCHjJr9heMRLZyd65cyh9l30S+VKMqx4oFmoYdkvj2v7veDsN9j6kJ7SYGSZOmgv9G/FZmQvyWyLLhpgzMw98WzS2/QsbhG8ZSUmlRYfXo+B1vgw1lDVn8iRFAjG3oFiY4qXTVeaBOi/qAY20Kd44qQpcb2CL1wV/zMjRFGLXtlaBoMMA/4s5uRrFfJHsqUxLIqmhuBlLtqOtyZd2CqP3EGSjkmxfNh/dMDA0zgd3o/IVLuz6owpbHR/9ypUKvuD91vtTp0BUM+6Uma9j+ODC2Zn+IBi6QogjBSBkzz8wEK3TdM2RdjtJ62lBCL8YWxmGCQfIGR+emo1BUFnCsgMYsscC5LoMzFaihBTZAqaMQ3grCi743F2ozHFB3J2DRId1QZD+nje8An3ALsa152BX+ItblyOD7MxfSXa6OtthlholPTiKhYyWBncQqFMBaYsglVVF8MONEYJUzbws2D7+0IdJ5sXZz8XM/sXUwxNkBIpjfQoaqOkYFILCkwab59D7AvZPyYb6hI+XRhvqvA7Z221d+6UloRCFJha/oaR8="
10+
- COMMIT=${TRAVIS_COMMIT::8}
11+
- REPO="shinydag"
12+
13+
script:
14+
- docker build -f Dockerfile -t $DOCKER_ORG/$REPO:$COMMIT .
15+
16+
after_success:
17+
- docker login -u $DOCKER_USER -p $DOCKER_PASS
18+
- if [[ $TRAVIS_PULL_REQUEST == "false" ]] && [[ $TRAVIS_BRANCH == "master" ]]; then
19+
docker tag $DOCKER_ORG/$REPO:$COMMIT $DOCKER_ORG/$REPO:latest;
20+
docker tag $DOCKER_ORG/$REPO:$COMMIT $DOCKER_ORG/$REPO:$TRAVIS_BUILD_NUMBER;
21+
docker push $DOCKER_ORG/$REPO;
22+
fi
23+
- if [[ $TRAVIS_PULL_REQUEST == "false" ]] && [[ $TRAVIS_BRANCH == "dev" ]]; then
24+
docker tag $DOCKER_ORG/$REPO:$COMMIT $DOCKER_ORG/$REPO:dev;
25+
docker tag $DOCKER_ORG/$REPO:$COMMIT $DOCKER_ORG/$REPO:$TRAVIS_BUILD_NUMBER;
26+
docker push $DOCKER_ORG/$REPO;
27+
fi

Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FROM rocker/shiny-verse:3.5.3
2+
3+
LABEL maintainer="Travis Gerke (Travis.Gerke@moffitt.org)"
4+
5+
# Install system dependencies for required packages
6+
RUN apt-get update -qq && apt-get -y --no-install-recommends install \
7+
libssl-dev \
8+
libxml2-dev \
9+
libmagick++-dev \
10+
libv8-3.14-dev \
11+
libglu1-mesa-dev \
12+
freeglut3-dev \
13+
mesa-common-dev \
14+
libudunits2-dev \
15+
libpoppler-cpp-dev \
16+
libwebp-dev \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/ \
19+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
20+
21+
RUN install2.r --error \
22+
shinyAce \
23+
shinydashboard \
24+
shinyWidgets \
25+
DiagrammeR \
26+
ggdag \
27+
igraph \
28+
pdftools \
29+
shinyBS \
30+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
31+
32+
RUN Rscript -e "devtools::install_github('metrumresearchgroup/texPreview', ref = 'e954322')" \
33+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
34+
35+
# Install TinyTeX
36+
RUN install2.r --error tinytex \
37+
&& wget -qO- \
38+
"https://github.com/yihui/tinytex/raw/master/tools/install-unx.sh" | \
39+
sh -s - --admin --no-path \
40+
&& mv ~/.TinyTeX /opt/TinyTeX \
41+
&& /opt/TinyTeX/bin/*/tlmgr path add \
42+
&& tlmgr install metafont mfware inconsolata tex ae parskip listings \
43+
&& tlmgr install standalone varwidth xcolor colortbl multirow psnfss setspace pgf \
44+
&& tlmgr path add \
45+
&& Rscript -e "tinytex::r_texmf()" \
46+
&& chown -R root:staff /opt/TinyTeX \
47+
&& chmod -R a+w /opt/TinyTeX \
48+
&& chmod -R a+wx /opt/TinyTeX/bin \
49+
&& echo "PATH=${PATH}" >> /usr/local/lib/R/etc/Renviron \
50+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
51+
52+
RUN install2.r --error shinyjs \
53+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
54+
55+
RUN install2.r --error plotly shinycssloaders \
56+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
57+
58+
RUN installGithub.r gadenbuie/shinyThings@4e8becb2972aa2f7f1960da6e5fe6ad39aeceda0 \
59+
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds
60+
61+
ARG SHINY_APP_IDLE_TIMEOUT=600
62+
RUN sed -i "s/directory_index on;/app_idle_timeout ${SHINY_APP_IDLE_TIMEOUT};/g" /etc/shiny-server/shiny-server.conf
63+
COPY . /srv/shiny-server/shinyDAG
64+
RUN chown -R shiny:shiny /srv/shiny-server/

Figures/AddNodeEdge.gif

-5.5 MB
Loading

Figures/editEdge.gif

-5.35 MB
Loading

Figures/paths.png

4.13 KB
Loading

Figures/paths2.png

-5.03 KB
Loading

R/aes_ui.R

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
2+
# * ui_edge_controls() builds an individual UI control element. These elements
3+
# are re-rendered whenever the tab is opened, so this function finds the
4+
# current value of the input and uses that instead of the value declared
5+
# in the definition in ui_edge_controls_row(). This function also isolates
6+
# the edge control UI from other changes in nodes, etc, because they happen
7+
# on different screens.
8+
ui_controls <- function(hash, inputFn, prefix_input, label, ..., input = NULL) {
9+
stopifnot(!is.null(input))
10+
current_value_arg_name <- intersect(names(list(...)), c("selected", "value"))
11+
if (!length(current_value_arg_name)) {
12+
stop("Must specifiy `selected` or `value` when specifying edge UI controls")
13+
}
14+
input_name <- paste(prefix_input, hash, sep = "__")
15+
input_label <- label
16+
17+
if (input_name %in% names(isolate(input))) {
18+
# Make sure current value doesn't change
19+
dots <- list(...)
20+
dots[current_value_arg_name] <- paste(isolate(input[[input_name]]))
21+
dots$inputId <- input_name
22+
dots$label <- HTML(input_label)
23+
do.call(inputFn, dots)
24+
} else {
25+
# Create new input
26+
inputFn(input_name, HTML(input_label), ...)
27+
}
28+
}
29+
30+
get_hashed_input_with_prefix <- function(input, prefix, hash_sep = "__") {
31+
prefix <- glue::glue("^({prefix}){hash_sep}")
32+
33+
tibble(
34+
inputId = grep(prefix, names(input), value = TRUE)
35+
) %>%
36+
filter(!grepl("-selectized$", inputId)) %>%
37+
# get current value of input
38+
mutate(value = lapply(inputId, function(x) input[[x]])) %>%
39+
tidyr::separate(inputId, into = c("var", "hash"), sep = hash_sep) %>%
40+
tidyr::spread(var, value) %>%
41+
mutate_if(is.list, ~ purrr::map(.x, ~ if (is.null(.x)) NA else .x)) %>%
42+
tidyr::unnest() %>%
43+
split(.$hash)
44+
}
45+
46+
# The input for angles (here for easy refactoring or future changes)
47+
selectDegree <- function(inputId, label = "Degree", min = -180, max = 180, by = 15, value = 0, ...) {
48+
sliderInput(inputId, label = label, min = min, max = max, value = value, step = by)
49+
}
50+
51+
52+
# Edge Aesthetic UI -------------------------------------------------------
53+
54+
# These helper functions build up the Edge UI elements.
55+
#
56+
# * ui_edge_controls_row() creates the entire row of UI elements for a given
57+
# edge. This function is where the UI inputs are initially defined.
58+
59+
ui_edge_controls_row <- function(hash, from_name, to_name, ..., input = NULL) {
60+
stopifnot(!is.null(input))
61+
62+
extra <- list(...)
63+
64+
col_4 <- function(x) {
65+
tags$div(class = "col-sm-6 col-md-3", style = "min-height: 80px", x)
66+
}
67+
title_row <- function(x) tags$div(class = "col-xs-12", tags$h3(x))
68+
edge_label <- paste0(from_name, "&nbsp;&#8594; ", to_name)
69+
70+
tagList(
71+
fluidRow(
72+
title_row(HTML(edge_label))
73+
),
74+
fluidRow(
75+
# Edge Curve Angle
76+
col_4(ui_controls(
77+
hash,
78+
inputFn = selectDegree,
79+
prefix_input = "angle",
80+
label = "Angle",
81+
value = extra[["angle"]] %||% 0,
82+
width = "95%",
83+
input = input
84+
)),
85+
# Edge Color
86+
col_4(ui_controls(
87+
hash,
88+
inputFn = xcolorPicker,
89+
prefix_input = "color",
90+
label = "Edge",
91+
selected = extra[["color"]] %||% "Black",
92+
width = "95%",
93+
input = input
94+
)),
95+
# Curve Angle
96+
col_4(ui_controls(
97+
hash,
98+
inputFn = selectInput,
99+
prefix_input = "lty",
100+
label = "Line Type",
101+
choices = c("solid", "dashed"),
102+
selected = extra[["lty"]] %||% "solid",
103+
width = "95%",
104+
input = input
105+
)),
106+
# Curve Angle
107+
col_4(ui_controls(
108+
hash,
109+
inputFn = selectInput,
110+
prefix_input = "lineT",
111+
label = "Line Thickness",
112+
choices = c("ultra thin", "very thin", "thin", "semithick", "thick", "very thick", "ultra thick"),
113+
selected = extra[["lineT"]] %||% "thin",
114+
width = "95%",
115+
input = input
116+
))
117+
)
118+
)
119+
}
120+
121+
122+
# Node Aesthetic UI -------------------------------------------------------
123+
124+
ui_node_controls_row <- function(hash, name, adjusted, name_latex, ..., input = NULL) {
125+
stopifnot(!is.null(input))
126+
127+
extra <- list(...)
128+
129+
col_4 <- function(x) {
130+
tags$div(class = "col-sm-6 col-md-3", style = "min-height: 80px", x)
131+
}
132+
title_row <- function(x) tags$div(class = "col-xs-12", tags$h3(x))
133+
134+
tagList(
135+
fluidRow(
136+
title_row(HTML(name))
137+
),
138+
fluidRow(
139+
# LaTeX version of node label
140+
col_4(ui_controls(
141+
hash,
142+
inputFn = textInput,
143+
prefix_input = "name_latex",
144+
label = "LaTeX Label",
145+
value = name_latex,
146+
width = "95%",
147+
input = input
148+
)),
149+
# Text Color
150+
col_4(ui_controls(
151+
hash,
152+
inputFn = xcolorPicker,
153+
prefix_input = "color_text",
154+
label = "Text",
155+
selected = extra[["color_text"]] %||% "Black",
156+
width = "95%",
157+
input = input
158+
)),
159+
# Fill Color
160+
col_4(ui_controls(
161+
hash,
162+
inputFn = xcolorPicker,
163+
prefix_input = "color_fill",
164+
label = "Fill",
165+
selected = extra[["color_fill"]] %||% "White",
166+
width = "95%",
167+
input = input
168+
)),
169+
# Box Color (if shown)
170+
if (adjusted) {
171+
col_4(ui_controls(
172+
hash,
173+
inputFn = xcolorPicker,
174+
prefix_input = "color_draw",
175+
label = "Border",
176+
selected = extra[["color_draw"]] %||% "Black",
177+
width = "95%",
178+
input = input
179+
))
180+
}
181+
)
182+
)
183+
}

R/columns.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class_3_col <- "col-md-4 col-md-offset-0 col-sm-8 col-sm-offset-2 col-xs-12"
2+
3+
4+
# Component Builders ------------------------------------------------------
5+
6+
two_column_flips_on_mobile <- function(left, right, override_width_classes = TRUE) {
7+
8+
left_col_class <- "col-sm-12 col-md-pull-6 col-md-6 col-lg-5 col-lg-pull-7"
9+
right_col_class <- "col-sm-12 col-md-push-6 col-md-6 col-lg-7 col-lg-push-5"
10+
11+
if (!override_width_classes) {
12+
right <- tags$div(class = right_col_class, right)
13+
left <- tags$div(class = left_col_class, left)
14+
} else {
15+
strip_col_class <- function(x) gsub("col-(xs|sm|md|lg)-\\d{1,2}\\s*", "", x)
16+
left$attrib$class <- strip_col_class(left$attrib$class)
17+
right$attrib$class <- strip_col_class(right$attrib$class)
18+
19+
left$attrib$class <- paste(left$attrib$class, left_col_class)
20+
right$attrib$class <- paste(right$attrib$class, right_col_class)
21+
}
22+
23+
fluidRow(right, left)
24+
}
25+
26+
col_4 <- function(x) {
27+
tags$div(class = "col-sm-6 col-md-3", style = "min-height: 80px", x)
28+
}

0 commit comments

Comments
 (0)