A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 240224f5db7e444682a6ef8ef01a4550a8571aff (5426 bytes)[doc][blame][raw]
1
import {$lang, http} from '../utils.js';2
import VTab from '../component/tab.js';3
import VSelect from '../component/select.js';4
import VButton from '../element/button.js';6
export default {7
props: ['state'],8
data() {9
const {name, language} = this.state.account;10
return {11
name,12
language13
};14
},15
components: {16
VTab,17
VSelect,18
VButton19
},20
methods: {21
$lang,22
isCurrentDevice(device) {23
return device.uid === this.state.token;24
},25
async updateAccount(type, value) {26
const account = {...this.state.account};27
account[type] = value;28
try {29
this.state.account = await http`put::/api/account`(account);30
}31
catch(err) {32
this.state.app.showError(err);33
this.reset();34
}35
},36
reset() {37
const {name, language} = this.state.account;38
this.name = name;39
this.language = language;40
},41
logout() {42
localStorage.removeItem('verbal-token');43
this.state.app.init();44
}45
},46
template: `47
<v-tab id="account" :tab="state.tab">48
<div class="flex flex-col flex-1 gap-[32px] pb-8 sm:pb-[100px] pt-2">49
<div>50
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.settings')}}</h3>51
<div class="flex flex-col md:flex-row gap-8">52
<div class="flex flex-col gap-2 w-full">53
<label for="username" class="text-white text-lg">{{$lang('account.username')}}</label>54
<span class="flex-1 text-gray-400 text-sm">{{$lang('account.username.info')}}</span>55
<input56
v-model="name"57
id="username"58
type="text"59
maxlength="20"60
spellcheck="false"61
autocomplete="off"62
@change="updateAccount('name', name)"63
class="rounded-md w-full h-[52px] px-4 mt-2 text-md bg-zinc-900 text-white placeholder:text-gray-500 focus:placeholder:text-gray-600 outline-none"64
>65
</div>66
<div class="flex flex-col gap-2 w-full">67
<label for="language" class="text-white text-lg">{{$lang('account.language')}}</label>68
<span class="flex-1 text-gray-400 text-sm">{{$lang('account.language.info')}}</span>69
<v-select70
id="language"71
v-model="language"72
@change="updateAccount('language', language)"73
class="mt-2"74
>75
<option value="en">English</option>76
<option value="de">Deutsch</option>77
</v-select>78
</div>79
</div>80
</div>81
<div v-if="state.devices" class="flex flex-col">82
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.devices')}}</h3>83
<ul class="flex flex-col gap-4">84
<li v-for="device in state.devices" class="w-full rounded-md bg-zinc-900 p-5 flex flex-col gap-1 cursor-pointer">85
<p class="text-lg text-white flex justify-between items-center">86
{{device.name ?? $lang('account.devices.unknown')}}87
<span88
v-if="isCurrentDevice(device)"89
class="text-sm text-white px-[7px] bg-blue-600/70 rounded-[4px] h-[24px] leading-[24px]"90
>91
{{$lang('account.devices.current')}}92
</span>93
</p>94
<p class="text-sm text-gray-500">{{device.uid}}</p>95
</li>96
</ul>97
<v-button98
icon="plus"99
:text="$lang('account.devices.add')"100
class="mt-4 mx-auto"101
></v-button>102
</div>103
<div class="flex flex-col">104
<button105
class="w-full h-[52px] px-4 text-md bg-zinc-900 hover:bg-zinc-800 text-zinc-100 rounded-md outline-none"106
@click="logout"107
>108
{{$lang('global.logout')}}109
</button>110
</div>111
<div>112
<p class="text-sm text-gray-400 text-center">Verbal - {{state.version}}</p>113
<p class="text-sm text-gray-400 text-center pt-1">114
Created by115
<a class="text-gray-200" href="https://github.com/typable" target="_blank">@typable</a>116
</p>117
</div>118
</div>119
</v-tab>120
`121
}