Skip to content

Commit

Permalink
Merge pull request #74 from inbo/fix_v1.0.0
Browse files Browse the repository at this point in the history
Fix v1.0.0
  • Loading branch information
SanderDevisscher authored Jul 15, 2024
2 parents 0074715 + 60bb655 commit 6c9d709
Show file tree
Hide file tree
Showing 53 changed files with 3,133 additions and 1,324 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ alienSpecies/alienSpecies-tests/

# aws secret
/script/

# temporary translations file
/alienSpecies/inst/extdata/translations*.csv
256 changes: 42 additions & 214 deletions Dockerfile

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,11 @@ Enkele relevante URLS:
# Build/Run docker image

The dockerfile needs to be updated only when some of the **dependencies** for `alienSpecies` changed.
This file is generated automatically by packamon: please do not edit by hand.
The following commands are run to update this dockerfile.

```
if (!require(packamon))
install.packages("packamon", repos = c(rdepot = "https://repos.openanalytics.eu/repo/public", getOption("repos")))
library(packamon)
writeDockerfile(sourceDir = ".", installSource = TRUE,
overwrite = TRUE, shinyFunction = "alienSpecies::runShiny()")
```

Then, to build the docker image with the latest dockerfile, run in bash
To build the docker image with the latest dockerfile, run in bash

```
cd git/alien-species-portal
docker build -t inbo/alienspecies .
docker build --build-arg GIT_SHA=$(git rev-parse HEAD) -t inbo/alienspecies .
```

