Spaces:
Running
Running
File size: 3,509 Bytes
8145f0e 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 8145f0e 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 5f02390 46f39c7 8145f0e 46f39c7 5f02390 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
library(shiny)
library(bs4Dash)
library(reactable)
library(openalexR)
library(shinyalert)
library(reactablefmtr)
library(shinycssloaders)
options(spinner.color.background = "#FFFFFF",
spinner.color = "#37a1e7",
spinner.size = 2)
ui <- dashboardPage(scrollToTop = T,
title = "OpenAlex4NodeXL",dark = NULL,help = NULL,
dashboardHeader(h2(strong("OpenAlex For NodeXL"),style = "margin-left:380px;color:#1b7ccc;")),
dashboardSidebar(id = "side",
actionButton("info",strong("Info"),style = "margin-left:75px;color:black;"),hr(),
h6(strong("Select Search Window"),style = "margin-left:35px;color:black;"),
dateInput("start",h6(strong("From"),style = "margin-left:80px;color:black;")),
dateInput("end",h6(strong("To"),style = "margin-left:90px;color:black;")),
textInput("text",h6(strong("Keyword Search"),style = "margin-left:40px;color:black;"),placeholder = "Enter keyword(s) here"),
actionButton("query",strong("Search"),icon = icon("search"),style = "margin-left:60px;color:black;"),hr(),
tags$a(href = "https://github.com/Ifeanyi55/OpenAlex4NodeXL", target = "_blank", h4(strong("GitHub"),icon("github", lib = "font-awesome"),style = "text-align:left;")),
minified = F),
dashboardBody(
includeCSS("styles.css"),
includeScript("code.js"),
fluidRow(
br(),style = "text-align:center;"),h4(strong("Author To Publication Network Data")),
withSpinner(reactableOutput("table",width = "100%",height = 400),type = 1),br(),
downloadButton("download",strong("Download CSV"),icon = icon("download"),style = "margin-left:1px;")
)
)
server <- function(input,output,session){
# read OpenAlex4NodeXL script
source("OpenAlex4NodeXL.R")
start_date <- reactive({input$start})
end_date <- reactive({input$end})
keywords <- reactive({input$text})
# make OpenAlex4NodeXL() a reactive function
OpenAlex4NodeXL_reactive <- reactive({
OpenAlex4NodeXL(
keywords = c(unlist(strsplit(keywords(),split = ","))),
pub_start_date = start_date(),
pub_end_date = end_date())
})
run_OpenAlex4NodeXL <- eventReactive(input$query,{
OpenAlex4NodeXL_reactive()
})
output$table <- renderReactable({
tryCatch(
{
reactable(run_OpenAlex4NodeXL(),
theme = reactableTheme(
borderColor = "#37a1e7",
borderWidth = 3
),
compact = T,
filterable = T,
bordered = T)
},
error = function(error){
safeError(error = "Please make sure to enter dates in chronological order")
}
)
})
# activate download handler
output$download <- downloadHandler(
filename = function(){
paste("Author2Pub",".csv",sep = "")
},
content = function(file){
write.csv(run_OpenAlex4NodeXL(),file,row.names = F)
}
)
observeEvent(input$info,{
shinyalert(title = "Info",
text = "Please note that the bigger the search window, the more data is collected. The more data is collected, the longer the runtime and the longer it takes to commence file download.",
confirmButtonCol = "#37a1e7",
closeOnEsc = T,
closeOnClickOutside = T,
showConfirmButton = T,
timer = 10000,
animation = "slide-from-top"
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
|