245 lines
15 KiB
HTML
245 lines
15 KiB
HTML
<a hx-get="{{ url_for('get_person', person_id=person['PersonId']) }}"
|
|
hx-include="[name='exercise_id'],[name='min_date'],[name='max_date']" hx-target="#container"
|
|
hx-trigger="refreshView" id="refreshViewElement"></a>
|
|
|
|
<div class="flex justify-center">
|
|
<div class="bg-white shadow rounded-lg p-4 sm:w-full xl:p-8 md:w-full lg:w-11/12">
|
|
|
|
<div class="mb-4 flex items-center justify-between">
|
|
<div>
|
|
<h3 class="text-xl font-bold text-gray-900 mb-2">{{ person['PersonName'] }}</h3>
|
|
<span class="text-base font-normal text-gray-500">List of workouts</span>
|
|
</div>
|
|
<div>
|
|
<select
|
|
class="block appearance-none w-40 bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500 mr-5"
|
|
name="view" hx-get="{{ url_for('get_calendar', person_id=person['PersonId']) }}"
|
|
hx-target="#container" hx-push-url="true">
|
|
<option value="month">Month</option>
|
|
<option value="year">Year</option>
|
|
<option value="all" selected>All</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="flex">
|
|
{% set exercise_list = person['FilteredExercises'] %}
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-wrap -mx-3 mb-1">
|
|
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
|
|
<div class="mb-1 w-full">
|
|
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-city">
|
|
Exercises
|
|
</label>
|
|
<select id="multiSelection" data-te-select-init data-te-select-filter="true"
|
|
data-te-select-size="lg" name="exercise_id" class="bg-gray-50 border border-gray-300 " multiple
|
|
hx-get="{{ url_for('get_person', person_id=person['PersonId']) }}"
|
|
hx-include="[name='min_date'],[name='max_date']" hx-target="#container" hx-push-url="true">
|
|
{% for e in person['Exercises'] %}
|
|
<option value="{{ e['ExerciseId'] }}" {{ in_list(e['ExerciseId'],
|
|
selected_exercise_ids, 'selected' ) }}>{{
|
|
e['ExerciseName']
|
|
}}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<script>
|
|
te.Select.getOrCreateInstance(document.querySelector("#multiSelection")).setValue({{ list_to_string(selected_exercise_ids) | safe }});
|
|
</script>
|
|
</div>
|
|
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
|
|
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-city">
|
|
Min date
|
|
</label>
|
|
<div class="relative">
|
|
<div class="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none">
|
|
<svg aria-hidden="true" class="w-5 h-5 text-gray-500 dark:text-gray-400" fill="currentColor"
|
|
viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
<path fill-rule="evenodd"
|
|
d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
|
|
clip-rule="evenodd"></path>
|
|
</svg>
|
|
</div>
|
|
<input type="date"
|
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full"
|
|
name="min_date" value="{{ min_date }}"
|
|
hx-get="{{ url_for('get_person', person_id=person['PersonId']) }}"
|
|
hx-include="[name='exercise_id'],[name='min_date'],[name='max_date']" hx-target="#container"
|
|
hx-push-url="true" hx-trigger="change">
|
|
</div>
|
|
</div>
|
|
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
|
|
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-zip">
|
|
Max date
|
|
</label>
|
|
<div class="relative">
|
|
<div class="flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none">
|
|
<svg aria-hidden="true" class="w-5 h-5 text-gray-500 dark:text-gray-400" fill="currentColor"
|
|
viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
<path fill-rule="evenodd"
|
|
d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
|
|
clip-rule="evenodd"></path>
|
|
</svg>
|
|
</div>
|
|
<input type="date"
|
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full"
|
|
name="max_date" value="{{ max_date }}"
|
|
hx-get="{{ url_for('get_person', person_id=person['PersonId']) }}"
|
|
hx-include="[name='exercise_id'],[name='min_date'],[name='max_date']" hx-target="#container"
|
|
hx-push-url="true" hx-trigger="change">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex w-full flex-wrap justify-center">
|
|
|
|
{% for t in tags %}
|
|
<div data-te-chip-init data-te-ripple-init
|
|
class="[word-wrap: break-word] my-[5px] mr-4 flex h-[32px] cursor-pointer items-center justify-between rounded-[16px] border border-[#9fa6b2] bg-[#eceff1] bg-[transparent] py-0 px-[12px] text-[13px] font-normal normal-case leading-loose text-[#4f4f4f] shadow-none transition-[opacity] duration-300 ease-linear hover:border-[#9fa6b2] hover:!shadow-none dark:text-neutral-200"
|
|
data-te-ripple-color="dark">
|
|
<span hx-get="{{ url_for('goto_tag', person_id=person['PersonId']) }}"
|
|
hx-vals='{"filter": "{{ t["TagFilter"] }}"}' hx-target="#container" hx-push-url="true">{{
|
|
t['TagName'] }}</span>
|
|
|
|
|
|
<span
|
|
class="float-right w-4 cursor-pointer pl-[8px] text-[16px] text-[#afafaf] opacity-[.53] transition-all duration-200 ease-in-out hover:text-[#8b8b8b] dark:text-neutral-400 dark:hover:text-neutral-100"
|
|
hx-get="{{ url_for('delete_tag', person_id=person['PersonId'], tag_id=t['TagId']) }}"
|
|
hx-vals='{"filter": "{{ t["TagFilter"] }}"}' hx-target="#container" hx-push-url="true" _="on htmx:confirm(issueRequest)
|
|
halt the event
|
|
call Swal.fire({title: 'Confirm', text:'Are you sure you want to delete {{ t['TagName'] }} tag?'})
|
|
if result.isConfirmed issueRequest()">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
|
stroke="currentColor" class="h-3 w-3">
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</span>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<div class="flex justify-center space-x-2">
|
|
<div>
|
|
<button type="button" data-te-ripple-init data-te-ripple-color="light"
|
|
class="inline-block rounded-full bg-primary p-2 uppercase leading-normal text-white shadow-md transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)]"
|
|
id="add-tag">
|
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
|
stroke="currentColor" class="w-5 h-5">
|
|
<path stroke-linecap="round" stroke-linejoin="round"
|
|
d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m3.75 9v6m3-3H9m1.5-12H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" />
|
|
</svg>
|
|
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
document.querySelector('#add-tag').addEventListener('click', function () {
|
|
Swal.fire({
|
|
title: 'Create a tag',
|
|
input: 'text',
|
|
inputAttributes: {
|
|
autocapitalize: 'off'
|
|
},
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Add',
|
|
showLoaderOnConfirm: true,
|
|
preConfirm: (tag) => {
|
|
return fetch(`{{ url_for('add_tag', person_id=person['PersonId']) }}?tag=${encodeURIComponent(tag)}&filter=${encodeURIComponent(window.location.search)}`)
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error(response.statusText)
|
|
}
|
|
return response.text()
|
|
})
|
|
.catch(error => {
|
|
Swal.showValidationMessage(
|
|
`Request failed: ${error}`
|
|
)
|
|
})
|
|
},
|
|
allowOutsideClick: () => !Swal.isLoading()
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
htmx.ajax('GET', `{{ url_for('get_person', person_id=person['PersonId']) + '?' + request.query_string.decode() }}`, '#container')
|
|
}
|
|
})
|
|
|
|
})
|
|
</script>
|
|
|
|
<div class="flex flex-col mt-3">
|
|
<div class="overflow-x-auto rounded-lg">
|
|
<div class="align-middle inline-block min-w-full">
|
|
<div class="shadow overflow-hidden sm:rounded-lg">
|
|
|
|
{% if person['Workouts']|length > 0 %}
|
|
<table class="min-w-full divide-y divide-gray-200">
|
|
<thead class="bg-gray-50">
|
|
<tr>
|
|
<th scope="col"
|
|
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
Date
|
|
</th>
|
|
{% for e in exercise_list %}
|
|
<th scope="col"
|
|
class="p-4 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
{{ e['ExerciseName'] }}
|
|
</th>
|
|
{% endfor %}
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white">
|
|
|
|
{% for w in person['Workouts'] %}
|
|
<tr hx-get="{{ url_for('get_workout_modal', person_id=person['PersonId'], workout_id=w['WorkoutId']) }}"
|
|
hx-target='body' hx-swap='beforeend' class="cursor-pointer">
|
|
<td class="p-4 whitespace-nowrap text-sm font-normal text-gray-500">
|
|
{{ strftime(w['StartDate'], "%b %d %Y") }}
|
|
</td>
|
|
|
|
{% for e in exercise_list %}
|
|
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
|
{% set topset_exercise =
|
|
get_first_element_from_list_with_matching_attribute(w['TopSets'],
|
|
'ExerciseId',
|
|
e['ExerciseId']) %}
|
|
{% if topset_exercise %}
|
|
{{ topset_exercise['Repetitions'] }} x {{ topset_exercise['Weight'] }}kg
|
|
{% endif %}
|
|
</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
</table>
|
|
{% endif %}
|
|
|
|
{% if person['Workouts']|length == 0 %}
|
|
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3"
|
|
role="alert">
|
|
No workouts found.
|
|
</div>
|
|
{% endif %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{ render_partial('partials/stats.html', stats=person['Stats']) }}
|
|
|
|
<button
|
|
class="fixed z-90 bottom-10 right-8 bg-blue-600 w-20 h-20 rounded-full drop-shadow-lg flex justify-center items-center text-white text-4xl hover:bg-blue-700 hover:drop-shadow-2xl hover:animate-bounce duration-300"
|
|
hx-post="{{ url_for('create_workout', person_id=person['PersonId']) }}" hx-target='body' hx-swap='beforeend'>
|
|
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
|
|
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
|
|
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399
|
|
C15.952,9,16,9.447,16,10z" />
|
|
</svg>
|
|
</button> |