A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 9ea2d5099007da08ccb55044133c5aec42e16450 (4799 bytes)[doc][blame][raw]
1
import {$lang, http} from '../utils.js';2
import VTab from '../component/tab.js';4
export default {5
props: ['state'],6
data() {7
const {name, language} = this.state.account;8
return {9
name,10
language11
};12
},13
components: {14
VTab15
},16
methods: {17
$lang,18
isCurrentDevice(device) {19
return device.uid === this.state.token;20
},21
async updateAccount(type, value) {22
const account = {...this.state.account};23
account[type] = value;24
try {25
this.state.account = await http`put::/api/account`(account);26
}27
catch(err) {28
this.state.app.showError(err);29
this.reset();30
}31
},32
reset() {33
const {name, language} = this.state.account;34
this.name = name;35
this.language = language;36
}37
},38
template: `39
<v-tab id="account" :tab="state.tab">40
<div class="flex flex-col flex-1 gap-[32px] pb-8 sm:pb-[100px] pt-2">41
<div>42
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.settings')}}</h3>43
<div class="flex flex-col gap-8">44
<div class="flex flex-col gap-2">45
<label for="username" class="text-white text-md">{{$lang('account.username')}}</label>46
<span class="text-gray-400 text-sm">{{$lang('account.username.info')}}</span>47
<input48
v-model="name"49
id="username"50
type="text"51
maxlength="20"52
spellcheck="false"53
autocomplete="off"54
@change="updateAccount('name', name)"55
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"56
>57
</div>58
<div class="flex flex-col gap-2">59
<label for="language" class="text-white text-md">{{$lang('account.language')}}</label>60
<span class="text-gray-400 text-sm">{{$lang('account.language.info')}}</span>61
<select62
v-model="language"63
id="language"64
autocomplete="off"65
@change="updateAccount('language', language)"66
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 appearance-none"67
>68
<option value="en">English</option>69
<option value="de">Deutsch</option>70
</select>71
</div>72
</div>73
</div>74
<div v-if="state.devices">75
<h3 class="text-white text-[24px] font-bold pb-6 pt-4 sm:pt-0">{{$lang('account.devices')}}</h3>76
<ul class="flex flex-col gap-4">77
<li v-for="device in state.devices" class="w-full rounded-md bg-zinc-900 p-5 flex flex-col gap-1">78
<p class="text-md text-white flex justify-between items-center">79
{{device.name ?? $lang('account.devices.unknown')}}80
<span81
v-if="isCurrentDevice(device)"82
class="text-sm text-white px-[7px] bg-blue-600/70 rounded-[4px] h-[24px] leading-[24px]"83
>84
{{$lang('account.devices.current')}}85
</span>86
</p>87
<p class="text-sm text-gray-500">{{device.uid}}</p>88
</li>89
</ul>90
</div>91
<div>92
<p class="text-md text-gray-400 text-center">Verbal</p>93
<p class="text-md text-gray-400 text-center">{{state.version}}</p>94
<p class="text-md text-gray-400 text-center pt-2">95
Created by96
<a class="text-gray-200" href="https://github.com/typable" target="_blank">@typable</a>97
</p>98
</div>99
</div>100
</v-tab>101
`102
}