Skip to content

Commit

Permalink
use rhino
Browse files Browse the repository at this point in the history
  • Loading branch information
RWParsons committed Aug 19, 2024
1 parent eaec500 commit f4795ff
Show file tree
Hide file tree
Showing 27 changed files with 1,794 additions and 733 deletions.
10 changes: 9 additions & 1 deletion .Rprofile
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
source("renv/activate.R")
if (file.exists("renv")) {
source("renv/activate.R")
} else {
# The `renv` directory is automatically skipped when deploying with rsconnect.
message("No 'renv' directory found; renv won't be activated.")
}

# Allow absolute module imports (relative to the app root).
options(box.path = getwd())
72 changes: 72 additions & 0 deletions .github/workflows/rhino-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Rhino Test
on: push
permissions:
contents: read
jobs:
main:
name: Run linters and tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup system dependencies
run: |
packages=(
# List each package on a separate line.
)
sudo apt-get update
sudo apt-get install --yes "${packages[@]}"
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: renv

- name: Setup R dependencies
uses: r-lib/actions/setup-renv@v2

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Lint R
if: always()
shell: Rscript {0}
run: rhino::lint_r()

- name: Lint JavaScript
if: always()
shell: Rscript {0}
run: rhino::lint_js()

- name: Lint Sass
if: always()
shell: Rscript {0}
run: rhino::lint_sass()

- name: Build JavaScript
if: always()
shell: Rscript {0}
run: rhino::build_js()

- name: Build Sass
if: always()
shell: Rscript {0}
run: rhino::build_sass()

- name: Run R unit tests
if: always()
shell: Rscript {0}
run: rhino::test_r()

- name: Run Cypress end-to-end tests
if: always()
uses: cypress-io/github-action@v6
with:
working-directory: .rhino # Created by earlier commands which use Node.js
start: npm run run-app
project: ../tests
wait-on: 'http://localhost:3333/'
wait-on-timeout: 60
9 changes: 9 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
linters:
linters_with_defaults(
line_length_linter = line_length_linter(100),
box_func_import_count_linter = rhino::box_func_import_count_linter(),
box_separate_calls_linter = rhino::box_separate_calls_linter(),
box_trailing_commas_linter = rhino::box_trailing_commas_linter(),
box_universal_import_linter = rhino::box_universal_import_linter(),
object_usage_linter = NULL # Does not work with `box::use()`.
)
3 changes: 3 additions & 0 deletions .renvignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Only use `dependencies.R` to infer project dependencies.
*
!dependencies.R
7 changes: 7 additions & 0 deletions .rscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
.lintr
.renvignore
.Renviron
.rhino
.rscignore
tests
2 changes: 2 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Rhino / shinyApp entrypoint. Do not edit.
rhino::app()
34 changes: 25 additions & 9 deletions app/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ facilities <<- process_facilities(facilities)
polyline_paths <<- process_polyline_paths(iTRAQI_paths, facilities)
observed_paths <<- process_observed_paths(observed_paths, iTRAQI_paths, polyline_paths)
observed_polyline_paths <<- process_observed_polyline_paths(observed_paths)
age_cats <<- get_age_cats(observed_paths = observed_paths)

source(file.path(app_dir, "mod-filters.R"))
source(file.path(app_dir, "mod-map-tab.R"))
Expand All @@ -35,27 +36,42 @@ moduleServer <- function(id, module) {
callModule(module, id)
}

library(shiny)
library(bs4Dash)
bodyTag <- dashboardBody(
tags$head(
includeCSS(file.path(app_dir, "styles.css"))
),
tagList(
ui_map("main")
)
# tags$head(
# includeCSS(file.path(app_dir, "styles.css"))
# ),
# tagList(
# ui_map("main")
# )
)

bodyTag$children[[1]]$attribs$style <- "padding: 0px 0px !important"


ui <- dashboardPage(
dark = TRUE,
# dark = TRUE,
header = dashboardHeader(),
sidebar = dashboardSidebar(width = "0px"),
body = bodyTag
)

server <- function(input, output, session) {
server_map("main")
server_mapclick("main")
# server_map("main")
# server_mapclick("main")
}
shinyApp(ui, server)


library(shiny)

ui <- fluidPage(

)

server <- function(input, output, session) {

}

shinyApp(ui, server)
6 changes: 3 additions & 3 deletions app/base-map.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# base-map.R

base_map <- function(map_bounds, facilities, iTRAQI_paths, polyline_paths, observed_paths, observed_polyline_paths) {
if ("base-map.rds" %in% list.files(fixtures_path)) {
return(readRDS(file.path(fixtures_path, "base-map.rds")))
}
# if ("base-map.rds" %in% list.files(fixtures_path)) {
# return(readRDS(file.path(fixtures_path, "base-map.rds")))
# }

# load palettes and acute raster from iTRAQI GitHub repo
source(file.path(here::here(), "app", "palettes.R"))
Expand Down
Empty file added app/js/index.js
Empty file.
2 changes: 2 additions & 0 deletions app/logic/__init__.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Logic: application code independent from Shiny.
# https://go.appsilon.com/rhino-project-structure
25 changes: 25 additions & 0 deletions app/main.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
box::use(
shiny[bootstrapPage, div, moduleServer, NS, renderUI, tags, uiOutput],
)

#' @export
ui <- function(id) {
ns <- NS(id)
bootstrapPage(
uiOutput(ns("message"))
)
}

#' @export
server <- function(id) {
moduleServer(id, function(input, output, session) {
output$message <- renderUI({
div(
style = "display: flex; justify-content: center; align-items: center; height: 100vh;",
tags$h1(
tags$a("Check out Rhino docs!", href = "https://appsilon.github.io/rhino/")
)
)
})
})
}
6 changes: 5 additions & 1 deletion app/path-category-controls.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ path_cats <- c("NO HLC", "FOLLOWED ITRAQI", "DID NOT FOLLOW ITRAQI")
death_flags <- c("Survived", "QAS", "Hospital", "ED")

age_cat_breaks <- c(0, 16, 24, 65, 99)
age_cats <- c(levels(cut(observed_paths$PAT_AGE, breaks = age_cat_breaks)), NA)

get_age_cats <- function(observed_paths){
c(levels(cut(observed_paths$PAT_AGE, breaks = age_cat_breaks)), NA)
}


final_facility_cats <- c("Brisbane (RBWH/PA/QCH)", "GOLD COAST", "OTHER", "TOWNSVILLE")

Expand Down
Binary file added app/static/favicon.ico
Binary file not shown.
Empty file added app/styles/main.scss
Empty file.
2 changes: 2 additions & 0 deletions app/view/__init__.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# View: Shiny modules and related code.
# https://go.appsilon.com/rhino-project-structure
3 changes: 3 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default:
rhino_log_level: !expr Sys.getenv("RHINO_LOG_LEVEL", "INFO")
rhino_log_file: !expr Sys.getenv("RHINO_LOG_FILE", NA)
19 changes: 19 additions & 0 deletions dependencies.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file allows packrat (used by rsconnect during deployment) to pick up dependencies.
library(bs4Dash)
library(dplyr)
library(glue)
library(haven)
library(here)
library(janitor)
library(leaflet)
library(parallel)
library(pbapply)
library(progress)
library(raster)
library(rhino)
library(sf)
library(shiny)
library(shinyjs)
library(shinyWidgets)
library(sp)
library(tidyverse)
9 changes: 9 additions & 0 deletions old.Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if (file.exists("renv")) {
source("renv/activate.R")
} else {
# The `renv` directory is automatically skipped when deploying with rsconnect.
message("No 'renv' directory found; renv won't be activated.")
}

# Allow absolute module imports (relative to the app root).
options(box.path = getwd())
Loading

0 comments on commit f4795ff

Please sign in to comment.