so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 2fe8465fc7f81ac59dbf85c4a2d251b78eb819dd (5386 bytes)[doc][blame][raw]

1import {$lang, http} from '../utils.js';

2import VTab from '../component/tab.js';

3import VSelect from '../component/select.js';

4import VButton from '../element/button.js';

5

6export default {

7 props: ['state'],

8 data() {

9 const {name, language} = this.state.account;

10 return {

11 name,

12 language

13 };

14 },

15 components: {

16 VTab,

17 VSelect,

18 VButton

19 },

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 gap-8">

52 <div class="flex flex-col gap-2">

53 <label for="username" class="text-white text-lg">{{$lang('account.username')}}</label>

54 <span class="text-gray-400 text-sm">{{$lang('account.username.info')}}</span>

55 <input

56 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">

67 <label for="language" class="text-white text-lg">{{$lang('account.language')}}</label>

68 <span class="text-gray-400 text-sm">{{$lang('account.language.info')}}</span>

69 <v-select

70 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 <span

88 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-button

98 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 <button

105 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 by

115 <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}