Fixed db issues for docker. Improved index.html for mobile.
This commit is contained in:
parent
31daee2dd8
commit
91832fd5bc
4 changed files with 420 additions and 349 deletions
|
|
@ -15,4 +15,4 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||||
COPY . /app/
|
COPY . /app/
|
||||||
|
|
||||||
# We'll run the server via docker-compose command, but this is a default
|
# We'll run the server via docker-compose command, but this is a default
|
||||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
CMD ["python", "manage.py", "runserver", "0.0.0.0:8001"]
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version: '3.8'
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
|
|
@ -7,9 +7,9 @@ services:
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
MYSQL_DATABASE: workouts
|
MYSQL_DATABASE: workouts
|
||||||
MYSQL_ROOT_PASSWORD: rootpassword
|
MYSQL_ROOT_PASSWORD: Throwaway
|
||||||
MYSQL_USER: user
|
ports:
|
||||||
MYSQL_PASSWORD: userpassword
|
- "3306:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/mysql
|
- db_data:/var/lib/mysql
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -18,19 +18,21 @@ services:
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
container_name: workouts_web
|
container_name: workouts_web
|
||||||
|
working_dir: /app/zed_workouts
|
||||||
command: >
|
command: >
|
||||||
sh -c "python manage.py migrate &&
|
sh -c "sleep 10 &&
|
||||||
python manage.py runserver 0.0.0.0:8000"
|
python manage.py migrate &&
|
||||||
|
python manage.py runserver 0.0.0.0:8001"
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8001:8001"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
environment:
|
environment:
|
||||||
- DB_NAME=workouts
|
- DB_NAME=workouts
|
||||||
- DB_USER=user
|
- DB_USER=root
|
||||||
- DB_PASSWORD=userpassword
|
- DB_PASSWORD=Throwaway
|
||||||
- DB_HOST=db
|
- DB_HOST=db
|
||||||
networks:
|
networks:
|
||||||
- workout_net
|
- workout_net
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,120 @@
|
||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||||
|
/>
|
||||||
<title>Zed Workouts</title>
|
<title>Zed Workouts</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link
|
||||||
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
<style>
|
<style>
|
||||||
.table-input { width: 100%; border: none; background: transparent; }
|
:root {
|
||||||
.hidden-inputs { display: none; }
|
--ios-blue: #007aff;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family:
|
||||||
|
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||||
|
Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* General Input Styling */
|
||||||
|
.table-input {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
background: #fff;
|
||||||
|
padding: 8px 4px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 16px; /* Essential for iOS to prevent zoom */
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile Optimization (< 600px) */
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.container {
|
||||||
|
padding: 8px !important;
|
||||||
|
}
|
||||||
|
h2,
|
||||||
|
h4 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hide the Group/Type columns to save horizontal space */
|
||||||
|
.col-grp,
|
||||||
|
.col-ty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table td,
|
||||||
|
.table th {
|
||||||
|
padding: 6px 2px !important;
|
||||||
|
font-size: 13px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Proportional Column Widths */
|
||||||
|
.col-ex {
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
.col-set {
|
||||||
|
width: 10%;
|
||||||
|
}
|
||||||
|
.col-rp {
|
||||||
|
width: 15%;
|
||||||
|
}
|
||||||
|
.col-wt {
|
||||||
|
width: 15%;
|
||||||
|
}
|
||||||
|
.col-nt {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
padding: 12px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop Polish */
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.table-input {
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.table-input:focus {
|
||||||
|
border: 1px solid var(--ios-blue);
|
||||||
|
background: #fff;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden-inputs {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.text-truncate-mobile {
|
||||||
|
max-width: 100px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-light p-4">
|
<body class="bg-light p-2 p-md-4">
|
||||||
<div class="container bg-white p-4 rounded shadow">
|
<div class="container bg-white p-3 p-md-4 rounded shadow">
|
||||||
<h2 class="mb-4">Workout Tracker</h2>
|
<h2 class="mb-3">Workout Tracker</h2>
|
||||||
|
|
||||||
<!-- SECTION 1: Template Selection -->
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-4">
|
<div class="col-12 col-md-4">
|
||||||
<label class="form-label"><strong>Template</strong></label>
|
<label class="form-label"><strong>Template</strong></label>
|
||||||
<select id="templateSelect" class="form-select" onchange="filterExercises()">
|
<select
|
||||||
|
id="templateSelect"
|
||||||
|
class="form-select form-select-lg"
|
||||||
|
onchange="filterExercises()"
|
||||||
|
>
|
||||||
<option value="">Select...</option>
|
<option value="">Select...</option>
|
||||||
<option value="Chest">Chest</option>
|
<option value="Chest">Chest</option>
|
||||||
<option value="Back">Back</option>
|
<option value="Back">Back</option>
|
||||||
|
|
@ -27,87 +123,107 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- SECTION 2: Exercise Selection -->
|
<div class="row g-2 mb-3">
|
||||||
<div class="row mb-3">
|
<div class="col-4">
|
||||||
<div class="col-md-4">
|
<label class="small">Primary</label>
|
||||||
<label>Primary Group</label>
|
<select
|
||||||
<select id="primarySelect" class="form-select"></select>
|
id="primarySelect"
|
||||||
|
class="form-select form-select-sm"
|
||||||
|
></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-4">
|
||||||
<label>Secondary Group</label>
|
<label class="small">Secondary</label>
|
||||||
<select id="secondarySelect" class="form-select"></select>
|
<select
|
||||||
|
id="secondarySelect"
|
||||||
|
class="form-select form-select-sm"
|
||||||
|
></select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-4">
|
||||||
<label>Core Group</label>
|
<label class="small">Core</label>
|
||||||
<select id="coreSelect" class="form-select"></select>
|
<select
|
||||||
|
id="coreSelect"
|
||||||
|
class="form-select form-select-sm"
|
||||||
|
></select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary mb-4" onclick="generateTable()">Generate Table</button>
|
<button
|
||||||
|
class="btn btn-primary w-100 mb-4"
|
||||||
|
onclick="generateTable()"
|
||||||
|
>
|
||||||
|
Generate Table
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- SECTION 3: Active Supersets Table -->
|
<h4 class="mb-2">Current Block</h4>
|
||||||
<h4>Current Block (4 Sets)</h4>
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered">
|
<table class="table table-sm table-bordered">
|
||||||
<thead class="table-dark">
|
<thead class="table-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Exercise</th>
|
<th class="col-ex">Exercise</th>
|
||||||
<th>Group</th>
|
<th class="col-grp">Group</th>
|
||||||
<th>Set</th>
|
<th class="col-set">Set</th>
|
||||||
<th>Reps</th>
|
<th class="col-rp">Reps</th>
|
||||||
<th>Weight</th>
|
<th class="col-wt">Weight</th>
|
||||||
<th>Notes</th>
|
<th class="col-nt">Note</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="activeTableBody"></tbody>
|
<tbody id="activeTableBody"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-warning mb-4" onclick="saveBlock()">Save Block (Clear Table)</button>
|
<button class="btn btn-warning w-100 mb-4" onclick="saveBlock()">
|
||||||
|
Save Block
|
||||||
|
</button>
|
||||||
|
|
||||||
<hr class="my-4">
|
<hr />
|
||||||
|
|
||||||
<!-- SECTION 3.5: Ad-Hoc Input -->
|
<h4 class="mb-2">Extra Exercise</h4>
|
||||||
<h4>Add Extra Exercise (4 Sets)</h4>
|
<select
|
||||||
<div class="row mb-3">
|
id="adhocSelect"
|
||||||
<div class="col-md-6">
|
class="form-select mb-2"
|
||||||
<label>Select Exercise</label>
|
onchange="generateAdhocRows()"
|
||||||
<select id="adhocSelect" class="form-select" onchange="generateAdhocRows()">
|
>
|
||||||
<option value="">Select...</option>
|
<option value="">Add individual exercise...</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-sm table-bordered">
|
||||||
|
<tbody id="adhocTableBody"></tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<button
|
||||||
<table class="table table-bordered">
|
id="saveAdhocBtn"
|
||||||
<thead class="table-dark">
|
class="btn btn-outline-warning w-100 mb-4 d-none"
|
||||||
<tr>
|
onclick="saveAdhocBlock()"
|
||||||
|
>
|
||||||
|
Save Extra
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="template_name"
|
||||||
|
id="formTemplateName"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<h4 class="mt-4">Final Log</h4>
|
||||||
|
<table class="table table-striped table-sm">
|
||||||
|
<thead>
|
||||||
|
<tr class="small text-muted">
|
||||||
<th>Exercise</th>
|
<th>Exercise</th>
|
||||||
<th>Group</th>
|
|
||||||
<th>Set</th>
|
<th>Set</th>
|
||||||
<th>Reps</th>
|
<th>Reps</th>
|
||||||
<th>Weight</th>
|
<th>Weight</th>
|
||||||
<th>Notes</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="adhocTableBody"></tbody>
|
|
||||||
</table>
|
|
||||||
<button class="btn btn-warning mb-4" onclick="saveAdhocBlock()">Save Extra Exercise</button>
|
|
||||||
<hr class="my-4">
|
|
||||||
|
|
||||||
<!-- SECTION 4: Final Submission -->
|
|
||||||
<form method="POST">
|
|
||||||
{% csrf_token %}
|
|
||||||
<input type="hidden" name="template_name" id="formTemplateName">
|
|
||||||
|
|
||||||
<h4>Completed Workout Log</h4>
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr><th>Exercise</th><th>Set</th><th>Reps</th><th>Weight</th><th>Notes</th></tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="logTableBody"></tbody>
|
<tbody id="logTableBody"></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- Hidden inputs container for POST data -->
|
|
||||||
<div id="hiddenInputs" class="hidden-inputs"></div>
|
<div id="hiddenInputs" class="hidden-inputs"></div>
|
||||||
|
<button type="submit" class="btn btn-success btn-lg w-100 mt-3">
|
||||||
<button type="submit" class="btn btn-success btn-lg w-100 mt-3">End Workout (Submit)</button>
|
End Workout
|
||||||
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -119,10 +235,7 @@
|
||||||
const template = document.getElementById('templateSelect').value;
|
const template = document.getElementById('templateSelect').value;
|
||||||
document.getElementById('formTemplateName').value = template;
|
document.getElementById('formTemplateName').value = template;
|
||||||
|
|
||||||
// Simple mapping logic: Chest Template implies Chest exercises for Primary, etc.
|
|
||||||
// You can customize this logic as needed.
|
|
||||||
let primaryType = [], secondaryType = [];
|
let primaryType = [], secondaryType = [];
|
||||||
|
|
||||||
if (template === 'Chest') { primaryType = ['Chest']; secondaryType = ['Arms', 'Triceps']; }
|
if (template === 'Chest') { primaryType = ['Chest']; secondaryType = ['Arms', 'Triceps']; }
|
||||||
else if (template === 'Back') { primaryType = ['Back']; secondaryType = ['Arms', 'Biceps']; }
|
else if (template === 'Back') { primaryType = ['Back']; secondaryType = ['Arms', 'Biceps']; }
|
||||||
else if (template === 'Legs') { primaryType = ['Legs']; secondaryType = ['Shoulders', 'Calves']; }
|
else if (template === 'Legs') { primaryType = ['Legs']; secondaryType = ['Shoulders', 'Calves']; }
|
||||||
|
|
@ -135,7 +248,7 @@
|
||||||
|
|
||||||
function populateDropdown(id, group, types) {
|
function populateDropdown(id, group, types) {
|
||||||
const select = document.getElementById(id);
|
const select = document.getElementById(id);
|
||||||
select.innerHTML = '<option value="">Select...</option>';
|
select.innerHTML = '<option value="">...</option>';
|
||||||
exercises.forEach(ex => {
|
exercises.forEach(ex => {
|
||||||
if (ex.group === group && (types.length === 0 || types.includes(ex.type))) {
|
if (ex.group === group && (types.length === 0 || types.includes(ex.type))) {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
|
|
@ -160,29 +273,28 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRowHtml(exName, group, type, set, reps=0, weight=0, notes='') {
|
||||||
|
return `
|
||||||
|
<tr>
|
||||||
|
<td class="col-ex text-truncate-mobile">${exName}<input type="hidden" class="d-ex" value="${exName}"></td>
|
||||||
|
<td class="col-grp">${group}<input type="hidden" class="d-gr" value="${group}"><input type="hidden" class="d-ty" value="${type}"></td>
|
||||||
|
<td class="col-set">${set}<input type="hidden" class="d-st" value="${set}"></td>
|
||||||
|
<td class="col-rp"><input type="number" inputmode="numeric" class="table-input d-rp" value="${reps}"></td>
|
||||||
|
<td class="col-wt"><input type="number" inputmode="decimal" class="table-input d-wt" step="0.5" value="${weight}"></td>
|
||||||
|
<td class="col-nt"><input type="text" class="table-input d-nt" value="${notes}" placeholder="..."></td>
|
||||||
|
</tr>`;
|
||||||
|
}
|
||||||
|
|
||||||
function loadTemplateData(templateName) {
|
function loadTemplateData(templateName) {
|
||||||
const tbody = document.getElementById('activeTableBody');
|
const tbody = document.getElementById('activeTableBody');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
const data = templates[templateName];
|
const data = templates[templateName];
|
||||||
if (data && data.length > 0) {
|
if (data) {
|
||||||
data.forEach(row => {
|
data.forEach(row => {
|
||||||
// Try to sync dropdowns based on first occurrence
|
|
||||||
if (row.group === 'Primary') setDropdownIfEmpty('primarySelect', row.exercise);
|
if (row.group === 'Primary') setDropdownIfEmpty('primarySelect', row.exercise);
|
||||||
if (row.group === 'Secondary') setDropdownIfEmpty('secondarySelect', row.exercise);
|
if (row.group === 'Secondary') setDropdownIfEmpty('secondarySelect', row.exercise);
|
||||||
if (row.group === 'Core') setDropdownIfEmpty('coreSelect', row.exercise);
|
if (row.group === 'Core') setDropdownIfEmpty('coreSelect', row.exercise);
|
||||||
|
tbody.insertAdjacentHTML('beforeend', getRowHtml(row.exercise, row.group, row.type, row.set, row.reps, row.weight, row.notes));
|
||||||
const html = `
|
|
||||||
<tr>
|
|
||||||
<td>${row.exercise}<input type="hidden" class="d-ex" value="${row.exercise}"></td>
|
|
||||||
<td>${row.group}<input type="hidden" class="d-gr" value="${row.group}">
|
|
||||||
<input type="hidden" class="d-ty" value="${row.type}"></td>
|
|
||||||
<td>${row.set}<input type="hidden" class="d-st" value="${row.set}"></td>
|
|
||||||
<td><input type="number" class="table-input d-rp" value="${row.reps}"></td>
|
|
||||||
<td><input type="number" class="table-input d-wt" step="0.5" value="${row.weight}"></td>
|
|
||||||
<td><input type="text" class="table-input d-nt" value="${row.notes || ''}" placeholder="Notes"></td>
|
|
||||||
</tr>`;
|
|
||||||
tbody.insertAdjacentHTML('beforeend', html);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -195,42 +307,21 @@
|
||||||
function generateTable() {
|
function generateTable() {
|
||||||
const tbody = document.getElementById('activeTableBody');
|
const tbody = document.getElementById('activeTableBody');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
// Get current template data to seed values
|
|
||||||
const templateName = document.getElementById('templateSelect').value;
|
const templateName = document.getElementById('templateSelect').value;
|
||||||
const templateData = templates[templateName] || [];
|
const templateData = templates[templateName] || [];
|
||||||
|
|
||||||
const selects = [
|
const selects = [
|
||||||
{ el: document.getElementById('primarySelect'), group: 'Primary' },
|
{ el: document.getElementById('primarySelect'), group: 'Primary' },
|
||||||
{ el: document.getElementById('secondarySelect'), group: 'Secondary' },
|
{ el: document.getElementById('secondarySelect'), group: 'Secondary' },
|
||||||
{ el: document.getElementById('coreSelect'), group: 'Core' }
|
{ el: document.getElementById('coreSelect'), group: 'Core' }
|
||||||
];
|
];
|
||||||
|
|
||||||
// Validate selection
|
if (selects.some(s => !s.el.value)) { alert("Select 3 exercises"); return; }
|
||||||
if (selects.some(s => !s.el.value)) { alert("Please select all 3 exercises."); return; }
|
|
||||||
|
|
||||||
for (let set = 1; set <= 4; set++) {
|
for (let set = 1; set <= 4; set++) {
|
||||||
selects.forEach(s => {
|
selects.forEach(s => {
|
||||||
const opt = s.el.options[s.el.selectedIndex];
|
const opt = s.el.options[s.el.selectedIndex];
|
||||||
const exName = s.el.value;
|
const match = templateData.find(row => row.exercise === s.el.value && row.set === set);
|
||||||
|
tbody.insertAdjacentHTML('beforeend', getRowHtml(s.el.value, s.group, opt.dataset.type, set, match?.reps || 0, match?.weight || 0, match?.notes || ''));
|
||||||
// Look for existing data in the template for this exercise/set
|
|
||||||
const match = templateData.find(row => row.exercise === exName && row.set === set);
|
|
||||||
const rReps = match ? match.reps : 0;
|
|
||||||
const rWeight = match ? match.weight : 0;
|
|
||||||
const rNotes = match ? (match.notes || '') : '';
|
|
||||||
|
|
||||||
const row = `
|
|
||||||
<tr>
|
|
||||||
<td>${exName}<input type="hidden" class="d-ex" value="${exName}"></td>
|
|
||||||
<td>${s.group}<input type="hidden" class="d-gr" value="${s.group}">
|
|
||||||
<input type="hidden" class="d-ty" value="${opt.dataset.type}"></td>
|
|
||||||
<td>${set}<input type="hidden" class="d-st" value="${set}"></td>
|
|
||||||
<td><input type="number" class="table-input d-rp" value="${rReps}"></td>
|
|
||||||
<td><input type="number" class="table-input d-wt" step="0.5" value="${rWeight}"></td>
|
|
||||||
<td><input type="text" class="table-input d-nt" value="${rNotes}" placeholder="Notes"></td>
|
|
||||||
</tr>`;
|
|
||||||
tbody.insertAdjacentHTML('beforeend', row);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,36 +330,20 @@
|
||||||
const select = document.getElementById('adhocSelect');
|
const select = document.getElementById('adhocSelect');
|
||||||
const tbody = document.getElementById('adhocTableBody');
|
const tbody = document.getElementById('adhocTableBody');
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
if (!select.value) { document.getElementById('saveAdhocBtn').classList.add('d-none'); return; }
|
||||||
|
|
||||||
if (!select.value) return;
|
document.getElementById('saveAdhocBtn').classList.remove('d-none');
|
||||||
|
|
||||||
const opt = select.options[select.selectedIndex];
|
const opt = select.options[select.selectedIndex];
|
||||||
const exName = select.value;
|
|
||||||
const gr = opt.dataset.group;
|
|
||||||
const ty = opt.dataset.type;
|
|
||||||
|
|
||||||
for (let set = 1; set <= 4; set++) {
|
for (let set = 1; set <= 4; set++) {
|
||||||
const row = `
|
tbody.insertAdjacentHTML('beforeend', getRowHtml(select.value, opt.dataset.group, opt.dataset.type, set));
|
||||||
<tr>
|
|
||||||
<td>${exName}<input type="hidden" class="d-ex" value="${exName}"></td>
|
|
||||||
<td>${gr}<input type="hidden" class="d-gr" value="${gr}">
|
|
||||||
<input type="hidden" class="d-ty" value="${ty}"></td>
|
|
||||||
<td>${set}<input type="hidden" class="d-st" value="${set}"></td>
|
|
||||||
<td><input type="number" class="table-input d-rp" value="0"></td>
|
|
||||||
<td><input type="number" class="table-input d-wt" step="0.5" value="0"></td>
|
|
||||||
<td><input type="text" class="table-input d-nt" value="" placeholder="Notes"></td>
|
|
||||||
</tr>`;
|
|
||||||
tbody.insertAdjacentHTML('beforeend', row);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveBlock() {
|
function saveBlock() { processSaveBlock('activeTableBody'); }
|
||||||
processSaveBlock('activeTableBody');
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveAdhocBlock() {
|
function saveAdhocBlock() {
|
||||||
processSaveBlock('adhocTableBody');
|
processSaveBlock('adhocTableBody');
|
||||||
document.getElementById('adhocSelect').value = '';
|
document.getElementById('adhocSelect').value = '';
|
||||||
|
document.getElementById('saveAdhocBtn').classList.add('d-none');
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSaveBlock(tableId) {
|
function processSaveBlock(tableId) {
|
||||||
|
|
@ -276,35 +351,30 @@
|
||||||
const logBody = document.getElementById('logTableBody');
|
const logBody = document.getElementById('logTableBody');
|
||||||
const hiddenDiv = document.getElementById('hiddenInputs');
|
const hiddenDiv = document.getElementById('hiddenInputs');
|
||||||
|
|
||||||
// Move rows from active table to log and create hidden inputs
|
|
||||||
activeBody.querySelectorAll('tr').forEach(row => {
|
activeBody.querySelectorAll('tr').forEach(row => {
|
||||||
const ex = row.querySelector('.d-ex').value;
|
const data = {
|
||||||
const gr = row.querySelector('.d-gr').value;
|
ex: row.querySelector('.d-ex').value,
|
||||||
const ty = row.querySelector('.d-ty').value;
|
gr: row.querySelector('.d-gr').value,
|
||||||
const st = row.querySelector('.d-st').value;
|
ty: row.querySelector('.d-ty').value,
|
||||||
const rp = row.querySelector('.d-rp').value;
|
st: row.querySelector('.d-st').value,
|
||||||
const wt = row.querySelector('.d-wt').value;
|
rp: row.querySelector('.d-rp').value,
|
||||||
const nt = row.querySelector('.d-nt').value;
|
wt: row.querySelector('.d-wt').value,
|
||||||
|
nt: row.querySelector('.d-nt').value
|
||||||
|
};
|
||||||
|
|
||||||
// Visual Log
|
logBody.insertAdjacentHTML('beforeend', `<tr><td>${data.ex}</td><td>${data.st}</td><td>${data.rp}</td><td>${data.wt}</td></tr>`);
|
||||||
const logRow = `<tr><td>${ex}</td><td>${st}</td><td>${rp}</td><td>${wt}</td><td>${nt}</td></tr>`;
|
hiddenDiv.insertAdjacentHTML('beforeend', `
|
||||||
logBody.insertAdjacentHTML('beforeend', logRow);
|
<input type="hidden" name="exercise[]" value="${data.ex}">
|
||||||
|
<input type="hidden" name="group[]" value="${data.gr}">
|
||||||
// Hidden Inputs for POST
|
<input type="hidden" name="type[]" value="${data.ty}">
|
||||||
const inputs = `
|
<input type="hidden" name="set[]" value="${data.st}">
|
||||||
<input type="hidden" name="exercise[]" value="${ex}">
|
<input type="hidden" name="reps[]" value="${data.rp}">
|
||||||
<input type="hidden" name="group[]" value="${gr}">
|
<input type="hidden" name="weight[]" value="${data.wt}">
|
||||||
<input type="hidden" name="type[]" value="${ty}">
|
<input type="hidden" name="notes[]" value="${data.nt}">
|
||||||
<input type="hidden" name="set[]" value="${st}">
|
`);
|
||||||
<input type="hidden" name="reps[]" value="${rp}">
|
|
||||||
<input type="hidden" name="weight[]" value="${wt}">
|
|
||||||
<input type="hidden" name="notes[]" value="${nt}">
|
|
||||||
`;
|
|
||||||
hiddenDiv.insertAdjacentHTML('beforeend', inputs);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Clear Active Table
|
|
||||||
activeBody.innerHTML = '';
|
activeBody.innerHTML = '';
|
||||||
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
populateAdhocDropdown();
|
populateAdhocDropdown();
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/6.0/ref/settings/
|
https://docs.djangoproject.com/en/6.0/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
@ -21,54 +21,54 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-a%mr&&f^u06y=$!cylb-wv&w3^booxo*48hymemf$ldj=$vkb%'
|
SECRET_KEY = "django-insecure-a%mr&&f^u06y=$!cylb-wv&w3^booxo*48hymemf$ldj=$vkb%"
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ["*"]
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
"django.contrib.admin",
|
||||||
'django.contrib.auth',
|
"django.contrib.auth",
|
||||||
'django.contrib.contenttypes',
|
"django.contrib.contenttypes",
|
||||||
'django.contrib.sessions',
|
"django.contrib.sessions",
|
||||||
'django.contrib.messages',
|
"django.contrib.messages",
|
||||||
'django.contrib.staticfiles',
|
"django.contrib.staticfiles",
|
||||||
'tracker',
|
"tracker",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
"django.middleware.security.SecurityMiddleware",
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
'django.middleware.common.CommonMiddleware',
|
"django.middleware.common.CommonMiddleware",
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
"django.middleware.csrf.CsrfViewMiddleware",
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
"django.contrib.messages.middleware.MessageMiddleware",
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'zed_workouts.urls'
|
ROOT_URLCONF = "zed_workouts.urls"
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
||||||
'DIRS': [],
|
"DIRS": [],
|
||||||
'APP_DIRS': True,
|
"APP_DIRS": True,
|
||||||
'OPTIONS': {
|
"OPTIONS": {
|
||||||
'context_processors': [
|
"context_processors": [
|
||||||
'django.template.context_processors.request',
|
"django.template.context_processors.request",
|
||||||
'django.contrib.auth.context_processors.auth',
|
"django.contrib.auth.context_processors.auth",
|
||||||
'django.contrib.messages.context_processors.messages',
|
"django.contrib.messages.context_processors.messages",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'zed_workouts.wsgi.application'
|
WSGI_APPLICATION = "zed_workouts.wsgi.application"
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
|
@ -83,46 +83,45 @@ WSGI_APPLICATION = 'zed_workouts.wsgi.application'
|
||||||
|
|
||||||
# Database connector for docker container
|
# Database connector for docker container
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
"default": {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
"ENGINE": "django.db.backends.mysql",
|
||||||
'NAME': os.environ.get('DB_NAME', 'workouts'),
|
"NAME": os.environ.get("DB_NAME", "workouts"),
|
||||||
'USER': os.environ.get('DB_USER', 'user'),
|
"USER": os.environ.get("DB_USER", "user"),
|
||||||
'PASSWORD': os.environ.get('DB_PASSWORD', 'userpassword'),
|
"PASSWORD": os.environ.get("DB_PASSWORD", "userpassword"),
|
||||||
'HOST': os.environ.get('DB_HOST', 'db'),
|
"HOST": os.environ.get("DB_HOST", "db"),
|
||||||
'PORT': '3306',
|
"PORT": "3306",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Database connector for local mysql instance
|
# Database connector for local mysql instance
|
||||||
DATABASES = {
|
# DATABASES = {
|
||||||
'default': {
|
# "default": {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
# "ENGINE": "django.db.backends.mysql",
|
||||||
'NAME': 'workouts',
|
# "NAME": "workouts",
|
||||||
'USER': 'root',
|
# "USER": "root",
|
||||||
'PASSWORD': 'Throwaway',
|
# "PASSWORD": "Throwaway",
|
||||||
'HOST': 'localhost', # Or your DB server IP
|
# "HOST": "localhost", # Or your DB server IP
|
||||||
'PORT': '3306', # Default MySQL port
|
# "PORT": "3306", # Default MySQL port
|
||||||
'OPTIONS': {
|
# "OPTIONS": {
|
||||||
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
# "init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
|
||||||
},
|
# },
|
||||||
}
|
# }
|
||||||
}
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -130,9 +129,9 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
# https://docs.djangoproject.com/en/6.0/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = "en-us"
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = "UTC"
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
|
|
@ -142,4 +141,4 @@ USE_TZ = True
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = 'static/'
|
STATIC_URL = "static/"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue