Skip to content

Commit

Permalink
Refactoring earnaud#6
Browse files Browse the repository at this point in the history
  • Loading branch information
earnaud committed Aug 11, 2020
1 parent 535f15b commit 1663804
Show file tree
Hide file tree
Showing 57 changed files with 4,277 additions and 3,366 deletions.
Binary file modified .RData
Binary file not shown.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export(runMetashark)
export(write.text)
import(shiny)
import(shinydashboard)
import(shinydashboardPlus)
importFrom(EML,eml_validate)
importFrom(EML,get_unitList)
importFrom(EML,read_eml)
Expand Down Expand Up @@ -66,8 +68,6 @@ importFrom(shinyFiles,shinyFilesButton)
importFrom(shinyTree,get_selected)
importFrom(shinyTree,renderTree)
importFrom(shinyTree,shinyTree)
importFrom(shinycssloaders,withSpinner)
importFrom(shinydashboard,box)
importFrom(shinydashboard,dashboardBody)
importFrom(shinydashboard,dashboardHeader)
importFrom(shinydashboard,dashboardPage)
Expand Down
79 changes: 65 additions & 14 deletions R/about-module.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,73 @@
#' @import shiny
#'
#' @noRd
aboutUI <- function(id) {
ns <- NS(id)

fluidPage(
tags$h1("About MetaShARK dev team"),
HTML("MetaShARK is developped within the french Museum National
d'Histoire Naturelle / UMS Patrimoine Naturel / Pole
National de Biodiversite. Its development team is currently
composed of <a href='https://fr.linkedin.com/in/elie-arnaud-440132151?trk=people-guest_profile-result-card_result-card_full-click'>Elie Arnaud</a>
(lead developer) and <a href ='https://fr.linkedin.com/in/yvan-le-bras-aa2b3738?trk=people-guest_profile-result-card_result-card_full-click'>Yvan Le Bras</a> (team director)."),

tags$h1("Thanks"),
HTML("MetaShARK could not be built without the help of those people: </br>
<ul>
<li>Colin Smith (EDI, US)</li> who collaborates with us since March
2019, and currently provides us the <a href='https://github.com/EDIorg/EMLassemblyline'>EML Assembly Line</a> tool.
</ul>"),

tags$h1("References"),
# Parties
tags$h2("LTER and EML Actors"),
tags$p("The following people and parties have worked upstream of
MetaShARK dev team to provide the fundamentals united in
the present tool."),
uiOutput(NS(id, "actors")),
# Informatics
tags$h2("Computer material"),
tags$p("The following references will lead the user to the source
of tools and methods reused in MetaShARK."),
uiOutput(NS(id, "informatics")),
# Sci litt
tags$h2("Literature"),
tags$p("MetaShARK is based on the following papers and articles
concerning mainly ecological metadata."),
uiOutput(NS(id, "ecology"))
)
}

#' @title about
#'
#' @description server part of the about module.
#'
#'
#' @import shiny
#'
#'
#' @noRd
about <- function(input, output, session) {
ns <- session$ns
about <- function(id) {
moduleServer(id, function(input, output, session) {

.bibliography <- reactiveValues(
actors = system.file("resources/bibliography-actors.bib", package = "MetaShARK"),
informatics = system.file("resources/bibliography-informatics.bib", package = "MetaShARK"),
ecology = system.file("resources/bibliography-ecology.bib", package = "MetaShARK"),
misc = system.file("resources/bibliography-misc.bib", package = "MetaShARK")
)
# misc = system.file("resources/bibliography-misc.bib", package = "MetaShARK")

# use function
output$actors <- renderBibliography(.bibliography$actors)
output$informatics <- renderBibliography(.bibliography$informatics)
output$ecology <- renderBibliography(.bibliography$ecology)
output$actors <- renderBibliography(
system.file(
"resources/bibliography-actors.bib",
package = "MetaShARK"
)
)
output$informatics <- renderBibliography(
system.file(
"resources/bibliography-informatics.bib",
package = "MetaShARK"
)
)
output$ecology <- renderBibliography(
system.file(
"resources/bibliography-ecology.bib",
package = "MetaShARK"
)
)
})
}
2 changes: 1 addition & 1 deletion R/about-module_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @importFrom utils capture.output
renderBibliography <- function(bib) {
.bib <- RefManageR::ReadBib(bib)
RefManageR::NoCite(bib, "*")
RefManageR::NoCite(.bib, "*")

renderUI(
withProgress(message = "Loading bibtex ...", value = 0, {
Expand Down
40 changes: 0 additions & 40 deletions R/aboutUI-module.R

This file was deleted.

77 changes: 40 additions & 37 deletions R/documentation-module.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#' @import shiny
#' @importFrom shinydashboard box
#' @importFrom shinyTree shinyTree
#'
#'
#' @noRd
docUI <- function(id) {
ns <- NS(id)
Expand All @@ -23,17 +22,16 @@ docUI <- function(id) {
shinyTree::shinyTree(
outputId = NS(id, "tree"),
search = TRUE,
theme = "proton"
theme = "proton",
wholerow = TRUE,
multiple = FALSE
)
)
),
# display main panel
column(
7,
div(
id = "docPanel",
uiOutput(NS(id, "doc"))
)
uiOutput(NS(id, "doc"))
)
)
)
Expand All @@ -42,40 +40,45 @@ docUI <- function(id) {
#' @import shiny
#' @importFrom shinyTree renderTree get_selected
#' @importFrom jsonlite read_json unserializeJSON
#'
#'
#' @noRd
documentation <- function(input, output, session) {
ns <- session$ns
documentation <- function(id) {
moduleServer(id, function(input, output, session) {

# Load data ====
withProgress(message = "Loading documentation.", {
doc <- system.file("resources/doc_guideline.json", package = "MetaShARK") %>%
jsonlite::read_json(simplifyVector = TRUE) %>%
jsonlite::unserializeJSON()
incProgress(0.5)
tree <- system.file("resources/tree_guideline.json", package = "MetaShARK") %>%
jsonlite::read_json(simplifyVector = TRUE) %>%
jsonlite::unserializeJSON()
incProgress(0.5)
})
# Load data ====
doc <- system.file("resources/doc_guideline.json", package = "MetaShARK")
doc <- jsonlite::unserializeJSON(jsonlite::read_json(doc)[[1]])

# UI render ====
tree <- system.file("resources/tree_guideline.json", package = "MetaShARK")
tree <- jsonlite::unserializeJSON(jsonlite::read_json(tree)[[1]])

# render tree
output$tree <- shinyTree::renderTree(tree)
# UI render ====

# output selected node
output$doc <- renderUI({
tree.node <- shinyTree::get_selected(input$tree)
validate(
need(unlist(tree.node), "(Select an item first)")
)
path <- paste(c(attr(tree.node[[1]], "ancestry"), unlist(tree.node)), collapse = "/")
doc.node <- followPath(doc, path)
if ("annotation" %in% names(doc.node)) {
doc.node$annotation
} else {
helpText("No content found at:", path)
}
# render tree
output$tree <- shinyTree::renderTree({
tree
})

# output selected node
output$doc <- renderUI({
req("tree" %in% names(input))
tree.node <- get_selected(input$tree)
validate(
need(unlist(tree.node), "(Select an item first)")
)
path <- paste(
c(
attr(tree.node[[1]], "ancestry"),
unlist(tree.node)
),
collapse = "/"
)
doc.node <- followPath(doc, path)
if ("annotation" %in% names(doc.node)) {
doc.node$annotation
} else {
helpText("No content found at:", path)
}
})
})
}
Loading

0 comments on commit 1663804

Please sign in to comment.