2019-09-23 10:07:59 +00:00
|
|
|
<template>
|
2019-10-24 10:53:33 +00:00
|
|
|
<div id="content-selections">
|
2019-10-28 11:16:47 +00:00
|
|
|
<div class="content-selection" v-for="contentSelection in getContentSelections()" :key="contentSelection.url">
|
2019-09-23 10:07:59 +00:00
|
|
|
<content-selection :type="contentSelection.type" :title="contentSelection.title"
|
2019-10-31 10:46:59 +00:00
|
|
|
:thumbnail-name="contentSelection.thumbnailName" :url="contentSelection.url" :tags="contentSelection.tags"
|
2019-09-23 10:07:59 +00:00
|
|
|
:description="contentSelection.description"
|
|
|
|
>
|
|
|
|
</content-selection>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2019-10-24 10:53:33 +00:00
|
|
|
<style lang="scss">
|
2019-09-23 10:07:59 +00:00
|
|
|
@import '../scss/_variables';
|
|
|
|
|
2019-10-24 10:53:33 +00:00
|
|
|
#content-selections {
|
|
|
|
.content-selection {
|
|
|
|
margin-bottom: 80px;
|
|
|
|
}
|
2019-09-23 10:07:59 +00:00
|
|
|
|
2019-10-24 10:53:33 +00:00
|
|
|
.discover-instances {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
2019-09-23 10:07:59 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ContentSelection from './ContentSelection'
|
2019-09-23 11:07:01 +00:00
|
|
|
import ContentSelectionsEN from '../mixins/ContentSelectionsEN'
|
|
|
|
import ContentSelectionsFR from '../mixins/ContentSelectionsFR'
|
|
|
|
import sampleSize from 'lodash/sampleSize'
|
2019-09-23 10:07:59 +00:00
|
|
|
|
|
|
|
export default {
|
2019-09-23 11:07:01 +00:00
|
|
|
mixins: [
|
|
|
|
ContentSelectionsEN,
|
|
|
|
ContentSelectionsFR
|
|
|
|
],
|
|
|
|
|
2019-09-23 10:07:59 +00:00
|
|
|
props: {
|
2019-09-23 11:07:01 +00:00
|
|
|
sampleSizeEach: Number
|
2019-09-23 10:07:59 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
|
|
|
ContentSelection
|
|
|
|
},
|
|
|
|
|
2019-09-23 11:07:01 +00:00
|
|
|
methods: {
|
|
|
|
getContentSelections () {
|
|
|
|
if (this.$language.current.startsWith('fr_')) {
|
|
|
|
return this.sampleIfNeeded(this.contentSelectionsFR)
|
2019-09-23 10:07:59 +00:00
|
|
|
}
|
2019-09-23 11:07:01 +00:00
|
|
|
|
|
|
|
return this.sampleIfNeeded(this.contentSelectionsEN)
|
|
|
|
},
|
|
|
|
|
|
|
|
sampleIfNeeded (objects) {
|
|
|
|
const videos = []
|
|
|
|
const channels = []
|
|
|
|
const instances = []
|
|
|
|
|
|
|
|
for (const o of objects) {
|
|
|
|
if (o.type === 'video') videos.push(o)
|
|
|
|
else if (o.type === 'channel') channels.push(o)
|
|
|
|
else if (o.type === 'instance') instances.push(o)
|
|
|
|
else console.error('Unknown content selection type %s.', o.type)
|
|
|
|
}
|
|
|
|
|
|
|
|
return sampleSize(videos, this.sampleSizeEach || videos.length)
|
|
|
|
.concat(sampleSize(channels, this.sampleSizeEach || channels.length))
|
|
|
|
.concat(sampleSize(instances, this.sampleSizeEach || instances.length))
|
|
|
|
}
|
|
|
|
}
|
2019-09-23 10:07:59 +00:00
|
|
|
}
|
|
|
|
</script>
|