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 17 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.9023
Version: 3.0.0.9024
Authors@R: c(
person("Aaron", "Clark", role = c("aut", "cre"), email = "[email protected]"),
person("Robert", "Krajcik", role = "aut", email = "[email protected]"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Allow users to specify decisions in the CSV upload file (#663)
* Fix bug causing application to crash when trying to delete zero packages (#781)
* Add `Decision` column to Package Dependencies tab so that users (#774)

* Added navigation controls in Function Explorer tab (#644)


# riskassessment 3.0.0
Expand Down
77 changes: 73 additions & 4 deletions R/mod_code_explorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ 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(
narayanan-iyer-pfizer marked this conversation as resolved.
Show resolved Hide resolved
column(3,
wellPanel(
Expand Down Expand Up @@ -69,7 +68,28 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(
div(id = ns("file_viewer"),
uiOutput(ns("file_output"), class = "file_browser"),
style = "height: 62vh; overflow: auto; border: 1px solid var(--bs-border-color-translucent);"
)
),
br(),
fluidRow(style = "height:35px !important;",
column(4,offset = 8,
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;",

div(id = "search_index","",style ="display:inline"),
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;
display:inline;
")|>bslib::tooltip("Next occurence",placement ="right"), style = "display: inline-block;")))
)
),
br(), br(),
Expand Down Expand Up @@ -127,7 +147,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 +164,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 @@ -166,7 +186,56 @@ mod_code_explorer_server <- function(id, selected_pkg, pkgarchive = reactiveVal(
bindEvent(input$man_files, input$exported_function, ignoreNULL = FALSE)

introJSServer("introJS", text = reactive(fe_steps), user, credentials)
search_index_value <- reactiveVal(1)
highlight_list <- reactiveVal(1)

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]
search_index.innerHTML = 1 + " of " + $highlights_list.length;

}
else
{
$curr_sel = $highlights_list[$index +1]
search_index.innerHTML = ( $index+2) + " of " + $highlights_list.length;
}

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

}

})

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]
search_index.innerHTML = $highlights_list.length + " of " + $highlights_list.length;
else
narayanan-iyer-pfizer marked this conversation as resolved.
Show resolved Hide resolved
{
$curr_sel = $highlights_list[$index -1]
search_index.innerHTML = ($index) + " of " + $highlights_list.length;
}
var $target = document.querySelector("#code_explorer-file_viewer")

$target.scrollTop = 0;
$target.scrollTop = $curr_sel.offsetTop - 40;

')
}

})
output$file_output <- renderUI({
switch (input$file_type,
test = test_code(),
Expand Down
10 changes: 10 additions & 0 deletions 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')
var $curr_sel = document.querySelector('.highlight')
if(typeof($highlights_list) != 'undefined' & $curr_sel != null){
var $target = document.querySelector('#code_explorer-file_viewer')
$target.scrollTop = 0;
$target.scrollTop = $curr_sel.offsetTop - 40;
var $index1 =Array.from($highlights_list).findIndex(node => node.isEqualNode($curr_sel)) +1;
search_index.innerHTML = $index1 + ' of ' + $highlights_list.length;
}
"))
)
}
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4367,7 +4367,7 @@
"Maintainer": "Kevin Ushey <[email protected]>",
"Repository": "RSPM",
"Date/Publication": "2024-02-29 01:10:07 UTC",
"Built": "R 4.3.3; ; 2024-06-06 17:15:02 UTC; unix"
"Built": "R 4.3.3; ; 2024-06-12 12:30:38 UTC; unix"
}
},
"reprex": {
Expand Down Expand Up @@ -6220,7 +6220,7 @@
"checksum": "99c5575cb81828e20a7fe1d205551316"
},
"DESCRIPTION": {
"checksum": "c4ce70d1592eea23d969d53b917c4a5b"
"checksum": "c7e19a728e7d1cb04961c5695ed151c2"
},
"inst/app/www/css/community_metrics.css": {
"checksum": "f08eb25c2ee48ac22ed63b0d18994a04"
Expand Down Expand Up @@ -6463,7 +6463,7 @@
"checksum": "97d1232340e04c53088bc8f814133dcd"
},
"NEWS.md": {
"checksum": "f9bc97131b3753ea173bff4248b97e1f"
"checksum": "876dad435c429e277f1f9b234ed8ec5c"
},
"R/app_config.R": {
"checksum": "c2b61f270b86b6833f0ee39c44a1a440"
Expand All @@ -6490,10 +6490,10 @@
"checksum": "61459e71d1e62587597ac1dac2c7c650"
},
"R/mod_code_explorer_utils.R": {
"checksum": "fe3bd5c1243d0ba649d070a6ecf29560"
"checksum": "2588e180a69a79b7be4e3818eb3931dc"
},
"R/mod_code_explorer.R": {
"checksum": "72a36a8c4d7f15e0da013104177328b1"
"checksum": "13c706c439a980b617e960b93414ad5c"
},
"R/mod_communityMetrics.R": {
"checksum": "fdd39bd2a7e19b8dccc195aaec57a3d8"
Expand Down
Loading