Add a button to start session from game overview
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Fix #62
This commit is contained in:
parent
518c0ecd56
commit
a5b2854bf6
|
@ -1,3 +1,8 @@
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
* Add a button to start session from game overview
|
||||||
|
|
||||||
## 1.1.2 / 2023-10-13 16:30+02:00
|
## 1.1.2 / 2023-10-13 16:30+02:00
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
|
@ -799,6 +799,10 @@ select {
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ml-1 {
|
||||||
|
margin-left: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
.ml-2 {
|
.ml-2 {
|
||||||
margin-left: 0.5rem;
|
margin-left: 0.5rem;
|
||||||
}
|
}
|
||||||
|
@ -811,14 +815,6 @@ select {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ml-8 {
|
|
||||||
margin-left: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ml-1 {
|
|
||||||
margin-left: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block {
|
.block {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
@ -839,10 +835,6 @@ select {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.h-6 {
|
|
||||||
height: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.h-4 {
|
.h-4 {
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
}
|
}
|
||||||
|
@ -851,26 +843,30 @@ select {
|
||||||
height: 1.25rem;
|
height: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h-6 {
|
||||||
|
height: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.min-h-screen {
|
.min-h-screen {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.w-6 {
|
|
||||||
width: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-full {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-5 {
|
.w-5 {
|
||||||
width: 1.25rem;
|
width: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.w-6 {
|
||||||
|
width: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.w-7 {
|
.w-7 {
|
||||||
width: 1.75rem;
|
width: 1.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.w-full {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.max-w-screen-lg {
|
.max-w-screen-lg {
|
||||||
max-width: 1024px;
|
max-width: 1024px;
|
||||||
}
|
}
|
||||||
|
@ -893,6 +889,10 @@ select {
|
||||||
animation: spin 1s linear infinite;
|
animation: spin 1s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-row {
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
.flex-col {
|
.flex-col {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
@ -905,6 +905,10 @@ select {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.items-baseline {
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
|
||||||
.justify-center {
|
.justify-center {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
@ -913,6 +917,10 @@ select {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gap-2 {
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.self-center {
|
.self-center {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
@ -935,6 +943,10 @@ select {
|
||||||
border-radius: 0.5rem;
|
border-radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rounded-sm {
|
||||||
|
border-radius: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
.border-gray-200 {
|
.border-gray-200 {
|
||||||
--tw-border-opacity: 1;
|
--tw-border-opacity: 1;
|
||||||
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
||||||
|
@ -950,21 +962,16 @@ select {
|
||||||
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.bg-white {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-blue-600 {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-violet-600 {
|
.bg-violet-600 {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(124 58 237 / var(--tw-bg-opacity));
|
background-color: rgb(124 58 237 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bg-white {
|
||||||
|
--tw-bg-opacity: 1;
|
||||||
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
||||||
|
}
|
||||||
|
|
||||||
.p-4 {
|
.p-4 {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
@ -992,10 +999,6 @@ select {
|
||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pl-8 {
|
|
||||||
padding-left: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.text-center {
|
.text-center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -1034,6 +1037,11 @@ select {
|
||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-sm {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
line-height: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
.font-semibold {
|
.font-semibold {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
@ -1282,11 +1290,6 @@ th label {
|
||||||
background-color: rgb(21 128 61 / var(--tw-bg-opacity));
|
background-color: rgb(21 128 61 / var(--tw-bg-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover\:bg-blue-700:hover {
|
|
||||||
--tw-bg-opacity: 1;
|
|
||||||
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.hover\:bg-violet-700:hover {
|
.hover\:bg-violet-700:hover {
|
||||||
--tw-bg-opacity: 1;
|
--tw-bg-opacity: 1;
|
||||||
background-color: rgb(109 40 217 / var(--tw-bg-opacity));
|
background-color: rgb(109 40 217 / var(--tw-bg-opacity));
|
||||||
|
@ -1312,11 +1315,6 @@ th label {
|
||||||
--tw-ring-color: rgb(34 197 94 / var(--tw-ring-opacity));
|
--tw-ring-color: rgb(34 197 94 / var(--tw-ring-opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
.focus\:ring-blue-500:focus {
|
|
||||||
--tw-ring-opacity: 1;
|
|
||||||
--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity));
|
|
||||||
}
|
|
||||||
|
|
||||||
.focus\:ring-violet-500:focus {
|
.focus\:ring-violet-500:focus {
|
||||||
--tw-ring-opacity: 1;
|
--tw-ring-opacity: 1;
|
||||||
--tw-ring-color: rgb(139 92 246 / var(--tw-ring-opacity));
|
--tw-ring-color: rgb(139 92 246 / var(--tw-ring-opacity));
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
<button
|
{% comment %}
|
||||||
type="button"
|
title
|
||||||
|
text
|
||||||
|
{% endcomment %}
|
||||||
|
<a
|
||||||
|
href="{{ link }}"
|
||||||
title="{{ title }}"
|
title="{{ title }}"
|
||||||
autofocus
|
class="truncate max-w-xs py-1 px-2 text-xs bg-green-600 hover:bg-green-700 focus:ring-green-500 focus:ring-offset-blue-200 text-white transition ease-in duration-200 text-center font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-sm"
|
||||||
class="truncate max-w-xs sm:max-w-md lg:max-w-lg py-1 px-2 bg-green-600 hover:bg-green-700 focus:ring-green-500 focus:ring-offset-blue-200 text-white transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg"
|
|
||||||
>
|
>
|
||||||
<svg
|
{% comment %} <svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="none"
|
fill="none"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
|
@ -18,5 +21,6 @@
|
||||||
d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z"
|
d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
{% endcomment %}
|
||||||
{{ text }}
|
{{ text }}
|
||||||
</button>
|
</a>
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% comment %}
|
||||||
|
title
|
||||||
|
text
|
||||||
|
{% endcomment %}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
title="{{ title }}"
|
||||||
|
autofocus
|
||||||
|
class="truncate max-w-xs sm:max-w-md lg:max-w-lg py-1 px-2 bg-green-600 hover:bg-green-700 focus:ring-green-500 focus:ring-offset-blue-200 text-white transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="self-center w-6 h-6 inline"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
{{ text }}
|
||||||
|
</button>
|
|
@ -10,8 +10,8 @@
|
||||||
<div class="mx-auto text-center my-4">
|
<div class="mx-auto text-center my-4">
|
||||||
<a
|
<a
|
||||||
id="last-session-start"
|
id="last-session-start"
|
||||||
href="{% url 'start_session' last.id %}"
|
href="{% url 'start_session_same_as_last' last.id %}"
|
||||||
hx-get="{% url 'start_session' last.id %}"
|
hx-get="{% url 'start_session_same_as_last' last.id %}"
|
||||||
hx-indicator="#indicator"
|
hx-indicator="#indicator"
|
||||||
hx-swap="afterbegin"
|
hx-swap="afterbegin"
|
||||||
hx-target=".responsive-table tbody"
|
hx-target=".responsive-table tbody"
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
onClick="document.querySelector('#last-session-start').classList.add('invisible')"
|
onClick="document.querySelector('#last-session-start').classList.add('invisible')"
|
||||||
class="{% if last.timestamp_end == null %}invisible{% endif %}"
|
class="{% if last.timestamp_end == null %}invisible{% endif %}"
|
||||||
>
|
>
|
||||||
{% include 'components/button.html' with text=last.purchase title="Start session of last played game" only %}
|
{% include 'components/button_start.html' with text=last.purchase title="Start session of last played game" only %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -47,7 +47,14 @@
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<h1 class="text-3xl mt-4 mb-1">Sessions <span class="dark:text-slate-500">({{ sessions.count }})</span></h1>
|
<h1 class="text-3xl mt-4 mb-1 flex gap-2 items-center">
|
||||||
|
Sessions
|
||||||
|
<span class="dark:text-slate-500">
|
||||||
|
({{ sessions.count }})
|
||||||
|
</span>
|
||||||
|
{% url 'start_game_session' game.id as add_session_link %}
|
||||||
|
{% include 'components/button.html' with title="Start new session" text="New" link=add_session_link %}
|
||||||
|
</h1>
|
||||||
<ul>
|
<ul>
|
||||||
{% for session in sessions %}
|
{% for session in sessions %}
|
||||||
<li class="sm:pl-2 flex items-center">
|
<li class="sm:pl-2 flex items-center">
|
||||||
|
|
|
@ -19,9 +19,14 @@ urlpatterns = [
|
||||||
name="update_session",
|
name="update_session",
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"start-session/<int:last_session_id>",
|
"start-session-same-as-last/<int:last_session_id>",
|
||||||
views.start_session,
|
views.start_session_same_as_last,
|
||||||
name="start_session",
|
name="start_session_same_as_last",
|
||||||
|
),
|
||||||
|
path(
|
||||||
|
"start-session/<int:game_id>",
|
||||||
|
views.start_game_session,
|
||||||
|
name="start_game_session",
|
||||||
),
|
),
|
||||||
# path(
|
# path(
|
||||||
# "delete_session/by-id/<int:session_id>",
|
# "delete_session/by-id/<int:session_id>",
|
||||||
|
|
|
@ -140,7 +140,24 @@ def edit_edition(request, edition_id=None):
|
||||||
return render(request, "add.html", context)
|
return render(request, "add.html", context)
|
||||||
|
|
||||||
|
|
||||||
def start_session(request, last_session_id: int):
|
def start_game_session(request, game_id: int):
|
||||||
|
last_session = (
|
||||||
|
Session.objects.filter(purchase__edition__game_id=game_id)
|
||||||
|
.order_by("-timestamp_start")
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
session = SessionForm(
|
||||||
|
{
|
||||||
|
"purchase": last_session.purchase.id,
|
||||||
|
"timestamp_start": now_with_tz(),
|
||||||
|
"device": last_session.device,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
session.save()
|
||||||
|
return redirect("list_sessions")
|
||||||
|
|
||||||
|
|
||||||
|
def start_session_same_as_last(request, last_session_id: int):
|
||||||
last_session = Session.objects.get(id=last_session_id)
|
last_session = Session.objects.get(id=last_session_id)
|
||||||
session = SessionForm(
|
session = SessionForm(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue