Skip to content

Commit

Permalink
Merge pull request #151 from miraisolutions/release/v1.3.0
Browse files Browse the repository at this point in the history
1.3.0 release
  • Loading branch information
riccardoporreca authored Nov 5, 2019
2 parents a4e3e4c + 75d7f00 commit d5033aa
Show file tree
Hide file tree
Showing 30 changed files with 1,271 additions and 210 deletions.
6 changes: 5 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
^doc$
^man-roxygen$
^Meta$
^\.Rproj\.user$

^.*\.Rproj$
^\.Rproj\.user$
^Dockerfile$
^\.dockerignore$
^docker$
^cloudbuild\.yaml$
^gke$
^git-flow$
^inst/application/data/taxdata$
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Exclude hidden files/dirs to cover items related to git checkout, R project
# and R session, which would be present in local builds and affect caching
.*
# .Rbuildignore however is relevant for the package build and must be kept
!.Rbuildignore

# Exclude the Dockerfile so that it does not affect caching either
Dockerfile
7 changes: 2 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SmaRP
Title: SmaRP: Smart Retirement Planning
Version: 1.2.0
Version: 1.3.0
Authors@R: c(person("Gabriel", "Foix", role = c("aut", "cre"),
email = "[email protected]"),
person("Francesca", "Vitalini", role = c("aut"),
Expand All @@ -27,16 +27,13 @@ Imports:
ggplot2,
googleVis,
htmltools,
kableExtra,
knitr,
lubridate,
magrittr,
pander,
reshape2,
rmarkdown,
shiny,
shinydashboardPlus,
shinyWidgets
shiny
Suggests: testthat, roxygen2 (>= 6.1.1)
VignetteBuilder: knitr
RoxygenNote: 6.1.1
Expand Down
97 changes: 58 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,68 @@
FROM rocker/r-ver:3.5.1
FROM rocker/r-ver:3.5.3

RUN apt-get update && apt-get install -y \
sudo \
pandoc \
pandoc-citeproc \
## Install required dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
## for R package 'curl'
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev \
## for R package 'xml2'
libxml2-dev \
texlive-full \
## for R package 'openssl'
libssl-dev \
## for install_tinytex.sh and install_pandoc.sh
wget \
curl
## for install_tinytex.sh
texinfo \
## for install_tinytex.sh
ghostscript \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/

## Install recent pandoc version, required by rmarkdown
# - see https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
# - https://pandoc.org/installing.html#linux
# We should use the same version as in rocker/rstudio:<R_VER>
# docker run --rm rocker/rstudio:<R_VER> /usr/lib/rstudio-server/bin/pandoc/pandoc -v
ENV PANDOC_DEB="2.3.1/pandoc-2.3.1-1-amd64.deb"
COPY docker/install_pandoc.sh .
RUN sh install_pandoc.sh $PANDOC_DEB && rm install_pandoc.sh

## Install TinyTeX as LaTeX installation
COPY docker/install_tinytex.sh .
# - Use a version-stable tlnet archive CTAN repo from texlive.info
# - here we consider the frozen TeXLive 2016 snapshot, corresponding to the TeXLive release
# shipped as texlive-* in Debian stretch (base image for the rocker/verse currently used)
# - note that https was not supported in TeXLive 2016 for the CTAN repository
ENV CTAN_REPO=http://www.texlive.info/tlnet-archive/2017/04/13/tlnet
# - It is important to also install all required LaTeX packages when building the image
RUN sh install_tinytex.sh fancyhdr
## Script for re-installation of TinyTeX in the running container
# - needed if at a certain point the "Remote repository is newer than local",
# for non-version-stable TinyTeX installations
# - this also (re-)executes (and therefore depends on) install_tinytex.sh
COPY docker/reinstall_tinytex.sh .

# Install needed packages
## Install major fixed R dependencies
# - they will always be needed and we want them in a dedicated layer,
# as opposed to getting them dynamically via `remotes::install_local()`
RUN install2.r --error \
bsplus \
dplyr \
ggplot2 \
googleVis \
htmltools \
kableExtra \
knitr \
lubridate \
magrittr \
pander \
reshape2 \
rmarkdown \
shiny \
shinydashboardPlus \
shinyWidgets


# copy the app to the image
RUN mkdir /root/SmaRP
COPY . /root/SmaRP

# set host and port
RUN echo "options(shiny.port = 80, shiny.host = '0.0.0.0')" >> /usr/local/lib/R/etc/Rprofile.site
shiny \
dplyr \
rmarkdown

## Copy the app to the image
# temporary location of the SmaRP source package in the image
ENV MARP=/tmp/SmaRP
COPY . $MARP

# install SmaRP
RUN cd /root && \
install2.r --repos NULL --error -- --no-multiarch --with-keep.source SmaRP
# Install SmaRP
RUN install2.r --error remotes \
&& R -e "remotes::install_local('$MARP')" \
&& rm -rf $MARP

# Set host and port
RUN echo "options(shiny.port = 80, shiny.host = '0.0.0.0')" >> /usr/local/lib/R/etc/Rprofile.site

EXPOSE 80

CMD ["R", "-e", "library(SmaRP); SmaRP::launch_application()"]
CMD ["R", "-e", "SmaRP::launch_application()"]
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(SmaRPanel)
export(buildContributionP2Path)
export(buildContributionP3path)
export(buildTaxBenefits)
Expand Down
17 changes: 17 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# SmaRP 1.3.0

### Changes

* The app now uses custom collapsible panels, removing the dependency on shinydashboardPlus (#113).
* The Dockerfile for the deployed app was improved, and is now based on R 3.5.3 (#91, #152).
* The total retirement fund text in the app was improved (#114).
* The PDF report now uses A4 as pages size (#131).
* The increment of interest rates in the app is now aligned to 0.1% (#142).
* The iframe-resizer version was upgraded to 4.2.1 (#144).

### Maintenance

* Instructions and manifests for the GKE deployment are now included in the `gke` directory (#141).
* GitFlow and release details are now included in the `git-flow` directory (#143).
* The README was updated based on the new website integration of the deployed app (#143).

# SmaRP 1.2.0

### Changes
Expand Down
77 changes: 77 additions & 0 deletions R/SmaRPanel.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#' @title SmaRPanel
#'
#' @rdname SmaRPanel
#'
#' @description Custom collapsible panel for the SmaRP Shiny app.
#'
#' @param id The unique id of the panel.
#' @param ... UI elements to be displayed in the panel body.
#' @param title The title to be displayed in the panel heading.
#' @param collapsed Whether the panel should be created as collapsed or
#' expanded. If `NA` (the default), a non-collapsible panel is created.
#'
#' @details All elements of the panel are specified with additional classes
#' `"panel-smarp"`, `"panel-heading-smarp"`, `"panel-title-smarp"`,
#' `"panel-body-smarp"`, used for CSS customization. Similarly, the collapse
#' [actionButton()] is defined with no `label` nor `icon` and has a custom
#' class `"btn-collapse-smarp"`, to be used for CSS customization via the
#' `:after` pseudo-element.
#'
#' @return The UI definition of the panel.
#'
#' @example man-roxygen/ex-SmaRPanel.R
#'
#' @export
#'
#' @md
SmaRPanel <- function(id, ..., title = NULL, collapsed = NA) {
# we can add footer if needed

tags <- htmltools::tags

# append -smarp to the first class
.class <- function(x) paste(x, sub("^([^ ]+).*$", "\\1-smarp", x), sep = " ")
# specific ids within the panel id
.with_id <- function(x) paste(id, x, sep = "-")

heading <- if (!is.null(title) || !is.na(collapsed)) {
tags$div(
id = .with_id("heading"),
class = .class("panel-heading"),
tags$div(
class = .class("panel-title"),
title,
if (!is.na(collapsed)) {
shiny::actionButton(.with_id("collapse"), NULL) %>%
bsplus::bs_attach_collapse(.with_id("body")) %>%
# class for styling expand / collapse button
htmltools::tagAppendAttributes(class = paste(
.class("btn-collapse"),
if (isTRUE(collapsed)) "collapsed")
)
}
)
)
}

body <- tags$div(
# div wrapper similar to bsplus::bs_collapse()
id = .with_id("body"),
class = paste(
if (!is.na(collapsed)) "collapse",
if (isTRUE(!collapsed)) "in"
),
tags$div(
class = .class("panel-body"),
...
)
)

tags$div(
id = id,
class = .class("panel panel-default"),
heading,
body
)

}
16 changes: 8 additions & 8 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
utils::globalVariables(
c("AHL", "ALV", "AgePath", "BVG", "BVGMindestzinssatz", "BVGcontributionrates",
"BVGcontributionratesPath", "BVGpurchase", "Beruf", "BerufsauslagenMax",
"BerufsauslagenMin", "BerufsauslagenTarif", "BundessteueTabelle", "DO", "DOV",
"DirectP3", "ExpectedSalaryPath", "Gemeindenummer", "Kids", "Kinder", "KinderabzugKG",
"Kirchensteuer", "MaxBVG", "MaxContrTax", "MinBVG", "NBU", "NetSalary",
"P3ContributionPath", "PLZ", "PLZGemeinden", "TaxBenefits", "TaxableIncome",
"TotalContr", "TotalP3", "TotalTax", "VM", "Verheiratet", "Versicherung",
"VersicherungsK", "VersicherungsL", "VersicherungsV", "Calendar", "h4", "icon", "maxALV",
"maxNBU", "modalDialog", "removeModal", "showModal", "taxburden.list")
"BVGcontributionratesPath", "BVGpurchase", "Beruf", "BerufsauslagenMax",
"BerufsauslagenMin", "BerufsauslagenTarif", "BundessteueTabelle", "DO", "DOV",
"DirectP3", "ExpectedSalaryPath", "Gemeindenummer", "Kids", "Kinder", "KinderabzugKG",
"Kirchensteuer", "MaxBVG", "MaxContrTax", "MinBVG", "NBU", "NetSalary",
"P3ContributionPath", "PLZ", "PLZGemeinden", "TaxBenefits", "TaxableIncome",
"TotalContr", "TotalP3", "TotalTax", "VM", "Verheiratet", "Versicherung",
"VersicherungsK", "VersicherungsL", "VersicherungsV", "Calendar", "maxALV",
"maxNBU", "taxburden.list")
)
14 changes: 7 additions & 7 deletions R/withModalSpinner.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @title withModalSpinner
#'
#' @rdname withModalSpinner
#'
#' @rdname withModalSpinner
#'
#' @description Display a modal window with a spinning wheel and an information message
#' while a (time-consuming) expression is evaluated.
Expand All @@ -16,15 +16,15 @@
#'
#' @md
withModalSpinner <- function(expr, info,
spinner = icon("spinner", "fa-spin"),
spinner = shiny::icon("spinner", "fa-spin"),
size = "m") {
showModal(
modalDialog(
h4(spinner, info),
shiny::showModal(
shiny::modalDialog(
htmltools::h4(spinner, info),
footer = NULL,
size = size
)
)
force(expr)
removeModal()
shiny::removeModal()
}
Loading

0 comments on commit d5033aa

Please sign in to comment.