-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ECCC-lavoie-ecotox/dev_app
Init shiny application
- Loading branch information
Showing
29 changed files
with
1,436 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
Package: toxbox | ||
Title: Miscellaneous utils for data processing and predictive models building | ||
Title: Application and utils for contaminants data processing | ||
Version: 0.0.1 | ||
Authors@R: c( | ||
person(given = "Steve", family = "Vissault", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0866-4376")), | ||
person(given = "Anais", family = "Kerric", email = "[email protected]", role = c("aut")), | ||
person(given = "Rose", family = "Lacombe", email = "[email protected]", role = c("aut")), | ||
person(given = "Raphael", family = "Lavoie", email = "[email protected]", role = c("aut")) | ||
) | ||
Description: This package aims at facilitate data processing and models building in order to spend more time on the field. | ||
person("Steve", "Vissault", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-0866-4376")), | ||
person("Anais", "Kerric", , "[email protected]", role = "aut"), | ||
person("Rose", "Lacombe", , "[email protected]", role = "aut"), | ||
person("Raphael", "Lavoie", , "[email protected]", role = "aut") | ||
) | ||
Description: This package aims at facilitate data processing and models | ||
building in order to spend more time on the field. | ||
License: MIT + file LICENSE | ||
URL: https://github.com/ECCC-lavoie-ecotox/toxbox | ||
BugReports: https://github.com/ECCC-lavoie-ecotox/toxbox/issues | ||
Depends: | ||
R (>= 4.0) | ||
Imports: | ||
bslib (>= 0.5.1), | ||
cli (>= 3.6.2), | ||
config (>= 0.3.2), | ||
DBI (>= 1.2.2), | ||
dplyr (>= 1.1.4), | ||
glue (>= 1.7.0), | ||
stringr (>= 1.5.1), | ||
cli (>= 3.6.2), | ||
tidyselect (>= 1.2.1), | ||
golem (>= 0.4.1), | ||
purrr (>= 1.0.2), | ||
RSQLite (>= 2.3.5) | ||
RSQLite (>= 2.3.5), | ||
shiny (>= 1.8.0), | ||
stringr (>= 1.5.1), | ||
tidyselect (>= 1.2.1) | ||
Suggests: | ||
devtools (>= 2.2.0), | ||
knitr, | ||
mockery (>= 0.4.4), | ||
rmarkdown, | ||
testthat (>= 3.0.0), | ||
withr (>= 3.0.0), | ||
mockery (>= 0.4.4) | ||
License: MIT + file LICENSE | ||
withr (>= 3.0.0) | ||
Config/Needs/website: rmarkdown | ||
Encoding: UTF-8 | ||
Language: en-US | ||
LazyData: true | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.3.1 | ||
URL: https://github.com/ECCC-lavoie-ecotox/toxbox | ||
BugReports: https://github.com/ECCC-lavoie-ecotox/toxbox/issues | ||
Depends: | ||
R (>= 4.0) | ||
LazyData: true | ||
Config/Needs/website: rmarkdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2024 ECCC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# toxbox 0.0.1 | ||
|
||
* Initial CRAN submission. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#' Access files in the current app | ||
#' | ||
#' NOTE: If you manually change your package name in the DESCRIPTION, | ||
#' don't forget to change it here too, and in the config file. | ||
#' For a safer name change mechanism, use the `golem::set_golem_name()` function. | ||
#' | ||
#' @param ... character vectors, specifying subdirectory and file(s) | ||
#' within your package. The default, none, returns the root of the app. | ||
#' | ||
#' @noRd | ||
app_sys <- function(...) { | ||
system.file(..., package = "toxbox") | ||
} | ||
|
||
|
||
#' Read App Config | ||
#' | ||
#' @param value Value to retrieve from the config file. | ||
#' @param config GOLEM_CONFIG_ACTIVE value. If unset, R_CONFIG_ACTIVE. | ||
#' If unset, "default". | ||
#' @param use_parent Logical, scan the parent directory for config file. | ||
#' @param file Location of the config file | ||
#' | ||
#' @noRd | ||
get_golem_config <- function( | ||
value, | ||
config = Sys.getenv( | ||
"GOLEM_CONFIG_ACTIVE", | ||
Sys.getenv( | ||
"R_CONFIG_ACTIVE", | ||
"default" | ||
) | ||
), | ||
use_parent = TRUE, | ||
# Modify this if your config file is somewhere else | ||
file = app_sys("golem-config.yml") | ||
) { | ||
config::get( | ||
value = value, | ||
config = config, | ||
file = file, | ||
use_parent = use_parent | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#' The application server-side | ||
#' | ||
#' @param input,output,session Internal parameters for {shiny}. | ||
#' DO NOT REMOVE. | ||
#' @import shiny | ||
#' @noRd | ||
app_server <- function(input, output, session) { | ||
# Your application server logic | ||
r <- reactiveValues( | ||
active_table = "species" | ||
) | ||
|
||
mod_table_view_server("table_viewer", r) | ||
mod_table_nav_server("table_nav", r) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#' The application User-Interface | ||
#' | ||
#' @param request Internal parameter for `{shiny}`. | ||
#' DO NOT REMOVE. | ||
#' @import shiny | ||
#' @noRd | ||
app_ui <- function(request) { | ||
# Leave this function for adding external resources | ||
golem_add_external_resources() | ||
shinyjs::useShinyjs() | ||
bslib::page_sidebar( | ||
window_title = "contaminR", | ||
theme = bslib::bs_theme( | ||
bootswatch = "zephyr", | ||
base_font = bslib::font_google("Poppins"), | ||
version = 5 | ||
), | ||
div(class = "col-auto d-none d-lg-block", | ||
img(class="img-fluid text-left d-inline", src="www/logo.png",height="100", width="100"), | ||
h3("ContaminR", class="d-inline", style="font-weight:bold;"), | ||
p("Database editor", class ="text-muted d-inline m-3") | ||
), | ||
sidebar = bslib::sidebar( | ||
position = "left", | ||
actionButton("dashboard", | ||
class = "btn btn-success", | ||
label = "Dashboard", | ||
icon = icon("gauge") | ||
), | ||
actionButton("documentation", | ||
class = "btn btn-success", | ||
label = "Documentation", | ||
icon = icon("book") | ||
), | ||
mod_table_nav_ui("table_nav") | ||
), | ||
mod_table_view_ui("table_viewer") | ||
) | ||
} | ||
|
||
#' Add external Resources to the Application | ||
#' | ||
#' This function is internally used to add external | ||
#' resources inside the Shiny application. | ||
#' | ||
#' @import shiny | ||
#' @importFrom golem add_resource_path activate_js favicon bundle_resources | ||
#' @noRd | ||
golem_add_external_resources <- function() { | ||
add_resource_path( | ||
"www", | ||
app_sys("app/www") | ||
) | ||
|
||
tags$head( | ||
favicon(), | ||
bundle_resources( | ||
path = app_sys("app/www"), | ||
app_title = "toxbox" | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#' Start function | ||
#' | ||
#' @export | ||
|
||
fct_start <- function() { | ||
con <<- init_con() | ||
onStop(clean_up_app) | ||
} | ||
|
||
clean_up_app <- function() { | ||
cli::cli_alert_info("Application stopped -- cleaning database connexion") | ||
DBI::dbDisconnect(con) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' Inverted versions of in, is.null and is.na | ||
#' | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' 1 %not_in% 1:10 | ||
#' not_null(NULL) | ||
`%not_in%` <- Negate(`%in%`) | ||
|
||
not_null <- Negate(is.null) | ||
|
||
not_na <- Negate(is.na) | ||
|
||
#' Removes the null from a vector | ||
#' | ||
#' @noRd | ||
#' | ||
#' @example | ||
#' drop_nulls(list(1, NULL, 2)) | ||
drop_nulls <- function(x) { | ||
x[!sapply(x, is.null)] | ||
} | ||
|
||
#' If x is `NULL`, return y, otherwise return x | ||
#' | ||
#' @param x,y Two elements to test, one potentially `NULL` | ||
#' | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' NULL %||% 1 | ||
"%||%" <- function(x, y) { | ||
if (is.null(x)) { | ||
y | ||
} else { | ||
x | ||
} | ||
} | ||
|
||
#' If x is `NA`, return y, otherwise return x | ||
#' | ||
#' @param x,y Two elements to test, one potentially `NA` | ||
#' | ||
#' @noRd | ||
#' | ||
#' @examples | ||
#' NA %|NA|% 1 | ||
"%|NA|%" <- function(x, y) { | ||
if (is.na(x)) { | ||
y | ||
} else { | ||
x | ||
} | ||
} | ||
|
||
#' Typing reactiveValues is too long | ||
#' | ||
#' @inheritParams reactiveValues | ||
#' @inheritParams reactiveValuesToList | ||
#' | ||
#' @noRd | ||
rv <- function(...) shiny::reactiveValues(...) | ||
rvtl <- function(...) shiny::reactiveValuesToList(...) |
Oops, something went wrong.