A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 72fcaadc4e6106aba1beb1ec4bdb453c7cf25da7 (3010 bytes)[doc][blame][raw]
1
import {$lang, http} from '../utils.js';2
import VIcon from '../element/icon.js';3
import VTab from '../component/tab.js';4
import VStation from '../component/station.js';6
export default {7
props: ['state'],8
data() {9
return {10
query: {11
name: '',12
page: 013
},14
results: [],15
loading: false,16
more: true17
};18
},19
components: {20
VIcon,21
VTab,22
VStation23
},24
methods: {25
$lang,26
async doSearch() {27
this.results = [];28
this.loading = true;29
this.more = true;30
this.query.page = 0;31
const result = await http`get::/api/search`(this.query);32
this.loading = false;33
this.results = result;34
},35
async doSearchMore() {36
if(this.loading) return;37
if(!this.more) return;38
this.query.page++;39
this.loading = true;40
const result = await http`get::/api/search`(this.query);41
this.loading = false;42
if(result.length == 0) {43
this.more = false;44
}45
this.results.push(...result);46
}47
},48
mounted() {49
this.doSearch();50
},51
template: `52
<v-tab id="search" :tab="state.tab" @show="doSearch">53
<input54
v-model="query.name"55
@keyup.enter="doSearch"56
type="text"57
:placeholder="$lang('search.input.placeholder')"58
class="w-full h-[56px] px-5 text-lg rounded-lg bg-zinc-900 text-white font-medium placeholder:font-normal placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"59
spellcheck="false"60
autocomplete="off"61
>62
<ul class="flex flex-col">63
<li64
:key="station.id"65
v-for="station in results"66
class="border-t sm:border-t-2 first:border-none border-zinc-900 py-5 first:pt-0"67
>68
<v-station :station="station"></v-station>69
</li>70
</ul>71
<div72
v-show="loading"73
class="w-[60px] h-[60px] select-none pointer-events-none mx-auto"74
>75
<v-icon76
id="loader"77
class="bg-gray-400 animate-spin"78
style="animation-duration: 2s;"79
size="80%"80
></v-icon>81
</div>82
<div83
v-if="!more && results.length > 0"84
class="text-zinc-400 text-md mx-auto pb-6"85
>86
{{$lang('search.list.end')}}87
</div>88
<div89
v-if="results.length == 0"90
class="text-zinc-400 text-md mx-auto pb-6"91
>92
{{$lang('search.list.empty')}}93
</div>94
</v-tab>95
`96
}