Skip to content

Commit

Permalink
adding upgrade and delete scenarios (#41)
Browse files Browse the repository at this point in the history
* adding upgrade and delete scenarios
* Improve setup script based on suggetions
* improve documentations for setup/upgrade
  • Loading branch information
MeWu-IDM authored Apr 26, 2024
1 parent c19ad4e commit acb807f
Show file tree
Hide file tree
Showing 6 changed files with 339 additions and 77 deletions.
150 changes: 109 additions & 41 deletions R/view_runs.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ viewRunsUI <- function(id) {
# actionButton(ns("refreshBtn"), "Refresh Results"),
actionButton(ns("compare_btn"), "Show / Compare Result"),
actionButton(ns("download_resultsBtn"), "Download Results (.csv)", ),
actionButton(ns("print_summaryBtn"), "Print PDF of Summary Plots")
actionButton(ns("print_summaryBtn"), "Print PDF of Summary Plots"),
actionButton(ns("deleteResultsBtn"), "Delete selected results"),
)
)
),
Expand Down Expand Up @@ -81,11 +82,14 @@ viewRunsServer <- function(id, rv, store) {
}
}

showWarningModalNoFiles <- function() {
showWarningModalNoFiles <- function(text="") {
if (text==""){
text <- "You do not have any result to view, please run at least one simulation!"
}
shiny::showModal(
modalDialog(
title = "Warning",
"You do not have any result to view, please run at least one simulation!",
text,
footer = tagList(
actionButton(ns("closeNoFileModal"), "Close", icon = icon("times"))
)
Expand All @@ -98,6 +102,12 @@ viewRunsServer <- function(id, rv, store) {

observeEvent(input$test_history, {
df_history <- jsonlite::fromJSON(input$test_history)
if (length(df_history) == 0){
shinyjs::hide(id=ns("history_table"), asis = TRUE)
} else{
shinyjs::show(id=ns("history_table"), asis = TRUE)
}

df_history$summary <- apply(df_history, 1, function(row) {
read_info(row["name"])
})
Expand Down Expand Up @@ -187,18 +197,66 @@ viewRunsServer <- function(id, rv, store) {

observeEvent(input$compare_btn, {
if(!is.null(rv$df_history)){
shinyjs::show(id=ns("search_msg"), asis = TRUE)
selected <- which(selectedRows())
print(paste0("selected ", length(selected)))
test_selected <- rv$df_history[selected, 'name']
redraw(combine_selected_data(selected))
shinyjs::hide(id=ns("search_msg"), asis = TRUE)
if (length(selected) >0 ){
shinyjs::show(id=ns("search_msg"), asis = TRUE)
# print(paste0("selected ", length(selected)))
test_selected <- rv$df_history[selected, 'name']
redraw(combine_selected_data(selected))
shinyjs::hide(id=ns("search_msg"), asis = TRUE)
}
else{
showWarningModalNoFiles("You did not select any result to compare.")
}
}
else{
showWarningModalNoFiles()
}
})

observeEvent(input$deleteResultsBtn, {
if(!is.null(rv$df_history)){
selected <- which(selectedRows())
if (length(selected) > 0)
{
showModal(
modalDialog(
title = "Delete Results",
"Are you sure you want to delete the selected results?",
footer = tagList(
actionButton(ns("deleteResultsConfirmBtn"), "Yes"),
modalButton("No")
)
)
)
}else{
showWarningModalNoFiles("You did not select any result to delete.")
}
}
})

observeEvent(input$deleteResultsConfirmBtn, {
shiny::removeModal()
selected <- which(selectedRows())
if (length(selected) > 0)
{
test_selected <- rv$df_history[selected, 'name']
tryCatch({
for (testname in test_selected){
# remove localstorage entries
shinyjs::runjs(sprintf("delete_tests(['%s'], '%s', '%s')", testname, ns("test_history"), ns("history_table")))
resultdir <- file.path(result_root, testname)
if (dir.exists(resultdir)){
unlink(resultdir, recursive = TRUE)
}
}
},
error = function(e){
session$sendCustomMessage("notify_handler", paste0("Error occurred deleting ", test_selected))
})
}
})

observe ({
if (rv$sim_refresh){
print(paste0("rv$sim_refresh: ", rv$sim_refresh))
Expand Down Expand Up @@ -252,24 +310,29 @@ viewRunsServer <- function(id, rv, store) {
observeEvent(input$download_resultsBtn, {

if(!is.null(rv$df_history)){
before_download()
download_filenames(NULL)
selected <- which(selectedRows())
test_selected <- rv$df_history[selected, 'name']
folder_name <- file.path(result_root, test_selected)
download_filenames(zip_folders(folder_name))
shinyjs::hide(id=ns("search_msg"), asis = TRUE)

output$downloadBtn <- renderUI({
req(download_filenames())
downloadButton(
outputId = ns("downloadZipBtn"),
label = "Download your zip file here!",
onclick = sprintf('Shiny.setInputValue("%s", true);', ns("download_clicked")),
class = "download-button"
)
})
shinyjs::show(ns("downloadZipBtn"), asis = TRUE)
if (length(selected) > 0){
before_download()
test_selected <- rv$df_history[selected, 'name']
folder_name <- file.path(result_root, test_selected)
download_filenames(zip_folders(folder_name))
shinyjs::hide(id=ns("search_msg"), asis = TRUE)

output$downloadBtn <- renderUI({
req(download_filenames())
downloadButton(
outputId = ns("downloadZipBtn"),
label = "Download your zip file here!",
onclick = sprintf('Shiny.setInputValue("%s", true);', ns("download_clicked")),
class = "download-button"
)
})
shinyjs::show(ns("downloadZipBtn"), asis = TRUE)
}
else{
showWarningModalNoFiles("You did not select any result to download.")
}
}
else{
showWarningModalNoFiles()
Expand All @@ -296,25 +359,30 @@ viewRunsServer <- function(id, rv, store) {
### handle pdf report
observeEvent(input$print_summaryBtn, {
if(!is.null(rv$df_history)){
before_download()
selected <- which(selectedRows())
test_selected <- rv$df_history[selected, 'name']
if(combine_selected_data(selected)){
filename1 <- get_pdf_report(rv=rv_results)
if (length(selected) > 0){
before_download()
test_selected <- rv$df_history[selected, 'name']
if(combine_selected_data(selected)){
filename1 <- get_pdf_report(rv=rv_results)
}
pdf_filenames(filename1)
shinyjs::hide(id=ns("search_msg"), asis = TRUE)

output$downloadBtn <- renderUI({
req(pdf_filenames())
downloadButton(
outputId = ns("downloadPDFBtn"),
label = "Download your pdf report here!",
onclick = sprintf('Shiny.setInputValue("%s", true);', ns("download_clicked")),
class = "download-button"
)
})
shinyjs::show(ns("downloadPDFBtn"), asis = TRUE)
}
else{
showWarningModalNoFiles("You did not select any result to print.")
}
pdf_filenames(filename1)
shinyjs::hide(id=ns("search_msg"), asis = TRUE)

output$downloadBtn <- renderUI({
req(pdf_filenames())
downloadButton(
outputId = ns("downloadPDFBtn"),
label = "Download your pdf report here!",
onclick = sprintf('Shiny.setInputValue("%s", true);', ns("download_clicked")),
class = "download-button"
)
})
shinyjs::show(ns("downloadPDFBtn"), asis = TRUE)
} else{
showWarningModalNoFiles()
}
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
---
editor_options:
markdown:
wrap: 72
---

# PACE-HRH-UI

In the rapidly evolving landscape of population health management, there
Expand Down Expand Up @@ -49,16 +43,17 @@ local storage.

To install the app in a separate environment: <br> Download
`start_pace_ui.bat` and run it by double clicking it (or open a
commandline window to your downloaded folder to run it). This will
prompt you a [step by step guide](./Setup.md) for installation and
commandline window to your downloaded folder to run it). If this is your first time installing, please follow the [step by step guide](./Setup.md) for installation and
running the app. <br> Once installed on your desired folder, for future
use, you should go to the subfolder with name PACE-HRH-UI-{version} and
run the start_pace_ui.bat from there, this will start the app in offline mode and open
your default browser so that you can interact with it. To close the app,
simply press any key on the command prompt window. <br> You can zip this
pre-installed self-contained folder and send it to those who do not have
internet access, they should be able to run `start_pace_ui.bat` without
installation. <br>
installation. <br><br>
If you need to update the app when there is [new releases](https://github.com/InstituteforDiseaseModeling/PACE-HRH-UI/releases) available,
please follow the [upgrade existing app guide](./Update.md)

### Screenshots

Expand Down
40 changes: 30 additions & 10 deletions Setup.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
### Setup PACE-HRH-UI using batch script

1. Download [start_pace_ui.bat](https://github.com/InstituteforDiseaseModeling/PACE-HRH-UI/blob/main/start_pace_ui.bat) to your computer. ![](./screenshots/download_batch.png)

2. Double-click on the downloaded file `start_pace_ui.bat` to start the PACE-HRH-UI application installation. Note: Your computer's antivirus scan may prevent you from running it, click on "More Info" and "Run Anyway" to proceed. If this works, please go to step 3.![](./screenshots/defender.png)

Alternatively you can use command prompt window to run it. In Windows search bar, type `%windir%\system32\cmd.exe` and click `Open` ![](./screenshots/cmd.png)

This should open a command prompt window (cmd), you can navigate to the folder where you downloaded the file using `CD` command. For example `CD C:\Users\mewu\Downloads` Run the following command: `start_pace_ui.bat` ![](./screenshots/commandline.png)
1. Download [start_pace_ui.bat](https://github.com/InstituteforDiseaseModeling/PACE-HRH-UI/blob/main/start_pace_ui.bat) to your computer.
<br><br>
<img src="./screenshots/download_batch.png" width="600">
<br><br>
2. Double-click on the downloaded file `start_pace_ui.bat` to start the PACE-HRH-UI application installation. Note: Your computer's antivirus scan may prevent you from running it, click on "More Info" and "Run Anyway" to proceed.
<br><br>
<img src="./screenshots/defender.png" width="600">
<br><br>
If this works, please ignore the following instruction about commandline and go directly to step 3.
<br><br>
If this still doesn't work you can use command prompt window to run it. In Windows search bar, type `%windir%\system32\cmd.exe` and click `Open`
<br><br>
<img src="./screenshots/cmd.png" width="600">
<br><br>
This should open a command prompt window (cmd), you can navigate to the folder where you downloaded the file using `CD` command. For example `CD C:\Users\mewu\Downloads` Run the following command: `start_pace_ui.bat`. If the path has spaces, you will need to put the path in quotes. For example `CD "C:\Users\mewu\Download\My Test"` and then `start_pace_ui.bat`.
<br><br>
<img src="./screenshots/commandline.png" width="600">
<br><br>

#### Installation process <!-- {#installation} -->
3. When you start the application, you will see a command prompt window asking for installation location. **You must have internet for the first time installation.** (However,You will be able to zip this "installed folder" later and send it to those who do not have internet access for offline run). You can enter either absolute or relative path, the installation process does not accept an existing folder and will create the new folder for you. All the files needed to run will be installed into this location and you will need to launch the app from this location later. **Please write down the path so that you can remember it later.**
**You will also need to agree on our license terms in order to proceed.**![](./screenshots/prompt.png)
**You will also need to agree on our license terms in order to proceed.**
<br><br>
<img src="./screenshots/prompt.png" width="600">
<br><br>

4. The installation may take 5-10 minutes depending on your computer's processing power and internet speed. Once the installation is completed, you will see it asking you to reopen the `start_pace_ui.bat` from your chosen directory (The one you wrote down from step 3). You can now close the command prompt window and go to this folder, from there you can launch the app using the `start_pace_ui.bat` in offline mode. ![](./screenshots/success.png)
4. The installation may take 5-10 minutes depending on your computer's processing power and internet speed. Once the installation is completed, you will see it asking you to reopen the `start_pace_ui.bat` from your chosen directory (The one you wrote down from step 3). You can now close the command prompt window and go to this folder, from there you can launch the app using the `start_pace_ui.bat` in offline mode.
<br><br>
<img src="./screenshots/success.png" width="600">
<br><br>

5. **Make sure to go to folder of your choice from step3, then double click `start_pace_ui.bat` from your installed location**, it should open the app on port 8888 using your default browser. Leave the commandline window open while interacting with the app. ![](./screenshots/app.png)
5. **Make sure to go to folder of your choice from step3, then double click `start_pace_ui.bat` from your installed location**, it should open the app on port 8888 using your default browser. Leave the commandline window open while interacting with the app.
<br><br>
<img src="./screenshots/success.png" width="600">
32 changes: 32 additions & 0 deletions Update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
### Upgrade PACE-HRH-UI using batch script

1. Download [start_pace_ui.bat](https://github.com/InstituteforDiseaseModeling/PACE-HRH-UI/blob/main/start_pace_ui.bat) to your computer.
<br><br>
<img src="./screenshots/download_batch.png" width="600">
<br><br>
2. Double-click on the downloaded file `start_pace_ui.bat` to start the PACE-HRH-UI application installation. Note: Your computer's antivirus scan may prevent you from running it, click on "More Info" and "Run Anyway" to proceed.
<br><br>
<img src="./screenshots/defender.png" width="600">
<br><br>
If this works, please ignore the following instruction about commandline and go directly to step 3.
<br><br>
If this still doesn't work you can use command prompt window to run it. In Windows search bar, type `%windir%\system32\cmd.exe` and click `Open`
<br><br>
<img src="./screenshots/cmd.png" width="600">
<br><br>
This should open a command prompt window (cmd), you can navigate to the folder where you downloaded the file using `CD` command. For example `CD C:\Users\mewu\Downloads` Run the following command: `start_pace_ui.bat`. If the path has spaces, you will need to put the path in quotes. For example `CD "C:\Users\mewu\Download\My Test"` and then `start_pace_ui.bat`.
<br><br>
<img src="./screenshots/commandline.png" width="600">
<br><br>
3.When you start the application, you will see a command prompt window asking for installation location. Since you have already installed in before, please enter the location that you used before. Using two different installation locations on the same machine will result in unexpected behavior, so always remember the path of your previous installation and update from it. The folder you enter should be the folder which contains "PACE-HRH-UI" subfolder, for example: "pace_test" in the example shown below.
<br><br>
<img src="./screenshots/folder.png" width="600">
<br><br>
4. After you enter an existing location, it will ask you to confirm the update. Type `Y` and press `Enter` to confirm the update.
<br><br>
<img src="./screenshots/Confirm_update.png" width="600">
<br><br>
5. The script will prompt you for the version of the application you want to install. You can enter the version number you want to install. For example, if you want to install version 1.0.0, you can enter `1.0.0` and press `Enter`. If you just want to use default version, please press `Enter` directly.
<br><br>
<img src="./screenshots/Version.png" width="600">
6. Follow steps as shown in [Installation](Setup.md#installation) section.
Loading

0 comments on commit acb807f

Please sign in to comment.