Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce413cf6bc | ||
|
|
5102ca86cb | ||
|
|
eb3d2c86d7 |
10
Dockerfile
10
Dockerfile
@@ -13,9 +13,16 @@ RUN npm ci
|
|||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install git to extract version information
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Extract version from git
|
||||||
|
RUN git describe --tags --always 2>/dev/null > /tmp/version.txt || echo "unknown" > /tmp/version.txt
|
||||||
|
|
||||||
# Next.js collects completely anonymous telemetry data about general usage.
|
# Next.js collects completely anonymous telemetry data about general usage.
|
||||||
# Learn more here: https://nextjs.org/telemetry
|
# Learn more here: https://nextjs.org/telemetry
|
||||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||||
@@ -53,6 +60,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|||||||
# Create uploads directory and set permissions
|
# Create uploads directory and set permissions
|
||||||
RUN mkdir -p public/uploads/covers && chown -R nextjs:nodejs public/uploads
|
RUN mkdir -p public/uploads/covers && chown -R nextjs:nodejs public/uploads
|
||||||
|
|
||||||
|
# Copy version file from builder
|
||||||
|
COPY --from=builder /tmp/version.txt /app/version.txt
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
@@ -106,6 +106,9 @@ export default function AdminPage() {
|
|||||||
const [uploadGenreIds, setUploadGenreIds] = useState<number[]>([]);
|
const [uploadGenreIds, setUploadGenreIds] = useState<number[]>([]);
|
||||||
const [uploadExcludeFromGlobal, setUploadExcludeFromGlobal] = useState(false);
|
const [uploadExcludeFromGlobal, setUploadExcludeFromGlobal] = useState(false);
|
||||||
|
|
||||||
|
// Batch upload genre selection
|
||||||
|
const [batchUploadGenreIds, setBatchUploadGenreIds] = useState<number[]>([]);
|
||||||
|
|
||||||
// AI Categorization state
|
// AI Categorization state
|
||||||
const [isCategorizing, setIsCategorizing] = useState(false);
|
const [isCategorizing, setIsCategorizing] = useState(false);
|
||||||
const [categorizationResults, setCategorizationResults] = useState<any>(null);
|
const [categorizationResults, setCategorizationResults] = useState<any>(null);
|
||||||
@@ -548,6 +551,28 @@ export default function AdminPage() {
|
|||||||
setUploadResults(results);
|
setUploadResults(results);
|
||||||
setFiles([]);
|
setFiles([]);
|
||||||
setIsUploading(false);
|
setIsUploading(false);
|
||||||
|
|
||||||
|
// Assign genres to successfully uploaded songs
|
||||||
|
if (batchUploadGenreIds.length > 0) {
|
||||||
|
const successfulUploads = results.filter(r => r.success && r.song);
|
||||||
|
for (const result of successfulUploads) {
|
||||||
|
try {
|
||||||
|
await fetch('/api/songs', {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: getAuthHeaders(),
|
||||||
|
body: JSON.stringify({
|
||||||
|
id: result.song.id,
|
||||||
|
title: result.song.title,
|
||||||
|
artist: result.song.artist,
|
||||||
|
genreIds: batchUploadGenreIds
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Failed to assign genres to ${result.song.title}:`, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fetchSongs();
|
fetchSongs();
|
||||||
fetchGenres();
|
fetchGenres();
|
||||||
fetchSpecials(); // Update special counts
|
fetchSpecials(); // Update special counts
|
||||||
@@ -564,6 +589,13 @@ export default function AdminPage() {
|
|||||||
if (failedCount > 0) {
|
if (failedCount > 0) {
|
||||||
msg += `\n❌ ${failedCount} failed`;
|
msg += `\n❌ ${failedCount} failed`;
|
||||||
}
|
}
|
||||||
|
if (batchUploadGenreIds.length > 0) {
|
||||||
|
const selectedGenreNames = genres
|
||||||
|
.filter(g => batchUploadGenreIds.includes(g.id))
|
||||||
|
.map(g => g.name)
|
||||||
|
.join(', ');
|
||||||
|
msg += `\n🏷️ Assigned genres: ${selectedGenreNames}`;
|
||||||
|
}
|
||||||
msg += '\n\n🤖 Starting auto-categorization...';
|
msg += '\n\n🤖 Starting auto-categorization...';
|
||||||
setMessage(msg);
|
setMessage(msg);
|
||||||
// Small delay to let user see the message
|
// Small delay to let user see the message
|
||||||
@@ -1219,6 +1251,48 @@ export default function AdminPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<div style={{ marginBottom: '1rem' }}>
|
||||||
|
<label style={{ fontWeight: '500', display: 'block', marginBottom: '0.5rem' }}>
|
||||||
|
Assign Genres (optional)
|
||||||
|
</label>
|
||||||
|
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
|
||||||
|
{genres.map(genre => (
|
||||||
|
<label
|
||||||
|
key={genre.id}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '0.25rem',
|
||||||
|
padding: '0.25rem 0.5rem',
|
||||||
|
background: batchUploadGenreIds.includes(genre.id) ? '#dbeafe' : '#f3f4f6',
|
||||||
|
border: batchUploadGenreIds.includes(genre.id) ? '2px solid #3b82f6' : '2px solid transparent',
|
||||||
|
borderRadius: '0.25rem',
|
||||||
|
cursor: 'pointer',
|
||||||
|
fontSize: '0.875rem',
|
||||||
|
transition: 'all 0.2s'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={batchUploadGenreIds.includes(genre.id)}
|
||||||
|
onChange={e => {
|
||||||
|
if (e.target.checked) {
|
||||||
|
setBatchUploadGenreIds([...batchUploadGenreIds, genre.id]);
|
||||||
|
} else {
|
||||||
|
setBatchUploadGenreIds(batchUploadGenreIds.filter(id => id !== genre.id));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{ margin: 0 }}
|
||||||
|
/>
|
||||||
|
{genre.name}
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<p style={{ fontSize: '0.875rem', color: '#666', marginTop: '0.25rem' }}>
|
||||||
|
Selected genres will be assigned to all uploaded songs.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: '1rem' }}>
|
<div style={{ marginBottom: '1rem' }}>
|
||||||
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', cursor: 'pointer' }}>
|
<label style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', cursor: 'pointer' }}>
|
||||||
<input
|
<input
|
||||||
|
|||||||
47
app/api/version/route.ts
Normal file
47
app/api/version/route.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
try {
|
||||||
|
// First check if version is set via environment variable (Docker build)
|
||||||
|
if (process.env.APP_VERSION) {
|
||||||
|
return NextResponse.json({ version: process.env.APP_VERSION });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to get the git tag/version
|
||||||
|
let version = 'dev';
|
||||||
|
|
||||||
|
try {
|
||||||
|
// First try to get the exact tag if we're on a tagged commit
|
||||||
|
version = execSync('git describe --tags --exact-match 2>/dev/null', {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
cwd: process.cwd()
|
||||||
|
}).trim();
|
||||||
|
} catch {
|
||||||
|
try {
|
||||||
|
// If not on a tag, get the latest tag with commit info
|
||||||
|
version = execSync('git describe --tags --always 2>/dev/null', {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
cwd: process.cwd()
|
||||||
|
}).trim();
|
||||||
|
} catch {
|
||||||
|
// If git is not available or no tags exist, try to get commit hash
|
||||||
|
try {
|
||||||
|
const hash = execSync('git rev-parse --short HEAD 2>/dev/null', {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
cwd: process.cwd()
|
||||||
|
}).trim();
|
||||||
|
version = `dev-${hash}`;
|
||||||
|
} catch {
|
||||||
|
// Fallback to just 'dev' if git is not available
|
||||||
|
version = 'dev';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json({ version });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting version:', error);
|
||||||
|
return NextResponse.json({ version: 'unknown' });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ export const viewport: Viewport = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
import InstallPrompt from "@/components/InstallPrompt";
|
import InstallPrompt from "@/components/InstallPrompt";
|
||||||
|
import AppFooter from "@/components/AppFooter";
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children,
|
||||||
@@ -36,15 +37,7 @@ export default function RootLayout({
|
|||||||
<body className={`${geistSans.variable} ${geistMono.variable}`}>
|
<body className={`${geistSans.variable} ${geistMono.variable}`}>
|
||||||
{children}
|
{children}
|
||||||
<InstallPrompt />
|
<InstallPrompt />
|
||||||
<footer className="app-footer">
|
<AppFooter />
|
||||||
<p>
|
|
||||||
Vibe coded with ☕ and 🍺 by{' '}
|
|
||||||
<a href="https://digitalcourage.social/@elpatron" target="_blank" rel="noopener noreferrer">
|
|
||||||
@elpatron@digitalcourage.social
|
|
||||||
</a>
|
|
||||||
{' '}- for personal use among friends only!
|
|
||||||
</p>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
34
components/AppFooter.tsx
Normal file
34
components/AppFooter.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
export default function AppFooter() {
|
||||||
|
const [version, setVersion] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('/api/version')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => setVersion(data.version))
|
||||||
|
.catch(() => setVersion(''));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<footer className="app-footer">
|
||||||
|
<p>
|
||||||
|
Vibe coded with ☕ and 🍺 by{' '}
|
||||||
|
<a href="https://digitalcourage.social/@elpatron" target="_blank" rel="noopener noreferrer">
|
||||||
|
@elpatron@digitalcourage.social
|
||||||
|
</a>
|
||||||
|
{' '}- for personal use among friends only!
|
||||||
|
{version && (
|
||||||
|
<>
|
||||||
|
{' '}·{' '}
|
||||||
|
<span style={{ fontSize: '0.85em', opacity: 0.7 }}>
|
||||||
|
{version}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Export version if available
|
||||||
|
if [ -f /app/version.txt ]; then
|
||||||
|
export APP_VERSION=$(cat /app/version.txt)
|
||||||
|
echo "App version: $APP_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Starting deployment..."
|
echo "Starting deployment..."
|
||||||
|
|
||||||
# Run migrations
|
# Run migrations
|
||||||
|
|||||||
Reference in New Issue
Block a user