mirror of
https://github.com/nfonteyne/octane-website.git
synced 2026-09-03 23:24:48 +02:00
update: visual update, phone responsive, db migration
This commit is contained in:
parent
73ebd6ad49
commit
e97aa2c6c3
16 changed files with 894 additions and 244 deletions
|
|
@ -1,172 +1,421 @@
|
||||||
:root {
|
:root {
|
||||||
--bg: #f7f7f9;
|
--bg: #f4f3fb;
|
||||||
--surface: #ffffff;
|
--surface: #ffffff;
|
||||||
--text: #1c1c1e;
|
--surface-alt: #f7f6fd;
|
||||||
--muted: #6b6b70;
|
--text: #201f2b;
|
||||||
--border: #e2e2e6;
|
--muted: #6b6878;
|
||||||
--accent: #3457d5;
|
--border: #e4e1f0;
|
||||||
|
--accent: #6c4cf0;
|
||||||
|
--accent-2: #ff5f8f;
|
||||||
--accent-contrast: #ffffff;
|
--accent-contrast: #ffffff;
|
||||||
--danger: #c0392b;
|
--danger: #d1453d;
|
||||||
--success: #1e8e3e;
|
--danger-bg: #fdecea;
|
||||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
--success: #1e8e5a;
|
||||||
|
--success-bg: #e8f7ef;
|
||||||
|
--radius: 14px;
|
||||||
|
--radius-sm: 8px;
|
||||||
|
--shadow: 0 1px 2px rgba(32, 31, 43, 0.04), 0 4px 16px rgba(32, 31, 43, 0.06);
|
||||||
|
font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
--bg: #121214;
|
--bg: #15131f;
|
||||||
--surface: #1c1c1f;
|
--surface: #1e1c2b;
|
||||||
--text: #ececef;
|
--surface-alt: #262436;
|
||||||
--muted: #9a9aa2;
|
--text: #ece9f7;
|
||||||
--border: #2e2e33;
|
--muted: #a29fb5;
|
||||||
--accent: #7189e8;
|
--border: #322f42;
|
||||||
--accent-contrast: #0d0d0f;
|
--accent: #9884f5;
|
||||||
|
--accent-2: #ff85ac;
|
||||||
|
--accent-contrast: #15131f;
|
||||||
|
--danger: #ef6b64;
|
||||||
|
--danger-bg: #3a201f;
|
||||||
|
--success: #4fd190;
|
||||||
|
--success-bg: #163828;
|
||||||
|
--shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root[data-theme="dark"] {
|
||||||
|
--bg: #15131f;
|
||||||
|
--surface: #1e1c2b;
|
||||||
|
--surface-alt: #262436;
|
||||||
|
--text: #ece9f7;
|
||||||
|
--muted: #a29fb5;
|
||||||
|
--border: #322f42;
|
||||||
|
--accent: #9884f5;
|
||||||
|
--accent-2: #ff85ac;
|
||||||
|
--accent-contrast: #15131f;
|
||||||
|
--danger: #ef6b64;
|
||||||
|
--danger-bg: #3a201f;
|
||||||
|
--success: #4fd190;
|
||||||
|
--success-bg: #163828;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-theme="light"] {
|
||||||
|
--bg: #f4f3fb;
|
||||||
|
--surface: #ffffff;
|
||||||
|
--surface-alt: #f7f6fd;
|
||||||
|
--text: #201f2b;
|
||||||
|
--muted: #6b6878;
|
||||||
|
--border: #e4e1f0;
|
||||||
|
--accent: #6c4cf0;
|
||||||
|
--accent-2: #ff5f8f;
|
||||||
|
--accent-contrast: #ffffff;
|
||||||
|
--danger: #d1453d;
|
||||||
|
--danger-bg: #fdecea;
|
||||||
|
--success: #1e8e5a;
|
||||||
|
--success-bg: #e8f7ef;
|
||||||
|
}
|
||||||
|
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Header / nav ---------- */
|
||||||
|
|
||||||
header.app-header {
|
header.app-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 20;
|
||||||
background: var(--surface);
|
background: var(--surface);
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
padding: 0.75rem 1.5rem;
|
padding: 0 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav#main-nav {
|
nav#main-nav {
|
||||||
|
max-width: 1100px;
|
||||||
|
margin: 0 auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 1rem;
|
||||||
|
min-height: 60px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand {
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
color: var(--text);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand .brand-dot {
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-toggle {
|
||||||
|
display: none;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
color: var(--text);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.4rem 0.6rem;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.4rem;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-links a {
|
.nav-links a {
|
||||||
margin-right: 1rem;
|
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
padding: 0.3rem 0;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-links a.active, .nav-links a:hover {
|
.nav-links a.active {
|
||||||
|
color: var(--accent);
|
||||||
|
border-bottom-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links a:hover {
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-user {
|
.nav-user {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 0.9rem;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: 0.9rem;
|
font-size: 0.88rem;
|
||||||
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-user a {
|
.nav-user a {
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
background: var(--accent);
|
background: linear-gradient(135deg, var(--accent), var(--accent-2));
|
||||||
color: var(--accent-contrast);
|
color: #fff;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
padding: 0.1rem 0.5rem;
|
padding: 0.1rem 0.55rem;
|
||||||
font-size: 0.75rem;
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.03em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Layout ---------- */
|
||||||
|
|
||||||
main {
|
main {
|
||||||
max-width: 900px;
|
max-width: 1100px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 1.5rem;
|
padding: 1.75rem 1.25rem 4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 { font-size: 1.5rem; }
|
h1 {
|
||||||
h2 { font-size: 1.15rem; margin-top: 2rem; }
|
font-size: 1.65rem;
|
||||||
|
margin: 0 0 0.25rem;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
margin: 2.25rem 0 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 { font-size: 1rem; margin: 0 0 0.5rem; }
|
||||||
|
|
||||||
|
.page-subtitle {
|
||||||
|
color: var(--muted);
|
||||||
|
margin: 0 0 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Cards / grids ---------- */
|
||||||
|
|
||||||
|
.card-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||||
|
gap: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
background: var(--surface);
|
background: var(--surface);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 10px;
|
border-radius: var(--radius);
|
||||||
padding: 1rem 1.25rem;
|
padding: 1rem 1.15rem;
|
||||||
margin-bottom: 0.75rem;
|
margin-bottom: 0.75rem;
|
||||||
|
box-shadow: var(--shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-grid .card { margin-bottom: 0; }
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: baseline;
|
align-items: flex-start;
|
||||||
gap: 1rem;
|
gap: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-title { font-weight: 600; }
|
.card-title { font-weight: 600; font-size: 1.02rem; }
|
||||||
.card-subtitle { color: var(--muted); font-size: 0.9rem; }
|
.card-subtitle { color: var(--muted); font-size: 0.88rem; margin-top: 0.1rem; }
|
||||||
|
|
||||||
.tag-list {
|
/* ---------- Song card (repertoire) ---------- */
|
||||||
|
|
||||||
|
.song-card {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.9rem;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-thumb {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 96px;
|
||||||
|
height: 72px;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--surface-alt);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-thumb img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-thumb.placeholder {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-thumb a.play-overlay {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(0, 0, 0, 0.15);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
text-decoration: none;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-thumb:hover a.play-overlay { opacity: 1; }
|
||||||
|
|
||||||
|
.song-body {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-links {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.4rem;
|
gap: 0.4rem;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.pill-link {
|
||||||
background: var(--bg);
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.3rem;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 0.25rem 0.65rem;
|
||||||
|
border-radius: 999px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
color: var(--text);
|
||||||
padding: 0.15rem 0.5rem;
|
background: var(--surface-alt);
|
||||||
font-size: 0.8rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag a { color: var(--accent); text-decoration: none; }
|
.pill-link.youtube { color: #d1272b; border-color: #f3c8c9; }
|
||||||
|
.pill-link.spotify { color: #1db954; border-color: #bdeccb; }
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.pill-link.youtube { border-color: #5a2b2b; }
|
||||||
|
.pill-link.spotify { border-color: #205934; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Tags (tutorials / instruments) ---------- */
|
||||||
|
|
||||||
|
.tag-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.4rem;
|
||||||
|
margin-top: 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
background: var(--surface-alt);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.2rem 0.65rem;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag a { color: var(--accent); text-decoration: none; font-weight: 500; }
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
font-size: 0.92rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Forms ---------- */
|
||||||
|
|
||||||
form.inline-form {
|
form.inline-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
gap: 0.5rem;
|
gap: 0.7rem;
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.85rem;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
form.inline-form label {
|
form.inline-form label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
color: var(--muted);
|
||||||
|
gap: 0.3rem;
|
||||||
|
flex: 1 1 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.stacked-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.7rem;
|
||||||
|
max-width: 480px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.stacked-form label {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
gap: 0.25rem;
|
gap: 0.3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
padding: 0.4rem 0.5rem;
|
padding: 0.5rem 0.65rem;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 6px;
|
border-radius: var(--radius-sm);
|
||||||
background: var(--surface);
|
background: var(--surface);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea { resize: vertical; min-height: 4.5em; }
|
||||||
|
|
||||||
|
input:focus, select:focus, textarea:focus {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
padding: 0.45rem 0.9rem;
|
font-weight: 600;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 6px;
|
border-radius: 999px;
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
color: var(--accent-contrast);
|
color: var(--accent-contrast);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button:hover { filter: brightness(1.07); }
|
||||||
|
|
||||||
button.secondary {
|
button.secondary {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.icon-btn {
|
||||||
|
padding: 0.35rem 0.55rem;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
button.danger {
|
button.danger {
|
||||||
background: var(--danger);
|
background: var(--danger);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
@ -177,78 +426,222 @@ button:disabled {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
background: var(--surface-alt);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: 1rem 1.15rem;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Suggestions / voting ---------- */
|
||||||
|
|
||||||
.vote-tally {
|
.vote-tally {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
font-size: 0.9rem;
|
font-size: 0.88rem;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vote-tally .approve { color: var(--success); }
|
.vote-tally .approve { color: var(--success); }
|
||||||
.vote-tally .reject { color: var(--danger); }
|
.vote-tally .reject { color: var(--danger); }
|
||||||
|
|
||||||
.vote-list {
|
.vote-list {
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.75rem;
|
||||||
border-top: 1px solid var(--border);
|
border-top: 1px solid var(--border);
|
||||||
padding-top: 0.5rem;
|
padding-top: 0.6rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vote-item {
|
.vote-item {
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
margin-bottom: 0.35rem;
|
background: var(--surface-alt);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.45rem 0.65rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vote-item .voter { font-weight: 600; }
|
.vote-item .voter { font-weight: 600; }
|
||||||
|
.vote-item.approve { border-left: 3px solid var(--success); }
|
||||||
|
.vote-item.reject { border-left: 3px solid var(--danger); }
|
||||||
|
|
||||||
|
.suggestion-note {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background: var(--surface-alt);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.5rem 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
.youtube-embed {
|
.youtube-embed {
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
aspect-ratio: 16 / 9;
|
aspect-ratio: 16 / 9;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 480px;
|
max-width: 480px;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
overflow: hidden;
|
||||||
|
background: var(--surface-alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
.youtube-embed iframe {
|
.youtube-embed iframe {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.setlist-section h3 {
|
/* ---------- Setlist ---------- */
|
||||||
margin-bottom: 0.4rem;
|
|
||||||
|
.setlist-columns {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1.4fr;
|
||||||
|
gap: 1.25rem;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-section { margin-top: 1.5rem; }
|
||||||
|
.setlist-section h3 { margin-bottom: 0.5rem; }
|
||||||
|
|
||||||
|
.setlist-rows {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.6rem;
|
||||||
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.55rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-row .row-index {
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--muted);
|
||||||
|
width: 1.5rem;
|
||||||
|
text-align: center;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-row .row-main {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-row .row-title { font-weight: 600; }
|
||||||
|
.setlist-row .row-artist { color: var(--muted); font-size: 0.85rem; }
|
||||||
|
|
||||||
|
.setlist-row .row-note-input {
|
||||||
|
flex: 1 1 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setlist-row .row-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.25rem;
|
||||||
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol.setlist {
|
ol.setlist {
|
||||||
padding-left: 1.25rem;
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
ol.setlist li {
|
ol.setlist li {
|
||||||
margin-bottom: 0.5rem;
|
background: var(--surface);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
padding: 0.6rem 0.8rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.note {
|
.note {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
display: block;
|
display: block;
|
||||||
|
margin-top: 0.15rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------- Misc ---------- */
|
||||||
|
|
||||||
.error-banner {
|
.error-banner {
|
||||||
background: #fdecea;
|
background: var(--danger-bg);
|
||||||
color: var(--danger);
|
color: var(--danger);
|
||||||
border: 1px solid var(--danger);
|
border: 1px solid var(--danger);
|
||||||
border-radius: 8px;
|
border-radius: var(--radius-sm);
|
||||||
padding: 0.6rem 0.9rem;
|
padding: 0.6rem 0.9rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1.25rem;
|
||||||
}
|
font-size: 0.9rem;
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
.error-banner {
|
|
||||||
background: #3a1f1c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.back-link {
|
a.back-link {
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
|
display: inline-block;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.back-link:hover { color: var(--accent); }
|
||||||
|
|
||||||
|
/* ---------- Responsive / mobile ---------- */
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.setlist-columns {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
nav#main-nav { min-height: 56px; }
|
||||||
|
|
||||||
|
.nav-toggle { display: inline-flex; }
|
||||||
|
|
||||||
|
.nav-links {
|
||||||
|
order: 3;
|
||||||
|
flex-basis: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.1rem;
|
||||||
|
max-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links.open {
|
||||||
|
max-height: 260px;
|
||||||
|
padding: 0.4rem 0 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links a {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-user {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
main { padding: 1.25rem 0.9rem 3rem; }
|
||||||
|
|
||||||
|
.card-grid { grid-template-columns: 1fr; }
|
||||||
|
|
||||||
|
.song-card { flex-wrap: wrap; }
|
||||||
|
.song-thumb { width: 100%; height: 160px; }
|
||||||
|
|
||||||
|
form.inline-form { flex-direction: column; align-items: stretch; }
|
||||||
|
form.inline-form label { flex: 1 1 auto; }
|
||||||
|
|
||||||
|
.setlist-row {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.setlist-row .row-note-input { flex-basis: 100%; order: 4; }
|
||||||
|
.setlist-row .row-actions { flex-basis: 100%; order: 5; justify-content: flex-end; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,9 @@
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<h1>Historique des concerts</h1>
|
<h1>Historique des concerts</h1>
|
||||||
|
<p class="page-subtitle">Retrouvez la setlist jouée à chaque concert précédent.</p>
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
<div id="history-list"></div>
|
<div id="history-list" class="card-grid"></div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script src="/js/api.js"></script>
|
<script src="/js/api.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,23 @@
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<h1>Répertoire</h1>
|
<h1>Répertoire</h1>
|
||||||
|
<p class="page-subtitle">Les morceaux travaillés par le groupe, avec liens d'écoute et tutos par instrument.</p>
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
|
|
||||||
<div id="admin-add-song" style="display:none">
|
<div id="admin-add-song" class="panel" style="display:none">
|
||||||
<h2>Ajouter un morceau</h2>
|
<h2 style="margin-top:0">Ajouter un morceau</h2>
|
||||||
<form id="add-song-form" class="inline-form">
|
<form id="add-song-form" class="stacked-form">
|
||||||
<label>Titre <input name="title" required></label>
|
<label>Titre <input name="title" required></label>
|
||||||
<label>Artiste <input name="artist" required></label>
|
<label>Artiste <input name="artist" required></label>
|
||||||
<label>Notes <input name="notes"></label>
|
<label>Notes <input name="notes"></label>
|
||||||
<button type="submit">Ajouter</button>
|
<label>Lien YouTube <input name="youtubeUrl" type="url" placeholder="https://youtube.com/watch?v=..."></label>
|
||||||
|
<label>Lien Spotify <input name="spotifyUrl" type="url" placeholder="https://open.spotify.com/track/..."></label>
|
||||||
|
<button type="submit">Ajouter au répertoire</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Morceaux travaillés</h2>
|
<h2>Morceaux travaillés</h2>
|
||||||
<div id="songs-list"></div>
|
<div id="songs-list" class="card-grid"></div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script src="/js/api.js"></script>
|
<script src="/js/api.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,23 @@ function showError(message) {
|
||||||
const setlist = await api.get(`/api/setlists/${id}`);
|
const setlist = await api.get(`/api/setlists/${id}`);
|
||||||
const main = setlist.songs.filter((s) => !s.is_encore);
|
const main = setlist.songs.filter((s) => !s.is_encore);
|
||||||
const encore = setlist.songs.filter((s) => s.is_encore);
|
const encore = setlist.songs.filter((s) => s.is_encore);
|
||||||
|
const rowHtml = (s) => `<li><span class="row-title">${escapeHtml(s.title)}</span> <span class="row-artist">— ${escapeHtml(s.artist)}</span>${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`;
|
||||||
|
|
||||||
container.innerHTML = `
|
container.innerHTML = `
|
||||||
<h1>${escapeHtml(setlist.name || 'Concert')}</h1>
|
<div class="card">
|
||||||
<p class="card-subtitle">${escapeHtml(setlist.venue || '')} · ${formatDate(setlist.concert_date)}</p>
|
<div class="card-title">${escapeHtml(setlist.name || 'Concert')}</div>
|
||||||
|
<div class="card-subtitle">${escapeHtml(setlist.venue || '')} · ${formatDate(setlist.concert_date)}</div>
|
||||||
|
</div>
|
||||||
<div class="setlist-section">
|
<div class="setlist-section">
|
||||||
<h3>Setlist</h3>
|
<h3>Setlist</h3>
|
||||||
${main.length
|
${main.length
|
||||||
? `<ol class="setlist">${main.map((s) => `<li>${escapeHtml(s.title)} — ${escapeHtml(s.artist)}${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
? `<ol class="setlist">${main.map(rowHtml).join('')}</ol>`
|
||||||
: '<p class="empty">Aucun morceau enregistré.</p>'}
|
: '<p class="empty">Aucun morceau enregistré.</p>'}
|
||||||
</div>
|
</div>
|
||||||
<div class="setlist-section">
|
<div class="setlist-section">
|
||||||
<h3>Rappel</h3>
|
<h3>Rappel</h3>
|
||||||
${encore.length
|
${encore.length
|
||||||
? `<ol class="setlist">${encore.map((s) => `<li>${escapeHtml(s.title)} — ${escapeHtml(s.artist)}${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
? `<ol class="setlist">${encore.map(rowHtml).join('')}</ol>`
|
||||||
: '<p class="empty">Aucun rappel enregistré.</p>'}
|
: '<p class="empty">Aucun rappel enregistré.</p>'}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ async function initNav(activePage) {
|
||||||
const me = await api.get('/api/users/me');
|
const me = await api.get('/api/users/me');
|
||||||
const nav = document.getElementById('main-nav');
|
const nav = document.getElementById('main-nav');
|
||||||
nav.innerHTML = `
|
nav.innerHTML = `
|
||||||
<div class="nav-links">
|
<span class="brand"><span class="brand-dot">♫</span> Octane</span>
|
||||||
|
<button type="button" class="nav-toggle" id="nav-toggle" aria-label="Menu">☰</button>
|
||||||
|
<div class="nav-links" id="nav-links">
|
||||||
<a href="/index.html" class="${activePage === 'repertoire' ? 'active' : ''}">Répertoire</a>
|
<a href="/index.html" class="${activePage === 'repertoire' ? 'active' : ''}">Répertoire</a>
|
||||||
<a href="/suggestions.html" class="${activePage === 'suggestions' ? 'active' : ''}">Suggestions</a>
|
<a href="/suggestions.html" class="${activePage === 'suggestions' ? 'active' : ''}">Suggestions</a>
|
||||||
<a href="/setlist.html" class="${activePage === 'setlist' ? 'active' : ''}">Prochain concert</a>
|
<a href="/setlist.html" class="${activePage === 'setlist' ? 'active' : ''}">Prochain concert</a>
|
||||||
|
|
@ -13,5 +15,11 @@ async function initNav(activePage) {
|
||||||
<a href="/auth/logout">Se déconnecter</a>
|
<a href="/auth/logout">Se déconnecter</a>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const toggle = document.getElementById('nav-toggle');
|
||||||
|
const links = document.getElementById('nav-links');
|
||||||
|
toggle.addEventListener('click', () => links.classList.toggle('open'));
|
||||||
|
links.querySelectorAll('a').forEach((a) => a.addEventListener('click', () => links.classList.remove('open')));
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,19 +12,30 @@ function escapeHtml(str) {
|
||||||
}[c]));
|
}[c]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function youtubeEmbedUrl(url) {
|
function youtubeVideoId(url) {
|
||||||
try {
|
try {
|
||||||
const parsed = new URL(url);
|
const parsed = new URL(url);
|
||||||
let videoId = null;
|
|
||||||
if (parsed.hostname === 'youtu.be') {
|
if (parsed.hostname === 'youtu.be') {
|
||||||
videoId = parsed.pathname.slice(1);
|
return parsed.pathname.slice(1) || null;
|
||||||
} else if (parsed.pathname === '/watch') {
|
|
||||||
videoId = parsed.searchParams.get('v');
|
|
||||||
} else if (parsed.pathname.startsWith('/embed/')) {
|
|
||||||
videoId = parsed.pathname.split('/embed/')[1];
|
|
||||||
}
|
}
|
||||||
return videoId ? `https://www.youtube.com/embed/${videoId}` : null;
|
if (parsed.pathname === '/watch') {
|
||||||
|
return parsed.searchParams.get('v');
|
||||||
|
}
|
||||||
|
if (parsed.pathname.startsWith('/embed/')) {
|
||||||
|
return parsed.pathname.split('/embed/')[1] || null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function youtubeEmbedUrl(url) {
|
||||||
|
const videoId = youtubeVideoId(url);
|
||||||
|
return videoId ? `https://www.youtube.com/embed/${videoId}` : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function youtubeThumbnailUrl(url) {
|
||||||
|
const videoId = youtubeVideoId(url);
|
||||||
|
return videoId ? `https://img.youtube.com/vi/${videoId}/mqdefault.jpg` : null;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ let me = null;
|
||||||
let instruments = [];
|
let instruments = [];
|
||||||
let songs = [];
|
let songs = [];
|
||||||
const expanded = new Set();
|
const expanded = new Set();
|
||||||
|
const editing = new Set();
|
||||||
|
|
||||||
async function loadInstruments() {
|
async function loadInstruments() {
|
||||||
instruments = await api.get('/api/instruments');
|
instruments = await api.get('/api/instruments');
|
||||||
|
|
@ -16,21 +17,56 @@ function instrumentOptions() {
|
||||||
return instruments.map((i) => `<option value="${i.id}">${escapeHtml(i.name)}</option>`).join('');
|
return instruments.map((i) => `<option value="${i.id}">${escapeHtml(i.name)}</option>`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function songThumbTemplate(song) {
|
||||||
|
const thumb = song.youtube_url ? youtubeThumbnailUrl(song.youtube_url) : null;
|
||||||
|
if (thumb) {
|
||||||
|
return `
|
||||||
|
<div class="song-thumb">
|
||||||
|
<img src="${thumb}" alt="${escapeHtml(song.title)}" loading="lazy">
|
||||||
|
<a class="play-overlay" href="${escapeHtml(song.youtube_url)}" target="_blank" rel="noopener" title="Écouter sur YouTube">►</a>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
return `<div class="song-thumb placeholder">♫</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function songLinksTemplate(song) {
|
||||||
|
const links = [];
|
||||||
|
if (song.youtube_url) {
|
||||||
|
links.push(`<a class="pill-link youtube" href="${escapeHtml(song.youtube_url)}" target="_blank" rel="noopener">► YouTube</a>`);
|
||||||
|
}
|
||||||
|
if (song.spotify_url) {
|
||||||
|
links.push(`<a class="pill-link spotify" href="${escapeHtml(song.spotify_url)}" target="_blank" rel="noopener">♫ Spotify</a>`);
|
||||||
|
}
|
||||||
|
return links.length ? `<div class="song-links">${links.join('')}</div>` : '';
|
||||||
|
}
|
||||||
|
|
||||||
function songCardTemplate(song) {
|
function songCardTemplate(song) {
|
||||||
|
if (editing.has(song.id)) return editSongCardTemplate(song);
|
||||||
|
|
||||||
const isOpen = expanded.has(song.id);
|
const isOpen = expanded.has(song.id);
|
||||||
return `
|
return `
|
||||||
<div class="card" data-song-id="${song.id}">
|
<div class="card" data-song-id="${song.id}">
|
||||||
|
<div class="song-card">
|
||||||
|
${songThumbTemplate(song)}
|
||||||
|
<div class="song-body">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div>
|
<div>
|
||||||
<div class="card-title">${escapeHtml(song.title)}</div>
|
<div class="card-title">${escapeHtml(song.title)}</div>
|
||||||
<div class="card-subtitle">${escapeHtml(song.artist)}</div>
|
<div class="card-subtitle">${escapeHtml(song.artist)}</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="secondary toggle-tutorials" data-id="${song.id}">
|
|
||||||
${isOpen ? 'Masquer les tutos' : `Tutos (${song.tutorial_count})`}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
${song.notes ? `<p class="note">${escapeHtml(song.notes)}</p>` : ''}
|
${song.notes ? `<p class="note">${escapeHtml(song.notes)}</p>` : ''}
|
||||||
<div class="tutorials-panel" style="${isOpen ? '' : 'display:none'}">
|
${songLinksTemplate(song)}
|
||||||
|
<div class="song-links">
|
||||||
|
<button class="secondary icon-btn toggle-tutorials" data-id="${song.id}">
|
||||||
|
${isOpen ? 'Masquer les tutos' : `Tutos (${song.tutorial_count})`}
|
||||||
|
</button>
|
||||||
|
${me && me.isAdmin ? `<button class="secondary icon-btn edit-song" data-id="${song.id}">Modifier</button>` : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="tutorials-panel panel" style="${isOpen ? '' : 'display:none'}">
|
||||||
<div class="tag-list" data-tutorials-for="${song.id}"><p class="empty">Chargement…</p></div>
|
<div class="tag-list" data-tutorials-for="${song.id}"><p class="empty">Chargement…</p></div>
|
||||||
${me && me.isAdmin ? `
|
${me && me.isAdmin ? `
|
||||||
<form class="inline-form add-tutorial-form" data-song-id="${song.id}">
|
<form class="inline-form add-tutorial-form" data-song-id="${song.id}">
|
||||||
|
|
@ -46,15 +82,53 @@ function songCardTemplate(song) {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function editSongCardTemplate(song) {
|
||||||
|
return `
|
||||||
|
<div class="card" data-song-id="${song.id}">
|
||||||
|
<form class="stacked-form edit-song-form" data-id="${song.id}">
|
||||||
|
<label>Titre <input name="title" value="${escapeHtml(song.title)}" required></label>
|
||||||
|
<label>Artiste <input name="artist" value="${escapeHtml(song.artist)}" required></label>
|
||||||
|
<label>Notes <input name="notes" value="${escapeHtml(song.notes || '')}"></label>
|
||||||
|
<label>Lien YouTube <input name="youtubeUrl" type="url" value="${escapeHtml(song.youtube_url || '')}" placeholder="https://youtube.com/watch?v=..."></label>
|
||||||
|
<label>Lien Spotify <input name="spotifyUrl" type="url" value="${escapeHtml(song.spotify_url || '')}" placeholder="https://open.spotify.com/track/..."></label>
|
||||||
|
<div class="song-links">
|
||||||
|
<button type="submit">Enregistrer</button>
|
||||||
|
<button type="button" class="secondary cancel-edit" data-id="${song.id}">Annuler</button>
|
||||||
|
<button type="button" class="danger delete-song" data-id="${song.id}">Supprimer</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
function renderSongs() {
|
function renderSongs() {
|
||||||
const container = document.getElementById('songs-list');
|
const container = document.getElementById('songs-list');
|
||||||
renderList(container, songs, songCardTemplate, 'Aucun morceau au répertoire pour le moment.');
|
renderList(container, songs, songCardTemplate, 'Aucun morceau au répertoire pour le moment.');
|
||||||
|
|
||||||
document.querySelectorAll('.toggle-tutorials').forEach((btn) => {
|
document.querySelectorAll('.toggle-tutorials').forEach((btn) => {
|
||||||
btn.addEventListener('click', () => onToggleTutorials(parseInt(btn.dataset.id, 10)));
|
btn.addEventListener('click', () => onToggleTutorials(parseInt(btn.dataset.id, 10)));
|
||||||
});
|
});
|
||||||
document.querySelectorAll('.add-tutorial-form').forEach((form) => {
|
document.querySelectorAll('.add-tutorial-form').forEach((form) => {
|
||||||
form.addEventListener('submit', onAddTutorial);
|
form.addEventListener('submit', onAddTutorial);
|
||||||
});
|
});
|
||||||
|
document.querySelectorAll('.edit-song').forEach((btn) => {
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
editing.add(parseInt(btn.dataset.id, 10));
|
||||||
|
renderSongs();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.cancel-edit').forEach((btn) => {
|
||||||
|
btn.addEventListener('click', () => {
|
||||||
|
editing.delete(parseInt(btn.dataset.id, 10));
|
||||||
|
renderSongs();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.edit-song-form').forEach((form) => {
|
||||||
|
form.addEventListener('submit', onSaveSong);
|
||||||
|
});
|
||||||
|
document.querySelectorAll('.delete-song').forEach((btn) => {
|
||||||
|
btn.addEventListener('click', () => onDeleteSong(parseInt(btn.dataset.id, 10)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onToggleTutorials(songId) {
|
async function onToggleTutorials(songId) {
|
||||||
|
|
@ -113,8 +187,10 @@ async function onAddSong(e) {
|
||||||
const title = form.title.value.trim();
|
const title = form.title.value.trim();
|
||||||
const artist = form.artist.value.trim();
|
const artist = form.artist.value.trim();
|
||||||
const notes = form.notes.value.trim();
|
const notes = form.notes.value.trim();
|
||||||
|
const youtubeUrl = form.youtubeUrl.value.trim();
|
||||||
|
const spotifyUrl = form.spotifyUrl.value.trim();
|
||||||
try {
|
try {
|
||||||
await api.post('/api/songs', { title, artist, notes });
|
await api.post('/api/songs', { title, artist, notes, youtubeUrl, spotifyUrl });
|
||||||
form.reset();
|
form.reset();
|
||||||
await loadSongs();
|
await loadSongs();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -122,6 +198,34 @@ async function onAddSong(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSaveSong(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const form = e.target;
|
||||||
|
const id = parseInt(form.dataset.id, 10);
|
||||||
|
const title = form.title.value.trim();
|
||||||
|
const artist = form.artist.value.trim();
|
||||||
|
const notes = form.notes.value.trim();
|
||||||
|
const youtubeUrl = form.youtubeUrl.value.trim();
|
||||||
|
const spotifyUrl = form.spotifyUrl.value.trim();
|
||||||
|
try {
|
||||||
|
await api.patch(`/api/songs/${id}`, { title, artist, notes, youtubeUrl, spotifyUrl });
|
||||||
|
editing.delete(id);
|
||||||
|
await loadSongs();
|
||||||
|
} catch (err) {
|
||||||
|
showError(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onDeleteSong(id) {
|
||||||
|
try {
|
||||||
|
await api.del(`/api/songs/${id}`);
|
||||||
|
editing.delete(id);
|
||||||
|
await loadSongs();
|
||||||
|
} catch (err) {
|
||||||
|
showError(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showError(message) {
|
function showError(message) {
|
||||||
document.getElementById('error').innerHTML = `<div class="error-banner">${escapeHtml(message)}</div>`;
|
document.getElementById('error').innerHTML = `<div class="error-banner">${escapeHtml(message)}</div>`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,15 @@
|
||||||
let me = null;
|
let me = null;
|
||||||
let allSongs = [];
|
let allSongs = [];
|
||||||
let setlist = null;
|
let setlist = null;
|
||||||
let editRows = [];
|
let mainRows = [];
|
||||||
|
let encoreRows = [];
|
||||||
|
let addSongId = null;
|
||||||
|
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
const d = new Date(dateStr);
|
const d = new Date(dateStr);
|
||||||
return d.toLocaleDateString('fr-FR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
return d.toLocaleDateString('fr-FR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
||||||
}
|
}
|
||||||
|
|
||||||
function songOptions(selectedId) {
|
|
||||||
return allSongs
|
|
||||||
.map((s) => `<option value="${s.id}" ${s.id === selectedId ? 'selected' : ''}>${escapeHtml(s.title)} — ${escapeHtml(s.artist)}</option>`)
|
|
||||||
.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function readOnlyView() {
|
function readOnlyView() {
|
||||||
const main = setlist.songs.filter((s) => !s.is_encore);
|
const main = setlist.songs.filter((s) => !s.is_encore);
|
||||||
const encore = setlist.songs.filter((s) => s.is_encore);
|
const encore = setlist.songs.filter((s) => s.is_encore);
|
||||||
|
|
@ -25,55 +21,16 @@ function readOnlyView() {
|
||||||
<div class="setlist-section">
|
<div class="setlist-section">
|
||||||
<h3>Setlist</h3>
|
<h3>Setlist</h3>
|
||||||
${main.length
|
${main.length
|
||||||
? `<ol class="setlist">${main.map((s) => `<li>${escapeHtml(s.title)} — ${escapeHtml(s.artist)}${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
? `<ol class="setlist">${main.map((s) => `<li><span class="row-title">${escapeHtml(s.title)}</span> <span class="row-artist">— ${escapeHtml(s.artist)}</span>${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
||||||
: '<p class="empty">Aucun morceau pour le moment.</p>'}
|
: '<p class="empty">Aucun morceau pour le moment.</p>'}
|
||||||
</div>
|
</div>
|
||||||
<div class="setlist-section">
|
<div class="setlist-section">
|
||||||
<h3>Rappel</h3>
|
<h3>Rappel</h3>
|
||||||
${encore.length
|
${encore.length
|
||||||
? `<ol class="setlist">${encore.map((s) => `<li>${escapeHtml(s.title)} — ${escapeHtml(s.artist)}${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
? `<ol class="setlist">${encore.map((s) => `<li><span class="row-title">${escapeHtml(s.title)}</span> <span class="row-artist">— ${escapeHtml(s.artist)}</span>${s.note ? `<span class="note">${escapeHtml(s.note)}</span>` : ''}</li>`).join('')}</ol>`
|
||||||
: '<p class="empty">Aucun morceau de rappel prévu.</p>'}
|
: '<p class="empty">Aucun morceau de rappel prévu.</p>'}
|
||||||
</div>
|
</div>
|
||||||
${me.isAdmin ? '<button id="edit-btn" class="secondary">Modifier la setlist</button>' : ''}
|
${me.isAdmin ? '<button id="edit-btn" class="secondary" style="margin-top:1rem">Modifier la setlist</button>' : ''}
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function editRowTemplate(row, index) {
|
|
||||||
return `
|
|
||||||
<div class="card" data-row-index="${index}">
|
|
||||||
<div class="inline-form">
|
|
||||||
<label>Morceau
|
|
||||||
<select data-field="songId">${songOptions(row.songId)}</select>
|
|
||||||
</label>
|
|
||||||
<label>Position <input type="number" min="1" value="${row.position}" data-field="position" style="width:4rem"></label>
|
|
||||||
<label>Note <input value="${escapeHtml(row.note || '')}" data-field="note"></label>
|
|
||||||
<label><input type="checkbox" ${row.isEncore ? 'checked' : ''} data-field="isEncore"> Rappel</label>
|
|
||||||
<button type="button" class="danger remove-row" data-index="${index}">Retirer</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function editView() {
|
|
||||||
return `
|
|
||||||
<div class="card">
|
|
||||||
<h3>Détails du concert</h3>
|
|
||||||
<form id="meta-form" class="inline-form">
|
|
||||||
<label>Nom <input name="name" value="${escapeHtml(setlist?.name || '')}"></label>
|
|
||||||
<label>Lieu <input name="venue" value="${escapeHtml(setlist?.venue || '')}"></label>
|
|
||||||
<label>Date <input type="date" name="concertDate" value="${setlist ? setlist.concert_date.slice(0, 10) : ''}" required></label>
|
|
||||||
<button type="submit">${setlist ? 'Enregistrer' : 'Créer le concert'}</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
${setlist ? `
|
|
||||||
<div id="rows-container">
|
|
||||||
${editRows.map(editRowTemplate).join('')}
|
|
||||||
</div>
|
|
||||||
<div class="inline-form">
|
|
||||||
<button type="button" id="add-row-btn" class="secondary">Ajouter un morceau</button>
|
|
||||||
<button type="button" id="save-songs-btn">Enregistrer la setlist</button>
|
|
||||||
<button type="button" id="cancel-edit-btn" class="secondary">Annuler</button>
|
|
||||||
</div>` : ''}
|
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +38,7 @@ function renderReadOnly() {
|
||||||
const container = document.getElementById('content');
|
const container = document.getElementById('content');
|
||||||
if (!setlist) {
|
if (!setlist) {
|
||||||
container.innerHTML = me.isAdmin
|
container.innerHTML = me.isAdmin
|
||||||
? `<p class="empty">Aucun concert à venir.</p>${editView()}`
|
? `<p class="empty">Aucun concert à venir.</p>${metaFormTemplate()}`
|
||||||
: '<p class="empty">Aucun concert à venir pour le moment.</p>';
|
: '<p class="empty">Aucun concert à venir pour le moment.</p>';
|
||||||
if (me.isAdmin) attachMetaFormHandler();
|
if (me.isAdmin) attachMetaFormHandler();
|
||||||
return;
|
return;
|
||||||
|
|
@ -91,14 +48,93 @@ function renderReadOnly() {
|
||||||
if (editBtn) editBtn.addEventListener('click', enterEditMode);
|
if (editBtn) editBtn.addEventListener('click', enterEditMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function metaFormTemplate() {
|
||||||
|
return `
|
||||||
|
<div class="panel">
|
||||||
|
<h3>${setlist ? 'Détails du concert' : 'Créer le prochain concert'}</h3>
|
||||||
|
<form id="meta-form" class="inline-form">
|
||||||
|
<label>Nom <input name="name" value="${escapeHtml(setlist?.name || '')}"></label>
|
||||||
|
<label>Lieu <input name="venue" value="${escapeHtml(setlist?.venue || '')}"></label>
|
||||||
|
<label>Date <input type="date" name="concertDate" value="${setlist ? setlist.concert_date.slice(0, 10) : ''}" required></label>
|
||||||
|
<button type="submit">${setlist ? 'Enregistrer' : 'Créer le concert'}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function usedSongIds() {
|
||||||
|
return new Set([...mainRows, ...encoreRows].map((r) => r.songId));
|
||||||
|
}
|
||||||
|
|
||||||
|
function availableSongOptions() {
|
||||||
|
const used = usedSongIds();
|
||||||
|
const available = allSongs.filter((s) => !used.has(s.id));
|
||||||
|
if (!available.length) return '<option value="">(tous les morceaux sont déjà dans la setlist)</option>';
|
||||||
|
return available.map((s) => `<option value="${s.id}">${escapeHtml(s.title)} — ${escapeHtml(s.artist)}</option>`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function rowTemplate(row, index, section, total) {
|
||||||
|
return `
|
||||||
|
<div class="setlist-row" data-section="${section}" data-index="${index}">
|
||||||
|
<div class="row-index">${index + 1}</div>
|
||||||
|
<div class="row-main">
|
||||||
|
<div class="row-title">${escapeHtml(row.title)}</div>
|
||||||
|
<div class="row-artist">${escapeHtml(row.artist)}</div>
|
||||||
|
</div>
|
||||||
|
<input class="row-note-input" data-field="note" placeholder="Note (optionnel)" value="${escapeHtml(row.note || '')}">
|
||||||
|
<div class="row-actions">
|
||||||
|
<button type="button" class="secondary icon-btn move-up" ${index === 0 ? 'disabled' : ''} title="Monter">↑</button>
|
||||||
|
<button type="button" class="secondary icon-btn move-down" ${index === total - 1 ? 'disabled' : ''} title="Descendre">↓</button>
|
||||||
|
<button type="button" class="secondary icon-btn move-section" title="${section === 'main' ? 'Déplacer en rappel' : 'Déplacer au programme'}">${section === 'main' ? '⇥ Rappel' : '⇤ Programme'}</button>
|
||||||
|
<button type="button" class="danger icon-btn remove-row" title="Retirer">×</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function editView() {
|
||||||
|
return `
|
||||||
|
${metaFormTemplate()}
|
||||||
|
${setlist ? `
|
||||||
|
<div class="panel">
|
||||||
|
<h3>Ajouter un morceau du répertoire</h3>
|
||||||
|
<form id="add-song-form" class="inline-form">
|
||||||
|
<label>Morceau
|
||||||
|
<select id="add-song-select">${availableSongOptions()}</select>
|
||||||
|
</label>
|
||||||
|
<button type="button" id="add-to-main-btn" class="secondary">Ajouter au programme</button>
|
||||||
|
<button type="button" id="add-to-encore-btn" class="secondary">Ajouter au rappel</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setlist-section">
|
||||||
|
<h3>Programme principal</h3>
|
||||||
|
<div class="setlist-rows" id="main-rows">
|
||||||
|
${mainRows.length ? mainRows.map((r, i) => rowTemplate(r, i, 'main', mainRows.length)).join('') : '<p class="empty">Aucun morceau. Ajoutez-en depuis le répertoire ci-dessus.</p>'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setlist-section">
|
||||||
|
<h3>Rappel</h3>
|
||||||
|
<div class="setlist-rows" id="encore-rows">
|
||||||
|
${encoreRows.length ? encoreRows.map((r, i) => rowTemplate(r, i, 'encore', encoreRows.length)).join('') : '<p class="empty">Aucun morceau de rappel prévu.</p>'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="inline-form" style="margin-top:1.25rem">
|
||||||
|
<button type="button" id="save-songs-btn">Enregistrer la setlist</button>
|
||||||
|
<button type="button" id="cancel-edit-btn" class="secondary">Retour</button>
|
||||||
|
</div>` : ''}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
function enterEditMode() {
|
function enterEditMode() {
|
||||||
editRows = setlist.songs.map((s) => ({
|
mainRows = setlist.songs
|
||||||
setlistSongId: s.id,
|
.filter((s) => !s.is_encore)
|
||||||
songId: s.song_id,
|
.map((s) => ({ setlistSongId: s.id, songId: s.song_id, title: s.title, artist: s.artist, note: s.note }));
|
||||||
position: s.position,
|
encoreRows = setlist.songs
|
||||||
note: s.note,
|
.filter((s) => s.is_encore)
|
||||||
isEncore: s.is_encore,
|
.map((s) => ({ setlistSongId: s.id, songId: s.song_id, title: s.title, artist: s.artist, note: s.note }));
|
||||||
}));
|
|
||||||
renderEdit();
|
renderEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,52 +168,79 @@ function attachMetaFormHandler() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rowsForSection(section) {
|
||||||
|
return section === 'main' ? mainRows : encoreRows;
|
||||||
|
}
|
||||||
|
|
||||||
function attachEditHandlers() {
|
function attachEditHandlers() {
|
||||||
document.querySelectorAll('.remove-row').forEach((btn) => {
|
const addSelect = document.getElementById('add-song-select');
|
||||||
btn.addEventListener('click', () => {
|
const addToMain = document.getElementById('add-to-main-btn');
|
||||||
editRows.splice(parseInt(btn.dataset.index, 10), 1);
|
const addToEncore = document.getElementById('add-to-encore-btn');
|
||||||
renderEdit();
|
if (addSelect) {
|
||||||
});
|
if (!addSelect.value) addSongId = null;
|
||||||
});
|
addSelect.addEventListener('change', () => { addSongId = addSelect.value ? parseInt(addSelect.value, 10) : null; });
|
||||||
document.querySelectorAll('[data-row-index]').forEach((rowEl) => {
|
|
||||||
const index = parseInt(rowEl.dataset.rowIndex, 10);
|
|
||||||
rowEl.querySelectorAll('[data-field]').forEach((input) => {
|
|
||||||
input.addEventListener('change', () => {
|
|
||||||
const field = input.dataset.field;
|
|
||||||
if (field === 'isEncore') editRows[index][field] = input.checked;
|
|
||||||
else if (field === 'position') editRows[index][field] = parseInt(input.value, 10);
|
|
||||||
else if (field === 'songId') editRows[index][field] = parseInt(input.value, 10);
|
|
||||||
else editRows[index][field] = input.value;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const addBtn = document.getElementById('add-row-btn');
|
|
||||||
if (addBtn) {
|
|
||||||
addBtn.addEventListener('click', () => {
|
|
||||||
const nextPos = editRows.filter((r) => !r.isEncore).length + 1;
|
|
||||||
editRows.push({ songId: allSongs[0]?.id, position: nextPos, note: '', isEncore: false });
|
|
||||||
renderEdit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if (addToMain) addToMain.addEventListener('click', () => addSongToSection('main', addSelect));
|
||||||
|
if (addToEncore) addToEncore.addEventListener('click', () => addSongToSection('encore', addSelect));
|
||||||
|
|
||||||
|
document.querySelectorAll('.setlist-row').forEach((rowEl) => {
|
||||||
|
const section = rowEl.dataset.section;
|
||||||
|
const index = parseInt(rowEl.dataset.index, 10);
|
||||||
|
const rows = rowsForSection(section);
|
||||||
|
|
||||||
|
rowEl.querySelector('.row-note-input').addEventListener('change', (e) => {
|
||||||
|
rows[index].note = e.target.value;
|
||||||
|
});
|
||||||
|
rowEl.querySelector('.move-up')?.addEventListener('click', () => {
|
||||||
|
if (index === 0) return;
|
||||||
|
[rows[index - 1], rows[index]] = [rows[index], rows[index - 1]];
|
||||||
|
renderEdit();
|
||||||
|
});
|
||||||
|
rowEl.querySelector('.move-down')?.addEventListener('click', () => {
|
||||||
|
if (index === rows.length - 1) return;
|
||||||
|
[rows[index + 1], rows[index]] = [rows[index], rows[index + 1]];
|
||||||
|
renderEdit();
|
||||||
|
});
|
||||||
|
rowEl.querySelector('.move-section').addEventListener('click', () => {
|
||||||
|
const [row] = rows.splice(index, 1);
|
||||||
|
if (section === 'main') encoreRows.push(row);
|
||||||
|
else mainRows.push(row);
|
||||||
|
renderEdit();
|
||||||
|
});
|
||||||
|
rowEl.querySelector('.remove-row').addEventListener('click', () => {
|
||||||
|
rows.splice(index, 1);
|
||||||
|
renderEdit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const saveBtn = document.getElementById('save-songs-btn');
|
const saveBtn = document.getElementById('save-songs-btn');
|
||||||
if (saveBtn) {
|
if (saveBtn) saveBtn.addEventListener('click', onSaveSongs);
|
||||||
saveBtn.addEventListener('click', async () => {
|
const cancelBtn = document.getElementById('cancel-edit-btn');
|
||||||
|
if (cancelBtn) cancelBtn.addEventListener('click', renderReadOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSongToSection(section, selectEl) {
|
||||||
|
const songId = selectEl.value ? parseInt(selectEl.value, 10) : null;
|
||||||
|
if (!songId) return;
|
||||||
|
const song = allSongs.find((s) => s.id === songId);
|
||||||
|
if (!song) return;
|
||||||
|
const row = { setlistSongId: null, songId: song.id, title: song.title, artist: song.artist, note: '' };
|
||||||
|
if (section === 'main') mainRows.push(row);
|
||||||
|
else encoreRows.push(row);
|
||||||
|
renderEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onSaveSongs() {
|
||||||
try {
|
try {
|
||||||
const payload = editRows.map((r) => ({
|
const payload = [
|
||||||
songId: r.songId,
|
...mainRows.map((r, i) => ({ songId: r.songId, position: i + 1, note: r.note, isEncore: false })),
|
||||||
position: r.position,
|
...encoreRows.map((r, i) => ({ songId: r.songId, position: i + 1, note: r.note, isEncore: true })),
|
||||||
note: r.note,
|
];
|
||||||
isEncore: !!r.isEncore,
|
|
||||||
}));
|
|
||||||
setlist = await api.put(`/api/setlists/${setlist.id}/songs`, { songs: payload });
|
setlist = await api.put(`/api/setlists/${setlist.id}/songs`, { songs: payload });
|
||||||
renderReadOnly();
|
renderReadOnly();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
showError(err.message);
|
showError(err.message);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
const cancelBtn = document.getElementById('cancel-edit-btn');
|
|
||||||
if (cancelBtn) cancelBtn.addEventListener('click', renderReadOnly);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showError(message) {
|
function showError(message) {
|
||||||
|
|
|
||||||
|
|
@ -11,23 +11,40 @@ function statusLabel(status) {
|
||||||
return { pending: 'En attente', approved: 'Approuvé', rejected: 'Rejeté' }[status] || status;
|
return { pending: 'En attente', approved: 'Approuvé', rejected: 'Rejeté' }[status] || status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function suggestionThumbTemplate(s) {
|
||||||
|
const thumb = youtubeThumbnailUrl(s.youtube_url);
|
||||||
|
if (thumb) {
|
||||||
|
return `
|
||||||
|
<div class="song-thumb">
|
||||||
|
<img src="${thumb}" alt="${escapeHtml(s.title)}" loading="lazy">
|
||||||
|
<a class="play-overlay" href="${escapeHtml(s.youtube_url)}" target="_blank" rel="noopener" title="Écouter sur YouTube">►</a>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
return `<div class="song-thumb placeholder">♫</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
function suggestionTemplate(s) {
|
function suggestionTemplate(s) {
|
||||||
const isOpen = expanded.has(s.id);
|
const isOpen = expanded.has(s.id);
|
||||||
const embed = youtubeEmbedUrl(s.youtube_url);
|
|
||||||
return `
|
return `
|
||||||
<div class="card" data-suggestion-id="${s.id}">
|
<div class="card" data-suggestion-id="${s.id}">
|
||||||
|
<div class="song-card">
|
||||||
|
${suggestionThumbTemplate(s)}
|
||||||
|
<div class="song-body">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div>
|
<div>
|
||||||
<div class="card-title">${escapeHtml(s.title)}${s.artist ? ` — ${escapeHtml(s.artist)}` : ''}</div>
|
<div class="card-title">${escapeHtml(s.title)}${s.artist ? ` — ${escapeHtml(s.artist)}` : ''}</div>
|
||||||
<div class="card-subtitle">Proposé par ${escapeHtml(s.suggested_by_name)} · ${statusLabel(s.status)}</div>
|
<div class="card-subtitle">Proposé par ${escapeHtml(s.suggested_by_name)} · ${statusLabel(s.status)}</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="secondary toggle-detail" data-id="${s.id}">${isOpen ? 'Masquer' : 'Voir / voter'}</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="vote-tally">
|
<div class="vote-tally">
|
||||||
<span class="approve">✔ ${s.approve_count}</span>
|
<span class="approve">✔ ${s.approve_count}</span>
|
||||||
<span class="reject">✘ ${s.reject_count}</span>
|
<span class="reject">✘ ${s.reject_count}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-panel" style="${isOpen ? '' : 'display:none'}" data-detail-for="${s.id}">
|
<button class="secondary icon-btn toggle-detail" data-id="${s.id}">${isOpen ? 'Masquer' : 'Voir / voter'}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="detail-panel panel" style="${isOpen ? '' : 'display:none'}" data-detail-for="${s.id}">
|
||||||
<p class="empty">Chargement…</p>
|
<p class="empty">Chargement…</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -39,6 +56,7 @@ function detailTemplate(s) {
|
||||||
const myVote = s.votes.find((v) => v.user_id === me.id);
|
const myVote = s.votes.find((v) => v.user_id === me.id);
|
||||||
return `
|
return `
|
||||||
${embed ? `<div class="youtube-embed"><iframe src="${embed}" allowfullscreen></iframe></div>` : `<p><a href="${escapeHtml(s.youtube_url)}" target="_blank" rel="noopener">${escapeHtml(s.youtube_url)}</a></p>`}
|
${embed ? `<div class="youtube-embed"><iframe src="${embed}" allowfullscreen></iframe></div>` : `<p><a href="${escapeHtml(s.youtube_url)}" target="_blank" rel="noopener">${escapeHtml(s.youtube_url)}</a></p>`}
|
||||||
|
${s.description ? `<div class="suggestion-note">${escapeHtml(s.description)}</div>` : ''}
|
||||||
|
|
||||||
<form class="inline-form vote-form" data-id="${s.id}">
|
<form class="inline-form vote-form" data-id="${s.id}">
|
||||||
<label>Mon vote
|
<label>Mon vote
|
||||||
|
|
@ -69,7 +87,7 @@ function detailTemplate(s) {
|
||||||
function voteItemTemplate(v) {
|
function voteItemTemplate(v) {
|
||||||
const icon = v.vote === 'approve' ? '✔' : '✘';
|
const icon = v.vote === 'approve' ? '✔' : '✘';
|
||||||
return `
|
return `
|
||||||
<div class="vote-item">
|
<div class="vote-item ${v.vote}">
|
||||||
<span class="voter">${escapeHtml(v.voter_name)}</span> ${icon}
|
<span class="voter">${escapeHtml(v.voter_name)}</span> ${icon}
|
||||||
${v.comment ? `— ${escapeHtml(v.comment)}` : ''}
|
${v.comment ? `— ${escapeHtml(v.comment)}` : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -170,8 +188,9 @@ async function onAddSuggestion(e) {
|
||||||
const title = form.title.value.trim();
|
const title = form.title.value.trim();
|
||||||
const artist = form.artist.value.trim();
|
const artist = form.artist.value.trim();
|
||||||
const youtubeUrl = form.youtubeUrl.value.trim();
|
const youtubeUrl = form.youtubeUrl.value.trim();
|
||||||
|
const description = form.description.value.trim();
|
||||||
try {
|
try {
|
||||||
await api.post('/api/suggestions', { title, artist, youtubeUrl });
|
await api.post('/api/suggestions', { title, artist, youtubeUrl, description });
|
||||||
form.reset();
|
form.reset();
|
||||||
await loadSuggestions();
|
await loadSuggestions();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
|
|
@ -12,18 +12,22 @@
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<h1>Suggestions de morceaux</h1>
|
<h1>Suggestions de morceaux</h1>
|
||||||
|
<p class="page-subtitle">Proposez un morceau et votez sur les suggestions des autres — chaque vote est nominatif.</p>
|
||||||
<div id="error"></div>
|
<div id="error"></div>
|
||||||
|
|
||||||
<h2>Proposer un morceau</h2>
|
<div class="panel">
|
||||||
<form id="add-suggestion-form" class="inline-form">
|
<h2 style="margin-top:0">Proposer un morceau</h2>
|
||||||
|
<form id="add-suggestion-form" class="stacked-form">
|
||||||
<label>Titre <input name="title" required></label>
|
<label>Titre <input name="title" required></label>
|
||||||
<label>Artiste <input name="artist"></label>
|
<label>Artiste <input name="artist"></label>
|
||||||
<label>Lien YouTube <input name="youtubeUrl" type="url" required placeholder="https://youtube.com/watch?v=..."></label>
|
<label>Lien YouTube <input name="youtubeUrl" type="url" required placeholder="https://youtube.com/watch?v=..."></label>
|
||||||
|
<label>Note / détails <textarea name="description" placeholder="Pourquoi ce morceau, difficulté, arrangement envisagé..."></textarea></label>
|
||||||
<button type="submit">Proposer</button>
|
<button type="submit">Proposer</button>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2>Toutes les suggestions</h2>
|
<h2>Toutes les suggestions</h2>
|
||||||
<div id="suggestions-list"></div>
|
<div id="suggestions-list" class="card-grid"></div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script src="/js/api.js"></script>
|
<script src="/js/api.js"></script>
|
||||||
|
|
|
||||||
3
src/db/migrations/003_song_links_and_suggestion_note.sql
Normal file
3
src/db/migrations/003_song_links_and_suggestion_note.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE songs ADD COLUMN IF NOT EXISTS youtube_url TEXT;
|
||||||
|
ALTER TABLE songs ADD COLUMN IF NOT EXISTS spotify_url TEXT;
|
||||||
|
ALTER TABLE suggestions ADD COLUMN IF NOT EXISTS description TEXT;
|
||||||
10
src/lib/spotify.js
Normal file
10
src/lib/spotify.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
function isValidSpotifyUrl(url) {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(url);
|
||||||
|
return parsed.hostname === 'open.spotify.com';
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { isValidSpotifyUrl };
|
||||||
|
|
@ -2,7 +2,7 @@ const pool = require('../db/pool');
|
||||||
|
|
||||||
async function findAll() {
|
async function findAll() {
|
||||||
const { rows } = await pool.query(`
|
const { rows } = await pool.query(`
|
||||||
SELECT s.id, s.title, s.artist, s.notes, s.created_at,
|
SELECT s.id, s.title, s.artist, s.notes, s.youtube_url, s.spotify_url, s.created_at,
|
||||||
COUNT(st.id)::int AS tutorial_count
|
COUNT(st.id)::int AS tutorial_count
|
||||||
FROM songs s
|
FROM songs s
|
||||||
LEFT JOIN song_tutorials st ON st.song_id = s.id
|
LEFT JOIN song_tutorials st ON st.song_id = s.id
|
||||||
|
|
@ -14,28 +14,29 @@ async function findAll() {
|
||||||
|
|
||||||
async function findById(id) {
|
async function findById(id) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
'SELECT id, title, artist, notes, added_by, created_at, updated_at FROM songs WHERE id = $1',
|
`SELECT id, title, artist, notes, youtube_url, spotify_url, added_by, created_at, updated_at
|
||||||
|
FROM songs WHERE id = $1`,
|
||||||
[id]
|
[id]
|
||||||
);
|
);
|
||||||
return rows[0] || null;
|
return rows[0] || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function create({ title, artist, notes, addedBy }) {
|
async function create({ title, artist, notes, youtubeUrl, spotifyUrl, addedBy }) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`INSERT INTO songs (title, artist, notes, added_by)
|
`INSERT INTO songs (title, artist, notes, youtube_url, spotify_url, added_by)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3, $4, $5, $6)
|
||||||
RETURNING id, title, artist, notes, added_by, created_at, updated_at`,
|
RETURNING id, title, artist, notes, youtube_url, spotify_url, added_by, created_at, updated_at`,
|
||||||
[title, artist, notes || null, addedBy]
|
[title, artist, notes || null, youtubeUrl || null, spotifyUrl || null, addedBy]
|
||||||
);
|
);
|
||||||
return rows[0];
|
return rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update(id, { title, artist, notes }) {
|
async function update(id, { title, artist, notes, youtubeUrl, spotifyUrl }) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`UPDATE songs SET title = $2, artist = $3, notes = $4, updated_at = now()
|
`UPDATE songs SET title = $2, artist = $3, notes = $4, youtube_url = $5, spotify_url = $6, updated_at = now()
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
RETURNING id, title, artist, notes, added_by, created_at, updated_at`,
|
RETURNING id, title, artist, notes, youtube_url, spotify_url, added_by, created_at, updated_at`,
|
||||||
[id, title, artist, notes || null]
|
[id, title, artist, notes || null, youtubeUrl || null, spotifyUrl || null]
|
||||||
);
|
);
|
||||||
return rows[0] || null;
|
return rows[0] || null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ const pool = require('../db/pool');
|
||||||
|
|
||||||
async function findAll() {
|
async function findAll() {
|
||||||
const { rows } = await pool.query(`
|
const { rows } = await pool.query(`
|
||||||
SELECT sg.id, sg.title, sg.artist, sg.youtube_url, sg.status, sg.promoted_song_id,
|
SELECT sg.id, sg.title, sg.artist, sg.youtube_url, sg.description, sg.status, sg.promoted_song_id,
|
||||||
sg.created_at, sg.suggested_by, u.name AS suggested_by_name,
|
sg.created_at, sg.suggested_by, u.name AS suggested_by_name,
|
||||||
COUNT(*) FILTER (WHERE v.vote = 'approve')::int AS approve_count,
|
COUNT(*) FILTER (WHERE v.vote = 'approve')::int AS approve_count,
|
||||||
COUNT(*) FILTER (WHERE v.vote = 'reject')::int AS reject_count
|
COUNT(*) FILTER (WHERE v.vote = 'reject')::int AS reject_count
|
||||||
|
|
@ -17,7 +17,7 @@ async function findAll() {
|
||||||
|
|
||||||
async function findById(id) {
|
async function findById(id) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`SELECT sg.id, sg.title, sg.artist, sg.youtube_url, sg.status, sg.promoted_song_id,
|
`SELECT sg.id, sg.title, sg.artist, sg.youtube_url, sg.description, sg.status, sg.promoted_song_id,
|
||||||
sg.created_at, sg.suggested_by, u.name AS suggested_by_name
|
sg.created_at, sg.suggested_by, u.name AS suggested_by_name
|
||||||
FROM suggestions sg
|
FROM suggestions sg
|
||||||
JOIN users u ON u.id = sg.suggested_by
|
JOIN users u ON u.id = sg.suggested_by
|
||||||
|
|
@ -39,12 +39,12 @@ async function findVotes(suggestionId) {
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function create({ title, artist, youtubeUrl, suggestedBy }) {
|
async function create({ title, artist, youtubeUrl, description, suggestedBy }) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`INSERT INTO suggestions (title, artist, youtube_url, suggested_by)
|
`INSERT INTO suggestions (title, artist, youtube_url, description, suggested_by)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
RETURNING id, title, artist, youtube_url, status, promoted_song_id, created_at, suggested_by`,
|
RETURNING id, title, artist, youtube_url, description, status, promoted_song_id, created_at, suggested_by`,
|
||||||
[title, artist || null, youtubeUrl, suggestedBy]
|
[title, artist || null, youtubeUrl, description || null, suggestedBy]
|
||||||
);
|
);
|
||||||
return rows[0];
|
return rows[0];
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ async function create({ title, artist, youtubeUrl, suggestedBy }) {
|
||||||
async function updateStatus(id, status) {
|
async function updateStatus(id, status) {
|
||||||
const { rows } = await pool.query(
|
const { rows } = await pool.query(
|
||||||
`UPDATE suggestions SET status = $2, updated_at = now() WHERE id = $1
|
`UPDATE suggestions SET status = $2, updated_at = now() WHERE id = $1
|
||||||
RETURNING id, title, artist, youtube_url, status, promoted_song_id, created_at, suggested_by`,
|
RETURNING id, title, artist, youtube_url, description, status, promoted_song_id, created_at, suggested_by`,
|
||||||
[id, status]
|
[id, status]
|
||||||
);
|
);
|
||||||
return rows[0] || null;
|
return rows[0] || null;
|
||||||
|
|
@ -94,10 +94,10 @@ async function promoteToSong(suggestionId, addedBy) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const { rows: songRows } = await client.query(
|
const { rows: songRows } = await client.query(
|
||||||
`INSERT INTO songs (title, artist, added_by)
|
`INSERT INTO songs (title, artist, notes, youtube_url, added_by)
|
||||||
VALUES ($1, $2, $3)
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
RETURNING id, title, artist, notes, added_by, created_at, updated_at`,
|
RETURNING id, title, artist, notes, youtube_url, spotify_url, added_by, created_at, updated_at`,
|
||||||
[suggestion.title, suggestion.artist || suggestion.title, addedBy]
|
[suggestion.title, suggestion.artist || suggestion.title, suggestion.description, suggestion.youtube_url, addedBy]
|
||||||
);
|
);
|
||||||
const song = songRows[0];
|
const song = songRows[0];
|
||||||
await client.query(
|
await client.query(
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,17 @@ const express = require('express');
|
||||||
const songsRepo = require('../repositories/songsRepo');
|
const songsRepo = require('../repositories/songsRepo');
|
||||||
const { requireAdmin } = require('../auth/middleware');
|
const { requireAdmin } = require('../auth/middleware');
|
||||||
const asyncHandler = require('../lib/asyncHandler');
|
const asyncHandler = require('../lib/asyncHandler');
|
||||||
|
const { isValidYoutubeUrl } = require('../lib/youtube');
|
||||||
|
const { isValidSpotifyUrl } = require('../lib/spotify');
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
function validateLinks(youtubeUrl, spotifyUrl) {
|
||||||
|
if (youtubeUrl && !isValidYoutubeUrl(youtubeUrl)) return 'invalid_youtube_url';
|
||||||
|
if (spotifyUrl && !isValidSpotifyUrl(spotifyUrl)) return 'invalid_spotify_url';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/',
|
'/',
|
||||||
asyncHandler(async (req, res) => {
|
asyncHandler(async (req, res) => {
|
||||||
|
|
@ -26,11 +34,20 @@ router.post(
|
||||||
'/',
|
'/',
|
||||||
requireAdmin,
|
requireAdmin,
|
||||||
asyncHandler(async (req, res) => {
|
asyncHandler(async (req, res) => {
|
||||||
const { title, artist, notes } = req.body || {};
|
const { title, artist, notes, youtubeUrl, spotifyUrl } = req.body || {};
|
||||||
if (!title || !title.trim() || !artist || !artist.trim()) {
|
if (!title || !title.trim() || !artist || !artist.trim()) {
|
||||||
return res.status(400).json({ error: 'title_and_artist_required' });
|
return res.status(400).json({ error: 'title_and_artist_required' });
|
||||||
}
|
}
|
||||||
const song = await songsRepo.create({ title: title.trim(), artist: artist.trim(), notes, addedBy: req.user.id });
|
const linkError = validateLinks(youtubeUrl, spotifyUrl);
|
||||||
|
if (linkError) return res.status(400).json({ error: linkError });
|
||||||
|
const song = await songsRepo.create({
|
||||||
|
title: title.trim(),
|
||||||
|
artist: artist.trim(),
|
||||||
|
notes,
|
||||||
|
youtubeUrl: youtubeUrl ? youtubeUrl.trim() : null,
|
||||||
|
spotifyUrl: spotifyUrl ? spotifyUrl.trim() : null,
|
||||||
|
addedBy: req.user.id,
|
||||||
|
});
|
||||||
res.status(201).json(song);
|
res.status(201).json(song);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
@ -39,11 +56,19 @@ router.patch(
|
||||||
'/:id',
|
'/:id',
|
||||||
requireAdmin,
|
requireAdmin,
|
||||||
asyncHandler(async (req, res) => {
|
asyncHandler(async (req, res) => {
|
||||||
const { title, artist, notes } = req.body || {};
|
const { title, artist, notes, youtubeUrl, spotifyUrl } = req.body || {};
|
||||||
if (!title || !title.trim() || !artist || !artist.trim()) {
|
if (!title || !title.trim() || !artist || !artist.trim()) {
|
||||||
return res.status(400).json({ error: 'title_and_artist_required' });
|
return res.status(400).json({ error: 'title_and_artist_required' });
|
||||||
}
|
}
|
||||||
const song = await songsRepo.update(req.params.id, { title: title.trim(), artist: artist.trim(), notes });
|
const linkError = validateLinks(youtubeUrl, spotifyUrl);
|
||||||
|
if (linkError) return res.status(400).json({ error: linkError });
|
||||||
|
const song = await songsRepo.update(req.params.id, {
|
||||||
|
title: title.trim(),
|
||||||
|
artist: artist.trim(),
|
||||||
|
notes,
|
||||||
|
youtubeUrl: youtubeUrl ? youtubeUrl.trim() : null,
|
||||||
|
spotifyUrl: spotifyUrl ? spotifyUrl.trim() : null,
|
||||||
|
});
|
||||||
if (!song) return res.status(404).json({ error: 'not_found' });
|
if (!song) return res.status(404).json({ error: 'not_found' });
|
||||||
res.json(song);
|
res.json(song);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ router.get(
|
||||||
router.post(
|
router.post(
|
||||||
'/',
|
'/',
|
||||||
asyncHandler(async (req, res) => {
|
asyncHandler(async (req, res) => {
|
||||||
const { title, artist, youtubeUrl } = req.body || {};
|
const { title, artist, youtubeUrl, description } = req.body || {};
|
||||||
if (!title || !title.trim() || !youtubeUrl || !youtubeUrl.trim()) {
|
if (!title || !title.trim() || !youtubeUrl || !youtubeUrl.trim()) {
|
||||||
return res.status(400).json({ error: 'title_and_youtube_url_required' });
|
return res.status(400).json({ error: 'title_and_youtube_url_required' });
|
||||||
}
|
}
|
||||||
|
|
@ -37,6 +37,7 @@ router.post(
|
||||||
title: title.trim(),
|
title: title.trim(),
|
||||||
artist: artist ? artist.trim() : null,
|
artist: artist ? artist.trim() : null,
|
||||||
youtubeUrl: youtubeUrl.trim(),
|
youtubeUrl: youtubeUrl.trim(),
|
||||||
|
description: description ? description.trim() : null,
|
||||||
suggestedBy: req.user.id,
|
suggestedBy: req.user.id,
|
||||||
});
|
});
|
||||||
res.status(201).json(suggestion);
|
res.status(201).json(suggestion);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue