diff --git a/app/Http/Controllers/Api/VideoAnnotationController.php b/app/Http/Controllers/Api/VideoAnnotationController.php index 619bd8aaa..f1ab24bcd 100644 --- a/app/Http/Controllers/Api/VideoAnnotationController.php +++ b/app/Http/Controllers/Api/VideoAnnotationController.php @@ -211,13 +211,8 @@ public function store(StoreVideoAnnotation $request) } } - // from a JSON request, the array may already be decoded $points = $request->input('points', []); - if (is_string($points)) { - $points = json_decode($points); - } - $annotation = new VideoAnnotation([ 'video_id' => $request->video->id, 'shape_id' => $request->input('shape_id'), diff --git a/app/Http/Controllers/Views/Videos/VideoAnnotationController.php b/app/Http/Controllers/Views/Videos/VideoAnnotationController.php index bd82a7c01..d5140a88f 100644 --- a/app/Http/Controllers/Views/Videos/VideoAnnotationController.php +++ b/app/Http/Controllers/Views/Videos/VideoAnnotationController.php @@ -18,7 +18,7 @@ public function show($id) $annotation = VideoAnnotation::findOrFail($id); $this->authorize('access', $annotation); - return redirect()->route('video', [ + return redirect()->route('video-annotate', [ 'id' => $annotation->video_id, 'annotation' => $annotation->id, ]); diff --git a/app/Http/Controllers/Views/Volumes/VideoController.php b/app/Http/Controllers/Views/Volumes/VideoController.php new file mode 100644 index 000000000..67dc46bc5 --- /dev/null +++ b/app/Http/Controllers/Views/Volumes/VideoController.php @@ -0,0 +1,36 @@ +findOrFail($id); + + $this->authorize('access', $video); + + $metadataMap = [ + 'gps_altitude' => 'GPS Altitude', + 'distance_to_ground' => 'Distance to ground', + 'yaw' => 'Yaw/Heading', + 'area' => 'Area', + ]; + + return view('volumes.videos.index', [ + 'video' => $video, + 'volume' => $video->volume, + 'metadata' => Arr::only($video->metadata, array_keys($metadataMap)), + 'metadataMap' => $metadataMap, + ]); + } +} diff --git a/app/Http/Requests/StoreVideoAnnotation.php b/app/Http/Requests/StoreVideoAnnotation.php index 1a9d18ff1..b42d2dd33 100644 --- a/app/Http/Requests/StoreVideoAnnotation.php +++ b/app/Http/Requests/StoreVideoAnnotation.php @@ -41,6 +41,8 @@ public function rules() 'required_unless:shape_id,'.Shape::wholeFrameId(), 'array', ], + 'points.*' => 'array', + 'points.*.*' => 'numeric', 'frames' => 'required|array', 'frames.*' => 'required|numeric|min:0|max:'.$this->video->duration, 'track' => 'filled|boolean', @@ -67,18 +69,13 @@ public function withValidator($validator) $validator->errors()->add('frames', 'A new whole frame annotation must not have more than two frames.'); } - $points = $this->input('points', []); - $allArrays = array_reduce($points, fn ($c, $i) => $c && is_array($i), true); - - if (!$allArrays) { - $validator->errors()->add('points', 'The points must be an array of arrays.'); - } if ($this->shouldTrack()) { if ($frameCount !== 1) { $validator->errors()->add('id', 'Only single frame annotations can be tracked.'); } + $points = $this->input('points', []); if (count($points) !== 1) { $validator->errors()->add('id', 'Only single frame annotations can be tracked.'); } diff --git a/resources/assets/js/volumes/components/metadataModal.vue b/resources/assets/js/volumes/components/metadataModal.vue new file mode 100644 index 000000000..3367f43a2 --- /dev/null +++ b/resources/assets/js/volumes/components/metadataModal.vue @@ -0,0 +1,81 @@ + + + diff --git a/resources/assets/js/volumes/main.js b/resources/assets/js/volumes/main.js index 396be858c..2982cdba7 100644 --- a/resources/assets/js/volumes/main.js +++ b/resources/assets/js/volumes/main.js @@ -14,6 +14,7 @@ import MetadataUpload from './metadataUpload'; import ProjectsBreadcrumb from './projectsBreadcrumb'; import SearchResults from './searchResults'; import VolumeContainer from './volumeContainer'; +import VideoMetadata from './videoMetadata.vue'; biigle.$mount('annotation-session-panel', AnnotationSessionPanel); biigle.$mount('create-volume-form-step-1', CreateFormStep1); @@ -30,3 +31,4 @@ biigle.$mount('search-results', SearchResults); biigle.$mount('volume-container', VolumeContainer); biigle.$mount('volume-file-count', FileCount); biigle.$mount('volume-metadata-upload', MetadataUpload); +biigle.$mount('video-metadata-modal', VideoMetadata); diff --git a/resources/assets/js/volumes/videoMetadata.vue b/resources/assets/js/volumes/videoMetadata.vue new file mode 100644 index 000000000..afc5e59a8 --- /dev/null +++ b/resources/assets/js/volumes/videoMetadata.vue @@ -0,0 +1,62 @@ + diff --git a/resources/views/search/videos-content.blade.php b/resources/views/search/videos-content.blade.php index 7e68e9711..4e036a7da 100644 --- a/resources/views/search/videos-content.blade.php +++ b/resources/views/search/videos-content.blade.php @@ -3,7 +3,7 @@