diff --git a/dashboard/src/Index.vue b/dashboard/src/Index.vue index 28a34d117..e8799066d 100644 --- a/dashboard/src/Index.vue +++ b/dashboard/src/Index.vue @@ -203,9 +203,16 @@ ProfileModel.onChange(ProfileModel.KEYS.AVATAR, (value) => { profile.value.avatarUrl = value; }); +async function refreshProfile() { + const [error, result] = await profileModel.get(); + if (error) return console.error(error); + profile.value = result; +} + provide('subscriptionRequiredDialog', subscriptionRequiredDialog); provide('features', features); provide('profile', profile); +provide('refreshProfile', refreshProfile); onMounted(async () => { let [error, result] = await provisionModel.status(); @@ -222,9 +229,7 @@ onMounted(async () => { return; } - [error, result] = await profileModel.get(); - if (error) return console.error(error); - profile.value = result; + await refreshProfile(); // ensure language from profile if set if (profile.value.language) await setLanguage(profile.value.language); @@ -304,7 +309,7 @@ onMounted(async () => {
- +
diff --git a/dashboard/src/components/Headerbar.vue b/dashboard/src/components/Headerbar.vue index 1b1add015..5d6335fa9 100644 --- a/dashboard/src/components/Headerbar.vue +++ b/dashboard/src/components/Headerbar.vue @@ -12,7 +12,9 @@ import { prettyDate, prettyLongDate } from '@cloudron/pankow/utils'; import NotificationsModel from '../models/NotificationsModel.js'; import ServicesModel from '../models/ServicesModel.js'; -const props = defineProps(['config', 'profile', 'subscription']); +const props = defineProps(['config', 'subscription']); + +const profile = inject('profile'); const helpButton = useTemplateRef('helpButton'); const helpPopover = useTemplateRef('helpPopover'); @@ -95,7 +97,7 @@ const description = marked.parse(t('support.help.description', { })); onMounted(async () => { - if (props.profile.isAtLeastAdmin) await refresh(); + if (profile.isAtLeastAdmin) await refresh(); await trackPlatformStatus(); }); diff --git a/dashboard/src/models/ProfileModel.js b/dashboard/src/models/ProfileModel.js index f1e293138..7da9debe5 100644 --- a/dashboard/src/models/ProfileModel.js +++ b/dashboard/src/models/ProfileModel.js @@ -59,7 +59,7 @@ function create() { result.body.isAtLeastOwner = [ ROLES.OWNER ].indexOf(result.body.role) !== -1; result.body.backgroundImageUrl = result.body.hasBackgroundImage ? `${API_ORIGIN}/api/v1/profile/background_image?access_token=${accessToken}&bustcache=${Date.now()}` : ''; - result.body.avatarUrl = `${API_ORIGIN}/api/v1/profile/avatar/${result.body.id}`; + result.body.avatarUrl = `${API_ORIGIN}/api/v1/profile/avatar/${result.body.id}?ts=${Date.now()}`; profileCached = result.body; diff --git a/dashboard/src/views/ProfileView.vue b/dashboard/src/views/ProfileView.vue index db246e49d..47674f9cb 100644 --- a/dashboard/src/views/ProfileView.vue +++ b/dashboard/src/views/ProfileView.vue @@ -3,7 +3,7 @@ import { useI18n } from 'vue-i18n'; const { t } = useI18n(); -import { ref, onMounted, useTemplateRef } from 'vue'; +import { ref, onMounted, useTemplateRef, inject } from 'vue'; import { Button, SingleSelect, Dialog, InputDialog, TextInput, InputGroup, FormGroup } from '@cloudron/pankow'; import { setLanguage } from '../i18n.js'; import { TOKEN_TYPES } from '../constants.js'; @@ -28,8 +28,10 @@ const profileModel = ProfileModel.create(); const cloudronModel = CloudronModel.create(); const tokensModel = TokensModel.create(); +const profile = inject('profile'); +const refreshProfile = inject('refreshProfile'); + const config = ref({}); -const user = ref({}); const inputDialog = useTemplateRef('inputDialog'); const primaryEmailDialog = useTemplateRef('primaryEmailDialog'); const fallbackEmailDialog = useTemplateRef('fallbackEmailDialog'); @@ -46,13 +48,6 @@ async function onSelectLanguage(lang) { await setLanguage(lang); } -async function refreshProfile() { - const [error, result] = await profileModel.get(); - if (error) return console.error(error); - - user.value = result; -} - // Profile edits async function onChangeDisplayName(currentDisplayName) { const displayName = await inputDialog.value.prompt({ @@ -216,43 +211,43 @@ onMounted(async () => {
- +
-
{{ user.username }}
+
{{ profile.username }}
-
{{ user.displayName }}
+
{{ profile.displayName }}
- +
-
{{ user.email }}
+
{{ profile.email }}
- +
-
{{ user.fallbackEmail || 'unset' }}
+
{{ profile.fallbackEmail || 'unset' }}
- +
@@ -267,15 +262,15 @@ onMounted(async () => {
- +
- + - +

{{ $t('profile.loginTokens.description', { webadminTokenCount: webadminTokens.length, cliTokenCount: cliTokens.length }) }}