Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5102ca86cb | ||
|
|
eb3d2c86d7 |
@@ -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
|
||||||
|
|||||||
42
app/api/version/route.ts
Normal file
42
app/api/version/route.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
try {
|
||||||
|
// 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user