feat: add timezone setting (#1379)
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1379 Reviewed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
This commit is contained in:
commit
2ea3499bf7
5 changed files with 50 additions and 13 deletions
|
@ -1,7 +1,18 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import {getToken} from '@/helpers/auth'
|
||||||
|
|
||||||
export const HTTPFactory = () => {
|
export function HTTPFactory() {
|
||||||
return axios.create({
|
return axios.create({
|
||||||
baseURL: window.API_URL,
|
baseURL: window.API_URL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function AuthenticatedHTTPFactory(token = getToken()) {
|
||||||
|
return axios.create({
|
||||||
|
baseURL: window.API_URL,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -85,7 +85,8 @@
|
||||||
"weekStartSunday": "Sunday",
|
"weekStartSunday": "Sunday",
|
||||||
"weekStartMonday": "Monday",
|
"weekStartMonday": "Monday",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"defaultList": "Default List"
|
"defaultList": "Default List",
|
||||||
|
"timezone": "Time Zone"
|
||||||
},
|
},
|
||||||
"totp": {
|
"totp": {
|
||||||
"title": "Two Factor Authentication",
|
"title": "Two Factor Authentication",
|
||||||
|
|
|
@ -11,6 +11,7 @@ export default class UserSettingsModel extends AbstractModel {
|
||||||
overdueTasksRemindersEnabled: true,
|
overdueTasksRemindersEnabled: true,
|
||||||
defaultListId: undefined,
|
defaultListId: undefined,
|
||||||
weekStart: 0,
|
weekStart: 0,
|
||||||
|
timezone: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import {HTTPFactory} from '@/http-common'
|
import {HTTPFactory, AuthenticatedHTTPFactory} from '@/http-common'
|
||||||
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
|
import {i18n, getCurrentLanguage, saveLanguage} from '@/i18n'
|
||||||
import {objectToSnakeCase} from '@/helpers/case'
|
import {objectToSnakeCase} from '@/helpers/case'
|
||||||
import {LOADING} from '../mutation-types'
|
import {LOADING} from '../mutation-types'
|
||||||
|
@ -215,13 +215,9 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const HTTP = HTTPFactory()
|
const HTTP = AuthenticatedHTTPFactory(jwt)
|
||||||
try {
|
try {
|
||||||
const response = await HTTP.get('user', {
|
const response = await HTTP.get('user')
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${jwt}`,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
const info = new UserModel(response.data)
|
const info = new UserModel(response.data)
|
||||||
info.type = state.info.type
|
info.type = state.info.type
|
||||||
info.email = state.info.email
|
info.email = state.info.email
|
||||||
|
|
|
@ -92,9 +92,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="is-flex is-align-items-center">
|
<label class="is-flex is-align-items-center">
|
||||||
<span>
|
<span>
|
||||||
{{ $t('user.settings.appearance.title') }}
|
{{ $t('user.settings.appearance.title') }}
|
||||||
</span>
|
</span>
|
||||||
<div class="select ml-2">
|
<div class="select ml-2">
|
||||||
<select v-model="activeColorSchemeSetting">
|
<select v-model="activeColorSchemeSetting">
|
||||||
<!-- TODO: use the Vikunja logo in color scheme as option buttons -->
|
<!-- TODO: use the Vikunja logo in color scheme as option buttons -->
|
||||||
|
@ -105,6 +105,20 @@
|
||||||
</div>
|
</div>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="is-flex is-align-items-center">
|
||||||
|
<span>
|
||||||
|
{{ $t('user.settings.general.timezone') }}
|
||||||
|
</span>
|
||||||
|
<div class="select ml-2">
|
||||||
|
<select v-model="settings.timezone">
|
||||||
|
<option v-for="tz in availableTimezones" :key="tz">
|
||||||
|
{{ tz }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<x-button
|
<x-button
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
@ -118,7 +132,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, watch} from 'vue'
|
import {computed, watch, ref} from 'vue'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import {playSoundWhenDoneKey, playPop} from '@/helpers/playPop'
|
import {playSoundWhenDoneKey, playPop} from '@/helpers/playPop'
|
||||||
|
@ -129,6 +143,7 @@ import ListSearch from '@/components/tasks/partials/listSearch'
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
import {useColorScheme} from '@/composables/useColorScheme'
|
import {useColorScheme} from '@/composables/useColorScheme'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
import {AuthenticatedHTTPFactory} from '@/http-common'
|
||||||
|
|
||||||
const DEFAULT_LIST_ID = 0
|
const DEFAULT_LIST_ID = 0
|
||||||
|
|
||||||
|
@ -155,6 +170,18 @@ function useColorSchemeSetting() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useAvailableTimezones() {
|
||||||
|
const availableTimezones = ref([])
|
||||||
|
|
||||||
|
const HTTP = AuthenticatedHTTPFactory()
|
||||||
|
HTTP.get('user/timezones')
|
||||||
|
.then(r => {
|
||||||
|
availableTimezones.value = r.data.sort()
|
||||||
|
})
|
||||||
|
|
||||||
|
return availableTimezones
|
||||||
|
}
|
||||||
|
|
||||||
function getPlaySoundWhenDoneSetting() {
|
function getPlaySoundWhenDoneSetting() {
|
||||||
return localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
|
return localStorage.getItem(playSoundWhenDoneKey) === 'true' || localStorage.getItem(playSoundWhenDoneKey) === null
|
||||||
}
|
}
|
||||||
|
@ -193,6 +220,7 @@ export default {
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
...useColorSchemeSetting(),
|
...useColorSchemeSetting(),
|
||||||
|
availableTimezones: useAvailableTimezones(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue