Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(cloud): use toasts for action feedback and fix site address display

Timothy Yin12780576f32a
diff --git a/apps/cloud/app/assets/cloud.css b/apps/cloud/app/assets/cloud.css
index 03a85ae9..494a34e6 100644
--- a/apps/cloud/app/assets/cloud.css
+++ b/apps/cloud/app/assets/cloud.css
@@ -1417,6 +1417,14 @@
font-size: 11px;
color: var(--muted-foreground);
}
+.cf-site-address-row {
+ flex-wrap: nowrap;
+}
+.cf-site-address-row > button,
+.cf-site-address-row > a {
+ flex-shrink: 0;
+ white-space: nowrap;
+}
.cf-site-address-value {
flex: 1;
min-width: 0;
@@ -1424,14 +1432,6 @@
overflow-wrap: anywhere;
user-select: text;
}
-@media (max-width: 600px) {
- .cf-site-address-label {
- flex-basis: 100%;
- }
- .cf-site-address-value {
- flex-basis: calc(100% - 90px);
- }
-}
.cf-site-settings-stack {
display: grid;
gap: 22px;
diff --git a/apps/cloud/app/components/CloudAccountConnections.vue b/apps/cloud/app/components/CloudAccountConnections.vue
index 3a5ec2b8..3a96f0e9 100644
--- a/apps/cloud/app/components/CloudAccountConnections.vue
+++ b/apps/cloud/app/components/CloudAccountConnections.vue
@@ -23,6 +23,17 @@ const busy = ref(''),
? t('cloud.connections.linkedNotice')
: '',
)
+const toast = useToast()
+watch(error, (text) => text && toast.add({ title: text, color: 'error' }), {
+ flush: 'sync',
+})
+watch(notice, (text) => text && toast.add({ title: text, color: 'success' }), {
+ flush: 'sync',
+})
+onMounted(() => {
+ if (error.value) toast.add({ title: error.value, color: 'error' })
+ if (notice.value) toast.add({ title: notice.value, color: 'success' })
+})
const removing = ref<{ account: Connection; name: string } | null>(null)
type ConnectionRow = {
provider: Provider
@@ -127,18 +138,11 @@ async function unlink() {
</div>
<div class="cf-settings-body cf-connections-body">
<p
- v-if="error || loadError"
+ v-if="loadError"
class="cf-error-message"
role="alert"
>
- {{ error || $t('cloud.connections.loadFailed') }}
- </p>
- <p
- v-if="notice"
- class="cf-notice"
- role="status"
- >
- {{ notice }}
+ {{ $t('cloud.connections.loadFailed') }}
</p>
<div
v-for="row in rows"
diff --git a/apps/cloud/app/components/CloudAccountProfile.vue b/apps/cloud/app/components/CloudAccountProfile.vue
index 8990af93..20321df3 100644
--- a/apps/cloud/app/components/CloudAccountProfile.vue
+++ b/apps/cloud/app/components/CloudAccountProfile.vue
@@ -8,6 +8,13 @@ const busy = ref(false),
processing = ref(false),
error = ref(''),
notice = ref('')
+const toast = useToast()
+watch(error, (text) => text && toast.add({ title: text, color: 'error' }), {
+ flush: 'sync',
+})
+watch(notice, (text) => text && toast.add({ title: text, color: 'success' }), {
+ flush: 'sync',
+})
async function chooseImage(event: Event) {
const input = event.target as HTMLInputElement
const file = input.files?.[0]
@@ -136,20 +143,6 @@ async function save() {
@change="chooseImage"
/>
</UFormField>
- <p
- v-if="error"
- class="cf-error-message"
- role="alert"
- >
- {{ error }}
- </p>
- <p
- v-if="notice"
- class="cf-notice"
- role="status"
- >
- {{ notice }}
- </p>
<div>
<CfButton
type="submit"
diff --git a/apps/cloud/app/components/CloudAlbumsManager.vue b/apps/cloud/app/components/CloudAlbumsManager.vue
index ba2bb609..cbfa2588 100644
--- a/apps/cloud/app/components/CloudAlbumsManager.vue
+++ b/apps/cloud/app/components/CloudAlbumsManager.vue
@@ -16,8 +16,6 @@ import type { Album, Photo } from '@chronoframe/contracts/resources'
import type { TableColumn } from '@nuxt/ui'
const {
albums,
- message,
- failed,
photos,
admin,
busy,
@@ -463,13 +461,6 @@ function menu(album: Album) {
:ui="{ footer: 'justify-end' }"
><template #body
><p
- v-if="failed && message"
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ message }}
- </p>
- <p
v-if="!loaded"
role="status"
>
diff --git a/apps/cloud/app/components/CloudMapSettings.vue b/apps/cloud/app/components/CloudMapSettings.vue
index 6c58d39f..c82fafa1 100644
--- a/apps/cloud/app/components/CloudMapSettings.vue
+++ b/apps/cloud/app/components/CloudMapSettings.vue
@@ -16,14 +16,11 @@ const draft = ref({
'maplibre.style': '',
...data.value?.config,
})
-const busy = ref(false),
- message = ref(''),
- failed = ref(false)
+const busy = ref(false)
+const toast = useToast()
async function save() {
if (!data.value || busy.value) return
busy.value = true
- message.value = ''
- failed.value = false
try {
const result = await $fetch(`/api/sites/${props.siteId}/map`, {
method: 'PUT',
@@ -36,13 +33,18 @@ async function save() {
error.value = null
if (context.value?.siteId === props.siteId && data.value)
store.data.map = { ...data.value.effective }
- message.value = t('Map settings saved.', '地图设置已保存。')
+ toast.add({
+ title: t('Map settings saved.', '地图设置已保存。'),
+ color: 'success',
+ })
} catch {
- failed.value = true
- message.value = t(
- 'Unable to save. Check public tokens and style URLs, then reload if someone else changed these settings.',
- '保存失败,请检查公共令牌和样式地址;如设置已被他人更改,请刷新后重试。',
- )
+ toast.add({
+ title: t(
+ 'Unable to save. Check public tokens and style URLs, then reload if someone else changed these settings.',
+ '保存失败,请检查公共令牌和样式地址;如设置已被他人更改,请刷新后重试。',
+ ),
+ color: 'error',
+ })
} finally {
busy.value = false
}
@@ -136,11 +138,6 @@ async function save() {
>
</div>
</fieldset>
- <CfAlert
- v-if="message"
- :tone="failed ? 'error' : 'info'"
- >{{ message }}</CfAlert
- >
</form>
</div>
</CfCard>
diff --git a/apps/cloud/app/components/CloudPhotoLibrary.vue b/apps/cloud/app/components/CloudPhotoLibrary.vue
index de808d24..c0abe48c 100644
--- a/apps/cloud/app/components/CloudPhotoLibrary.vue
+++ b/apps/cloud/app/components/CloudPhotoLibrary.vue
@@ -14,8 +14,6 @@ import type { Photo } from '@chronoframe/contracts/resources'
import type { TableColumn } from '@nuxt/ui'
const {
photos,
- message,
- failed,
albums,
loading,
ready,
@@ -569,13 +567,6 @@ watch(
:ui="{ footer: 'justify-end' }"
><template #body
><p
- v-if="failed && message"
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ message }}
- </p>
- <p
v-if="photoLoaded !== editPhoto.id"
role="status"
>
diff --git a/apps/cloud/app/components/CloudProcessingSettings.vue b/apps/cloud/app/components/CloudProcessingSettings.vue
index d4801a0b..58dfdf21 100644
--- a/apps/cloud/app/components/CloudProcessingSettings.vue
+++ b/apps/cloud/app/components/CloudProcessingSettings.vue
@@ -2,6 +2,10 @@
const props = defineProps<{ siteId: number }>()
const { locale } = useI18n(),
t = (en: string, zh: string) => (locale.value === 'zh-Hans' ? zh : en)
+const saveFailed = t(
+ 'Unable to save; reload and retry.',
+ '保存失败,请重新加载后重试。',
+)
const endpoint = `/api/sites/${props.siteId}/media/processing-settings`
const { data, error, refresh } = await useFetch<{
eraseLocation: boolean | number
@@ -10,6 +14,14 @@ const { data, error, refresh } = await useFetch<{
const erase = ref(!!data.value?.eraseLocation),
busy = ref(false),
message = ref('')
+const toast = useToast()
+watch(message, (text) => {
+ if (text)
+ toast.add({
+ title: text,
+ color: text === saveFailed ? 'error' : 'success',
+ })
+})
async function save() {
if (!data.value || busy.value) return
busy.value = true
@@ -22,10 +34,7 @@ async function save() {
await refresh()
message.value = t('Processing settings saved.', '处理设置已保存。')
} catch {
- message.value = t(
- 'Unable to save; reload and retry.',
- '保存失败,请重新加载后重试。',
- )
+ message.value = saveFailed
} finally {
busy.value = false
}
@@ -66,12 +75,6 @@ async function save() {
>
{{ t('Unable to load processing settings.', '无法加载处理设置。') }}
</p>
- <p
- v-if="message"
- role="status"
- >
- {{ message }}
- </p>
<div class="cf-site-actions">
<CfButton
type="submit"
diff --git a/apps/cloud/app/components/CloudSecuritySettings.vue b/apps/cloud/app/components/CloudSecuritySettings.vue
index 9c2c163e..eba1f94f 100644
--- a/apps/cloud/app/components/CloudSecuritySettings.vue
+++ b/apps/cloud/app/components/CloudSecuritySettings.vue
@@ -20,6 +20,13 @@ const busy = ref(false),
qr = ref(''),
totpURI = ref(''),
backupCodes = ref<string[]>([])
+const toast = useToast()
+watch(error, (text) => text && toast.add({ title: text, color: 'error' }), {
+ flush: 'sync',
+})
+watch(notice, (text) => text && toast.add({ title: text, color: 'success' }), {
+ flush: 'sync',
+})
async function run(action: () => Promise<void>) {
if (busy.value) return
busy.value = true
@@ -151,20 +158,6 @@ async function deletePasskey(id: number) {
</p>
</div>
</div>
- <p
- v-if="error"
- class="cf-error-message"
- role="alert"
- >
- {{ error }}
- </p>
- <p
- v-if="notice"
- class="cf-notice"
- role="status"
- >
- {{ notice }}
- </p>
<CfCard class="cf-security-card"
><div class="cf-settings-intro">
<h2>{{ $t('cloud.messages.password') }}</h2>
diff --git a/apps/cloud/app/components/CloudSitePublication.vue b/apps/cloud/app/components/CloudSitePublication.vue
index 647f9183..5dcc8aec 100644
--- a/apps/cloud/app/components/CloudSitePublication.vue
+++ b/apps/cloud/app/components/CloudSitePublication.vue
@@ -23,8 +23,6 @@ const {
refresh: refreshDomains,
} = useFetch<DomainOverview>(`/api/sites/${context.value?.siteId}/domains`)
const customHost = computed(() => {
- if (!domainOverview.value?.enabled || !domainOverview.value.routingReady)
- return undefined
const eligible =
domainOverview.value?.domains.filter(
(d) => d.status === 'active' && !d.holdReason && !d.cleanupPending,
@@ -40,14 +38,13 @@ const host = computed(
)
const address = computed(() => (host.value ? `https://${host.value}` : ''))
const copied = ref(false),
- copyError = ref(false),
- unpublishOpen = ref(false),
- unpublishError = ref('')
+ unpublishOpen = ref(false)
+const toast = useToast()
+const { t } = useI18n()
let copiedTimer: ReturnType<typeof setTimeout> | undefined
onBeforeUnmount(() => clearTimeout(copiedTimer))
async function copyAddress() {
copied.value = false
- copyError.value = false
try {
await navigator.clipboard.writeText(address.value)
copied.value = true
@@ -56,16 +53,26 @@ async function copyAddress() {
copied.value = false
}, 2500)
} catch {
- copyError.value = true
+ toast.add({
+ title: t('cloud.messages.couldNotCopyTheLinkSelectAndCopyThe'),
+ color: 'error',
+ })
}
}
-watch(unpublishOpen, () => {
- unpublishError.value = ''
+watch(domainError, (err) => {
+ if (err)
+ toast.add({
+ title: t('cloud.domains.loadFailed'),
+ color: 'error',
+ actions: [
+ { label: t('cloud.messages.retry'), onClick: () => refreshDomains() },
+ ],
+ })
})
async function unpublish() {
- unpublishError.value = ''
await publish(false)
- if (failed.value) unpublishError.value = message.value
+ if (failed.value)
+ toast.add({ title: message.value, color: 'error' })
if (!context.value?.published) unpublishOpen.value = false
}
</script>
@@ -118,29 +125,11 @@ async function unpublish() {
>
{{ $t('cloud.domains.routingPending') }}
</p>
- <CfAlert
- v-if="domainError"
- tone="error"
- >{{ $t('cloud.domains.loadFailed')
- }}<template #actions
- ><CfButton
- size="sm"
- variant="secondary"
- @click="refreshDomains()"
- >{{ $t('cloud.messages.retry') }}</CfButton
- ></template
- ></CfAlert
- >
<div class="cf-site-address-block">
<div
v-if="address"
class="cf-site-address-row"
>
- <span class="cf-site-address-label">{{
- context?.published
- ? $t('cloud.messages.publicAddress')
- : $t('cloud.messages.reservedAddress')
- }}</span>
<span class="cf-site-address-value">{{ address }}</span>
<CfButton
variant="ghost"
@@ -187,23 +176,6 @@ async function unpublish() {
>
{{ $t('cloud.messages.noDefaultAddressIsAvailableForThisSite') }}
</p>
- <p
- v-if="!context?.published"
- class="cf-draft-hint"
- >
- {{ $t(admin ? 'cloud.ui.draftReady' : 'cloud.ui.draftAskAdmin') }}
- </p>
- <p
- v-if="copied || copyError"
- class="cf-draft-hint"
- role="status"
- >
- {{
- copyError
- ? $t('cloud.messages.couldNotCopyTheLinkSelectAndCopyThe')
- : $t('cloud.messages.siteAddressCopiedToClipboard')
- }}
- </p>
</div>
<UModal
v-model:open="unpublishOpen"
@@ -213,16 +185,6 @@ async function unpublish() {
"
:dismissible="!busy"
>
- <template
- v-if="unpublishError"
- #body
- ><p
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ unpublishError }}
- </p></template
- >
<template #footer>
<CfButton
variant="secondary"
diff --git a/apps/cloud/app/components/CloudSiteSettings.vue b/apps/cloud/app/components/CloudSiteSettings.vue
index 8f78c3d7..477712f2 100644
--- a/apps/cloud/app/components/CloudSiteSettings.vue
+++ b/apps/cloud/app/components/CloudSiteSettings.vue
@@ -108,6 +108,14 @@ async function chooseIcon(event: Event) {
const busy = ref(false)
const message = ref('')
const failed = ref(false)
+const toast = useToast()
+watch(
+ message,
+ (text) =>
+ text &&
+ toast.add({ title: text, color: failed.value ? 'error' : 'success' }),
+ { flush: 'sync' },
+)
async function reload() {
await refresh()
name.value = data.value?.site.name ?? ''
@@ -409,13 +417,6 @@ async function save() {
)
}}
</p>
- <p
- v-if="message"
- :role="failed ? 'alert' : 'status'"
- class="cf-notice"
- >
- {{ message }}
- </p>
</div>
</template>
</CfCard>
diff --git a/apps/cloud/app/components/CloudSiteWorkspace.vue b/apps/cloud/app/components/CloudSiteWorkspace.vue
index d239ecb2..5239e8eb 100644
--- a/apps/cloud/app/components/CloudSiteWorkspace.vue
+++ b/apps/cloud/app/components/CloudSiteWorkspace.vue
@@ -21,6 +21,11 @@ const media = provideCloudSiteMedia(props)
const { photos, loading, message, failed, reload, loadError, refreshMedia } =
media
const status = computed(() => (loading.value ? 'pending' : 'success'))
+const toast = useToast()
+watch(message, (text) => {
+ if (text && text !== loadError.value)
+ toast.add({ title: text, color: failed.value ? 'error' : 'success' })
+})
</script>
<template>
<PhotosProvider
@@ -44,12 +49,6 @@ const status = computed(() => (loading.value ? 'pending' : 'success'))
></template
></CfAlert
>
- <CfAlert
- class="mb-4"
- v-if="message && message !== loadError"
- :tone="failed ? 'error' : 'info'"
- >{{ message }}</CfAlert
- >
<slot /><CloudUploadDrawer />
</PhotosProvider>
</template>
diff --git a/apps/cloud/app/components/CloudStorageSettings.vue b/apps/cloud/app/components/CloudStorageSettings.vue
index fd884cd6..baa00775 100644
--- a/apps/cloud/app/components/CloudStorageSettings.vue
+++ b/apps/cloud/app/components/CloudStorageSettings.vue
@@ -144,10 +144,6 @@ const byosAdmission = computed(() => quota.gate('byos'))
if (!value) removal = null
}
"
- ><template
- v-if="failed"
- #body
- ><CfAlert tone="error">{{ message }}</CfAlert></template
><template #footer
><CfButton
variant="secondary"
diff --git a/apps/cloud/app/components/CloudUploadDrawer.vue b/apps/cloud/app/components/CloudUploadDrawer.vue
index 0480fc54..6bd4b170 100644
--- a/apps/cloud/app/components/CloudUploadDrawer.vue
+++ b/apps/cloud/app/components/CloudUploadDrawer.vue
@@ -4,8 +4,6 @@ const {
uploadOpen,
albums,
selectedAlbumIds,
- message,
- failed,
connections,
connectionId,
upload,
@@ -63,14 +61,6 @@ async function startUpload() {
@upload="startUpload"
>
<template #before-files>
- <p
- v-if="message"
- :role="failed ? 'alert' : 'status'"
- class="cf-notice"
- :class="{ 'cf-notice-error': failed }"
- >
- {{ message }}
- </p>
<UFormField :label="$t('cloud.messages.storageConnection')">
<USelect
v-model="connectionId"
diff --git a/apps/cloud/app/pages/account/plan.vue b/apps/cloud/app/pages/account/plan.vue
index 62cde55e..58ace4a0 100644
--- a/apps/cloud/app/pages/account/plan.vue
+++ b/apps/cloud/app/pages/account/plan.vue
@@ -23,6 +23,12 @@ const latestSubscription = computed(() => {
})
const portalBusy = ref(false),
portalError = ref('')
+const toast = useToast()
+watch(
+ portalError,
+ (text) => text && toast.add({ title: text, color: 'error' }),
+ { flush: 'sync' },
+)
async function openBillingPortal() {
if (portalBusy.value) return
portalBusy.value = true
@@ -158,13 +164,6 @@ const date = (time: number) => new Date(time).toLocaleString(locale.value)
@click="openBillingPortal"
>{{ $t('cloud.payments.manage') }}</CfButton
>
- <p
- v-if="portalError"
- class="cf-error-message"
- role="alert"
- >
- {{ portalError }}
- </p>
<CfButton
v-if="data.workspace.role === 'admin'"
variant="secondary"
diff --git a/apps/cloud/app/pages/account/redeem.vue b/apps/cloud/app/pages/account/redeem.vue
index 9e159642..ac269ab9 100644
--- a/apps/cloud/app/pages/account/redeem.vue
+++ b/apps/cloud/app/pages/account/redeem.vue
@@ -21,6 +21,12 @@ watch([code, selected], () => {
requestId.value = ''
failure.value = ''
})
+const toast = useToast()
+watch(
+ failure,
+ (text) => text && toast.add({ title: text, color: 'error' }),
+ { flush: 'sync' },
+)
async function inspect() {
busy.value = true
failure.value = ''
@@ -185,13 +191,7 @@ const date = (time: number) => new Date(time).toLocaleString(locale.value)
>
{{ $t('cloud.billing.failed') }}
</p>
- <p
- v-if="failure"
- role="alert"
- class="cf-error-message"
- >
- {{ failure }}
- </p></CfCard
+</CfCard
>
<CloudLegalLinks />
</div>
diff --git a/apps/cloud/app/pages/sites/[siteId]/domains.vue b/apps/cloud/app/pages/sites/[siteId]/domains.vue
index efdd9bd8..dd41ea33 100644
--- a/apps/cloud/app/pages/sites/[siteId]/domains.vue
+++ b/apps/cloud/app/pages/sites/[siteId]/domains.vue
@@ -31,15 +31,14 @@ const addOpen = ref(false),
renameOpen = ref(false),
removal = shallowRef<CustomDomain | null>(null),
expandedHost = ref('')
-watch([addOpen, renameOpen, () => !!removal.value], (current, previous) => {
- if (
- failure.value &&
- current.some((open, index) => previous[index] && !open)
- ) {
- failure.value = false
- notice.value = ''
- }
-})
+const toast = useToast()
+watch(
+ notice,
+ (text) =>
+ text &&
+ toast.add({ title: text, color: failure.value ? 'error' : 'success' }),
+ { flush: 'sync' },
+)
watch(result, (value) => {
if (value) data.value = value
})
@@ -209,14 +208,6 @@ async function copy(value: string) {
>{{ t('cloud.messages.retry') }}</CfButton
>
</p>
- <p
- v-if="notice && !addOpen && !renameOpen && !removal"
- :role="failure ? 'alert' : 'status'"
- class="cf-notice"
- :class="{ 'cf-notice-error': failure }"
- >
- {{ notice }}
- </p>
<template v-if="data">
<CfCard
><div class="cf-panel-heading cf-domain-section-heading">
@@ -376,13 +367,6 @@ async function copy(value: string) {
required
/>
<p class="cf-field-hint">{{ t('cloud.domains.addHint') }}</p>
- <p
- v-if="failure"
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ notice }}
- </p>
<div class="cf-domain-modal-actions">
<CfButton
variant="secondary"
@@ -432,13 +416,6 @@ async function copy(value: string) {
<p class="cf-field-hint">
{{ t('cloud.domains.slugHint', { base: data?.baseDomain }) }}
</p>
- <p
- v-if="failure"
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ notice }}
- </p>
<div class="cf-domain-modal-actions">
<CfButton
variant="secondary"
@@ -468,14 +445,7 @@ async function copy(value: string) {
}
"
><template #body
- ><p
- v-if="failure"
- role="alert"
- class="cf-notice cf-notice-error"
- >
- {{ notice }}
- </p>
- <div class="cf-domain-modal-actions">
+ ><div class="cf-domain-modal-actions">
<CfButton
variant="secondary"
:disabled="busy"