1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
<template>
<NcContent app-name="news">
<div id="news-app">
<div id="content-display" :class="{ playing: playingItem }">
<Sidebar />
<NcAppContent>
<RouterView />
</NcAppContent>
</div>
<div v-if="playingItem" class="podcast">
<audio controls
autoplay
:src="playingItem.enclosureLink"
@play="stopVideo()" />
<a class="button podcast-download"
:title="t('news', 'Download')"
:href="playingItem.enclosureLink"
target="_blank"
rel="noreferrer">{{ t('news', 'Download') }}</a>
<button class="podcast-close"
:title="t('news', 'Close')"
@click="stopPlaying()">
{{ t('news', 'Close') }}
</button>
</div>
</div>
</NcContent>
</template>
<script lang="ts">
import Vue from 'vue'
import NcContent from '@nextcloud/vue/dist/Components/NcContent.js'
import NcAppContent from '@nextcloud/vue/dist/Components/NcAppContent.js'
import Sidebar from './components/Sidebar.vue'
import { ACTIONS, MUTATIONS } from './store'
export default Vue.extend({
components: {
NcContent,
Sidebar,
NcAppContent,
},
computed: {
playingItem() {
return this.$store.state.items.playingItem
},
},
async created() {
// fetch folders and feeds to build side bar
await this.$store.dispatch(ACTIONS.FETCH_FOLDERS)
await this.$store.dispatch(ACTIONS.FETCH_FEEDS)
// fetch starred to get starred count
await this.$store.dispatch(ACTIONS.FETCH_STARRED)
},
methods: {
stopPlaying() {
this.$store.commit(MUTATIONS.SET_PLAYING_ITEM, { item: undefined })
},
stopVideo() {
const videoElements = document.getElementsByTagName('video')
for (let i = 0; i < videoElements.length; i++) {
videoElements[i].pause()
}
},
},
})
</script>
<style>
.material-design-icon {
color: var(--color-text-lighter)
}
#news-app {
display: flex;
flex-direction: column;
width: 100%;
}
#content-display {
display: flex;
flex-direction: row;
}
#content-display.playing {
height: calc(100vh - 98px)
}
.podcast {
position: absolute;
bottom: 0px;
height: 40px;
display: flex;
background-color: #474747;
width: 100%;
}
.podcast audio {
flex-grow: 1;
background-color: rgba(0,0,0,0);
height: 40px;
}
.podcast .podcast-download {
padding: 4px 10px;
margin: 2px 6px;
}
.podcast .podcast-close {
margin: 2px 6px;
}
</style>
|