2020-11-24 14:16:53 +00:00
|
|
|
<!--
|
|
|
|
- @copyright Copyright (c) 2020 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/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
<template>
|
2020-11-21 09:50:26 +00:00
|
|
|
<table>
|
2020-10-17 18:06:57 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-10-21 08:31:59 +00:00
|
|
|
<th class="iconColumn" />
|
2020-10-17 18:06:57 +00:00
|
|
|
<th class="nameColumn">
|
2020-10-18 09:49:17 +00:00
|
|
|
{{ t('radio', 'Name') }}
|
2020-10-17 18:06:57 +00:00
|
|
|
</th>
|
2020-10-21 08:31:59 +00:00
|
|
|
<th class="actionColumn" />
|
2020-10-17 18:06:57 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
2020-10-19 19:23:26 +00:00
|
|
|
<tbody>
|
2020-11-21 22:06:42 +00:00
|
|
|
<template v-if="!isFolder">
|
2020-11-21 18:23:26 +00:00
|
|
|
<tr
|
|
|
|
v-for="(station, idx) in stationData"
|
|
|
|
:key="idx"
|
|
|
|
:class="{ selected: idx === activeItem}">
|
|
|
|
<td @click="doPlay(idx, station)">
|
|
|
|
<blur-hash-image
|
|
|
|
class="stationIcon"
|
|
|
|
width="32"
|
|
|
|
height="32"
|
|
|
|
:hash="station.blurHash"
|
|
|
|
:src="station.favicon" />
|
|
|
|
<span :class="{ 'icon-starred': favorites.flat().includes(station.stationuuid) }" />
|
|
|
|
</td>
|
|
|
|
<td class="nameColumn" @click="doPlay(idx, station)">
|
|
|
|
<span class="innernametext">
|
|
|
|
{{ station.name }}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td class="actionColumn">
|
|
|
|
<Actions>
|
|
|
|
<ActionButton
|
|
|
|
v-if="!favorites.flat().includes(station.stationuuid)"
|
|
|
|
icon="icon-star"
|
|
|
|
:close-after-click="true"
|
|
|
|
@click="doFavor(idx, station)">
|
|
|
|
{{ t('radio', 'Add to favorites') }}
|
|
|
|
</ActionButton>
|
|
|
|
<ActionButton
|
|
|
|
v-if="favorites.flat().includes(station.stationuuid)"
|
|
|
|
icon="icon-star"
|
|
|
|
:close-after-click="true"
|
|
|
|
@click="doFavor(idx, station)">
|
|
|
|
{{ t('radio', 'Remove from favorites') }}
|
|
|
|
</ActionButton>
|
|
|
|
<ActionButton
|
|
|
|
icon="icon-info"
|
|
|
|
:close-after-click="true"
|
|
|
|
@click="toggleSidebar(station)">
|
|
|
|
{{ t('radio', 'Details') }}
|
|
|
|
</ActionButton>
|
|
|
|
</Actions>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
2020-11-21 22:06:42 +00:00
|
|
|
<template v-if="isFolder">
|
2020-11-21 18:23:26 +00:00
|
|
|
<tr
|
|
|
|
v-for="(station, idx) in stationData"
|
|
|
|
:key="idx"
|
2020-11-21 22:06:42 +00:00
|
|
|
@click="changeRoute(station.path)">
|
2020-11-21 18:23:26 +00:00
|
|
|
<td>
|
|
|
|
<span class="icon-folder" />
|
|
|
|
</td>
|
|
|
|
<td class="nameColumn">
|
|
|
|
<span class="innernametext">
|
|
|
|
{{ station.name }}
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td class="actionColumn" />
|
|
|
|
</tr>
|
|
|
|
</template>
|
2020-10-17 18:06:57 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Actions from '@nextcloud/vue/dist/Components/Actions'
|
|
|
|
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Table',
|
|
|
|
components: {
|
|
|
|
Actions,
|
|
|
|
ActionButton,
|
|
|
|
},
|
|
|
|
props: {
|
2020-11-08 08:35:08 +00:00
|
|
|
favorites: {
|
|
|
|
type: Array,
|
|
|
|
default() { return [] },
|
|
|
|
},
|
2020-10-17 18:06:57 +00:00
|
|
|
stationData: {
|
|
|
|
type: Array,
|
|
|
|
default() { return [] },
|
|
|
|
},
|
|
|
|
},
|
2020-10-22 11:53:40 +00:00
|
|
|
data: () => ({
|
|
|
|
activeItem: null,
|
|
|
|
}),
|
2020-11-21 22:06:42 +00:00
|
|
|
computed: {
|
|
|
|
isFolder() {
|
|
|
|
if (this.stationData[0]) {
|
|
|
|
if (this.stationData[0].type === 'folder') {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
},
|
|
|
|
},
|
2020-10-18 09:38:10 +00:00
|
|
|
methods: {
|
2020-10-19 18:06:07 +00:00
|
|
|
doPlay(idx, station) {
|
|
|
|
this.activeItem = idx
|
2020-10-18 09:38:10 +00:00
|
|
|
this.$emit('doPlay', station)
|
|
|
|
},
|
2020-10-19 19:23:26 +00:00
|
|
|
doFavor(idx, station) {
|
|
|
|
this.$emit('doFavor', station)
|
|
|
|
},
|
2020-11-14 11:37:51 +00:00
|
|
|
toggleSidebar(station) {
|
|
|
|
this.$emit('toggleSidebar', station)
|
|
|
|
},
|
2020-11-21 22:06:42 +00:00
|
|
|
changeRoute(path) {
|
|
|
|
this.$router.push({ path })
|
|
|
|
},
|
2020-10-18 09:38:10 +00:00
|
|
|
},
|
2020-10-17 18:06:57 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
2020-11-14 11:03:45 +00:00
|
|
|
/* Workaround wrong positioning
|
|
|
|
actions popover menu
|
|
|
|
https://github.com/nextcloud/nextcloud-vue/issues/1384 */
|
|
|
|
body {
|
|
|
|
min-height: 100%;
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
table {
|
|
|
|
width: 100%;
|
|
|
|
min-width: 250px;
|
2020-10-21 08:05:18 +00:00
|
|
|
table-layout:fixed;
|
2020-11-14 11:03:45 +00:00
|
|
|
position: relative;
|
2020-10-17 18:06:57 +00:00
|
|
|
|
|
|
|
thead {
|
|
|
|
background-color: var(--color-main-background-translucent);
|
|
|
|
z-index: 60;
|
|
|
|
position: sticky;
|
2020-11-15 22:39:03 +00:00
|
|
|
top: 50px;
|
2020-10-17 18:06:57 +00:00
|
|
|
|
|
|
|
th {
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
|
|
|
padding: 15px;
|
|
|
|
height: 50px;
|
|
|
|
}
|
|
|
|
|
|
|
|
th, th a {
|
|
|
|
color: var(--color-text-maxcontrast);
|
|
|
|
}
|
|
|
|
|
2020-10-21 08:31:59 +00:00
|
|
|
th.iconColumn {
|
|
|
|
padding: 0px;
|
|
|
|
width: 72px;
|
|
|
|
}
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
th.nameColumn {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
2020-10-21 08:31:59 +00:00
|
|
|
th.actionColumn {
|
2020-10-21 08:02:38 +00:00
|
|
|
width: 72px;
|
|
|
|
}
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tbody {
|
|
|
|
|
|
|
|
td {
|
|
|
|
padding: 0 15px;
|
|
|
|
font-style: normal;
|
|
|
|
background-position: 8px center;
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
border-bottom: 1px solid var(--color-border);
|
2020-10-19 19:23:26 +00:00
|
|
|
cursor: pointer;
|
2020-11-21 18:23:26 +00:00
|
|
|
|
|
|
|
span.icon-folder {
|
|
|
|
display: block;
|
|
|
|
background-size: cover;
|
|
|
|
width: 30px;
|
|
|
|
height: 30px;
|
|
|
|
}
|
2020-10-17 18:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tr {
|
|
|
|
height: 51px;
|
|
|
|
background-color: var(--color-background-light);
|
2020-11-14 11:03:45 +00:00
|
|
|
transition: opacity 500ms ease 0s;
|
2020-10-17 18:06:57 +00:00
|
|
|
|
|
|
|
tr:hover, tr:focus, tr.mouseOver td {
|
|
|
|
background-color: var(--color-background-hover);
|
|
|
|
}
|
|
|
|
|
2020-10-20 13:03:20 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 08:14:50 +00:00
|
|
|
tr td * {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
2020-10-20 13:03:20 +00:00
|
|
|
tr.selected {
|
|
|
|
background-color: var(--color-primary-light);
|
2020-10-19 18:06:07 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
tr td:first-child {
|
|
|
|
padding-left: 40px;
|
|
|
|
width: 32px;
|
|
|
|
padding-right: 0px;
|
|
|
|
}
|
|
|
|
|
2020-11-18 13:21:33 +00:00
|
|
|
td.nameColumn {
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
padding-right: 0px;
|
|
|
|
}
|
|
|
|
|
2020-10-21 08:31:59 +00:00
|
|
|
td.nameColumn .innernametext {
|
2020-10-17 18:06:57 +00:00
|
|
|
color: var(--color-main-text);
|
2020-10-18 09:38:10 +00:00
|
|
|
position: relative;
|
|
|
|
vertical-align: top;
|
|
|
|
user-select: none;
|
2020-10-19 19:23:26 +00:00
|
|
|
cursor: pointer;
|
2020-10-17 18:06:57 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 19:23:26 +00:00
|
|
|
.icon-starred {
|
|
|
|
background-image: var(--icon-star-dark-fc0);
|
|
|
|
background-size: 16px 16px;
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
background-position: center;
|
|
|
|
min-width: 16px;
|
|
|
|
min-height: 16px;
|
2020-10-20 13:03:20 +00:00
|
|
|
right: -7px;
|
2020-11-08 08:06:21 +00:00
|
|
|
top: -38px;
|
|
|
|
margin-bottom: -38px;
|
2020-10-20 13:03:20 +00:00
|
|
|
float: right;
|
|
|
|
position: relative;
|
2020-11-08 08:14:50 +00:00
|
|
|
pointer-events: none;
|
2020-10-19 19:23:26 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 18:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|