Run the new docker image from bash. You need to point docker to the .aws folder on your local system to retrieve the credentials.
Expand Down
28 changes: 16 additions & 12 deletions alienSpecies/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
Package: alienSpecies
Type: Package
Title: Portal for alien and invasive species indicators
Version: 0.0.5
Version: 1.0.0
Date: 2023-11-30
Author: Machteld Varewyck, Yingjie Zhang, Eva Adriaensen
Maintainer: Machteld Varewyck <[email protected]>
Description: INBO shiny application based on the TRIAS package.
Encoding: UTF-8
License: MIT + file LICENSE
Imports:
arrow,
aws.ec2metadata,
aws.s3,
aws.signature,
Expand All @@ -17,29 +18,32 @@ Imports:
dplyr,
DT,
ggplot2,
ggspatial,
htmltools,
htmlwidgets,
httr,
INBOtheme (<= 0.5.9),
jsonlite,
leaflet,
leaflet (>= 2.2.0),
leaflet.extras,
methods,
plotly,
reshape2,
rgbif,
shiny,
shinycssloaders,
sf,
testthat (>= 3.0.0),
shiny,
shinycssloaders,
sf,
terra,
testthat (>= 3.0.0),
tidyr,
tidyverse,
trias (>= 2.0.3),
webshot,
xtable
tidyverse,
trias (>= 2.0.8),
webshot,
xtable
Suggests:
shinyjs
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Remotes:
inbo/[email protected],
trias-project/[email protected].6
trias-project/[email protected].8
Config/testthat/edition: 3
32 changes: 30 additions & 2 deletions alienSpecies/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(barplotLenteNesten)
export(checkS3)
export(combineActiveData)
export(combineNestenData)
export(combineVespaData)
export(comboTreeInput)
export(countNestenServer)
export(countNestenUI)
Expand All @@ -24,16 +25,18 @@ export(createSummaryNesten)
export(createSummaryRegions)
export(createTabularData)
export(createTaxaChoices)
export(createTaxaChoices2)
export(createTimeseries)
export(createTranslations)
export(decodeText)
export(displayName)
export(downloadS3)
export(drawBullet)
export(filterCombo)
export(filterSelectServer)
export(filterSelectUI)
export(getDutchNames)
export(getGbifOccurrence)
export(getPathLogo)
export(getRegionNames)
export(loadGbif)
export(loadMetaData)
export(loadOccupancyData)
Expand All @@ -47,7 +50,11 @@ export(mapHeatServer)
export(mapHeatUI)
export(mapOccurrence)
export(mapPopup)
export(mapRaster)
export(mapRasterServer)
export(mapRasterUI)
export(mapRegions)
export(mapRegionsFacet)
export(mapRegionsServer)
export(mapRegionsUI)
export(matchCombo)
Expand All @@ -59,12 +66,14 @@ export(plotModuleUI)
export(plotTrias)
export(plotTriasServer)
export(plotTriasUI)
export(plotlyReport)
export(readS3)
export(replicateColors)
export(runShiny)
export(setupS3)
export(simpleCap)
export(summarizeTimeSeries)
export(summarizeYearGroupData)
export(tableIndicators)
export(tableIndicatorsServer)
export(tableIndicatorsUI)
Expand All @@ -76,6 +85,8 @@ export(titleModuleUI)
export(translate)
export(trendYearRegion)
export(vectorToTitleString)
export(versionServer)
export(versionUI)
export(welcomeSectionServer)
export(welcomeSectionUI)
export(writeS3)
Expand All @@ -96,6 +107,9 @@ importFrom(INBOtheme,inbo_lichtgrijs)
importFrom(INBOtheme,inbo_palette)
importFrom(INBOtheme,inbo_steun_blauw)
importFrom(INBOtheme,theme_inbo)
importFrom(arrow,open_dataset)
importFrom(arrow,read_parquet)
importFrom(arrow,write_parquet)
importFrom(aws.ec2metadata,is_ec2)
importFrom(aws.ec2metadata,metadata)
importFrom(aws.s3,get_bucket_df)
Expand All @@ -119,7 +133,10 @@ importFrom(data.table,setDT)
importFrom(data.table,setkey)
importFrom(data.table,setkeyv)
importFrom(data.table,setnames)
importFrom(data.table,year)
importFrom(dplyr,all_of)
importFrom(dplyr,case_when)
importFrom(dplyr,collect)
importFrom(dplyr,filter)
importFrom(dplyr,group_by)
importFrom(dplyr,mutate)
Expand All @@ -128,15 +145,21 @@ importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(dplyr,ungroup)
importFrom(ggplot2,ggsave)
importFrom(ggspatial,annotation_map_tile)
importFrom(htmltools,div)
importFrom(htmlwidgets,saveWidget)
importFrom(httr,GET)
importFrom(httr,http_status)
importFrom(jsonlite,toJSON)
importFrom(leaflet,`%>%`)
importFrom(leaflet,addCircleMarkers)
importFrom(leaflet,addLegend)
importFrom(leaflet,addMarkers)
importFrom(leaflet,addRasterImage)
importFrom(leaflet,addScaleBar)
importFrom(leaflet,addTiles)
importFrom(leaflet,colorNumeric)
importFrom(leaflet,leaflet)
importFrom(leaflet,leafletOutput)
importFrom(leaflet,markerClusterOptions)
Expand All @@ -163,9 +186,14 @@ importFrom(shiny,singleton)
importFrom(shinycssloaders,withSpinner)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
importFrom(stats,complete.cases)
importFrom(terra,rast)
importFrom(terra,values)
importFrom(testthat,test_file)
importFrom(tidyr,pivot_wider)
importFrom(utils,capture.output)
importFrom(utils,download.file)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(utils,tail)
Expand Down
70 changes: 40 additions & 30 deletions alienSpecies/R/app_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#' User input for controlling specific plot (ui-side)
#' @param id character, module id, unique name per plot
#' @param showGroup boolean, whether to show a select input field for group variable
#' @param showSummary boolean, whether to show a select input field for summary choice
#' @param showPeriod boolean, whether to show a slider input field for period (first_observed)
#' @param showGewest boolean, whether to show filter for gewest
Expand All @@ -20,7 +19,7 @@
#' @return ui object (tagList)
#' @import shiny
#' @export
optionsModuleUI <- function(id, showGroup = FALSE, showSummary = FALSE,
optionsModuleUI <- function(id, showSummary = FALSE,
showPeriod = FALSE, showGewest = FALSE,
exportData = TRUE, doWellPanel = TRUE) {

Expand All @@ -31,8 +30,7 @@ optionsModuleUI <- function(id, showGroup = FALSE, showSummary = FALSE,
fixedRow(
if (showGewest)
column(6, uiOutput(ns("gewest"))),
if (showGroup)
column(6, uiOutput(ns("group"))),
column(6, uiOutput(ns("group"))),
if (showSummary)
column(6, uiOutput(ns("summarizeBy"))),
if (showPeriod)
Expand Down Expand Up @@ -65,8 +63,11 @@ plotModuleUI <- function(id, height = "600px") {

ns <- NS(id)

withSpinner(plotlyOutput(ns("plot"), height = height))

if (id == "management2_lente-plotTrias")
# dirty fix: this plot stays hidden when behind spinner
plotlyOutput(ns("plot"), height = height) else
withSpinner(plotlyOutput(ns("plot"), height = height))

}


Expand Down Expand Up @@ -103,6 +104,8 @@ tableModuleUI <- function(id, includeTotal = FALSE) {
#' @param data reactive data.frame, data for chosen species
#' @param period reactive numeric vector of length 2, selected period
#' @param combine reactive boolean, see \code{\link{trendYearRegion}}
#' @param groupChoices reactive character, defines the choices for group variable;
#' if NULL no groupChoices available
#' @return no return value; plot output object is created
#' @author mvarewyck
#' @import shiny
Expand All @@ -111,7 +114,7 @@ tableModuleUI <- function(id, includeTotal = FALSE) {
#' @importFrom plotly ggplotly layout
#' @export
plotModuleServer <- function(id, plotFunction, data, uiText = NULL,
outputType = NULL, triasFunction = NULL, triasArgs = NULL,
outputType = NULL, triasFunction = NULL, triasArgs = NULL, groupChoices = NULL,
period = NULL, combine = NULL) {

moduleServer(id,
Expand All @@ -131,11 +134,9 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,

output$group <- renderUI({

choices <- c("", "lifeStage")
names(choices) <- c("", translate(uiText(), choices[-1])$title)

selectInput(inputId = ns("group"), label = translate(uiText(), "group")$title,
choices = choices)
if (!is.null(groupChoices))
selectInput(inputId = ns("group"), label = translate(uiText(), "group")$title,
choices = groupChoices())

})

Expand All @@ -145,7 +146,7 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,
names(choices) <- translate(uiText(), choices)$title

selectInput(inputId = ns("summarizeBy"),
label = translate(uiText(), "summary")$title, choices = choices)
label = translate(uiText(), "summarizeBy")$title, choices = choices)

})

Expand Down Expand Up @@ -181,7 +182,7 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,

argList <- reactive({

req(nrow(subData()) > 0)
validate(need(nrow(subData()) > 0, translate(uiText(), "noData")$title))

argList <- c(
list(
Expand Down Expand Up @@ -214,8 +215,11 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,

resultFct <- reactive({

toReturn <- tryCatch(
do.call(plotFunction, args = argList()),
req(argList())

toReturn <- tryCatch({
do.call(plotFunction, args = argList())
},
error = function(err)
validate(need(FALSE, err$message))
)
Expand All @@ -226,22 +230,19 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,

})


output$plot <- renderPlotly({

if (!is.null(triasFunction) && triasFunction == "apply_gam") {
# remove title
myPlot <- resultFct()$plot %>% layout(title = "")
# move annotation to the left
myPlot$x$data[[2]]$x <- tail(sort(myPlot$x$data[[1]]$x), n = 3)
myPlot$x$data[[2]]$hovertext <- NULL
myPlot
} else resultFct()$plot
finalPlot <- reactive({

req(resultFct())

resultFct()$plot

})

if (!(plotFunction == "countOccupancy" |
(!is.null(triasFunction) && triasFunction %in% c("barplotLenteNesten", "countNesten"))))


output$plot <- renderPlotly(finalPlot())


if (plotFunction != "countOccupancy" & plotFunction != "countOccurrence")
outputOptions(output, "plot", suspendWhenHidden = FALSE)


Expand Down Expand Up @@ -286,6 +287,15 @@ plotModuleServer <- function(id, plotFunction, data, uiText = NULL,

})


reactive(c(
list(plot = if (!is.null(outputType) && outputType == "table")
req(resultFct()) else
req(finalPlot())
),
reactiveValuesToList(input)
))

})

}
Expand Down
Loading

0 comments on commit 6c9d709

Please sign in to comment.