Using dateInput on a CRUD Shiny app - r

I am looking for some assistance regarding using a dateInput in a CRUD app. I used the source code from the iPub blog post about CRUD Shiny Apps : https://ipub.com/shiny-crud-app/
I've been trying to modify the code so that there is a dateInput. I was able to get the format to be a date (different source code than below) but it will only show the current date even when you change the input. The solve on that code does not work on the sample code below and this will also demo that the date will not change.
I'm getting only characters instead of a date format and it is the same characters/dates regardless of what is selected via the input.
https://gist.github.com/john-magrini/c9a6a5cf11653b40edc77cffbe632f8b
Thanks in advance!

Related

Integrating Seurat CellSelector function inside a shiny app

I'm writing a ShinyApp which presents Seurat data. I want the app users to be able to select specific cell for later comparison and analysis. I want the cellSelcetor to be activated when a button is pressed, so I tried:
observeEvent(input$selectCells, {
output$clusterCompPlot <- renderPlot({CellSelector(plot = chosenClusterPlot)})
})
The problem is, I think, that cellSelector is already based on shiny, so I'm currently getting the following error:
Error in shiny::runApp: Can't call runApp() from within runApp(). If your application code contains runApp(), please remove it.
Is there any way to integrate this feature into my app?
Thanks!

R Shiny - Run application in background and issue UI controls with code

I am writing a vignette for my Shiny application package. At the beginning of my vignette, I source a file called screenshots.R that produces nice screenshots of my application. I am producing them like so:
webshot::appshot(mypackage::run_datepicker_app(),
file = "man/figures/datepicker.png", vwidth = 500, vheight = 200)
This works great and it gives me a great screenshot of what is - in this case - a couple dateInput fields. However, I'd like to be able to get a screenshot of the dateInput in use (say, with the calendar selection exposed).
Is there a way to issue commands to the application object in a script so I can get screenshots of the application in use, rather than having to do it manually?
Have you tried using ShinyDriver from the shinytest package?
You can use shinytest to have a headless browser run the app, interact with it, and take screenshots programmatically. If you don't have phantomJS installed, you'll need to run shinytest::installDependencies() before using ShinyDriver. All you need to do is point it to a directory containing a shiny app (in my case, the folder is 'myApp').
install.packages("shinytest")
shinytest::installDependencies()
app <- shinytest::ShinyDriver$new("myApp")
app$takeScreenshot("screenshot1.png")
button <- app$findElement("#button")
button$click()
Sys.sleep(1)
app$takeScreenshot("screenshot2.png")
app$stop()
I am starting the app in a headless browser, taking a screenshot, finding the button with the id 'button', clicking it, and taking another screenshot, then closing the app. Navigate to specific elements using "#id", where id is just the id you gave the shiny input. You can specify a file path to a png file in the takeScreenshot calls, so that you can then use them in your code elsewhere. Note that you may need to use Sys.sleep to stop the screenshots from being taken before the UI updates.

R Highcharter: How to show No Data to Display message?

I have created a dynamic Highchart in R Shiny App. I want to display a customized message when there is no data to display the charts.
In Highchart API, there is setOptions where you can display the customized message. Something similar is mentioned in this question: How to display No Data Available Message in highcharts.
But I haven't found anything similar in Highcharter.
Any solutions?
Within your renderHighcharter function, you can put something like this:
shiny::validate(
need((nrow(DataSet()) != 0), "No data available based on your selection")
)
You can have as many validate functions that you need and make them as complicated as you need to help the user troubleshoot.

How to get the correct LastModifiedDate from SPFile in SP2013

I've got a Issue with SharePoint 2013 Files in Libraries. If I push an File via WebDAV into an Folder the file will still hold it's created/modified date (and that's good!).
Other Case is: I use the "New Document" Upload Form - the File will be newly created and loses its correct created/modified date.
I'm looking for a way to get these correct Values of the SPFile Item.
DateTime modified = Li.File.TimeLastModified;
That's my current attempt to get the DateTime but it only retrieves the "sharepoint" value and not the "filesystem" value of the LastModifiedDate.
I tried to let my Webpart open the File on the server.. but URI-Formats arent supported :-(
Has anybody already run into this problem?
Thanks for your help in advance!
EDIT:
This is what I get in explorer view of the document library. For example the file lync.PNG has a last modified date of 26.12.2013.
this is what I get from my webpart using the code snippet (sorry for the german description; "geƤndert am" means lastmodifieddate)
You can get the modified date that SharePoint uses by getting the Item of the SPFile then reading the date property. Something like this:
DateTime date = DateTime.Parse(file.Item["Modified"].ToString());
Once its in SharePoint any changes should come from the modified property of the item. You would have to use an event receiver to capture the original file date and then overwrite the SharePoint created date, or add the value to another field in the item.
Hope this helps.

Notifying user about his bad input in Shiny app

Let's take a look at one of the demos.
runExample("09_upload")
I am using the supplied file to perform some computations and to display an aggregated performance across all uploaded files. Therefore, I use something like
tryCatch(compute.smth(), error=function(e){})
so that the displayed result is not affected by the bad input. However, I'd like to indicate somehow that uploading the bad file lead to an error, notifying the user about the problem with his input. It'll be something like
tryCatch(compute.smth(), error=badFile())
where badFile() should modify some displayable output. Any ideas?
As a last resort, this is probably an option, but I'd like some native Shiny.
You can show alerts like below with the ShinySky package: https://github.com/AnalytixWare/ShinySky
You can install the package using
install.packages("devtools")#if not alrady installed
devtools::install_github("ShinySky","AnalytixWare")
Place a shinyalert(id) in the ui.R for where you want the alert to appear.
In your server.R
Make sure you have a 3 parameters funciton being passed to shinyServer e.g.shinyServer(function(input, output,session) {
use showshinyalert(id,HTMLText,session) to show the alert. Clicking on the alert will dismiss it.
See this gist for example https://gist.github.com/xiaodaigh/7707701
Run this too see an example
shinysky::run.shinysky.example()

Resources