Skip to content

Commit

Permalink
Merge pull request #153 from EPPIcenter/add-multiselect
Browse files Browse the repository at this point in the history
Add multiselect
  • Loading branch information
bgpalmer authored Sep 12, 2023
2 parents e90b4cd + 0192dc1 commit 1b98707
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 38 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ A docker image for sampleDB can be pulled from [DockerHub](https://hub.docker.co
To pull from DockerHub, run the command below:

```bash
docker pull eppicenter/sampledb:v2.1.1
docker pull eppicenter/sampledb:v2.2.0
```

##### Option 2: Build the image

You can build the image instead of pulling from DockerHub. To do so, run the following command:

```bash
docker build -t eppicenter/sampledb:v2.1.1 .
docker build -t eppicenter/sampledb:v2.2.0 .
```

#### 3. Create your container

This is the final step. The host `localhost` and port `8080` will be used to access the application within the container, and all volumes needed to run the container are passed in on the command line. Notice that the sampleDB database volume is also include in the list of volumes.

```bash
docker run -d -p 8080:3838 -v /srv/shinyapps/:/srv/shiny-server -v /srv/shinylog/:/var/log/shiny-server -v sampledb_database:/usr/local/share/sampleDB --restart unless-stopped --name sampleDB eppicenter/sampledb:v2.1.1
docker run -d -p 8080:3838 -v /srv/shinyapps/:/srv/shiny-server -v /srv/shinylog/:/var/log/shiny-server -v sampledb_database:/usr/local/share/sampleDB --restart unless-stopped --name sampleDB eppicenter/sampledb:v2.2.0
```

#### 4. Access sampleDB
Expand Down Expand Up @@ -79,7 +79,7 @@ To install sampleDB at the site level, you can run the command below using an R
```R
remotes::install_github(
"https://github.com/EPPIcenter/sampleDB-rpackage",
ref = "v2.1.1",
ref = "v2.2.0",
lib = .libPaths()[1]
)
```
Expand All @@ -93,7 +93,7 @@ For a local install, the below command is sufficient within a regular RStudio or
```R
remotes::install_github(
"https://github.com/EPPIcenter/sampleDB-rpackage",
ref = "v2.1.1"
ref = "v2.2.0"
)
```

Expand Down
28 changes: 20 additions & 8 deletions inst/sampleDB/server_helpers/AppSearchDelArchSamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ library(stringr)

SearchDelArchSamples <- function(session, input, database, output, dbUpdateEvent) {

# Your existing 'selected()' reactive
selected <- reactive(getReactableState("DelArchSearchResultsTable", "selected"))

observe({
if (!is.null(input$shiftKeyEnabled) && input$shiftKeyEnabled) {
if (!is.null(input$selectedRange)) {

# Get the selected range
start_row <- input$selectedRange[1]
end_row <- input$selectedRange[2]

# Create new selection sequence
new_selection <- seq(from = start_row + 1, to = end_row + 1)

# Update the selected rows
updateReactable(outputId = "DelArchSearchResultsTable", selected = new_selection)
}
}
})

# Reactive to store retrieved database data
createFilterSetReactive <- function(defaults = list()) {
rv <- reactiveVal(defaults)
Expand Down Expand Up @@ -127,16 +147,10 @@ SearchDelArchSamples <- function(session, input, database, output, dbUpdateEvent
searchable = TRUE,
selection = "multiple",
onClick = "select",
columns = list(
.selection = colDef(
headerStyle = list(pointerEvents = "none")
)
),
striped = TRUE,
showPageSizeOptions = TRUE,
theme = reactableTheme(
headerStyle = list(
"& input[type='checkbox']" = list(display = "none"),
"&:hover[aria-sort]" = list(background = "hsl(0, 0%, 96%)"),
"&[aria-sort='ascending'], &[aria-sort='descending']" = list(background = "hsl(0, 0%, 96%)"),
borderColor = "#555"
Expand Down Expand Up @@ -405,8 +419,6 @@ SearchDelArchSamples <- function(session, input, database, output, dbUpdateEvent

###### Delarch specific functionality

selected <- reactive(getReactableState("DelArchSearchResultsTable", "selected"))

observeEvent(input$ArchiveAction, ignoreInit = TRUE, {

user.filtered.rows = filtered_data()
Expand Down
62 changes: 37 additions & 25 deletions inst/sampleDB/ui_helpers/UICSS.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
UICSS <- function(){
tags$head(
tags$style(HTML("
.shiny-file-input-progress {
display: none
}
.progress-bar {
color: transparent!important
}
h5 {
line-height: 150%;
}
::-webkit-input-placeholder {
font-style: italic;
}
:-moz-placeholder {
font-style: italic;
}
::-moz-placeholder {
font-style: italic;
}
:-ms-input-placeholder {
font-style: italic;
}
.shiny-output-error-validation {
color: #c4244c; font-weight: normal;
}")))
tags$style(
HTML("
.shiny-file-input-progress {
display: none
}
.progress-bar {
color: transparent!important
}
h5 {
line-height: 150%;
}
::-webkit-input-placeholder {
font-style: italic;
}
:-moz-placeholder {
font-style: italic;
}
::-moz-placeholder {
font-style: italic;
}
:-ms-input-placeholder {
font-style: italic;
}
.shiny-output-error-validation {
color: #c4244c; font-weight: normal;
}
.no-select {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none;
}"
)
)
)
}
20 changes: 20 additions & 0 deletions inst/sampleDB/ui_helpers/UISearchDelArchSamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ UISearchDelArchSamples <- function(){
selectizeInput("DelArchSearchByStatus", "Status", choices = c("In Use"), selected = "In Use")
),
mainPanel(
tags$script(HTML("
var firstSelectedRow = null;
var shiftKeyEnabled = false;
$(document).on('click', '.rt-tbody .rt-tr-group', function(evt) {
evt.preventDefault()
var row = $(this).closest('.rt-tr-group').index();
if (evt.shiftKey && firstSelectedRow !== null) {
var start = Math.min(firstSelectedRow, row);
var end = Math.max(firstSelectedRow, row);
$('body').addClass('no-select');
Shiny.setInputValue('selectedRange', [start, end], {priority: 'event'});
} else {
$('body').removeClass('no-select');
firstSelectedRow = row;
}
shiftKeyEnabled = evt.shiftKey;
Shiny.setInputValue('shiftKeyEnabled', shiftKeyEnabled);
});
")
),
width = 10,
reactableOutput("DelArchSearchResultsTable"),
hr(),
Expand Down

0 comments on commit 1b98707

Please sign in to comment.