-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1014 from ToukL/video-info-view
Add video info view
- Loading branch information
Showing
13 changed files
with
329 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Biigle\Http\Controllers\Views\Volumes; | ||
|
||
use Arr; | ||
use Biigle\Http\Controllers\Views\Controller; | ||
use Biigle\Video; | ||
|
||
class VideoController extends Controller | ||
{ | ||
/** | ||
* Shows the video index page. | ||
* | ||
* @param int $id volume ID | ||
*/ | ||
public function index($id) | ||
{ | ||
$video = Video::with('volume')->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, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<modal | ||
ref="modal" | ||
v-model="show" | ||
size="md" | ||
:title="name" | ||
:footer="false" | ||
> | ||
<div class="panel panel-default"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th class="text-center" v-if="times">{{ "Time" }}</th> | ||
<th class="text-center" v-if="name !== 'Times'">{{ name }}</th> | ||
</tr> | ||
</thead> | ||
<tbody v-if="name === 'Times'"> | ||
<tr v-for="time in times"> | ||
<td class="text-center">{{ time }}</td> | ||
</tr> | ||
</tbody> | ||
<tbody v-else-if="times.length === items.length"> | ||
<tr v-for="(item, index) in items"> | ||
<td class="text-center">{{ times[index] }}</td> | ||
<td class="text-center">{{ item }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</modal> | ||
</template> | ||
|
||
<script> | ||
import { Modal } from 'uiv'; | ||
export default { | ||
components: { | ||
modal: Modal, | ||
}, | ||
props: { | ||
showModal: { | ||
required: true, | ||
type: Boolean, | ||
}, | ||
times: { | ||
required: true, | ||
type: Array, | ||
}, | ||
items: { | ||
required: true, | ||
type: Array, | ||
}, | ||
name: { | ||
required: true, | ||
type: String, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
show: false, | ||
}; | ||
}, | ||
watch: { | ||
// if volume-metadata-button pressed, trigger modal | ||
showModal: function () { | ||
if (this.showModal) { | ||
this.show = true; | ||
} | ||
}, | ||
// if modal is closed, trigger the close-modal-event, which sets 'showModal' in parent container to false again | ||
show: function() { | ||
if (this.show === false) { | ||
this.$emit('close-modal'); | ||
} | ||
} | ||
}, | ||
created() { | ||
this.show = false; | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script> | ||
import LoaderMixin from '../core/mixins/loader'; | ||
import Messages from '../core/messages/store'; | ||
import metadataModal from './components/metadataModal'; | ||
/** | ||
* The video container for metadata. | ||
*/ | ||
export default { | ||
mixins: [ | ||
LoaderMixin, | ||
], | ||
components: { | ||
metadataModal: metadataModal, | ||
}, | ||
data() { | ||
return { | ||
showModal: false, | ||
metadata: null, | ||
metadataMap: {}, | ||
times: [], | ||
items: [], | ||
name: "", | ||
}; | ||
}, | ||
methods: { | ||
getTimes(values) { | ||
// If modal has been opened before, use cached data | ||
if (this.times.length === 0) { | ||
let dateStrings = []; | ||
const options = { year: "numeric", month: "numeric", day: "numeric", hour: '2-digit', minute:'2-digit', second:'2-digit'} | ||
values.forEach(element => { | ||
dateStrings.push(new Date(element).toLocaleDateString(undefined, options)); | ||
}); | ||
this.times = dateStrings; | ||
} | ||
}, | ||
showTimes() { | ||
if (this.times.length === 0) | ||
this.handleError("No times data found."); | ||
this.name = "Times"; | ||
this.showModal = true; | ||
}, | ||
showMetadata(field) { | ||
this.name = this.metadataMap[field]; | ||
this.items = this.metadata[field]; | ||
this.showModal = true; | ||
}, | ||
hideMetadataModal() { | ||
this.showModal = false; | ||
}, | ||
handleError(message) { | ||
Messages.danger(message); | ||
}, | ||
}, | ||
created() { | ||
this.getTimes(biigle.$require('videos.times')); | ||
this.metadata = biigle.$require('videos.metadata'); | ||
this.metadataMap = biigle.$require('videos.metadataMap'); | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@extends('app') | ||
@section('title', $video->filename) | ||
|
||
@section('content') | ||
<div class="container"> | ||
<div class="row"> | ||
<h2 class="col-lg-12 clearfix file-info-title" title="{{ $video->filename }}"> | ||
{{ $video->filename }} | ||
<span class="pull-right"> | ||
<a href="{{route('volume', $volume->id)}}" title="Back to {{ $volume->name }}" class="btn btn-default">back</a> | ||
@mixin('imagesIndexButtons') | ||
</span> | ||
</h2> | ||
</div> | ||
<div class="row"> | ||
<div class="col-sm-6 col-lg-4"> | ||
<div class="panel panel-default panel-image"> | ||
<img src="{{ $video->thumbnail_url }}" onerror="this.src='{{ asset(config('thumbnails.empty_url')) }}'"> | ||
</div> | ||
@include('volumes.videos.index.meta') | ||
</div> | ||
</div> | ||
</div> | ||
@endsection | ||
|
||
@section('navbar') | ||
<div class="navbar-text navbar-volumes-breadcrumbs"> | ||
@include('volumes.partials.projectsBreadcrumb', ['projects' => $volume->projects]) / | ||
<a href="{{route('volume', $volume->id)}}" class="navbar-link" title="Show volume {{$volume->name}}">{{$volume->name}}</a> / | ||
<strong title="{{$video->filename}}">{{$video->filename}}</strong> | ||
@include('volumes.partials.annotationSessionIndicator') | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@push('scripts') | ||
<script type="text/javascript"> | ||
biigle.$declare('videos.times', {!! collect($video->taken_at) !!}); | ||
biigle.$declare('videos.metadata', {!! collect($video->metadata) !!}); | ||
biigle.$declare('videos.metadataMap', {!! collect($metadataMap) !!}); | ||
</script> | ||
@endpush | ||
|
||
<div id="video-metadata-modal" class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Video information</h3> | ||
</div> | ||
<table class="table"> | ||
@if ($video->width && $video->height) | ||
<tr> | ||
<th>Dimensions</th> | ||
<td>{{ $video->width }} × {{ $video->height }} px </td> | ||
</tr> | ||
@endif | ||
@if ($video->size) | ||
<tr> | ||
<th>Size</th> | ||
<td>{{ round($video->size / 1E+6, 2) }} MBytes </td> | ||
</tr> | ||
@endif | ||
@if ($video->mimetype) | ||
<tr> | ||
<th>MIME</th> | ||
<td><code>{{ $video->mimetype }}</code></td> | ||
</tr> | ||
@endif | ||
@if ($video->taken_at) | ||
@if (is_array($video->taken_at)) | ||
<metadata-modal v-bind:show-modal="showModal" v-bind:times="times" v-bind:items="items" v-bind:name="name" v-on:close-modal="hideMetadataModal"></metadata-modal> | ||
<tr> | ||
<th> | ||
<a href="#" v-on:click.prevent="showTimes()">Created</a> | ||
</th> | ||
<td></td> | ||
</tr> | ||
@foreach ($metadata as $field => $value) | ||
<tr> | ||
@if (is_array($value)) | ||
<th> | ||
<a href="#" v-on:click.prevent="showMetadata({{ json_encode($field) }})">{{ $metadataMap[$field] }}</a> | ||
</th> | ||
<td></td> | ||
@else | ||
<th>{{ $metadataMap[$field] }}</th> | ||
<td>{{ $value }}</td> | ||
@endif | ||
</tr> | ||
@endforeach | ||
@else | ||
<tr> | ||
<th>Created</th> | ||
<td>{{ $video->taken_at }}</td> | ||
</tr> | ||
@foreach ($metadata as $field => $value) | ||
<tr> | ||
<th>{{ $metadataMap[$field] }}</th> | ||
<td>{{ $value }}</td> | ||
</tr> | ||
@endforeach | ||
@endif | ||
@endif | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.