Skip to content

Commit

Permalink
Everything except compare page fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
cherriae committed Feb 19, 2025
1 parent f6f47ce commit 30b7207
Show file tree
Hide file tree
Showing 19 changed files with 817 additions and 448 deletions.
11 changes: 11 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ def handle_exception(e):
def rate_limit_error(e):
return render_template("429.html"), 429

@app.route('/static/manifest.json')
def serve_manifest():
return send_from_directory(app.static_folder, 'manifest.json')

@app.route('/static/js/service-worker.js')
def serve_service_worker():
response = make_response(send_from_directory(app.static_folder, 'js/service-worker.js'))
response.headers['Service-Worker-Allowed'] = '/'
response.headers['Cache-Control'] = 'no-cache'
return response

return app


Expand Down
360 changes: 194 additions & 166 deletions app/scout/routes.py

Large diffs are not rendered by default.

414 changes: 236 additions & 178 deletions app/scout/scouting_utils.py

Large diffs are not rendered by default.

Binary file added app/static/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/icons/icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 86 additions & 50 deletions app/static/js/compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,20 +568,94 @@ function displayRawData(teamsData) {
});
}

// Make sure showAutoPath function is defined globally
window.showAutoPath = function(pathData, autoNotes = '') {
let modalCanvas, modalCoordSystem;
let currentPathData = null;

// Update the showAutoPath function
function showAutoPath(pathData, autoNotes = '') {
currentPathData = pathData;

const modal = document.getElementById('autoPathModal');
const image = document.getElementById('modalAutoPathImage');
const notes = document.getElementById('modalAutoNotes');
modal.classList.remove('hidden');

if (!modalCanvas) {
modalCanvas = document.getElementById('modalAutoPathCanvas');
modalCoordSystem = new CanvasCoordinateSystem(modalCanvas);

resizeModalCanvas();
window.addEventListener('resize', resizeModalCanvas);
}

redrawPaths();

if (modal && image && notes) {
image.src = pathData;
notes.textContent = autoNotes || 'No auto notes provided';
modal.classList.remove('hidden');
} else {
console.error('Modal elements not found');
const notesElement = document.getElementById('modalAutoNotes');
if (notesElement) {
notesElement.textContent = autoNotes || 'No notes available';
}
}

function resizeModalCanvas() {
const container = modalCanvas.parentElement;
modalCanvas.width = container.clientWidth;
modalCanvas.height = container.clientHeight;
modalCoordSystem.updateTransform();
redrawPaths();
}

function redrawPaths() {
if (!modalCoordSystem || !currentPathData) return;

modalCoordSystem.clear();

let paths = currentPathData;
if (typeof paths === 'string') {
try {
paths = JSON.parse(paths);
} catch (e) {
console.error('Failed to parse path data:', e);
return;
}
}

if (Array.isArray(paths)) {
paths.forEach(path => {
if (Array.isArray(path) && path.length > 0) {
const formattedPath = path.map(point => {
if (typeof point === 'object' && 'x' in point && 'y' in point) {
return {
x: (point.x / 1000) * modalCanvas.width,
y: (point.y / 300) * modalCanvas.height
};
}
return null;
}).filter(point => point !== null);

if (formattedPath.length > 0) {
modalCoordSystem.drawPath(formattedPath, '#3b82f6', 3);
}
}
});
}
}

function closeAutoPathModal() {
const modal = document.getElementById('autoPathModal');
if (modal) {
modal.classList.add('hidden');
}
}

// Initialize modal click handler
window.addEventListener('load', function() {
const modal = document.getElementById('autoPathModal');
if (modal) {
modal.addEventListener('click', function(e) {
if (e.target === modal) {
closeAutoPathModal();
}
});
}
};
});

function createRadarChart(data) {
// Extract teams for comparison
Expand Down Expand Up @@ -658,42 +732,4 @@ function getTeamColor(index) {
'#FF9F40'
];
return colors[index % colors.length];
}

function showAutoPath(pathData, autoNotes = '') {
const modal = document.getElementById('autoPathModal');
const image = document.getElementById('modalAutoPathImage');
const notes = document.getElementById('modalAutoNotes');

image.src = pathData;
notes.textContent = autoNotes || 'No auto notes provided';
modal.classList.remove('hidden');
}

function closeAutoPathModal() {
document.getElementById('autoPathModal').classList.add('hidden');
}

document.addEventListener('DOMContentLoaded', function() {
// ... existing initialization code ...

// Add modal event listeners
const modal = document.getElementById('autoPathModal');
if (modal) {
// Close on clicking outside the modal
modal.addEventListener('click', function(e) {
if (e.target === this) {
closeAutoPathModal();
}
});

// Close on Escape key
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeAutoPathModal();
}
});
}

// ... rest of your initialization code ...
});
}
24 changes: 19 additions & 5 deletions app/static/js/scout.add.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ function startDrawing(e) {
}

function draw(e) {
if (!isDrawing) return;
if (!isDrawing) {
return;
}
e.preventDefault();
const point = getPointFromEvent(e);
currentPath.push(point);
redrawPaths();
}

function stopDrawing(e) {
if (!isDrawing) return;
if (!isDrawing) {
return;
}
e.preventDefault();
isDrawing = false;
if (currentPath.length > 1) {
Expand Down Expand Up @@ -123,7 +127,7 @@ function redrawPaths() {

function updateHiddenInput() {
const input = document.getElementById('auto_path');
input.value = JSON.stringify(paths);
input.value = paths.length > 0 ? JSON.stringify(paths) : JSON.stringify([]);
}

function undoLastPath() {
Expand All @@ -145,7 +149,9 @@ function resetZoom() {
}

function zoomIn(event) {
if (!coordSystem) return;
if (!coordSystem) {
return;
}
const rect = canvas.getBoundingClientRect();
let mouseX, mouseY;

Expand All @@ -165,7 +171,9 @@ function zoomIn(event) {
}

function zoomOut(event) {
if (!coordSystem) return;
if (!coordSystem) {
return;
}
const rect = canvas.getBoundingClientRect();
let mouseX, mouseY;

Expand Down Expand Up @@ -210,6 +218,12 @@ document.addEventListener('DOMContentLoaded', function() {
const eventCode = form.querySelector('input[name="event_code"]').value;
const matchNumber = form.querySelector('input[name="match_number"]').value;

// Initialize auto_path with empty array if not set
const autoPathInput = form.querySelector('input[name="auto_path"]');
if (!autoPathInput.value) {
autoPathInput.value = JSON.stringify([]);
}

try {
const response = await fetch(`/scouting/check_team?team=${teamNumber}&event=${eventCode}&match=${matchNumber}`);
const data = await response.json();
Expand Down
Loading

0 comments on commit 30b7207

Please sign in to comment.