Skip to content

Commit

Permalink
fixed video sync
Browse files Browse the repository at this point in the history
  • Loading branch information
camdnnn committed Jan 8, 2025
1 parent a8013f0 commit 7652d43
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions front-end/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dataviewer",
"version": "1.0.0",
"version": "1.2.0",
"private": true,
"type": "module",
"main": "build/main.js",
Expand Down Expand Up @@ -84,7 +84,7 @@
}
],
"artifactName": "${productName}-v${version}-installer.exe",
"requestedExecutionLevel": "asInvoker"
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"oneClick": false,
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/components/modal/download/DownloadModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const DownloadModal = ({ setModal }) => {

// Add each selected file to the zip archive
for (const file of selectedFiles) {
const blob = await ApiUtil.getFile(file.key);
const blob = await ApiUtil.getFileAsText(file.key);

// Add the file to the zip archive with the file name as the key
zip.file(file.key, blob);
Expand Down
2 changes: 1 addition & 1 deletion front-end/src/components/views/VideoPlayer/VideoPlayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const VideoPlayer = ({ video, setVideoTimestamp }) => {

useEffect(() => {
// Fetch data when the component mounts
ApiUtil.getFile(video.key)
ApiUtil.getFileAsBlob(video.key)
.then((blob) => {
const url = URL.createObjectURL(blob);
setVideoURL(url);
Expand Down
14 changes: 13 additions & 1 deletion front-end/src/lib/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ export const ApiUtil = {
* @param {string} fileKey - The unique identifier of the file.
* @returns {Promise<Blob>} A promise that resolves to the fetched file in the form of a Blob.
*/
getFile: async (fileKey: string) => {
getFileAsText: async (fileKey: string) => {
fileKey = encodeURIComponent(fileKey);
const response = await fetch(`${baseApiUrl}/files/${fileKey}`);
if (!response.ok) throw Error(response.statusText);
return response.text();
},

/**
* Sends a GET request to the server to fetch a specific file.
* @param {string} fileKey - The unique identifier of the file.
* @returns {Promise<Blob>} A promise that resolves to the fetched file in the form of a Blob.
*/
getFileAsBlob: async (fileKey: string) => {
fileKey = encodeURIComponent(fileKey);
const response = await fetch(`${baseApiUrl}/files/${fileKey}`);
if (!response.ok) throw Error(response.statusText);
return response.blob();
},

/**
* @description Fetches a list of files from the server.
* @returns {Promise<string[]>} A promise that resolves to an array of file names.
Expand Down
8 changes: 4 additions & 4 deletions front-end/src/lib/modelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const combineData = (timestamps: string[], x: string[], y: string[], z: string[]
export const fetchData = async (bin: string) => {
let data: quatReplayData = [];
await Promise.all([
ApiUtil.getFile(`${bin}/IMU QUAT W.csv`),
ApiUtil.getFile(`${bin}/IMU QUAT X.csv`),
ApiUtil.getFile(`${bin}/IMU QUAT Y.csv`),
ApiUtil.getFile(`${bin}/IMU QUAT Z.csv`)
ApiUtil.getFileAsText(`${bin}/IMU QUAT W.csv`),
ApiUtil.getFileAsText(`${bin}/IMU QUAT X.csv`),
ApiUtil.getFileAsText(`${bin}/IMU QUAT Y.csv`),
ApiUtil.getFileAsText(`${bin}/IMU QUAT Z.csv`)
]).then(([wDataRaw, xDataRaw, yDataRaw, zDataRaw]) => {
const wData = parseCSV(wDataRaw);
const xData = parseCSV(xDataRaw);
Expand Down

0 comments on commit 7652d43

Please sign in to comment.