From 124e833d28e2f7981d05d5579c7a94e9e3fd98d8 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Wed, 25 Jan 2023 12:42:33 +0100 Subject: [PATCH] Added working exercise submission. --- .../service/ExerciseSubmissionService.java | 3 +- gymboard-app/src/api/gymboard-api.ts | 27 ++++++++ .../src/pages/gym/GymSubmissionPage.vue | 66 +++++++++++++++---- 3 files changed, 81 insertions(+), 15 deletions(-) diff --git a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java index 2c3c58e..6c2ab58 100644 --- a/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java +++ b/gymboard-api/src/main/java/nl/andrewlalis/gymboard_api/service/ExerciseSubmissionService.java @@ -167,7 +167,7 @@ public class ExerciseSubmissionService { Path dir = tempFilePath.getParent(); String tempFileName = tempFilePath.getFileName().toString(); String tempFileBaseName = tempFileName.substring(0, tempFileName.length() - ".tmp".length()); - Path outFilePath = dir.resolve(tempFileBaseName + "-out.tmp"); + Path outFilePath = dir.resolve(tempFileBaseName + "-out.mp4"); StoredFile file; try { processVideo(dir, tempFilePath, outFilePath); @@ -229,7 +229,6 @@ public class ExerciseSubmissionService { .command(command) .redirectOutput(tmpStdout.toFile()) .redirectError(tmpStderr.toFile()) - .redirectInput(ProcessBuilder.Redirect.DISCARD) .directory(dir.toFile()) .start(); int result = ffmpegProcess.waitFor(); diff --git a/gymboard-app/src/api/gymboard-api.ts b/gymboard-app/src/api/gymboard-api.ts index ac5e808..b1dac84 100644 --- a/gymboard-app/src/api/gymboard-api.ts +++ b/gymboard-app/src/api/gymboard-api.ts @@ -6,6 +6,7 @@ export const BASE_URL = 'http://localhost:8080'; const api = axios.create({ baseURL: BASE_URL }); +api.defaults.headers.post['Content-Type'] = 'application/json'; export interface Exercise { shortName: string, @@ -25,6 +26,17 @@ export interface ExerciseSubmissionPayload { videoId: number } +export interface ExerciseSubmission { + id: number, + createdAt: string, + gym: SimpleGym, + exercise: Exercise, + status: string, + submitterName: string, + weight: number, + reps: number +} + export interface Gym { countryCode: string, countryName: string, @@ -38,6 +50,13 @@ export interface Gym { streetAddress: string } +export interface SimpleGym { + countryCode: string, + cityShortName: string, + shortName: string, + displayName: string +} + /** * Gets the URL for uploading a video file when creating an exercise submission * for a gym. @@ -82,3 +101,11 @@ export async function getGym( streetAddress: d.streetAddress, }; } + +export async function createSubmission(gym: Gym, payload: ExerciseSubmissionPayload): Promise { + const response = await api.post( + `/gyms/${gym.countryCode}/${gym.cityShortName}/${gym.shortName}/submissions`, + payload + ); + return response.data; +} diff --git a/gymboard-app/src/pages/gym/GymSubmissionPage.vue b/gymboard-app/src/pages/gym/GymSubmissionPage.vue index 4d9f87b..41e5aac 100644 --- a/gymboard-app/src/pages/gym/GymSubmissionPage.vue +++ b/gymboard-app/src/pages/gym/GymSubmissionPage.vue @@ -2,10 +2,19 @@ +
+ +
@@ -27,7 +36,7 @@
@@ -39,12 +48,22 @@ class="col-12" /> +
+ +
@@ -54,26 +73,35 @@