Hi, I am trying to deploy my shiny application and I get an error that my content cannot be published. I do not understand exactly why.
I would be very grateful If anyone could help me with that because I really need to publish this app
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(DT)
library(shinyjs)
library(sodium)
library(ggplot2)
library(hrbrthemes)
library(readxl)
library(rsconnect)
StudentProgress2 <- read_excel("StudentProgress2.xlsx")
StudentProgress2$Week <- as.integer(StudentProgress2$Week)
#Code test login page + dashboard
# Main log in screen
loginpage <- div(id = "loginpage", style = "width: 500px; max-width: 100%; margin: 0 auto; padding: 20px;",
wellPanel(
tags$h2("LOG IN", class = "text-center", style = "padding-top: 0;color:#333; font-weight:600;"),
textInput("userName", placeholder="Username", label = tagList(icon("user"), "Username")),
passwordInput("passwd", placeholder="Password", label = tagList(icon("unlock-alt"), "Password")
),
setBackgroundImage(
src = "https://www.datocms-assets.com/32427/1631000692-image.png?auto=format&max-w=980",
shinydashboard = TRUE
),
br(),
div(
style = "text-align: center;",
actionButton("login", "SIGN IN", style = "color: white; background-color:#3c8dbc;
padding: 10px 15px; width: 150px; cursor: pointer;
font-size: 18px; font-weight: 600;"),
shinyjs::hidden(
div(id = "nomatch",
tags$p("Oops! Incorrect username or password!",
style = "color: red; font-weight: 600;
padding-top: 5px;font-size:16px;",
class = "text-center"))),
br(),
br(),
tags$code(""),
br(),
tags$code("")
)),
)
credentials = data.frame(
username_id = c("mariasilva", "myuser1"),
passod = sapply(c("mypass", "mypass1"),password_store),
permission = c("basic", "advanced"),
stringsAsFactors = F
)
header <- dashboardHeader (userOutput("navbarPage"), userOutput("user"), dropdownMenu(type = "tasks", badgeStatus = "success",
taskItem(value = 100, color = "green",
"Profile Setup"
),
taskItem(value = 100, color = "aqua",
"Introducing Arduino"
),
taskItem(value = 10, color = "yellow",
"My First Project"
),
taskItem(value = 0, color = "red",
"Adicional Tasks"
)
))
sidebar <- dashboardSidebar(uiOutput("sidebarpanel"))
body <- dashboardBody(shinyjs::useShinyjs(), uiOutput("body"))
ui<-dashboardPage(header, sidebar, body, skin = "yellow")
server <- function(input, output, session) {
login = FALSE
USER <- reactiveValues(login = login)
observe({
if (USER$login == FALSE) {
if (!is.null(input$login)) {
if (input$login > 0) {
Username <- isolate(input$userName)
Password <- isolate(input$passwd)
if(length(which(credentials$username_id==Username))==1) {
pasmatch <- credentials["passod"][which(credentials$username_id==Username),]
pasverify <- password_verify(pasmatch, Password)
if(pasverify) {
USER$login <- TRUE
} else {
shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade")
shinyjs::delay(3000, shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade"))
}
} else {
shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade")
shinyjs::delay(3000, shinyjs::toggle(id = "nomatch", anim = TRUE, time = 1, animType = "fade"))
}
}
}
}
})
output$logoutbtn <- renderUI({
req(USER$login)
tags$li(a(icon("sign-out-alt"), "Logout",
href="javascript:window.location.reload(true)"),
class = "dropdown",
style = "background-color: #eee !important; border: 0;
font-weight: bold; margin:5px; padding: 10px;")
})
output$navbarPage <- renderUI({
if (USER$login == TRUE){
navbarPage(tabPanel("AppPR",
includeHTML("home.html"),
includeCSS("stylesheet.css")))
}
})
output$sidebarpanel <- renderUI({
if (USER$login == TRUE ){
sidebarMenu(
menuItem("My Courses", tabName = "dashboard", icon = icon("book-reader")),
menuItem("My Progress", tabName = "second", icon = icon("chart-line")),
menuItem("My Results", tabName = "results", icon = icon("poll-h")),
menuItem("My Letters", tabName = "letters", icon = icon("envelope"))
)
}
})
output$body <- renderUI({
if (USER$login == TRUE ) {
tabItems(
# First tab
tabItem(tabName ="dashboard", class = "active",
fluidRow(box(title = "I need to Google something", "Click on the icon to search for something",
shiny::actionButton(inputId='ab1', label="Search",
icon = icon("google"),
onclick ="window.open('https://www.google.com/', '_blank')")
),
box(title = "Check your courses", "Click on the icon to go to your Arduino course page",
shiny::actionButton(inputId='ab1', label="Arduino Education",
icon = icon("laptop-code"),
onclick ="window.open('https://classroom.arduino.cc/?_gl=1*1wqybs1*_ga*MTQ1MzQzMzkuMTYzMTg5ODIyNg..*_ga_NEXN8H46L5*MTYzODIyMjAxOC4zMi4xLjE2MzgyMjIwMjkuMA..', '_blank')")
),
box(width = 12, dataTableOutput('results'), title = "Grades Overview"))
),
# Second tab
tabItem(tabName = "second",
fluidRow(
box(
title = "Today's Learning",
"How difficult the lessons of today was? ", br(),
sliderInput("slider", "Slider input:", 1, 100, 50),
textInput("text", "What was more difficult for me?"),
submitButton("Submit")
)
)
),
#Third tab
tabItem(tabName = "results",
fluidPage(
tags$head(
tags$style(HTML(".bucket-list-container {min-height: 350px;}"))
),
fluidRow(
titlePanel("Grades of courses in the past 10 weeks"),
sidebarLayout(
sidebarPanel(
selectizeInput("weekInput", "Week",
choices = unique(StudentProgress2$Week),
selected = c(1,2,3,4,5,6,7,8,9,10), multiple = TRUE),
checkboxGroupInput("courseInput", "Course",
choices = c("ArduinoIntroduction",
"BasicFunctions",
"ProjectBasics",
"TasksManagement"),
selected = c("ArduinoIntroduction",
"BasicFunctions",
"ProjectBasics",
"TasksManagement"))
),
mainPanel(
plotOutput("coursegradesplot"),
br(), br(),
verbatimTextOutput("random text")
)
)
)
)
)
,
tabItem(tabName = "letters",
fluidPage(
textAreaInput("caption", "Dear Sponsor", "I would like to let you know that", width = "10000px", rows = 15),
submitButton("Submit"),
verbatimTextOutput("caption")
)
)
)
}
else {
loginpage
}
})
output$results_1 <-
renderPrint(
input$rank_list_1 # This matches the input_id of the first rank list
)
output$results_2 <-
renderPrint(
input$rank_list_2 # This matches the input_id of the second rank list
)
output$results_3 <-
renderPrint(
input$bucket_list_group # Matches the group_name of the bucket list
)
output$results <- DT::renderDataTable({
datatable(StudentProgressWeek, options = list(autoWidth = TRUE,
searching = FALSE))
})
d <- reactive({
StudentProgress2 %>%
filter(Week %in% input$weekInput,
Course %in% input$courseInput)
})
output$coursegradesplot <- renderPlot({
ggplot(d(), aes(x=Week, y = Grade, color=Course)) +
geom_line() +
theme_bw() +
xlab("Week") +
ylab("Grade") +
ggtitle("Grades over time") +
scale_x_discrete("Week", limits = c("1","2","3",'4','5','6','7','8','9','10'))
})
output$stats <- renderPrint({
aggregate(Grade ~ Course, data = d(), mean)
})
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$user <- renderUser({
if (USER$login == TRUE ) {
dashboardUser(
name = "Maria Silva",
image = "https://cdn4.iconfinder.com/data/icons/avatars-xmas-giveaway/128/girl_avatar_child_kid-512.png",
title = "Student",
subtitle = "level 1",
footer = uiOutput("logoutbtn"),
fluidRow(
dashboardUserItem(
width = 6,
socialButton(
href = "https://classroom.arduino.cc/?_gl=1*9d4fsz*_ga*MTQ1MzQzMzkuMTYzMTg5ODIyNg..*_ga_NEXN8H46L5*MTYzNTkzNTM5MC4yNS4wLjE2MzU5MzUzOTAuMA..",
icon = icon("mouse-pointer")
)
),
dashboardUserItem(
width = 6,
socialButton(
href = "https://app.mystudylife.com/dashboard",
icon = icon("tasks")
)
)
)
)
}
})
}
runApp(list(ui = ui, server = server), launch.browser = TRUE)