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

Vps 104/upload csv #116

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42,014 changes: 42,014 additions & 0 deletions frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"material-ui-image": "^3.3.2",
"node-sass": "^6.0.0",
"normalize.css": "^8.0.1",
"papaparse": "^5.4.1",
"react": "^17.0.2",
"react-audio-player": "^0.17.0",
"react-dom": "^17.0.2",
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/components/DraggableScene.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// DraggableScene.js
import React from "react";
import { useDrag } from "react-dnd";

Check failure on line 3 in frontend/src/components/DraggableScene.js

View workflow job for this annotation

GitHub Actions / Run linters frontend

Unable to resolve path to module 'react-dnd'

const DraggableScene = ({ scene, index, onDragStart }) => {

Check warning on line 5 in frontend/src/components/DraggableScene.js

View workflow job for this annotation

GitHub Actions / Run linters frontend

'scene' is defined but never used
const [{ isDragging }, drag] = useDrag({
type: "SCENE",
item: { index },
collect: (monitor) => ({
isDragging: !!monitor.isDragging(),
}),
begin: () => {
onDragStart(index);
},
});

return (
<div ref={drag} style={{ opacity: isDragging ? 0.5 : 1 }}>
{/* Render your scene component here */}
{/* For example: <div>{scene.name}</div> */}
</div>
);
};

export default DraggableScene;

Check failure on line 25 in frontend/src/components/DraggableScene.js

View workflow job for this annotation

GitHub Actions / Run linters frontend

Insert `⏎`
33 changes: 32 additions & 1 deletion frontend/src/containers/pages/SceneSelectionPage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useContext, useEffect, useState } from "react";
import React, { useContext, useEffect, useState, useRef } from "react";
import {
useParams,
Route,
useRouteMatch,
Switch,
useHistory,
} from "react-router-dom";
import Papa from "papaparse";
import { Button } from "@material-ui/core";
import TopBar from "../../components/TopBar";
import ListContainer from "../../components/ListContainer";
Expand Down Expand Up @@ -33,6 +34,20 @@ export function SceneSelectionPage({ data = null }) {
const { scenes, currentScene, setCurrentScene, reFetch } =
useContext(SceneContext);
const { getUserIdToken, VpsUser } = useContext(AuthenticationContext);
const fileInputRef = useRef(null);
const handCSVClick = () => {
fileInputRef.current.click();
};
const handleFileChange = (e) => {
const selectedFile = e.target.files[0];
Papa.parse(selectedFile, {
header: true,
skipEmptyLines: true,
complete(results) {
console.log(results.data);
},
});
};

/** called when the Add card is clicked */
async function createNewScene() {
Expand Down Expand Up @@ -173,6 +188,22 @@ export function SceneSelectionPage({ data = null }) {
>
Share
</Button>
<Button
className="btn top contained white"
color="default"
variant="outlined"
onClick={() => handCSVClick(true)}
>
Upload CSV
</Button>
<input
type="file"
ref={fileInputRef}
accept=".csv"
style={{ display: "none" }}
onChange={handleFileChange}
/>

<HelpButton />
</TopBar>
<ListContainer
Expand Down
526 changes: 281 additions & 245 deletions frontend/yarn.lock

Large diffs are not rendered by default.

Loading
Loading