feat(admin): add asset picker with favorites, drag-and-drop reordering, preview links, and keyboard shortcuts

- Asset Picker: Visual browser for hero images with Favorites tab (shown first)
  and All Photos tab. Includes infinite scroll and UUID fallback input for
  assets not easily found in the grid.
- Drag & Drop: All lists (hero images, standalone albums, subpage albums,
  subpage tiles) are now reorderable via drag handles using @dnd-kit.
- Preview Links: 'Preview Site' button in save bar, '↗ Site' in header, and
  per-subpage preview links with URL slug preview shown inline.
- Keyboard Shortcuts: ⌘+S / Ctrl+S to save in both Pages and Settings tabs.
- Unsaved Changes Guard: beforeunload warning prevents accidental data loss.
- New API route /api/admin/assets for browsing Immich assets with pagination
  and favorites filter via search/metadata endpoint.
This commit is contained in:
ralksta
2026-05-29 17:59:25 +02:00
parent 2e4cde4b6e
commit e8e65e7172
8 changed files with 1075 additions and 174 deletions

View File

@@ -1120,6 +1120,245 @@
cursor: pointer;
}
/* ── Asset Picker (Hero) ───────────────────────────────────── */
.asset-picker-modal {
width: 100%;
max-width: 720px;
max-height: 85vh;
background: var(--admin-bg-raised);
border: 1px solid var(--admin-border);
border-radius: 12px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.asset-picker-tabs {
display: flex;
border-bottom: 1px solid var(--admin-border);
}
.asset-picker-tab {
flex: 1;
padding: 0.7rem 1rem;
background: none;
border: none;
color: var(--admin-text-muted);
font-size: 0.85rem;
cursor: pointer;
transition: all 0.15s;
border-bottom: 2px solid transparent;
}
.asset-picker-tab:hover {
color: var(--admin-text-secondary);
background: var(--admin-bg-elevated);
}
.asset-picker-tab.active {
color: var(--admin-text);
border-bottom-color: var(--admin-accent);
}
.asset-picker-grid {
flex: 1;
overflow-y: auto;
padding: 0.75rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
gap: 0.5rem;
align-content: start;
}
.asset-picker-loading {
grid-column: 1 / -1;
display: flex;
align-items: center;
justify-content: center;
padding: 3rem;
}
.asset-picker-loading-more {
grid-column: 1 / -1;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.asset-picker-tile {
position: relative;
aspect-ratio: 1;
border-radius: 8px;
overflow: hidden;
cursor: pointer;
background: var(--admin-bg-elevated);
border: 2px solid transparent;
transition: border-color 0.15s, transform 0.1s;
}
.asset-picker-tile:hover:not(.used) {
border-color: var(--admin-accent);
transform: scale(1.03);
}
.asset-picker-tile.used {
opacity: 0.4;
cursor: not-allowed;
}
.asset-picker-tile img {
width: 100%;
height: 100%;
object-fit: cover;
}
.asset-picker-used-badge {
position: absolute;
top: 4px;
right: 4px;
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--admin-accent);
color: #000;
font-size: 0.7rem;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
}
.asset-picker-fav-badge {
position: absolute;
top: 4px;
left: 4px;
font-size: 0.7rem;
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.asset-picker-uuid-section {
padding: 0.75rem 1rem;
border-top: 1px solid var(--admin-border);
background: var(--admin-bg);
}
.asset-picker-uuid-form {
display: flex;
gap: 0.5rem;
align-items: center;
}
.asset-picker-uuid-input {
flex: 1;
padding: 0.5rem 0.75rem;
background: var(--admin-bg-input);
border: 1px solid var(--admin-border);
border-radius: 6px;
color: var(--admin-text);
font-size: 0.8rem;
font-family: monospace;
}
.asset-picker-uuid-input:focus {
outline: none;
border-color: var(--admin-border-focus);
}
.asset-picker-uuid-error {
font-size: 0.7rem;
color: var(--admin-error);
margin-top: 0.3rem;
display: block;
}
/* ── Drag Handles ──────────────────────────────────────────── */
.hero-tile-drag,
.album-tile-drag,
.subpage-tile-drag {
position: absolute;
z-index: 5;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.85rem;
color: rgba(255, 255, 255, 0.8);
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(4px);
border-radius: 4px;
cursor: grab;
opacity: 0;
transition: opacity 0.15s;
user-select: none;
touch-action: none;
}
.hero-tile-drag:active,
.album-tile-drag:active,
.subpage-tile-drag:active {
cursor: grabbing;
}
.hero-tile-drag {
top: 6px;
left: 6px;
}
.album-tile-drag {
top: 6px;
left: 6px;
}
.subpage-tile-drag {
top: 6px;
left: 6px;
}
.hero-tile:hover .hero-tile-drag,
.album-tile:hover .album-tile-drag,
.subpage-tile:hover .subpage-tile-drag {
opacity: 1;
}
/* ── Preview & Slug ───────────────────────────────────────────── */
.subpage-slug-preview {
font-size: 0.72rem;
color: var(--admin-text-muted);
font-family: monospace;
padding: 0.15rem 0.4rem;
background: var(--admin-bg);
border-radius: 3px;
white-space: nowrap;
}
.save-bar-right {
display: flex;
align-items: center;
gap: 0.5rem;
}
.admin-btn-preview {
font-size: 0.8rem;
padding: 0.4rem 0.8rem;
text-decoration: none;
}
.save-hint {
font-size: 0.7rem;
color: var(--admin-text-muted);
}
/* ── Danger icon button ───────────────────────────────────────── */
.admin-btn-icon-danger:hover {
color: var(--admin-error) !important;
}
/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {