correccion formaciones
This commit is contained in:
parent
e3c2d63ffa
commit
2e0e57d606
|
@ -1,262 +1,168 @@
|
||||||
/* ------------------- ESTILO GLOBAL ------------------- */
|
/* === Variables === */
|
||||||
:root {
|
:root {
|
||||||
--color-primary: #0d6efd;
|
--color-primary: #0d6efd;
|
||||||
--color-success: #198754;
|
--color-secondary: #6c757d;
|
||||||
|
--color-light: #f9fafb;
|
||||||
|
--color-border: #dee2e6;
|
||||||
--radius-lg: 0.75rem;
|
--radius-lg: 0.75rem;
|
||||||
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
|
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||||
--transition-fast: all 0.25s ease;
|
|
||||||
--font-family: 'Inter', sans-serif;
|
--font-family: 'Inter', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
/* === Reset === */
|
||||||
overflow-y: scroll;
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: var(--font-family);
|
font-family: var(--font-family);
|
||||||
font-size: clamp(1rem, 1vw + 0.2rem, 1.1rem);
|
font-size: 1rem;
|
||||||
line-height: 1.7;
|
background-color: var(--color-light);
|
||||||
background-color: #f9fafb;
|
|
||||||
color: #212529;
|
color: #212529;
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- NAVBAR ------------------- */
|
/* === Navbar === */
|
||||||
.navbar {
|
.navbar {
|
||||||
min-height: 72px;
|
min-height: 72px;
|
||||||
padding-top: 1rem !important;
|
|
||||||
padding-bottom: 1rem !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .nav-link {
|
.navbar .nav-link {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 1rem;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar .nav-link:hover {
|
/* === Cards === */
|
||||||
opacity: 0.85;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar * {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------- TARJETAS ------------------- */
|
|
||||||
.card {
|
.card {
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
box-shadow: var(--shadow-md);
|
box-shadow: var(--shadow-md);
|
||||||
background-color: white;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- FORMULARIOS ------------------- */
|
/* === Forms === */
|
||||||
.form-control,
|
.form-control,
|
||||||
.form-select {
|
.form-select {
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
border: 1px solid #ced4da;
|
border: 1px solid var(--color-border);
|
||||||
transition: var(--transition-fast);
|
transition: border-color 0.2s;
|
||||||
font-size: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-control:focus,
|
.form-control:focus,
|
||||||
.form-select:focus {
|
.form-select:focus {
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
|
box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- BOTONES ------------------- */
|
/* === Botones === */
|
||||||
button,
|
button,
|
||||||
.btn {
|
.btn {
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
padding: 0.6rem 1.2rem;
|
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1rem;
|
|
||||||
transition: var(--transition-fast);
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary,
|
|
||||||
.btn-success,
|
|
||||||
.btn-outline-primary,
|
|
||||||
.btn-outline-secondary {
|
|
||||||
border-width: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background-color: var(--color-primary);
|
background-color: var(--color-primary);
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
color: #fff;
|
|
||||||
}
|
}
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
background-color: #084298;
|
background-color: #084298;
|
||||||
border-color: #084298;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-success {
|
|
||||||
background-color: var(--color-success);
|
|
||||||
border-color: var(--color-success);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.btn-success:hover {
|
|
||||||
background-color: #145c32;
|
|
||||||
border-color: #145c32;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-outline-primary {
|
|
||||||
color: var(--color-primary);
|
|
||||||
border-color: var(--color-primary);
|
|
||||||
background-color: white;
|
|
||||||
}
|
}
|
||||||
|
.btn-outline-secondary:hover,
|
||||||
.btn-outline-primary:hover {
|
.btn-outline-primary:hover {
|
||||||
background-color: var(--color-primary);
|
opacity: 0.9;
|
||||||
color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-outline-secondary {
|
/* === Piscina === */
|
||||||
color: #6c757d;
|
|
||||||
border-color: #6c757d;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
.btn-outline-secondary:hover {
|
|
||||||
background-color: #6c757d;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:disabled,
|
|
||||||
.btn:disabled {
|
|
||||||
opacity: 0.65;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------- PISCINA ------------------- */
|
|
||||||
#piscinaContainer {
|
#piscinaContainer {
|
||||||
background-color: #e6f7ff;
|
background-color: #e6f7ff;
|
||||||
border: 2px dashed #007bff;
|
border: 2px dashed #007bff;
|
||||||
padding: 1rem;
|
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
width: fit-content;
|
aspect-ratio: 2 / 1;
|
||||||
height: fit-content;
|
width: 100%;
|
||||||
min-width: 300px;
|
height: auto;
|
||||||
min-height: 200px;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
box-sizing: border-box;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#piscina {
|
#piscina {
|
||||||
display: block;
|
width: 100%;
|
||||||
width: 100% !important;
|
height: 100%;
|
||||||
height: 100% !important;
|
|
||||||
background-image:
|
background-image:
|
||||||
linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
|
linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
|
||||||
linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
|
linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
|
||||||
background-size: 45px 45px;
|
background-size: 45px 45px;
|
||||||
background-position: top left;
|
display: block;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- TIMELINE ------------------- */
|
/* === Timeline === */
|
||||||
.timeline-placeholder {
|
.timeline-placeholder {
|
||||||
display: flex;
|
border: 1px solid #ccc;
|
||||||
overflow-x: auto;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 1rem;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
background: #ffffff;
|
|
||||||
border-radius: var(--radius-lg);
|
border-radius: var(--radius-lg);
|
||||||
box-shadow: 0 1px 4px rgba(0,0,0,0.05);
|
padding: 1rem;
|
||||||
|
background-color: white;
|
||||||
|
box-shadow: var(--shadow-md);
|
||||||
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-placeholder .step {
|
.timeline-placeholder .step {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
border: 1px solid #ccc;
|
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 8px;
|
border: 1px solid #ccc;
|
||||||
text-align: center;
|
border-radius: 0.5rem;
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
box-shadow: 1px 1px 3px rgba(0,0,0,0.05);
|
|
||||||
}
|
}
|
||||||
.timeline-placeholder .step:hover {
|
.timeline-placeholder .step:hover {
|
||||||
background-color: #dbeafe;
|
background-color: #dbeafe;
|
||||||
font-weight: bold;
|
|
||||||
transform: scale(1.03);
|
|
||||||
}
|
}
|
||||||
.step.active {
|
.step.active {
|
||||||
background-color: #0d6efd !important;
|
background-color: var(--color-primary);
|
||||||
color: white !important;
|
color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- AUTOCOMPLETADO ------------------- */
|
/* === Sugerencias figura === */
|
||||||
#sugerenciasFigura {
|
#sugerenciasFigura {
|
||||||
margin-top: 4px;
|
background: #fff;
|
||||||
padding: 6px 0;
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
|
||||||
max-height: 160px;
|
|
||||||
overflow-y: auto;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
max-height: 160px;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
#sugerenciasFigura button {
|
#sugerenciasFigura button {
|
||||||
display: block;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
font-size: 0.9rem;
|
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
color: #333;
|
font-size: 0.9rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background 0.2s ease;
|
|
||||||
}
|
}
|
||||||
#sugerenciasFigura button:hover {
|
#sugerenciasFigura button:hover {
|
||||||
background-color: #edf6ff;
|
background-color: #edf6ff;
|
||||||
color: #007bff;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- VISTA PREVIA FIGURA ------------------- */
|
/* === Audio === */
|
||||||
#previewFigura img {
|
|
||||||
margin-top: 8px;
|
|
||||||
max-width: 100%;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 6px;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
#previewFigura p {
|
|
||||||
font-size: 0.85rem;
|
|
||||||
color: #555;
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------- MULTIMEDIA ------------------- */
|
|
||||||
#waveform {
|
#waveform {
|
||||||
width: 100%;
|
height: 80px;
|
||||||
height: 100px;
|
background: #f1f3f5;
|
||||||
margin-bottom: 10px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
#audioPlayer {
|
#audioPlayer {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------- RESPONSIVO ------------------- */
|
/* === Responsivo === */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
#piscina {
|
|
||||||
min-height: 280px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-placeholder .step {
|
.timeline-placeholder .step {
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
font-size: 0.75rem;
|
}
|
||||||
|
#piscinaContainer {
|
||||||
|
aspect-ratio: 1.5 / 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* === Ancho de página controlado === */
|
||||||
|
main.container-xl {
|
||||||
|
max-width: 1440px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
padding-left: 2rem;
|
||||||
|
padding-right: 2rem;
|
||||||
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ atletas.forEach(a => {
|
||||||
|
|
||||||
select.addEventListener('change', () => {
|
select.addEventListener('change', () => {
|
||||||
const datos = JSON.parse(select.value || '{}');
|
const datos = JSON.parse(select.value || '{}');
|
||||||
|
select.dataset.id = datos.id; // << GUARDAS el ObjectId real
|
||||||
|
|
||||||
if (datos.idPers) {
|
if (datos.idPers) {
|
||||||
document.getElementById('idPersonalizado').value = datos.idPers;
|
document.getElementById('idPersonalizado').value = datos.idPers;
|
||||||
document.getElementById('idPersonalizado').disabled = true;
|
document.getElementById('idPersonalizado').disabled = true;
|
||||||
|
@ -48,6 +50,7 @@ select.addEventListener('change', () => {
|
||||||
document.getElementById('idPersonalizado').disabled = false;
|
document.getElementById('idPersonalizado').disabled = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let figurasFINA = [];
|
let figurasFINA = [];
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/catalog/figurasFINA.json');
|
const res = await fetch('/catalog/figurasFINA.json');
|
||||||
|
@ -192,7 +195,7 @@ tipoPiscinaSelect.addEventListener('change', async () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const idAtleta = select.value;
|
const idAtleta = select.dataset.id;
|
||||||
const rol = document.getElementById('rolAtleta').value.trim().toLowerCase();
|
const rol = document.getElementById('rolAtleta').value.trim().toLowerCase();
|
||||||
const idPersonalizado = document.getElementById('idPersonalizado').value.trim();
|
const idPersonalizado = document.getElementById('idPersonalizado').value.trim();
|
||||||
const figura = inputFigura?.value.trim();
|
const figura = inputFigura?.value.trim();
|
||||||
|
@ -236,7 +239,6 @@ tipoPiscinaSelect.addEventListener('change', async () => {
|
||||||
|
|
||||||
function dibujarAtleta(atleta) {
|
function dibujarAtleta(atleta) {
|
||||||
const color = atleta.rol === 'volador' ? 'purple' : atleta.rol === 'pilar' ? 'blue' : 'red';
|
const color = atleta.rol === 'volador' ? 'purple' : atleta.rol === 'pilar' ? 'blue' : 'red';
|
||||||
|
|
||||||
const metros = convertirAMetros(atleta.x, atleta.y);
|
const metros = convertirAMetros(atleta.x, atleta.y);
|
||||||
|
|
||||||
const circle = new Konva.Circle({
|
const circle = new Konva.Circle({
|
||||||
|
@ -261,7 +263,6 @@ tipoPiscinaSelect.addEventListener('change', async () => {
|
||||||
text.offsetX(text.width() / 2);
|
text.offsetX(text.width() / 2);
|
||||||
text.offsetY(text.height() / 2);
|
text.offsetY(text.height() / 2);
|
||||||
|
|
||||||
|
|
||||||
const figuraText = new Konva.Text({
|
const figuraText = new Konva.Text({
|
||||||
x: atleta.x - 25,
|
x: atleta.x - 25,
|
||||||
y: atleta.y + 18,
|
y: atleta.y + 18,
|
||||||
|
@ -281,6 +282,20 @@ tipoPiscinaSelect.addEventListener('change', async () => {
|
||||||
});
|
});
|
||||||
coordText.listening(false);
|
coordText.listening(false);
|
||||||
|
|
||||||
|
let flecha = null;
|
||||||
|
if (atleta.direccion) {
|
||||||
|
flecha = new Konva.Arrow({
|
||||||
|
points: [atleta.direccion.x1, atleta.direccion.y1, atleta.direccion.x2, atleta.direccion.y2],
|
||||||
|
stroke: 'black',
|
||||||
|
fill: 'black',
|
||||||
|
strokeWidth: 2,
|
||||||
|
pointerLength: 10,
|
||||||
|
pointerWidth: 10,
|
||||||
|
dash: [4, 4]
|
||||||
|
});
|
||||||
|
layer.add(flecha);
|
||||||
|
}
|
||||||
|
|
||||||
circle.on('dblclick', () => {
|
circle.on('dblclick', () => {
|
||||||
const i = formacionActual.findIndex(a => a.idPersonalizado === atleta.idPersonalizado);
|
const i = formacionActual.findIndex(a => a.idPersonalizado === atleta.idPersonalizado);
|
||||||
const html = `
|
const html = `
|
||||||
|
@ -313,36 +328,32 @@ tipoPiscinaSelect.addEventListener('change', async () => {
|
||||||
figuraText.x(newX - 25);
|
figuraText.x(newX - 25);
|
||||||
figuraText.y(newY + 18);
|
figuraText.y(newY + 18);
|
||||||
|
|
||||||
|
if (flecha) {
|
||||||
|
// Actualiza flecha si existe
|
||||||
|
const dx = atleta.direccion.x2 - atleta.direccion.x1;
|
||||||
|
const dy = atleta.direccion.y2 - atleta.direccion.y1;
|
||||||
|
flecha.points([newX, newY, newX + dx, newY + dy]);
|
||||||
|
}
|
||||||
|
|
||||||
layer.batchDraw();
|
layer.batchDraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
layer.add(circle);
|
layer.add(circle);
|
||||||
atletasKonva[atleta.idPersonalizado] = {
|
|
||||||
circle,
|
|
||||||
text,
|
|
||||||
figuraText,
|
|
||||||
coordText
|
|
||||||
};
|
|
||||||
layer.add(text);
|
layer.add(text);
|
||||||
layer.add(figuraText);
|
layer.add(figuraText);
|
||||||
layer.add(coordText);
|
layer.add(coordText);
|
||||||
|
|
||||||
if (atleta.direccion) {
|
atletasKonva[atleta.idPersonalizado] = {
|
||||||
const linea = new Konva.Arrow({
|
circle,
|
||||||
points: [start.x, start.y, start.x, start.y],
|
text,
|
||||||
stroke: 'black',
|
figuraText,
|
||||||
fill: 'black',
|
coordText,
|
||||||
strokeWidth: 2,
|
flecha
|
||||||
pointerLength: 10,
|
};
|
||||||
pointerWidth: 10,
|
|
||||||
dash: [4, 4]
|
|
||||||
});
|
|
||||||
|
|
||||||
layer.add(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
layer.draw();
|
layer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
window.activarModoDireccion = function(index) {
|
window.activarModoDireccion = function(index) {
|
||||||
|
@ -418,55 +429,22 @@ const linea = new Konva.Arrow({
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function animarTransicion(nuevaFormacion) {
|
function animarTransicion(nuevaFormacion) {
|
||||||
|
// Limpiar capa y diccionario de atletas previos
|
||||||
|
layer.destroyChildren();
|
||||||
|
atletasKonva = {};
|
||||||
|
|
||||||
|
// Redibujar cuadrícula
|
||||||
|
dibujarCuadricula(layer, piscinaWidth, piscinaHeight);
|
||||||
|
|
||||||
|
// Dibujar cada atleta
|
||||||
nuevaFormacion.forEach(a => {
|
nuevaFormacion.forEach(a => {
|
||||||
const obj = atletasKonva[a.idPersonalizado];
|
|
||||||
if (obj) {
|
|
||||||
const { circle, text, figuraText, coordText } = obj;
|
|
||||||
|
|
||||||
// Animar círculo
|
|
||||||
new Konva.Tween({
|
|
||||||
node: circle,
|
|
||||||
duration: 1.0,
|
|
||||||
x: a.x,
|
|
||||||
y: a.y,
|
|
||||||
easing: Konva.Easings.EaseInOut,
|
|
||||||
}).play();
|
|
||||||
|
|
||||||
// Mover textos en paralelo
|
|
||||||
new Konva.Tween({
|
|
||||||
node: text,
|
|
||||||
duration: 1.0,
|
|
||||||
x: a.x - 10,
|
|
||||||
y: a.y - 7,
|
|
||||||
easing: Konva.Easings.EaseInOut,
|
|
||||||
}).play();
|
|
||||||
|
|
||||||
new Konva.Tween({
|
|
||||||
node: figuraText,
|
|
||||||
duration: 1.0,
|
|
||||||
x: a.x - 25,
|
|
||||||
y: a.y + 18,
|
|
||||||
easing: Konva.Easings.EaseInOut,
|
|
||||||
}).play();
|
|
||||||
|
|
||||||
new Konva.Tween({
|
|
||||||
node: coordText,
|
|
||||||
duration: 1.0,
|
|
||||||
x: a.x - 35,
|
|
||||||
y: a.y + 30,
|
|
||||||
easing: Konva.Easings.EaseInOut,
|
|
||||||
onUpdate: () => {
|
|
||||||
const metros = convertirAMetros(a.x, a.y);
|
|
||||||
coordText.text(`${metros.metrosX}m, ${metros.metrosY}m`);
|
|
||||||
}
|
|
||||||
}).play();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
dibujarAtleta(a);
|
dibujarAtleta(a);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
layer.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
btnGuardarFormacion.addEventListener('click', async () => {
|
btnGuardarFormacion.addEventListener('click', async () => {
|
||||||
|
@ -484,7 +462,7 @@ const linea = new Konva.Arrow({
|
||||||
notasTacticas: notas,
|
notasTacticas: notas,
|
||||||
duracion: duracion || 0,
|
duracion: duracion || 0,
|
||||||
atletas: formacionActual.map(a => ({
|
atletas: formacionActual.map(a => ({
|
||||||
atletaId: a.atletaId._id || a.atletaId,
|
atletaId: a.atletaId,
|
||||||
idPersonalizado: a.idPersonalizado,
|
idPersonalizado: a.idPersonalizado,
|
||||||
x: a.x,
|
x: a.x,
|
||||||
y: a.y,
|
y: a.y,
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- NAV -->
|
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top shadow-sm px-4 py-3">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top shadow-sm px-4 py-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand fw-bold text-white" href="#">SwimmingArt</a>
|
<a class="navbar-brand fw-bold text-white" href="#">SwimmingArt</a>
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- MAIN -->
|
|
||||||
<main class="container-xl px-4 my-4">
|
<main class="container-xl px-4 my-4">
|
||||||
<section class="mb-4">
|
<section class="mb-4">
|
||||||
<h2 id="tituloRutina" class="fw-bold fs-2 mb-2">Editor de Formación</h2>
|
<h2 id="tituloRutina" class="fw-bold fs-2 mb-2">Editor de Formación</h2>
|
||||||
|
@ -34,10 +32,9 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="row gx-4 gy-4 align-items-start">
|
<div class="row gx-4 gy-4">
|
||||||
<!-- Formulario Atleta -->
|
<div class="col-lg-4">
|
||||||
<div class="col-lg-5 col-xl-4">
|
<div class="card p-4 h-100 d-flex flex-column">
|
||||||
<div class="card p-4 h-100">
|
|
||||||
<h5 class="fw-semibold mb-3 text-primary">Agregar Atleta</h5>
|
<h5 class="fw-semibold mb-3 text-primary">Agregar Atleta</h5>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -58,7 +55,6 @@
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="idPersonalizado" class="form-label">ID personalizado</label>
|
<label for="idPersonalizado" class="form-label">ID personalizado</label>
|
||||||
<input type="text" id="idPersonalizado" class="form-control" placeholder="Ej: A, 1, V2" readonly>
|
<input type="text" id="idPersonalizado" class="form-control" placeholder="Ej: A, 1, V2" readonly>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -82,13 +78,12 @@
|
||||||
<input type="text" id="codigoElemento" class="form-control" placeholder="Ej: TRE 1A, H4...">
|
<input type="text" id="codigoElemento" class="form-control" placeholder="Ej: TRE 1A, H4...">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button id="btnAgregarAtleta" class="btn btn-primary w-100">Añadir Atleta</button>
|
<button id="btnAgregarAtleta" class="btn btn-primary mt-auto">Añadir Atleta</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Piscina y Línea de Tiempo -->
|
<div class="col-lg-8 d-flex flex-column gap-3">
|
||||||
<div class="col-lg-7 col-xl-8">
|
<div class="card p-4">
|
||||||
<div class="card p-4 h-100">
|
|
||||||
<h5 class="fw-semibold mb-3 text-primary">Piscina</h5>
|
<h5 class="fw-semibold mb-3 text-primary">Piscina</h5>
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
|
@ -100,21 +95,26 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="piscinaContainer" class="border rounded p-2 mb-4" style="width: 100%; max-width: 100%; height: auto;">
|
<div id="piscinaContainer" class="border rounded p-2 mb-4" style="width: 100%; height: auto;">
|
||||||
<div id="piscina"></div>
|
<div id="piscina"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="d-flex align-items-center justify-content-between flex-wrap gap-2 mb-3">
|
||||||
<button id="btnEditarFormacion" class="btn btn-outline-secondary btn-sm" disabled>Editar formación</button>
|
<button id="btnEditarFormacion" class="btn btn-outline-secondary btn-sm">Editar formación</button>
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div id="waveform" style="height: 80px;"></div>
|
||||||
|
<div class="text-end">
|
||||||
|
<button id="playPauseBtn" class="btn btn-outline-primary btn-sm">Reproducir</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="form-label fw-semibold">Línea de Tiempo</label>
|
<label class="form-label fw-semibold mt-3">Línea de Tiempo</label>
|
||||||
<div id="lineaTiempo" class="timeline-placeholder d-flex flex-wrap gap-2"></div>
|
<div id="lineaTiempo" class="timeline-placeholder d-flex flex-wrap gap-2"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Datos de Formación -->
|
|
||||||
<div class="card p-4 mt-4">
|
<div class="card p-4 mt-4">
|
||||||
<h5 class="fw-semibold mb-3 text-primary">Datos de Formación</h5>
|
<h5 class="fw-semibold mb-3 text-primary">Datos de Formación</h5>
|
||||||
<div class="row gy-3">
|
<div class="row gy-3">
|
||||||
|
@ -138,15 +138,6 @@
|
||||||
<button id="btnGuardarFormacion" class="btn btn-primary">Guardar Formación</button>
|
<button id="btnGuardarFormacion" class="btn btn-primary">Guardar Formación</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Reproductor de audio -->
|
|
||||||
<div class="card p-4 mt-4">
|
|
||||||
<h5 class="fw-semibold mb-3 text-primary">Reproductor de Audio</h5>
|
|
||||||
<div id="waveform" class="mb-3"></div>
|
|
||||||
<div class="text-end">
|
|
||||||
<button id="playPauseBtn" class="btn btn-outline-secondary">Reproducir</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<audio id="audioPlayer" class="d-none" controls></audio>
|
<audio id="audioPlayer" class="d-none" controls></audio>
|
||||||
|
|
|
@ -5,20 +5,19 @@ const User = require('./user');
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Configuración de almacenamiento para música
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function (req, file, cb) {
|
destination: function (req, file, cb) {
|
||||||
cb(null, 'uploads/music');
|
cb(null, 'uploads/music');
|
||||||
},
|
},
|
||||||
filename: function (req, file, cb) {
|
filename: function (req, file, cb) {
|
||||||
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
|
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1e9);
|
||||||
cb(null, uniqueSuffix + path.extname(file.originalname));
|
cb(null, uniqueSuffix + path.extname(file.originalname));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const upload = multer({
|
const upload = multer({
|
||||||
storage: storage,
|
storage: storage,
|
||||||
limits: { fileSize: 10 * 1024 * 1024 }, // máx 10MB
|
limits: { fileSize: 10 * 1024 * 1024 },
|
||||||
fileFilter: function (req, file, cb) {
|
fileFilter: function (req, file, cb) {
|
||||||
if (!file.originalname.match(/\.(mp3)$/)) {
|
if (!file.originalname.match(/\.(mp3)$/)) {
|
||||||
return cb(new Error('Solo se permiten archivos .mp3'));
|
return cb(new Error('Solo se permiten archivos .mp3'));
|
||||||
|
@ -63,7 +62,7 @@ const routineSchema = new mongoose.Schema({
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
createdAt: { type: Date, default: Date.now }
|
createdAt: { type: Date, default: Date.now }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ router.get('/:id', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST agregar formación
|
// POST agregar formación (corregido y robusto)
|
||||||
router.post('/:id/formations', async (req, res) => {
|
router.post('/:id/formations', async (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
if (!mongoose.Types.ObjectId.isValid(id)) {
|
if (!mongoose.Types.ObjectId.isValid(id)) {
|
||||||
|
@ -116,13 +115,29 @@ router.post('/:id/formations', async (req, res) => {
|
||||||
const rutina = await Routine.findById(id);
|
const rutina = await Routine.findById(id);
|
||||||
if (!rutina) return res.status(404).json({ error: 'Rutina no encontrada' });
|
if (!rutina) return res.status(404).json({ error: 'Rutina no encontrada' });
|
||||||
|
|
||||||
rutina.formaciones.push(req.body);
|
const formacionLimpia = {
|
||||||
|
...req.body,
|
||||||
|
atletas: req.body.atletas.map(a => {
|
||||||
|
const rawId = typeof a.atletaId === 'object' && a.atletaId?.id ? a.atletaId.id : a.atletaId;
|
||||||
|
|
||||||
const nuevosAtletas = req.body.atletas.map(a => a.atletaId);
|
return {
|
||||||
|
...a,
|
||||||
|
atletaId: mongoose.Types.ObjectId.isValid(rawId)
|
||||||
|
? new mongoose.Types.ObjectId(rawId)
|
||||||
|
: undefined
|
||||||
|
};
|
||||||
|
}).filter(a => a.atletaId !== undefined)
|
||||||
|
};
|
||||||
|
|
||||||
nuevosAtletas.forEach(idAtleta => {
|
rutina.formaciones.push(formacionLimpia);
|
||||||
if (!rutina.participantes.includes(idAtleta.toString())) {
|
|
||||||
rutina.participantes.push(idAtleta);
|
formacionLimpia.atletas.forEach(({ atletaId }) => {
|
||||||
|
if (
|
||||||
|
atletaId &&
|
||||||
|
mongoose.Types.ObjectId.isValid(atletaId) &&
|
||||||
|
!rutina.participantes.map(p => p.toString()).includes(atletaId.toString())
|
||||||
|
) {
|
||||||
|
rutina.participantes.push(atletaId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,7 +149,6 @@ router.post('/:id/formations', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// GET formaciones de rutina
|
// GET formaciones de rutina
|
||||||
router.get('/:id/formations', async (req, res) => {
|
router.get('/:id/formations', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
@ -217,12 +231,10 @@ router.post('/upload/music', upload.single('music'), (req, res) => {
|
||||||
res.status(200).json({ url: fileUrl });
|
res.status(200).json({ url: fileUrl });
|
||||||
});
|
});
|
||||||
|
|
||||||
const { Types } = require('mongoose');
|
|
||||||
|
|
||||||
router.delete('/:id', async (req, res) => {
|
router.delete('/:id', async (req, res) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
|
||||||
if (!Types.ObjectId.isValid(id)) {
|
if (!mongoose.Types.ObjectId.isValid(id)) {
|
||||||
return res.status(400).json({ error: 'ID inválido' });
|
return res.status(400).json({ error: 'ID inválido' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +251,6 @@ router.delete('/:id', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// GET rutinas asignadas a un atleta
|
// GET rutinas asignadas a un atleta
|
||||||
router.get('/atleta/:id', async (req, res) => {
|
router.get('/atleta/:id', async (req, res) => {
|
||||||
const atletaId = req.params.id;
|
const atletaId = req.params.id;
|
||||||
|
@ -254,7 +265,4 @@ router.get('/atleta/:id', async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
Loading…
Reference in New Issue