Skip to content

Commit

Permalink
Add icons and custome viewer header
Browse files Browse the repository at this point in the history
  • Loading branch information
CORBIERE Sebastien committed Mar 4, 2024
1 parent 434023d commit bc274b7
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 26 deletions.
56 changes: 53 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.6.7",
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.3.0",
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
Binary file modified src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions src/components/SegmentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<div>
<span>Start: {{ formatTime(localSegment.startTime) }}&nbsp;</span>
<!-- Conditionally display set start time button -->
<span v-if="!isReadOnly" @click="$emit('set-start-time', localSegment)" class="time-setter fa fa-pencil" title="Set with the current play time"></span>
<span v-if="!isReadOnly" @click="$emit('set-start-time', localSegment)" class="time-setter fa fa-pencil"
title="Set with the current play time"></span>
</div>
<div>
<span>End: {{ formatTime(localSegment.endTime) }}&nbsp;</span>
<!-- Conditionally display set end time button -->
<span v-if="!isReadOnly" @click="$emit('set-end-time', localSegment)" class="time-setter fa fa-pencil" title="Set with the current play time"></span>
<span v-if="!isReadOnly" @click="$emit('set-end-time', localSegment)" class="time-setter fa fa-pencil"
title="Set with the current play time"></span>
</div>
<!-- The delete button can also be conditionally shown or hidden -->
<button v-if="!isReadOnly" class="delete-button" @click="$emit('delete-segment', segment)">X</button>
Expand All @@ -23,12 +25,12 @@
<script>
export default {
props: {
segment: Object,
isReadOnly: {
type: Boolean,
default: false,
segment: Object,
isReadOnly: {
type: Boolean,
default: false,
},
},
},
data() {
return {
localSegment: this.segment,
Expand Down
12 changes: 12 additions & 0 deletions src/components/headers/MomentumMovementAcademy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div style="background-color: hsla(0, 100%, 50%, 1);width:100%"><a href="https://www.momentum-movement.ca/"><img
elementtiming="nbf-header-logo-desktop"
src="https://images.squarespace-cdn.com/content/v1/63a61ed2a637cd7b726fd375/2f4bfd8a-bcf3-4fdd-ae81-eb0dfcfd2f8d/mma-logo-website3.png?format=1500w"
alt="Momentum Movement Academy" style="display:block" fetchpriority="high" loading="eager"
decoding="async" data-loader="raw"></a></div>
</template>

<script>
export default {
}
</script>
3 changes: 2 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const routes = [
component: SegmentSelector,
},
{
path: '/viewer',
path: '/viewer/:customHeader?',
name: 'ViewerInterface',
component: ViewerInterface,
props: true,
},
];

Expand Down
50 changes: 40 additions & 10 deletions src/views/SegmentSelector.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<template>
<div class="segment-selector">
<header>
<h1>Video Segment Selector</h1>
<input type="file" @change="loadJson" ref="fileInput" style="display: none;" />
<button @click="triggerFileInput">Load JSON File</button>
<button @click="saveJson">Save/Download JSON File</button>
<button @click="createSharableLink">Create a Sharable Link</button>
<a v-if="sharableLink" :href="sharableLink" target="_blank">Open Sharable Link</a>
<div style="width: 100%;">
<h1 style="text-align: center;">Video Segment Selector</h1>
<div>
<input type="file" @change="loadJson" ref="fileInput" style="display: none;" />
<button @click="triggerFileInput">Load JSON File</button>
<button @click="saveJson">Save/Download JSON File</button>
</div>
<div>
Style: <select v-model="selectedStyle"
@change="() => { console.log('selectedStyle', this.selectedStyle) }">
<option v-for="option in styleOptions" :key="option.id" :value="option.id">
{{ option.name }}
</option>
</select>
<button @click="createSharableLink">Create a Sharable Link</button>
<a v-if="sharableLink" :href="sharableLink" target="_blank">Open Sharable Link</a>
</div>
</div>
</header>
<div class="content-area">
<main>
Expand Down Expand Up @@ -43,6 +55,16 @@ import draggable from 'vuedraggable';
import YouTubePlayer from '@/components/YouTubePlayer.vue';
import SegmentItem from '@/components/SegmentItem.vue';
import { segmentMixin } from '@/mixins/segmentMixin.js';
import axios from 'axios';
function shortenURL(longUrl) {
return axios.get(`https://tinyurl.com/api-create.php?url=${encodeURIComponent(longUrl)}`)
.then(response => response.data)
.catch(error => {
console.error('Erreur lors de la création de l’URL courte :', error);
return longUrl; // Retournez l'URL originale en cas d'erreur
});
}
export default {
mixins: [segmentMixin],
Expand All @@ -61,6 +83,12 @@ export default {
filterText: '',
sharableLink: '',
maxSegmentId: 0,
styleOptions: [
{ id: '', name: 'Default' },
{ id: 'mma', name: 'Momentum' },
// Ajoutez d'autres options ici
],
selectedStyle: '',
};
},
watch: {
Expand Down Expand Up @@ -121,15 +149,17 @@ export default {
const compactSegments = this.convertToCompactFormat(this.segments);
const jsonData = JSON.stringify(compactSegments);
const base64EncodedData = btoa(encodeURIComponent(jsonData)); // Encode the JSON string as Base64
const viewerUrl = `${window.location.origin}/viewer?data=${base64EncodedData}`; // Construct the viewer URL with the encoded data as a parameter
const viewerStyle = this.selectedStyle && ('/' + this.selectedStyle) || '';
const viewerUrl = `${window.location.origin}/viewer${viewerStyle}?data=${base64EncodedData}`; // Construct the viewer URL with the encoded data as a parameter
// Check if the URL exceeds 2000 characters, a common practical limit
if (viewerUrl.length > 2000) {
alert("The generated link is too long and might not be supported by some browsers. Please reduce the number of segments.");
} else {
this.sharableLink = viewerUrl;
window.focus(); // Attempt to focus the window before accessing the clipboard
this.copyToClipboard(viewerUrl);
shortenURL(viewerUrl).then(shortUrl => {
this.sharableLink = shortUrl;
this.copyToClipboard(shortUrl);
});
}
},
copyToClipboard(text) {
Expand Down
25 changes: 20 additions & 5 deletions src/views/ViewerInterface.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<div class="viewer-interface">
<header>
<h1>Video Segment Viewer</h1>
<Momentum v-if="customHeader === 'mma'" />
<h1 v-else>Video Segment Viewer</h1>
</header>
<div class="content-area">
<main>
<YouTubePlayer class="youtube-player" ref="youtubePlayer" :videoId="selectedSegment.videoId"
:startTime="selectedSegment.startTime" :pauseTime="selectedSegment.endTime"
@over-pause-time="nextSegment" />
@over-pause-time="nextSegment" :enablePause="autoPause" />
</main>
<aside>
<h2>Segments</h2>
Expand All @@ -16,9 +17,9 @@
</div>
<div>
<ul class="segments-list">
<SegmentItem v-for="(segment, index) in filteredSegments" :key="index" :segment="segment" :index="index"
:class="{ 'selected-segment': segment === selectedSegment }" @click="selectSegment(segment)"
:is-read-only="true" />
<SegmentItem v-for="(segment, index) in filteredSegments" :key="index" :segment="segment"
:index="index" :class="{ 'selected-segment': segment === selectedSegment }"
@click="selectSegment(segment)" :is-read-only="true" />
</ul>
</div>
</aside>
Expand All @@ -29,20 +30,29 @@
<script>
import YouTubePlayer from '@/components/YouTubePlayer.vue';
import SegmentItem from '@/components/SegmentItem.vue';
import Momentum from '@/components/headers/MomentumMovementAcademy.vue';
import { segmentMixin } from '@/mixins/segmentMixin.js';
export default {
mixins: [segmentMixin],
components: {
YouTubePlayer,
SegmentItem,
Momentum,
},
name: 'ViewerInterface',
props: {
customHeader: {
type: String,
default: '' // Fournit une valeur par défaut si 'type' n'est pas passé
}
},
data() {
return {
segments: [],
selectedSegment: {},
filterText: '',
autoPause: false,
};
},
computed: {
Expand Down Expand Up @@ -74,6 +84,11 @@ export default {
},
selectSegment(segment) {
this.selectedSegment = segment;
const segmentList = this.filteredSegments;
const isLast = segmentList && segmentList.length &&
segment === segmentList[segmentList.length - 1]
this.autoPause = !!isLast;
// console.log("autoPause", this.autoPause, isLast, segmentList, segmentList.length);
},
},
mounted() {
Expand Down

0 comments on commit bc274b7

Please sign in to comment.