Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autonavigation #779

Merged
merged 21 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: riskassessment
Title: A web app designed to interface with the `riskmetric` package
Version: 3.0.0.9020
Version: 3.0.0.9021
Authors@R: c(
person("Aaron", "Clark", role = c("aut", "cre"), email = "[email protected]"),
person("Robert", "Krajcik", role = "aut", email = "[email protected]"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Added more context to the metric score card visuals by inserting tool tips & creating a legend modal that describes & interprets all possible visuals (#652)
* Added `{riskmetric}` assessment documentation URLs to About tab, on Risk Assessment Criteria page.
* Updated the Dependency Cards to be slightly more informative
* Added navigation controls in Function Explorer tab.


# riskassessment 3.0.0
Expand Down
63 changes: 60 additions & 3 deletions R/mod_code_explorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(
showHelperMessage(message = glue::glue("Source code not available for {{{selected_pkg$name()}}}"))
} else {
div(introJSUI(NS(id, "introJS")),
br(),
fluidRow(style = "height:35px !important;",
column(2,offset = 10,
conditionalPanel(
condition = "typeof(window.$highlights_list) != 'undefined' && window.$highlights_list.length > 1",
actionButton(ns("prev_button"),label = "",icon = icon("chevron-left"),
style ="width: 32px !important;
height: 32px !important;
font-size: 16px !important;
line-height: 5px !important;
padding: 0px !important;") |>bslib::tooltip("Previous occurence"), style = "display: inline-block;"),
conditionalPanel(
condition = "typeof(window.$highlights_list) != 'undefined' && window.$highlights_list.length > 1",
actionButton(ns("next_button"),label = "",icon = icon("chevron-right"),
style = "width: 32px !important;
height: 32px !important;
font-size: 16px !important;
line-height: 5px !important;
padding: 0px !important;")|>bslib::tooltip("Next occurence",placement ="right"), style = "display: inline-block;"))),
fluidRow(
narayanan-iyer-pfizer marked this conversation as resolved.
Show resolved Hide resolved
column(3,
wellPanel(
Expand Down Expand Up @@ -127,7 +144,7 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(
close(con)
func_list <- c(input$exported_function, paste0("`", input$exported_function, "`"))
highlight_index <- parse_data() %>%
filter(stringr::str_ends(file, input$test_files) & func %in% func_list) %>%
filter(basename(file) == input$test_files & func %in% func_list) %>%
pull(line)
renderCode(lines, highlight_index)
}) %>%
Expand All @@ -144,7 +161,7 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(
close(con)
func_list <- c(input$exported_function, paste0("`", input$exported_function, "`"))
highlight_index <- parse_data() %>%
filter(stringr::str_ends(file, input$source_files) & func %in% func_list) %>%
filter(basename(file) == input$source_files & func %in% func_list) %>%
pull(line)
renderCode(lines, highlight_index)
}) %>%
Expand All @@ -167,6 +184,46 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(

introJSServer("introJS", text = reactive(fe_steps), user, credentials)

observeEvent(input$next_button,{
if (input$next_button > 0){
shinyjs::runjs('
var $index =Array.from($highlights_list).findIndex(node => node.isEqualNode($curr_sel));
narayanan-iyer-pfizer marked this conversation as resolved.
Show resolved Hide resolved
if( $index == $highlights_list.length -1)
{

$curr_sel = $highlights_list[0]

}
else
{
$curr_sel = $highlights_list[$index +1]
}

var $target = document.querySelector("#code_explorer-file_viewer")
$target.scrollTop = 0;
')
}

})

observeEvent(input$prev_button,{
if (input$prev_button > 0){
shinyjs::runjs('
var $index =Array.from($highlights_list).findIndex(node => node.isEqualNode($curr_sel));
if( $index ==0)
{
$curr_sel = $highlights_list[$highlights_list.length -1]
}
else
{
$curr_sel = $highlights_list[$index -1]
}
var $target = document.querySelector("#code_explorer-file_viewer")
$target.scrollTop = 0; # scroll to the top
$target.scrollTop = $curr_sel.offsetTop - 40; ')
}

})
output$file_output <- renderUI({
switch (input$file_type,
test = test_code(),
Expand Down
12 changes: 11 additions & 1 deletion R/mod_code_explorer_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,19 @@ renderCode <- function(lines, hlindex) {
})
),
tags$script(HTML("

document.querySelectorAll('.code pre').forEach(bl => {
hljs.highlightBlock(bl);
});
});
var $highlights_list = document.querySelectorAll('.highlight')
if(typeof($highlights_list) != 'undefined'){

var $curr_sel = document.querySelector('.highlight')

var $target = document.querySelector('#code_explorer-file_viewer')
$target.scrollTop = 0;
$target.scrollTop = $curr_sel.offsetTop - 40;
}
"))
)
}
27 changes: 10 additions & 17 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,7 @@
"Maintainer": "Marcel Ramos <[email protected]>",
"Repository": "RSPM",
"Date/Publication": "2023-08-08 23:40:06 UTC",
"Built": "R 4.3.0; ; 2023-08-09 11:24:46 UTC; unix",
"RemoteType": "standard",
"RemotePkgRef": "BiocManager",
"RemoteRef": "BiocManager",
"RemoteRepos": "https://packagemanager.posit.co/cran/__linux__/jammy/latest",
"RemoteReposName": "CRAN",
"RemotePkgPlatform": "source",
"RemoteSha": "1.30.22"
"Built": "R 4.3.0; ; 2023-08-09 11:24:46 UTC; unix"
}
},
"DBI": {
Expand Down Expand Up @@ -947,7 +940,7 @@
"RoxygenNote": "7.3.0",
"Author": "Sebastien Rochette [aut, cre] (<https://orcid.org/0000-0002-1565-9313>),\n Vincent Guyader [aut] (<https://orcid.org/0000-0003-0671-9270>),\n Arthur Bréant [aut] (<https://orcid.org/0000-0003-1668-0963>),\n Murielle Delmotte [aut] (<https://orcid.org/0000-0002-1339-2424>),\n ThinkR [cph]",
"Maintainer": "Sebastien Rochette <[email protected]>",
"Built": "R 4.3.3; ; 2024-04-30 19:03:05 UTC; unix",
"Built": "R 4.3.3; ; 2024-05-14 16:45:15 UTC; unix",
"RemoteType": "github",
"RemoteUsername": "thinkr-open",
"RemoteRepo": "checkhelper",
Expand Down Expand Up @@ -1310,7 +1303,7 @@
"Imports": "callr,\ncranlike (>= 1.0.2),\ncurl,\ndesc (>= 1.1.0),\ndigest,\nparsedate,\nrappdirs,\nrematch2,\ntools,\nutils,\nwithr",
"Suggests": "covr,\npingr,\ntestthat,\nzip",
"Encoding": "UTF-8",
"Built": "R 4.3.3; ; 2024-04-30 19:03:13 UTC; unix",
"Built": "R 4.3.3; ; 2024-05-14 16:45:23 UTC; unix",
"RemoteType": "github",
"RemoteHost": "api.github.com",
"RemoteUsername": "r-lib",
Expand Down Expand Up @@ -4410,7 +4403,7 @@
"RoxygenNote": "7.2.3",
"Author": "Gábor Csárdi [cre, aut, cph],\n Hadley Wickham [aut],\n RConsortium [cph],\n RStudio [cph, fnd]",
"Maintainer": "Gábor Csárdi <[email protected]>",
"Built": "R 4.3.3; ; 2024-04-30 19:03:46 UTC; unix",
"Built": "R 4.3.3; ; 2024-05-14 16:45:55 UTC; unix",
"RemoteType": "github",
"RemoteUsername": "r-lib",
"RemoteRepo": "revdepcheck",
Expand Down Expand Up @@ -4528,7 +4521,7 @@
"Config/testthat/edition": "3",
"Author": "R Validation Hub [aut],\n Doug Kelkhoff [aut],\n Marly Gotti [aut],\n Eli Miller [cre, aut],\n Kevin K [aut],\n Yilong Zhang [aut],\n Eric Milliman [aut],\n Juliane Manitz [aut],\n Mark Padgham [ctb],\n PSI special interest group Application and Implementation of\n Methodologies in Statistics [cph]",
"Maintainer": "Eli Miller <[email protected]>",
"Built": "R 4.3.3; ; 2024-04-30 19:03:52 UTC; unix",
"Built": "R 4.3.3; ; 2024-05-14 16:46:00 UTC; unix",
"RemoteType": "github",
"RemoteUsername": "pharmaR",
"RemoteRepo": "riskmetric",
Expand Down Expand Up @@ -5101,7 +5094,7 @@
"Maintainer": "Barret Schloerke <[email protected]>",
"Repository": "RSPM",
"Date/Publication": "2023-08-26 13:50:02 UTC",
"Built": "R 4.3.0; x86_64-pc-linux-gnu; 2023-12-04 11:55:11 UTC; unix"
"Built": "R 4.3.0; x86_64-pc-linux-gnu; 2023-08-28 11:40:29 UTC; unix"
}
},
"sortable": {
Expand Down Expand Up @@ -6205,7 +6198,7 @@
"checksum": "77a60b438dc99504d00b3f1b8bbc68c8"
},
"DESCRIPTION": {
"checksum": "ed68114e40c06e742a6cdb0d34f5ddf9"
"checksum": "0e46a273454297087402bede0202718b"
},
"inst/app/www/css/community_metrics.css": {
"checksum": "f08eb25c2ee48ac22ed63b0d18994a04"
Expand Down Expand Up @@ -6409,7 +6402,7 @@
"checksum": "60c2908e00b99b39cc28bdab6d6a5f3c"
},
"NEWS.md": {
"checksum": "3a683ee2adb456bdc7a58ab604c4c241"
"checksum": "e2459a4b82048dcb48db23f08b33f5b2"
},
"R/app_config.R": {
"checksum": "c2b61f270b86b6833f0ee39c44a1a440"
Expand All @@ -6433,10 +6426,10 @@
"checksum": "61459e71d1e62587597ac1dac2c7c650"
},
"R/mod_code_explorer_utils.R": {
"checksum": "fe3bd5c1243d0ba649d070a6ecf29560"
"checksum": "8c8d69c2431385b76971f6b413923c7e"
},
"R/mod_code_explorer.R": {
"checksum": "72a36a8c4d7f15e0da013104177328b1"
"checksum": "4be660d4a8b6f4b9835ec236d4f14dd5"
},
"R/mod_communityMetrics.R": {
"checksum": "fdd39bd2a7e19b8dccc195aaec57a3d8"
Expand Down