2025-02-17 11:18:57 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
2025-04-09 19:17:23 +02:00
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
const i18n = useI18n();
|
|
|
|
|
const t = i18n.t;
|
|
|
|
|
|
2025-07-02 21:04:39 +02:00
|
|
|
import { ref, onMounted } from 'vue';
|
2025-07-10 11:55:11 +02:00
|
|
|
import { SingleSelect } from '@cloudron/pankow';
|
2025-09-17 12:06:50 +02:00
|
|
|
import { setLanguage } from '../i18n.js';
|
2025-03-16 11:12:49 +01:00
|
|
|
import moment from 'moment-timezone';
|
2025-05-22 16:26:24 +02:00
|
|
|
import SettingsItem from '../components/SettingsItem.vue';
|
2025-02-17 11:18:57 +01:00
|
|
|
import Section from '../components/Section.vue';
|
2025-05-22 16:26:24 +02:00
|
|
|
import CloudronModel from '../models/CloudronModel.js';
|
2025-05-22 16:51:26 +02:00
|
|
|
import DashboardModel from '../models/DashboardModel.js';
|
|
|
|
|
import SystemModel from '../models/SystemModel.js';
|
2025-05-22 16:26:24 +02:00
|
|
|
|
2025-05-22 16:51:26 +02:00
|
|
|
const systemModel = SystemModel.create();
|
|
|
|
|
const dashboardModel = DashboardModel.create();
|
2025-05-22 16:26:24 +02:00
|
|
|
const cloudronModel = CloudronModel.create();
|
2025-04-09 19:17:23 +02:00
|
|
|
|
2025-05-22 16:51:26 +02:00
|
|
|
const config = ref({});
|
|
|
|
|
const info = ref({});
|
|
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
// Timezone
|
|
|
|
|
const allTimezones = moment.tz.names().map(t => { return { id: t }; });
|
|
|
|
|
const timeZone = ref('');
|
|
|
|
|
const currentTimeZone = ref('');
|
2025-04-09 19:17:23 +02:00
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
async function onTimeZoneChange(value) {
|
|
|
|
|
const [error] = await cloudronModel.setTimeZone(value);
|
|
|
|
|
if (error) return console.error(error);
|
2025-04-09 19:17:23 +02:00
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
currentTimeZone.value = value;
|
2025-02-17 11:18:57 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
// Language
|
|
|
|
|
const allLanguages = ref([]);
|
|
|
|
|
const language = ref('');
|
|
|
|
|
const currentLanguage = ref('');
|
|
|
|
|
|
|
|
|
|
async function onLanguageChange(value) {
|
|
|
|
|
const [error] = await cloudronModel.setLanguage(value);
|
2025-02-17 11:18:57 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
currentLanguage.value = value;
|
2025-09-17 12:06:50 +02:00
|
|
|
|
|
|
|
|
await setLanguage(value, false);
|
2025-05-22 16:26:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2025-09-10 16:57:45 +02:00
|
|
|
let [error, result] = await cloudronModel.getTimeZone();
|
2025-02-17 11:18:57 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
timeZone.value = result;
|
|
|
|
|
currentTimeZone.value = result;
|
|
|
|
|
|
|
|
|
|
[error, result] = await cloudronModel.languages();
|
2025-02-17 11:18:57 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
allLanguages.value = result.map(l => {
|
|
|
|
|
return {
|
|
|
|
|
id: l,
|
2025-07-10 14:37:31 +02:00
|
|
|
display: t(`lang.${l}`, l /* default fallback */, { locale: 'en' })
|
2025-05-22 16:26:24 +02:00
|
|
|
};
|
2025-07-10 14:37:31 +02:00
|
|
|
}).sort((a, b) => {
|
|
|
|
|
return a.display.localeCompare(b.display);
|
2025-05-22 16:26:24 +02:00
|
|
|
});
|
2025-02-17 11:42:10 +01:00
|
|
|
|
2025-05-22 16:26:24 +02:00
|
|
|
[error, result] = await cloudronModel.getLanguage();
|
2025-02-17 11:18:57 +01:00
|
|
|
if (error) return console.error(error);
|
2025-05-22 16:26:24 +02:00
|
|
|
|
|
|
|
|
language.value = result;
|
|
|
|
|
currentLanguage.value = result;
|
2025-05-22 16:51:26 +02:00
|
|
|
|
|
|
|
|
[error, result] = await systemModel.info();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
info.value = result;
|
|
|
|
|
|
|
|
|
|
[error, result] = await dashboardModel.config();
|
|
|
|
|
if (error) return console.error(error);
|
|
|
|
|
config.value = result;
|
2025-02-17 11:18:57 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="content">
|
2025-09-25 12:04:12 +02:00
|
|
|
<Section :title="$t('system.locale.title')">
|
2025-05-22 16:26:24 +02:00
|
|
|
<SettingsItem wrap>
|
2025-08-06 20:08:53 +02:00
|
|
|
<div>
|
2025-05-22 16:26:24 +02:00
|
|
|
<label>{{ $t('settings.timezone.title') }}</label>
|
2025-09-10 17:08:30 +02:00
|
|
|
<div v-html="$t('settings.timezone.description')"></div>
|
2025-08-06 20:08:53 +02:00
|
|
|
</div>
|
2025-05-22 16:26:24 +02:00
|
|
|
<div style="display: flex; gap: 6px; align-items: center;">
|
|
|
|
|
<SingleSelect style="min-width: 160px" v-model="timeZone" :searchThreshold="10" :options="allTimezones" option-key="id" option-label="id" @select="onTimeZoneChange" />
|
|
|
|
|
</div>
|
|
|
|
|
</SettingsItem>
|
|
|
|
|
|
|
|
|
|
<SettingsItem wrap>
|
2025-08-06 20:08:53 +02:00
|
|
|
<div>
|
2025-05-22 16:26:24 +02:00
|
|
|
<label>{{ $t('settings.language.title') }}</label>
|
|
|
|
|
<div>{{ $t('settings.language.description') }}</div>
|
2025-08-06 20:08:53 +02:00
|
|
|
</div>
|
2025-05-22 16:26:24 +02:00
|
|
|
<div style="display: flex; gap: 6px; align-items: center;">
|
|
|
|
|
<SingleSelect v-model="language" :options="allLanguages" option-key="id" option-label="display" @select="onLanguageChange" />
|
|
|
|
|
</div>
|
|
|
|
|
</SettingsItem>
|
2025-02-17 11:18:57 +01:00
|
|
|
</Section>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|