A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 4365e743361ec1d78be8383ecab0ca932b436bcc (5258 bytes)[doc][blame][raw]
1
import {$lang, $route, 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
$route,23
isCurrentDevice(device) {24
return device.uid === this.state.token;25
},26
async updateAccount(type, value) {27
const account = {...this.state.account};28
account[type] = value;29
try {30
this.state.account = await http`put::/api/account`(account);31
}32
catch(err) {33
this.state.app.showError(err);34
this.reset();35
}36
},37
reset() {38
const {name, language} = this.state.account;39
this.name = name;40
this.language = language;41
},42
logout() {43
localStorage.removeItem('verbal-token');44
$route('/', { reload: true });45
}46
},47
template: `48
<v-tab id="account" :tab="state.tab">49
<div class="flex flex-col flex-1 gap-[32px] pb-8 sm:pb-[100px] pt-2">50
<div>51
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.settings')}}</h3>52
<div class="flex flex-col md:flex-row gap-8">53
<div class="flex flex-col gap-2 w-full">54
<label for="username" class="text-white text-lg">{{$lang('account.username')}}</label>55
<span class="flex-1 text-gray-400 text-sm">{{$lang('account.username.info')}}</span>56
<input57
v-model="name"58
id="username"59
type="text"60
maxlength="20"61
spellcheck="false"62
autocomplete="off"63
@change="updateAccount('name', name)"64
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"65
>66
</div>67
<div class="flex flex-col gap-2 w-full">68
<label for="language" class="text-white text-lg">{{$lang('account.language')}}</label>69
<span class="flex-1 text-gray-400 text-sm">{{$lang('account.language.info')}}</span>70
<v-select71
id="language"72
v-model="language"73
@change="updateAccount('language', language)"74
class="mt-2"75
>76
<option value="en">English</option>77
<option value="de">Deutsch</option>78
</v-select>79
</div>80
</div>81
</div>82
<div v-if="state.devices" class="flex flex-col">83
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.devices')}}</h3>84
<ul class="flex flex-col gap-4">85
<li v-for="device in state.devices" class="w-full rounded-md bg-zinc-900 p-5 flex flex-col gap-1 cursor-pointer">86
<p class="text-lg text-white flex justify-between items-center">87
{{device.name ?? $lang('account.devices.unknown')}}88
<span89
v-if="isCurrentDevice(device)"90
class="text-sm text-white px-[7px] bg-blue-600/70 rounded-[4px] h-[24px] leading-[24px]"91
>92
{{$lang('account.devices.current')}}93
</span>94
</p>95
<p class="text-sm text-gray-500">{{device.uid}}</p>96
</li>97
</ul>98
</div>99
<div class="flex flex-col pt-4">100
<button101
class="w-full h-[52px] px-4 text-md bg-zinc-900 hover:bg-zinc-800 text-zinc-100 rounded-md outline-none"102
@click="logout"103
>104
{{$lang('global.logout')}}105
</button>106
</div>107
<div>108
<p class="text-sm text-gray-400 text-center">Verbal - {{state.version}}</p>109
<p class="text-sm text-gray-400 text-center pt-1">110
Created by111
<a class="text-gray-200" href="https://github.com/typable" target="_blank">@typable</a>112
</p>113
</div>114
</div>115
</v-tab>116
`117
}