I've made a Shiny app that connects to a remote database (PostgreSQL) to pull tables in order to display in my app and use the values from the tables to generate user-interactive plots(box-plots, scatter, histogram).
Another part of the app was to render HTML files that are hosted on a website, such as GitHub, in the app.
Here is a portion of the code I used:
output$genotyping <- renderUI({
if (creds_reactive()$user == "Admin") {
fluidPage(useShinyjs(),
titlePanel("Github HTML file"),
mainPanel(
h3("Click this button to display/hide the html file"),
br(),
br(),
actionButton("genotype", "Click me!"),
hidden(
div(id = 'text_div',
htmlOutput("includeHTML")
) )
)
) }
else {
mainPanel(
fluidRow(
align = "center",
h3("Sorry! You don't have the permissions required to view this content.")
)
)
}
})
request <- GET("link to html file")
github.html <-content(request, as ="text")
observeEvent(input$genotype, {
toggle('text_div')
output$includeHTML <- renderText({github.html})
})
I'm using code from here. However, it's quite outdated and Dropbox has since removed HTML rendering support/disabled some Java features so the HTML file doesn't load, so using Dropbox links in my code would generate a blank page in my app. Therefore, I'm using GitHub to store my file. The file itself is rather large, so GitHub itself can't render it. I've used the link to the raw code generated by github as well as raw.githack to render the file with a URL. Both options are able to render the HTML file in my app after the screen quickly refreshes. The problem is, all other interactive tables and plots can't be used after loading in the HTML file. Any tabs(from tabsetPanel) have their font turned red and can't load any of the tables and plots created from before.
I would store the report on a local drive/folder but that's not very practical as this is just one report(there will be many more and the EC2 instance I am using to run the shiny-server would get too full).
EDIT: I should note that even having it on a local folder and using includeHTML has the same problems as using the URL, so maybe it's just a problem with rendering HTML within a Shiny app?
I'm also not too sure how the http request works with the GET function. Is it creating a new connection that replaces the original one? Why aren't my plots/tables loading anymore after rendering in the HTML file via URL? Should I be disconnecting from the GET connection?
I'm also using a package called shinymanager to create a secure app login with credentials and passwords, so I have that "if" statement there to generate customized UI. shinyJS is also used here to create the hidden effect. Pressing a button will display/hide the report.
Let me know if there's anything else I can provide. Thanks.