#307 Add ipp.upload.notice for a customisable notice on the upload page

This commit is contained in:
Alan Grainger
2026-10-19 14:25:55 +13:00
parent c739e931ea
commit 8bf1d753aa
9 changed files with 47 additions and 18 deletions
-2
View File
@@ -32,7 +32,6 @@ const run = createLimiter(CONCURRENT_UPLOADS)
const panelEl = document.getElementById('upload-panel') as HTMLElement
const progressEl = document.getElementById('upload-progress') as HTMLElement
const countsEl = document.getElementById('upload-counts') as HTMLElement
const noteEl = document.getElementById('upload-note') as HTMLElement
const listEl = document.getElementById('upload-list') as HTMLElement
const dropEl = document.getElementById('upload-drop') as HTMLElement
@@ -72,7 +71,6 @@ function updateSummary () {
uploaded.textContent = String(stats.uploaded)
errors.textContent = String(stats.errors)
duplicates.textContent = String(stats.duplicates)
noteEl.hidden = stats.remaining > 0 || stats.uploaded === 0
}
function setState (row: UploadRow, state: RowState) {
+6
View File
@@ -32,6 +32,12 @@ export function filenamePrefix (): string {
return typeof configured === 'string' ? configured : ''
}
/** Text shown under the placeholder on the upload page, from `ipp.upload.notice`. Empty hides it. */
export function uploadNotice (): string {
const configured = getConfigOption('ipp.upload.notice', 'Uploaded photos may not appear in the gallery immediately.')
return typeof configured === 'string' ? configured : ''
}
/** Notification webhook settings from `ipp.upload.notify*`, or undefined when no URL is set. */
export function notifyConfig (): { url: string, headers: Record<string, string>, timeoutMs: number } | undefined {
const url = getConfigOption('ipp.upload.notifyUrl', '')
+3 -2
View File
@@ -28,7 +28,7 @@ import {
title,
unlockHandler
} from '@ipp/core'
import { galleryUrl, maxFileSize } from './config'
import { galleryUrl, maxFileSize, uploadNotice } from './config'
import { uploadAllowed } from './gate'
import { createUploadReceiver } from './receive'
import { getShare } from './share'
@@ -142,7 +142,8 @@ router.get('/:shareType(share|s)/:key', decodeCookie, asyncHandler(async (req, r
title: title(resolved.link)
},
basePath: req.baseUrl,
galleryLink: gallery && `${gallery}/${req.params.shareType}/${encodeURIComponent(key)}`
galleryLink: gallery && `${gallery}/${req.params.shareType}/${encodeURIComponent(key)}`,
notice: uploadNotice()
})))
}))
+4 -2
View File
@@ -9,6 +9,8 @@ export interface UploadPageProps {
basePath: string
/** This share's gallery on IPP, when `PUBLIC_BASE_URL` is set. */
galleryLink?: string
/** Plain text shown under the placeholder. Empty hides it. */
notice: string
}
function Icon ({ path, class: className }: { path: string, class?: string }) {
@@ -24,7 +26,7 @@ function Icon ({ path, class: className }: { path: string, class?: string }) {
* gallery's header, a placeholder to click or drop on, and an upload panel
* the client fills.
*/
export function UploadPage ({ config, basePath, galleryLink }: UploadPageProps) {
export function UploadPage ({ config, basePath, galleryLink, notice }: UploadPageProps) {
const staticPath = `${basePath}/share/static/${ASSET_VERSION}`
return (
<html lang="en">
@@ -55,11 +57,11 @@ export function UploadPage ({ config, basePath, galleryLink }: UploadPageProps)
<span class="upload-placeholder-title">Add photos</span>
<span class="upload-placeholder-text">Choose photos and videos<span class="upload-drop-hint">, or drop them here</span></span>
</button>
{notice && <p class="upload-notice">{notice}</p>}
<input id="upload-input" type="file" multiple accept={UPLOAD_ACCEPT} hidden/>
<section id="upload-panel" hidden aria-live="polite" aria-label="Uploads">
<p id="upload-progress"></p>
<p id="upload-counts"></p>
<p id="upload-note" hidden>New photos appear in the gallery once Immich has processed them.</p>
<ul id="upload-list"></ul>
</section>
</main>