Newer
Older
- @copyright Copyright (c) 2021 Jonas Heinrich
-
- @author Jonas Heinrich <onny@project-insanity.org>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->
<template>
<table class="episodeTable">
<thead>
<tr>
<th class="iconColumn" />
<th class="nameColumn">
<th class="durationColumn">
<th class="dateColumn">
<div v-lazy:background-image="episode.imgURL"
class="episodeImage" />
<td
class="nameColumn"
@click="changeRoute(`/browse/show/${episode.podcast_id}/${episode.id}`)">
<div class="-amp-video-eq-col">
<div class="-amp-video-eq-1-1" />
<div class="-amp-video-eq-1-2" />
</div>
<div class="-amp-video-eq-col">
<div class="-amp-video-eq-2-1" />
<div class="-amp-video-eq-2-2" />
</div>
<div class="-amp-video-eq-col">
<div class="-amp-video-eq-3-1" />
<div class="-amp-video-eq-3-2" />
</div>
<div class="-amp-video-eq-col">
<div class="-amp-video-eq-4-1" />
<div class="-amp-video-eq-4-2" />
</div>
<vue-show-more-text
:text="escapedEpisodeDescription(episode.description)"
:lines="2"
:has-more="false"
additional-container-css="padding: 0px;" />
</td>
<td class="actionColumn">
<Actions>
<ActionButton
:icon="isPlaying(episode.id) ? 'icon-pause' : 'icon-play'"
@click="changeRoute(`/browse/show/${episode.podcast_id}/${episode.id}`)">
@click="downloadFile(episode.enclosure)">
{{ t('podcast', 'Download') }}
</ActionButton>
<ActionButton
icon="icon-shared"
:close-after-click="true">
{{ t('podcast', 'Share') }}
<td
class="durationColumn"
@click="changeRoute(`/browse/show/${episode.podcast_id}/${episode.id}`)">
<td
class="dateColumn"
@click="changeRoute(`/browse/show/${episode.podcast_id}/${episode.id}`)">
<span :title="readableDate(episode.inserted)">
{{ readableTimeAgo(episode.inserted) }}
</span>
</tbody>
</table>
</template>
<script>
import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import TimeAgo from 'javascript-time-ago'
import en from 'javascript-time-ago/locale/en'
import vueShowMoreText from 'vue-show-more-text'
TimeAgo.addDefaultLocale(en)
const timeAgo = new TimeAgo('en-US')
export default {
name: 'Table',
components: {
Actions,
ActionButton,
type: Array,
default() { return [] },
},
},
methods: {
playButtonText(episodeId) {
if (this.isPlaying(episodeId)) {
return t('podcast', 'Pause')
} else if (this.isPaused(episodeId)) {
return t('podcast', 'Resume')
} else {
return t('podcast', 'Play')
}
},
isPlaying(episodeId) {
return this.$store.getters.isPlaying(episodeId)
},
isPaused(episodeId) {
return this.$store.getters.isPaused(episodeId)
},
escapedEpisodeDescription(episodeDescription) {
episodeDescription = episodeDescription.replace(/\n/g, '')
return episodeDescription
},
readableDate(datetime) {
const date = new Date(datetime)
return date.toDateString()
},
readableTimeAgo(datetime) {
return timeAgo.format(Date.parse(datetime), 'twitter-minute-now')
downloadFile(episodeURL) {
window.open(episodeURL, 'download')
},
changeRoute(path) {
this.$router.push({ path })
},
},
}
</script>
<style lang="scss">
/* Workaround wrong positioning
actions popover menu
https://github.com/nextcloud/nextcloud-vue/issues/1384 */
body {
min-height: 100%;
height: auto;
}
table.episodeTable {
width: 100%;
min-width: 250px;
table-layout:fixed;
position: relative;
thead {
background-color: var(--color-main-background-translucent);
z-index: 60;
position: sticky;
top: 50px;
th {
border-bottom: 1px solid var(--color-border);
padding: 15px;
height: 50px;
color: var(--color-text-maxcontrast);
}
th.iconColumn {
padding: 0px;
}
th.nameColumn {
width: 100%;
}
th.actionColumn {
width: 72px;
}
th.durationColumn {
width: 90px;
}
th.dateColumn {
width: 130px;
}
.selected {
background: var(--color-primary-light);
td {
padding: 0 15px;
font-style: normal;
border-bottom: 1px solid var(--color-border);
background: #ccc;
background-size: cover;
background-position: center;
}
td.nameColumn {
overflow: hidden;
text-overflow: ellipsis;
padding-right: 0px;
b {
color: var(--color-main-text);
user-select: none;
cursor: pointer;
font-size: 1.05em;
}
tr:hover td {
background: var(--color-background-hover);
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
@media only screen and (max-width: 500px) {
table {
thead {
th.iconColumn {
width: 85px;
}
th.nameColumn {
padding-left: 0px;
}
th.actionColumn {
padding-left: 5px;
padding-right: 5px;
width: 50px;
}
th.durationColumn, th.dateColumn {
display: none;
}
}
tbody {
td.iconColumn {
padding-left: 10px;
}
td.nameColumn {
padding-left: 0px;
}
td.actionColumn {
padding-left: 5px;
padding-right: 5px;
width: 50px;
}
td.durationColumn, td.dateColumn {
display: none;
}
}
}
}
align-items: flex-end;
display: none;
width: 20px;
height: 12px;
overflow: hidden;
opacity: 0.8;
position: relative;
float: left;
top: 5px;
margin-right: 5px;
}
flex: 1;
position: relative;
height: 100%;
margin-right: 1px;
}
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
animation-name: amp-video-eq-animation;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
background-color: rgb(0, 130, 201);
position: absolute;
width: 100%;
height: 100%;
transform: translateY(100%);
will-change: transform;
}
.-amp-video-eq-1-1 {
animation-duration: 0.3s;
}
.-amp-video-eq-1-2 {
animation-duration: 0.45s;
}
.-amp-video-eq-2-1 {
animation-duration: 0.5s;
}
.-amp-video-eq-2-2 {
animation-duration: 0.4s;
}
.-amp-video-eq-3-1 {
animation-duration: 0.3s;
}
.-amp-video-eq-3-2 {
animation-duration: 0.35s;
}
.-amp-video-eq-4-1 {
animation-duration: 0.4s;
}
.-amp-video-eq-4-2 {
animation-duration: 0.25s;
}
@keyframes amp-video-eq-animation {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(0);
}
}
[lazy=loading] {
opacity: 0;
}
[lazy=loaded] {
opacity: 1;