Skip to content

Commit

Permalink
Active Timers List view
Browse files Browse the repository at this point in the history
  • Loading branch information
Fingolfin7 committed Jun 14, 2024
1 parent d0733b9 commit 3e734a0
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ Web based tine and project tracking software based on Autumn.

Work in Progress Screenshot:

## Projects Page
![image](https://github.com/Fingolfin7/AutumnWeb/assets/63872314/d04be761-f826-4346-a207-bded54d3db60)

## Timers Page
17 changes: 17 additions & 0 deletions core/migrations/0007_alter_projects_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2 on 2024-06-13 23:44

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0006_alter_sessions_start_time'),
]

operations = [
migrations.AlterModelOptions(
name='projects',
options={'ordering': ['name'], 'verbose_name_plural': 'Projects'},
),
]
17 changes: 17 additions & 0 deletions core/migrations/0008_alter_sessions_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2 on 2024-06-14 00:04

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0007_alter_projects_options'),
]

operations = [
migrations.AlterModelOptions(
name='sessions',
options={'ordering': ['-end_time'], 'verbose_name_plural': 'Sessions'},
),
]
8 changes: 7 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime, time
from django.db import models
from django.utils import timezone


status_choices = (
Expand All @@ -17,8 +18,10 @@ class Projects(models.Model):
total_time = models.FloatField(default=0.0)
status = models.CharField(max_length=25, choices=status_choices, default='active')


class Meta:
verbose_name_plural = 'Projects'
ordering = ['name']

def __str__(self):
return self.name
Expand Down Expand Up @@ -66,6 +69,7 @@ class Sessions(models.Model):

class Meta:
verbose_name_plural = 'Sessions'
ordering = ['-end_time']

def __str__(self):
sub_list = [sub.name for sub in self.subprojects.all()]
Expand All @@ -77,8 +81,10 @@ def duration(self):
Return the duration of the session in minutes or None if the session is still active
:return:
"""
if self.end_time is None:
if self.end_time is None and not self.is_active:
return None
elif self.is_active:
return (timezone.make_aware(datetime.now()) - self.start_time).total_seconds() / 60.0
else:
return (self.end_time - self.start_time).total_seconds() / 60.0

Expand Down
16 changes: 15 additions & 1 deletion core/static/core/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ body.dark-mode {
margin: 0;
}

.plain-link {
text-decoration: none;
color: inherit;
}

.ribbon {
padding: 2%;
display: flex;
Expand All @@ -57,6 +62,7 @@ body.dark-mode {
color: var(--light-background);
}


.ribbon-buttons{
display: flex;
align-items: center;
Expand Down Expand Up @@ -122,6 +128,10 @@ body.dark-mode .main-link {
background-color: var(--primary-color);
}

.timer-button:hover a, .primary-button:hover a {
background-color: var(--primary-color);
}

.secondary-button {
background-color: var(--secondary-accent-color);
border: none;
Expand Down Expand Up @@ -168,6 +178,7 @@ body.dark-mode .main-link {
margin-left: 16%;
padding: 2%;
border-left: var(--section-border-width) solid #ccc;
/*min-height: calc(100vh - 90px);*/
}

.card {
Expand Down Expand Up @@ -198,9 +209,12 @@ body.dark-mode .main-link {
}

.grid-rows > * {
margin: 1rem 0;
margin: 0.5rem 0;
}

.timer-row{
border-spacing: 1rem 0;
}


body.dark-mode .card {
Expand Down
6 changes: 4 additions & 2 deletions core/templates/core/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<body>
<div class="container">
<div class="ribbon"> <!-- ribbon at the top of the page -->
<h1 class="main-title">Autumn</h1>
<h1 class="main-title">
<a href="{% url 'home' %}" class="plain-link">Autumn</a>
</h1>
<div class="ribbon-buttons">
<i class="fas fa-bars burger-menu" id="burger-menu"></i> <!-- Added burger menu icon -->
<label class="switch">
Expand Down Expand Up @@ -61,7 +63,7 @@ <h1 class="main-title">Autumn</h1>

<nav class="left-panel">
<a href="{% url 'projects' %}" class="main-link"><i class="fas fa-project-diagram"></i> Manage Projects</a>
<a href="#" class="main-link"><i class="fas fa-clock"></i> Timers</a>
<a href="{% url 'timers' %}" class="main-link"><i class="fas fa-clock"></i> Timers</a>
<a href="#" class="main-link"><i class="fas fa-book"></i> Session Logs</a>
<a href="#" class="main-link"><i class="fas fa-chart-bar"></i> Charts</a>
<a href="#" class="main-link"><i class="fas fa-cog"></i> Settings</a>
Expand Down
36 changes: 36 additions & 0 deletions core/templates/core/start_timer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends 'core/base.html' %}
{% load static %}
{% load time_formats %}
{% block content %}
<div id="search-projects">
<input type="text" id="search-projects-input" placeholder="Search projects...">
<div id="search-projects-results">
{% for project in projects %}
<span class="card">
<a href="#" class="plain-link">
<i class="fa fa-select"></i>
{{ project.name }}
</a>
</span>
{% endfor %}
</div>
</div>

<div class="sub-projects">
{% for sub in project.subprojects.all %}
<span class="card">
<a href="#" class="plain-link">
<i class="fa fa-select"></i>
{{ sub.name }}
</a>
</span>
{% endfor %}
</div>

<button type="submit" id="start-timer" class="timer-button">
<a href="#" class="plain-link">
<i class="fa fa-hourglass-start"></i>
Start Timer
</a>
</button>
{% endblock %}
50 changes: 50 additions & 0 deletions core/templates/core/timers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{% extends 'core/base.html' %}
{% load static %}
{% load time_formats %}
{% block content %}
<button id="start-timer" class="timer-button">
<a href="#" class="plain-link">
<i class="fa fa-plus"></i>
New Timer
</a>
</button>
<div id="active-timers">
{% for timer in timers %}
<div class="card" id="timer-{{ timer.id }}">
<table class="timer-row">
<tr>
<td>
[{{ forloop.counter0 }}]: Started
</td>
<td class="text-red">
{{ timer.project.name }}
</td>
<td >
[
{% for subproject in timer.subprojects.all %}
'<span class="text-cyan">{{ subproject.name }}</span>'{% if not forloop.last %}, {% endif %}
{% endfor %}
]
</td>
<td class="text-green">
{{ timer.duration|min_formatter }} ago
</td>
<td>
<button class="timer-button">
<a href="#" class="plain-link">
<i class="fa fa-check"></i>
</a>
</button>
<button class="timer-button">
<a href="#" class="plain-link">
<i class="fa fa-trash"></i>
</a>
</button>
</td>

</tr>
</table>
</div>
{% endfor %}
</div>
{% endblock %}
3 changes: 2 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

urlpatterns = [
# path('start_timer', views.start_timer, name='start_timer'),
path('', home),
path('', home, name='home'),
path('projects/', ProjectsListView.as_view(), name='projects'),
path('timers/', TimerListView.as_view(), name='timers'),

# api paths
path('api/create_project/', create_project, name='create_project'),
Expand Down
15 changes: 14 additions & 1 deletion core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,20 @@ def get_queryset(self):
return Projects.objects.all()


# class ProjectUpdateView(UpdateView):
class TimerListView(ListView):
model = Sessions
template_name = 'core/timers.html'
context_object_name = 'timers'
ordering = ['-start_time']

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = 'Timers'

return context

def get_queryset(self):
return Sessions.objects.filter(is_active=True)



Expand Down

0 comments on commit 3e734a0

Please sign in to comment.