Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: UI for loading CSVs (CSV pt. 3) #213

Merged
merged 43 commits into from
Dec 2, 2024

Conversation

ShrimpCryptid
Copy link
Contributor

@ShrimpCryptid ShrimpCryptid commented Oct 31, 2024

Problem

Closes #211, "prototype direct spreadsheet import."

Adds the ability to drag and drop CSVs onto the landing page and have them be opened as a dataset.

Estimated review size: small, 15-20 minutes

This PR also spins off into a few new issue tickets:

Solution

  • Changed imageDataset to be part of the redux-managed state, instead of an immutable global dependency. This lets it be changed at runtime when a CSV is uploaded.
  • Fix loading of thumbnails and volumes so they do not need to be relative paths.
  • Added the CsvUploadButton component, which handles logic for initializing the CSV dataset and replacing it in redux state.
    • Added related state/reducers/actions

Changes that still need to be made:

  • Page will load indefinitely if refreshed-- some sort of flag indicating that a CSV is loaded should be saved to the URL.
  • Add warnings/error handling for bad CSV data

Type of change

  • New feature (non-breaking change which adds functionality)

Steps to Verify:

  1. Download this example CSV: simple_test_dataset.csv
  2. Clone and run the branch.
  3. Open the landing page and scroll down to the CSV import area. Drag and drop (or upload) the example CSV.
  4. The dataset should load and be interactive.

Screenshots (optional):

Video Talk-through (🔊):

2024-11-15.13-46-31.mp4

image

@ShrimpCryptid ShrimpCryptid added the enhancement New feature or request label Oct 31, 2024
@ShrimpCryptid ShrimpCryptid self-assigned this Oct 31, 2024
Comment on lines 21 to 25
export interface ReduxLogicDeps {
action: AnyAction;
httpClient: AxiosInstance;
imageDataSet: ImageDataset;
getState: () => State;
ctx?: any;
Copy link
Contributor Author

@ShrimpCryptid ShrimpCryptid Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from logic dependencies into metadata new imageDataset state branch

src/components/CsvUpload/index.tsx Outdated Show resolved Hide resolved
src/state/selection/logics.ts Outdated Show resolved Hide resolved
src/state/selection/logics.ts Outdated Show resolved Hide resolved
src/state/selection/logics.ts Outdated Show resolved Hide resolved
@meganrm
Copy link
Contributor

meganrm commented Nov 21, 2024

@ShrimpCryptid I see a bunch of small things that need to be fixed, like using selectors instead of accessing state directly in your logics.

But I think we need to do a call to talk about the overall approach here. the original idea of the json verses firebase dataset is that the app is agnostic to where the data came from. So the fact that you're adding a new item in state seems wrong to me without digging in further (I've just done a surface level review of this)

UPDATE: I read the other PRs associated with this, and I'm now understanding better what you're doing here, I'll keep making comments

const thumbnailSrc = formatThumbnailSrc(
thumbnailRoot,
hoveredPointData?.thumbnailPath || ""
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we do this earlier? like in the image-dataset class functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, but I think I'd need to change functionality in the existing ImageDataset classes as well, and I didn't want to touch them too much in this PR.

<Descriptions.Item label={downloadInfo.date}>
<Descriptions.Item
label={downloadInfo.date}
key={index}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a key because React was complaining

Copy link
Contributor

@toloudis toloudis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

export function loadCsvDataset(payload: string): LoadCsvDatasetAction {
return {
payload,
type: LOAD_CSV_DATASET,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird formatting here: compare line 6 vs lines 10-13


<div className={styles.sectionContent}>
<CsvInput />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you load a CSV and then select one of the existing datasets afterwards?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loading a CSV immediately takes you to the plot view, so you can no longer select the JSON or Firebase datasets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if you hit back you can, and it's a SPA

Copy link
Contributor Author

@ShrimpCryptid ShrimpCryptid Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack !!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a ticket as #221. I've started tinkering with this but need more time to make the solution not too janky.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we headed with this? In my mind this PR was never meant to be released to production - it was just supposed to be something we could demo with BFF. IMO it's already gotten way more engineering than it initially deserved. The dynamic dataset changing is out of scope for the functionality we wanted to deliver. I suggest that we need to stop and decide what to do with this functionality.

Copy link
Contributor Author

@ShrimpCryptid ShrimpCryptid Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood! Yeah, my plan is to disable the UI component that gives access to CSVs once this PR has been approved, with #218 and #219 being next steps on this for a BFF demo.

Base automatically changed from feature/csv-loader-2 to feature/csv-datasets December 2, 2024 18:34
@ShrimpCryptid ShrimpCryptid merged commit 22e316d into feature/csv-datasets Dec 2, 2024
1 check passed
@ShrimpCryptid ShrimpCryptid deleted the feature/csv-loader branch December 2, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prototype direct spreadsheet import
3 participants