Files
workout/templates/program_import.html
2026-02-03 15:10:59 +11:00

89 lines
5.2 KiB
HTML

{% extends "base.html" %}
{% block title %}Import Program{% endblock %}
{% block content %}
<div class="container mx-auto px-4 py-8">
<div class="max-w-2xl mx-auto">
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-900">Import Workout Program</h1>
<p class="mt-1 text-sm text-gray-500">
Upload a JSON file containing your program structure, sessions, and sets/reps metadata.
</p>
</div>
<div class="bg-white shadow sm:rounded-lg">
<div class="px-4 py-5 sm:p-6">
<form action="{{ url_for('programs.import_program') }}" method="POST" enctype="multipart/form-data"
class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700">Program JSON File</label>
<div
class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md hover:border-indigo-400 transition-colors">
<div class="space-y-1 text-center">
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none"
viewBox="0 0 48 48" aria-hidden="true">
<path
d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<div class="flex text-sm text-gray-600">
<label for="file-upload"
class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
<span>Upload a file</span>
<input id="file-upload" name="file" type="file" accept=".json" class="sr-only"
required onchange="updateFileName(this)">
</label>
<p class="pl-1">or drag and drop</p>
</div>
<p class="text-xs text-gray-500">JSON file up to 10MB</p>
<p id="file-name" class="mt-2 text-sm text-indigo-600 font-semibold"></p>
</div>
</div>
</div>
<div class="flex justify-end space-x-3">
<a href="{{ url_for('programs.list_programs') }}"
class="inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Cancel
</a>
<button type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Upload and Import
</button>
</div>
</form>
</div>
</div>
<div class="mt-8 bg-indigo-50 rounded-md p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-indigo-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-indigo-800">JSON Format Requirement</h3>
<div class="mt-2 text-sm text-indigo-700">
<p>The JSON file should follow the shared schema, including <code>program_name</code>,
<code>description</code>, and a <code>sessions</code> array with <code>exercises</code>.
Each exercise should have <code>id</code>, <code>name</code>, <code>sets</code>,
<code>rep_range</code>, and <code>order</code>.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function updateFileName(input) {
const fileName = input.files[0] ? input.files[0].name : '';
document.getElementById('file-name').textContent = fileName;
}
</script>
{% endblock %}