2025-01-23 18:36:30 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
const i18n = useI18n();
|
|
|
|
|
const t = i18n.t;
|
|
|
|
|
|
|
|
|
|
import { ref, onMounted, watch } from 'vue';
|
|
|
|
|
import { Dropdown } from 'pankow';
|
|
|
|
|
import Section from '../components/Section.vue';
|
2025-01-24 18:28:45 +01:00
|
|
|
import CloudronAccount from '../components/CloudronAccount.vue';
|
2025-01-23 18:36:30 +01:00
|
|
|
import SystemUpdate from '../components/SystemUpdate.vue';
|
2025-01-24 17:38:18 +01:00
|
|
|
import PrivateRegistry from '../components/PrivateRegistry.vue';
|
2025-01-23 18:36:30 +01:00
|
|
|
import CloudronModel from '../models/CloudronModel.js';
|
|
|
|
|
|
2025-01-31 21:02:48 +01:00
|
|
|
const cloudronModel = CloudronModel.create();
|
2025-01-23 18:36:30 +01:00
|
|
|
|
|
|
|
|
// Timezone
|
|
|
|
|
const allTimezones = window.timezones;
|
|
|
|
|
const timeZone = ref('');
|
|
|
|
|
const currentTimeZone = ref('');
|
|
|
|
|
|
|
|
|
|
function prettyTimeZone(timeZone) {
|
|
|
|
|
const tz = window.timezones.find(function (t) { return t.id === timeZone; });
|
|
|
|
|
if (!tz) return '';
|
|
|
|
|
return tz.display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(timeZone, async (newTimeZone, oldTimeZone) => {
|
|
|
|
|
if (!oldTimeZone) return;
|
|
|
|
|
|
|
|
|
|
const [error] = await cloudronModel.setTimeZone(newTimeZone);
|
|
|
|
|
if (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
window.pankow.notify({ text: 'Failed to set timezone. Check logs', type: 'danger' });
|
|
|
|
|
timeZone.value = currentTimeZone.value;
|
|
|
|
|
} else {
|
|
|
|
|
currentTimeZone.value = newTimeZone;
|
|
|
|
|
window.pankow.notify({ text: 'Timezone changed', type: 'success' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Language
|
|
|
|
|
const allLanguages = ref([]);
|
|
|
|
|
const language = ref('');
|
|
|
|
|
const currentLanguage = ref('');
|
|
|
|
|
|
|
|
|
|
watch(language, async (newLanguage, oldLanguage) => {
|
|
|
|
|
if (!oldLanguage) return;
|
|
|
|
|
|
|
|
|
|
const [error] = await cloudronModel.setLanguage(newLanguage);
|
|
|
|
|
if (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
window.pankow.notify({ text: 'Failed to set language. Check logs', type: 'danger' });
|
|
|
|
|
language.value = currentLanguage.value;
|
|
|
|
|
} else {
|
|
|
|
|
currentLanguage.value = newLanguage;
|
|
|
|
|
window.pankow.notify({ text: 'Language changed', type: 'success' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
let [error, result] = await cloudronModel.getTimeZone();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
timeZone.value = result;
|
|
|
|
|
currentTimeZone.value = result;
|
|
|
|
|
|
|
|
|
|
[error, result] = await cloudronModel.languages();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
allLanguages.value = result.map(l => {
|
|
|
|
|
return {
|
|
|
|
|
id: l,
|
|
|
|
|
display: t(`lang.${l}`)
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
[error, result] = await cloudronModel.getLanguage();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
|
|
|
|
language.value = result;
|
|
|
|
|
currentLanguage.value = result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-01-24 14:09:30 +01:00
|
|
|
<div class="content">
|
2025-01-23 18:36:30 +01:00
|
|
|
|
|
|
|
|
<h1>{{ $t('settings.title') }}</h1>
|
|
|
|
|
|
2025-01-24 18:28:45 +01:00
|
|
|
<CloudronAccount />
|
2025-01-23 18:36:30 +01:00
|
|
|
|
|
|
|
|
<Section :title="$t('settings.timezone.title')">
|
|
|
|
|
<p v-html="$t('settings.timezone.description', { timeZone: prettyTimeZone(timeZone) })"></p>
|
|
|
|
|
<Dropdown v-model="timeZone" :options="allTimezones" option-key="id" option-label="display" />
|
|
|
|
|
</Section>
|
|
|
|
|
|
|
|
|
|
<Section :title="$t('settings.language.title')">
|
|
|
|
|
<p>{{ $t('settings.language.description') }}</p>
|
|
|
|
|
<Dropdown v-model="language" :options="allLanguages" option-key="id" option-label="display" />
|
|
|
|
|
</Section>
|
|
|
|
|
|
|
|
|
|
<SystemUpdate />
|
2025-01-24 17:38:18 +01:00
|
|
|
<PrivateRegistry />
|
2025-01-23 18:36:30 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|