Skip to content

Commit

Permalink
fixes to get report-v2 up again after new projects loaded #128 #129
Browse files Browse the repository at this point in the history
  • Loading branch information
bbest committed Mar 29, 2023
1 parent 4937a5c commit cab0653
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 50 deletions.
1 change: 1 addition & 0 deletions report-v2/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dir_scripts <<- here::here("scripts")
dir_data <<- here::here("data")
source(file.path(dir_scripts, "db.R"))
source(file.path(dir_scripts, "shiny_report.R")) # loads content d_*
debug = T

# devtools::install_github("RinteRface/shinydashboardPlus@4f23ece8c1ab50ae8e9505400ea7c266c6a04731") # Dec 7, 2020
librarian::shelf(
Expand Down
12 changes: 8 additions & 4 deletions report-v2/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,27 @@ server <- function(input, output, session) {
#* get_projects ----
get_projects <- reactive({

# #message("get_projects - beg")
if (debug)
message("get_projects - beg")

prj <- get_projects_tbl(ixns = values$ixns)

# #message("get_projects - end")
if (debug)
message("get_projects - end")

prj
})

#* prj_map ----
output$prj_map <- renderLeaflet({

# #message("prj_map - beg")
if (debug)
message("prj_map - beg")

m <- map_projects(get_projects())

# #message("prj_map - end")
if (debug)
message("prj_map - end")

m
})
Expand Down
78 changes: 39 additions & 39 deletions report-v2/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,45 +151,45 @@ ui <- dashboardPage(


#** tab_ba ----
tabItem(
tabName = "tab_ba",
# div(
# "Filters by:", icon("tags"),
# get_content_tag_categories("documents", html=T)),
helpText(
HTML("For a proposed project that is likely to affect species listed
as endangered or threatened under the Endangered Species Act (ESA) or
their designated critical habitat, the U.S. Department of Energy (DOE)
must provide the National Marine Fisheries Service (NMFS) and/or the
US Fish and Wildlife Service (USFWS) with a Biological Assessment (BA)
or Biological Evaluation (BE) and seek concurrence that the project is
unlikely to adversely affect the species or habitat.")),
# conditionalPanel(
# condition = "output.msg_docs",
# htmlOutput("msg_docs")),
tabsetPanel(
#*** ba_subtab_map ----
tabPanel(
"Map of BA Projects",
leafletOutput("ba_map")),
#*** ba_subtab_tbl ----
tabPanel(
"Table of Excerpts",
checkboxGroupInput(
"cks_docs",
"Binary Filters:",
c(
"Ixn: Presented as potential interaction?" = "ck_ixn",
"Obs: Described from observations at the project site?" = "ck_obs",
"MP: Monitoring Plan?" = "ck_mp",
"AMP: Adaptive Management Plan?" = "ck_amp",
"BMP: Best Management Practices applied?" = "ck_bmps")),
fluidRow(
box(
title = uiOutput("box_ba", inline=T), width = 12,
withSpinner(
color = "#3C8DBC",
dataTableOutput("tbl_ba"))))) )),
# tabItem(
# tabName = "tab_ba",
# # div(
# # "Filters by:", icon("tags"),
# # get_content_tag_categories("documents", html=T)),
# helpText(
# HTML("For a proposed project that is likely to affect species listed
# as endangered or threatened under the Endangered Species Act (ESA) or
# their designated critical habitat, the U.S. Department of Energy (DOE)
# must provide the National Marine Fisheries Service (NMFS) and/or the
# US Fish and Wildlife Service (USFWS) with a Biological Assessment (BA)
# or Biological Evaluation (BE) and seek concurrence that the project is
# unlikely to adversely affect the species or habitat.")),
# # conditionalPanel(
# # condition = "output.msg_docs",
# # htmlOutput("msg_docs")),
# tabsetPanel(
# #*** ba_subtab_map ----
# tabPanel(
# "Map of BA Projects",
# leafletOutput("ba_map")),
# #*** ba_subtab_tbl ----
# tabPanel(
# "Table of Excerpts",
# checkboxGroupInput(
# "cks_docs",
# "Binary Filters:",
# c(
# "Ixn: Presented as potential interaction?" = "ck_ixn",
# "Obs: Described from observations at the project site?" = "ck_obs",
# "MP: Monitoring Plan?" = "ck_mp",
# "AMP: Adaptive Management Plan?" = "ck_amp",
# "BMP: Best Management Practices applied?" = "ck_bmps")),
# fluidRow(
# box(
# title = uiOutput("box_ba", inline=T), width = 12,
# withSpinner(
# color = "#3C8DBC",
# dataTableOutput("tbl_ba"))))) )),

#** tab_pubs ----
tabItem(
Expand Down
16 changes: 9 additions & 7 deletions scripts/shiny_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ get_content_data <- function(ixns, type = "publications", ...){
# type = "publications"; ixns = list(c("Stressor.Noise.Airborne", "Receptor.MarineMammals"), c("Technology.Tidal", "Receptor.Fish", "Consequence.Collision"))
# type = "publications"; ixns = list(c("Stressor.Noise.Airborne", "Receptor.MarineMammals"), c("Technology.Tidal", "Receptor.Fish", "Consequence.Collision"), c("Receptor.Fish", "Management.Compliance"))

# if (type=="projects")
# browser()
# type = "projects"; ixns = list()

tbl_tags <- get_content_tags_tbl(type)
get_rowids_per_ixn <- function(tags){
Expand All @@ -161,6 +160,7 @@ get_content_data <- function(ixns, type = "publications", ...){
# functions of lazy data, ie before collect(), per content type
get_prj_tags <- function(){
tbl(con, "project_sites") %>%
select(-geometry) |>
left_join(
tbl(con, "project_tags"), by = "rowid") }
get_mgt_tags <- function(){
Expand All @@ -187,19 +187,19 @@ get_content_data <- function(ixns, type = "publications", ...){
tbl(con, "mc_spatial_tags"),
by = "rowid") }


# get lazy data per content type
d <- list(
d <- switch(
type,
projects = get_prj_tags(),
management = get_mgt_tags(),
documents = get_doc_tags(),
publications = get_pub_tags(),
spatial = get_spa_tags())[[type]]
spatial = get_spa_tags())

if (!is.null(rowids))
d <- filter(d, rowid %in% !!rowids)

d <- d_to_tags_html(d) %>%
d <- d_to_tags_html(d) %>%
mutate(
across(where(is.character), na_if, "NA"))

Expand Down Expand Up @@ -900,8 +900,10 @@ plot_project_timelines <- function(d_projects){
cols <- setNames(
c(cols_type, cols_status),
c(permit_types, project_statuses))
symbls_type <- c(rep('triangle-up', 3), 'triangle-down', 'triangle-up', 'triangle-down', 'triangle-up', 'triangle-down', rep('triangle-up', 3))
symbls_type <- c(rep('triangle-up', 3), 'triangle-down', 'triangle-up', 'triangle-down', 'triangle-up', 'triangle-down', rep('triangle-up', 3), 'triangle-down')
# + last symbls_type triangle-down for permit_type == Decommissioning
stopifnot(length(permit_types) == length(symbls_type))

symbls_status <- rep(NA, 2)
symbls <- setNames(
c(symbls_type, symbls_status),
Expand Down

0 comments on commit cab0653

Please sign in to comment.