DickinsonCollege / FD2School-FarmData2-S23

A fork of FarmData2 that is used for the FarmData2 School Activities.
Other
1 stars 36 forks source link

Save CSV To Specific Directory #255

Open braughtg opened 11 months ago

braughtg commented 11 months ago

Current Functionality

currentFunc
clicking the export button simply saves the file in the user's downloads folder.

Desired Functionality

An enhancement of this feature would be allowing users to decide where they want the csv file to be saved on their system. They would click the export button but instead of the file automatically saving into their downloads folder, a file explorer window would open up and allow the user to pick which directory they would like to save the csv file in. desiredFunc
here's a quick example using Microsoft Word.

The CSV function is located inside of the CustomTableComponent.js file. Altering this file means the contributor should also add an additional test into the CustomTableComponent.spec.comp.js file if possible (or opening another issue so somebody else can do it) to make sure that the file has full coverage of the component's functionality.

Good place to start: here

braughtg commented 11 months ago

For anyone seeking to resolve this issue, there are some pretty conflicting responses on whether or not saving to a specific directory is possible. [This] StackOverFlow forum has many users noting that it's impossible because it would pose a serious security threat to users. However, [this] website has an example of saving a file to a specific directory location. It's incompatible with Firefox though, and I wasn't able to make it work on Google Chrome or Edge as it suggests you use. It mentions using the [File System Access] but this might involve incorporating this project into our own which might be undesirable. There seems to be a much newer, and more maintained, project that could be a helpful resource. The [File System Standard] seeks to,

define[s] an API that makes it possible for websites to get access to a file system directory without having to first prompt the user for access. This enables use cases where a website wants to save data to disk before a user has picked a location to save to, without forcing the website to use a completely different storage mechanism with a different API for such files.

This project's GitHub repo can be found [here] but this could also mean incorporating something into the project that might be undesirable for functionality that's more of a leisure than a necessity.

Additional resources: Note, the goal is to save a file to the system with a file explorer that allows the user to specify where in the system they want to save the file.

  1. StackOverFlow forum post that details how to open the file explorer using JQuery [link]
  2. Codepen demonstrating how to open the file explorer [link]

Comment by FutzMonitor Tuesday Feb 21, 2023 at 15:00 GMT

braughtg commented 11 months ago

If this was an implemented feature, would it be worthwhile to add another issue allowing admins to configure whether the CSV is downloaded straight to the downloads folder or a specified directory?

I think so since it would be nice to switch between the two. This would necessitate more updates to the CustomTable, UI, and both their testing files.


Comment by FutzMonitor Friday Mar 03, 2023 at 16:52 GMT

braughtg commented 11 months ago

If this was an implemented feature, would it be worthwhile to add another issue allowing admins to configure whether the CSV is downloaded straight to the downloads folder or a specified directory?

Possibly a simpler solution would be to have the "Save As" dialog that would open default either to Downloads, or preferably just to the last location that the user had used. That's still 2 clicks instead of 1 to get something into downloads if that is where you always put it. But I am hesitant to make more configuration options than we really really need.

That said, when someone works on this issue we can revisit this point.


Comment by braughtg Friday Mar 03, 2023 at 19:54 GMT