A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 1f56ab838a43e89542103d62f9dacb695587bebf (4017 bytes)[doc][blame][raw]
1
import {state} from '../main.js';2
import {$lang, http} from '../utils.js';3
import VButton from '../element/button.js';4
import VIcon from '../element/icon.js';6
export default {7
props: ['station'],8
components: {9
VButton,10
VIcon11
},12
methods: {13
$lang,14
async setLike(is_favorite) {15
try {16
await http`${is_favorite ? 'post' : 'delete'}::/api/favorite`(this.station.id);17
this.station.is_favorite = is_favorite;18
state.app.$refs.favorites.doFetch();19
}20
catch(error) {21
console.log(error);22
}23
},24
setStation(station) {25
state.station = station;26
}27
},28
template: `29
<div class="w-full gap-4 group flex items-center">30
<div31
class="w-[54px] h-[54px] min-w-[54px] bg-zinc-900 rounded-md overflow-hidden cursor-pointer"32
@click="() => setStation(station)"33
>34
<img35
v-if="station.icon"36
:alt="station.name"37
:src="station.icon"38
@error="() => station.icon = null"39
class="w-full h-full object-contain"40
>41
<v-icon42
v-else43
id="access-point"44
size="32px"45
class="text-gray-400"46
></v-icon>47
</div>48
<div class="flex flex-col flex-1 min-w-0 cursor-pointer">49
<p50
:title="station.name"51
class="text-lg font-medium text-gray-100 pb-0 overflow-hidden text-ellipsis whitespace-nowrap"52
>53
{{station.name}}54
</p>55
<span class="text-md text-gray-400 overflow-hidden flex gap-2 sm:gap-3">56
<span57
v-if="station.country"58
class="text-gray-400 inline-flex items-center gap-[5px]"59
:title="$lang('global.country')"60
>61
<v-icon62
id="map-pin"63
class="w-[18px] h-[18px] !min-w-[18px] inline-flex text-gray-400"64
size="100%"65
></v-icon>66
<p>{{station.state ? station.state + ', ' : ''}}{{station.country}}</p>67
</span>68
<span69
v-if="station.is_restricted"70
class="text-white/90 items-center gap-[5px] bg-blue-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"71
>72
<p class="-mt-[1px]">Restricted</p>73
</span>74
<span75
v-if="station.is_broken"76
class="text-white/90 items-center gap-[5px] bg-red-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"77
>78
<p class="-mt-[1px]">Broken</p>79
</span>80
<span81
v-if="station.is_no_track_info"82
class="text-white/90 items-center gap-[5px] bg-green-600/70 rounded-[4px] text-[14px] px-[7px] hidden sm:inline-flex"83
>84
<p class="-mt-[1px]">No track info</p>85
</span>86
</span>87
</div>88
<div class="inline-flex gap-3 sm:gap-4">89
<v-button90
:icon="[ station.is_favorite ? 'bookmark-off' : 'bookmark' ]"91
:title="[ $lang(station.is_favorite ? 'global.unlike' : 'global.like') ]"92
:active="station.is_favorite"93
@click="() => setLike(!station.is_favorite)"94
class="bg-zinc-900 hover:bg-white"95
></v-button>96
</div>97
</div>98
`99
}