Compare commits
13 Commits
9d33377ac1
...
dev
Author | SHA1 | Date | |
---|---|---|---|
da9be74050 | |||
7d3f13657f
|
|||
0be774531c
|
|||
756b51309a
|
|||
cef66f2bd4
|
|||
2aa80e094a
|
|||
57231c0d34 | |||
842d0ff11e
|
|||
87005efcf5
|
|||
7f845dcb1d
|
|||
9e2566ba03
|
|||
af938f405d | |||
c090b611e2
|
@ -17,7 +17,7 @@ from dotenv import load_dotenv
|
|||||||
# 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
|
||||||
|
|
||||||
APP_VERSION = "0.1.0"
|
APP_VERSION = "0.1.4"
|
||||||
|
|
||||||
load_dotenv(BASE_DIR / ".env")
|
load_dotenv(BASE_DIR / ".env")
|
||||||
|
|
||||||
|
19
dispatcher/migrations/0011_alter_project_parent.py
Normal file
19
dispatcher/migrations/0011_alter_project_parent.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.1.5 on 2025-04-23 20:09
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('dispatcher', '0010_realsagexhours_unique_monthly_sagex'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='project',
|
||||||
|
name='parent',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='dispatcher.parent'),
|
||||||
|
),
|
||||||
|
]
|
@ -15,7 +15,8 @@ class Project(models.Model):
|
|||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
Parent,
|
Parent,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
null=True
|
null=True,
|
||||||
|
blank=True
|
||||||
)
|
)
|
||||||
name = models.CharField(max_length=256)
|
name = models.CharField(max_length=256)
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
:root {
|
||||||
|
--invalid-col: #f1232394;
|
||||||
|
}
|
||||||
|
|
||||||
#table {
|
#table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
@ -49,6 +53,11 @@
|
|||||||
border-top: solid #71717185 1px;
|
border-top: solid #71717185 1px;
|
||||||
td {
|
td {
|
||||||
padding: 0.4em;
|
padding: 0.4em;
|
||||||
|
font-style: italic;
|
||||||
|
&.invalid {
|
||||||
|
background-color: var(--invalid-col);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +94,17 @@
|
|||||||
border-bottom: var(--border);
|
border-bottom: var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.day-totals {
|
||||||
|
td {
|
||||||
|
text-align: right;
|
||||||
|
font-style: italic;
|
||||||
|
&.invalid {
|
||||||
|
background-color: var(--invalid-col);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
col.day-5, col.day-6 {
|
col.day-5, col.day-6 {
|
||||||
background-color: var(--dark3);
|
background-color: var(--dark3);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ class Table {
|
|||||||
this.weekNames = elmt.querySelector(".week-names")
|
this.weekNames = elmt.querySelector(".week-names")
|
||||||
this.dayNames = elmt.querySelector(".day-names")
|
this.dayNames = elmt.querySelector(".day-names")
|
||||||
this.dayDates = elmt.querySelector(".day-dates")
|
this.dayDates = elmt.querySelector(".day-dates")
|
||||||
|
this.dayTotals = elmt.querySelector(".day-totals")
|
||||||
this.columns = elmt.querySelector(".columns")
|
this.columns = elmt.querySelector(".columns")
|
||||||
|
|
||||||
this.timeInputTemplate = getTemplate("time-input")
|
this.timeInputTemplate = getTemplate("time-input")
|
||||||
@ -22,6 +23,7 @@ class Table {
|
|||||||
this.endDate = today
|
this.endDate = today
|
||||||
|
|
||||||
this.totalProjects = 0
|
this.totalProjects = 0
|
||||||
|
this.dailyTotals = []
|
||||||
this.clockingTotals = []
|
this.clockingTotals = []
|
||||||
this.clockingRemotes = []
|
this.clockingRemotes = []
|
||||||
|
|
||||||
@ -67,6 +69,7 @@ class Table {
|
|||||||
this.weekNames.querySelectorAll("td").forEach(c => c.remove())
|
this.weekNames.querySelectorAll("td").forEach(c => c.remove())
|
||||||
this.dayNames.querySelectorAll("td").forEach(c => c.remove())
|
this.dayNames.querySelectorAll("td").forEach(c => c.remove())
|
||||||
this.dayDates.innerHTML = ""
|
this.dayDates.innerHTML = ""
|
||||||
|
this.dayTotals.querySelectorAll("td").forEach(c => c.remove())
|
||||||
this.times.querySelectorAll("tr.project").forEach(r => r.remove())
|
this.times.querySelectorAll("tr.project").forEach(r => r.remove())
|
||||||
this.nDays = 0
|
this.nDays = 0
|
||||||
}
|
}
|
||||||
@ -112,6 +115,7 @@ class Table {
|
|||||||
this.addClockings(date)
|
this.addClockings(date)
|
||||||
let dayName = this.dayNames.insertCell(this.nDays + 2)
|
let dayName = this.dayNames.insertCell(this.nDays + 2)
|
||||||
let dayDate = this.dayDates.insertCell(this.nDays)
|
let dayDate = this.dayDates.insertCell(this.nDays)
|
||||||
|
this.dayTotals.insertCell(this.nDays + 1)
|
||||||
let weekDay = (date.getDay() + 6) % 7
|
let weekDay = (date.getDay() + 6) % 7
|
||||||
dayName.innerText = DAYS_SHORT[weekDay]
|
dayName.innerText = DAYS_SHORT[weekDay]
|
||||||
dayDate.innerText = `${dayPadded}/${monthPadded}`
|
dayDate.innerText = `${dayPadded}/${monthPadded}`
|
||||||
@ -211,25 +215,33 @@ class Table {
|
|||||||
displayData(data) {
|
displayData(data) {
|
||||||
this.displayClockings(data.clockings)
|
this.displayClockings(data.clockings)
|
||||||
this.totalProjects = 0
|
this.totalProjects = 0
|
||||||
|
this.dailyTotals = Array(this.nDays).fill(0)
|
||||||
data.parents.forEach(parent => {
|
data.parents.forEach(parent => {
|
||||||
let parentDurations = Array(this.nDays).fill(0)
|
let parentDurations = Array(this.nDays).fill(0)
|
||||||
|
|
||||||
let projects = parent.projects.map(project => {
|
let projects = parent.projects.map(project => {
|
||||||
let durations = Array(this.nDays).fill("")
|
let durations = Array(this.nDays).fill("")
|
||||||
|
let total = 0
|
||||||
project.tasks.forEach(task => {
|
project.tasks.forEach(task => {
|
||||||
let date = new Date(task.date)
|
let date = new Date(task.date)
|
||||||
let i = Math.floor((date.valueOf() - this.startDate.valueOf()) / DAY_MS)
|
let i = Math.floor((date.valueOf() - this.startDate.valueOf()) / DAY_MS)
|
||||||
let hours = task.duration / 60
|
let hours = task.duration / 60
|
||||||
durations[i] = hours
|
durations[i] = hours
|
||||||
|
total += hours
|
||||||
parentDurations[i] += hours
|
parentDurations[i] += hours
|
||||||
|
if (parent.is_productive) {
|
||||||
|
this.dailyTotals[i] += hours
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
id: project.id,
|
id: project.id,
|
||||||
name: project.name,
|
name: project.name,
|
||||||
durations: durations
|
durations: durations,
|
||||||
|
total: total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (parentDurations.reduce((a, b) => a + b, 0) !== 0) {
|
||||||
this.addProject(
|
this.addProject(
|
||||||
parent.id,
|
parent.id,
|
||||||
parent.name,
|
parent.name,
|
||||||
@ -239,9 +251,10 @@ class Table {
|
|||||||
parent.is_productive
|
parent.is_productive
|
||||||
)
|
)
|
||||||
|
|
||||||
projects.forEach(project => {
|
projects.filter(p => p.total !== 0).forEach(project => {
|
||||||
this.addProject(project.id, project.name, "", project.durations)
|
this.addProject(project.id, project.name, "", project.durations)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.updateTotals()
|
this.updateTotals()
|
||||||
}
|
}
|
||||||
@ -334,6 +347,24 @@ class Table {
|
|||||||
let sagexTime = imputedTimeRatio * totalClockings
|
let sagexTime = imputedTimeRatio * totalClockings
|
||||||
parent.cells[this.nDays + 5].innerText = Math.round(sagexTime * 100) / 100
|
parent.cells[this.nDays + 5].innerText = Math.round(sagexTime * 100) / 100
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for (let i = 0; i < this.nDays; i++) {
|
||||||
|
let total = this.dailyTotals[i]
|
||||||
|
let cell = this.dayTotals.cells[i + 1]
|
||||||
|
if (total === 0) {
|
||||||
|
cell.innerText = ""
|
||||||
|
} else {
|
||||||
|
cell.innerText = Math.round(total * 100) / 100
|
||||||
|
}
|
||||||
|
let clocking = this.clockings.querySelector(".clocking.total").cells[i + 1]
|
||||||
|
if (total > this.clockingTotals[i]) {
|
||||||
|
clocking.classList.add("invalid")
|
||||||
|
cell.classList.add("invalid")
|
||||||
|
} else {
|
||||||
|
clocking.classList.remove("invalid")
|
||||||
|
cell.classList.remove("invalid")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post(endpoint, data) {
|
post(endpoint, data) {
|
||||||
|
@ -267,6 +267,7 @@ def set_clocking(request, date: datetime.date):
|
|||||||
clocking.out_pm = request.POST.get("out_pm", clocking.out_pm) or None
|
clocking.out_pm = request.POST.get("out_pm", clocking.out_pm) or None
|
||||||
remote = request.POST.get("remote", clocking.remote) or None
|
remote = request.POST.get("remote", clocking.remote) or None
|
||||||
if remote is not None:
|
if remote is not None:
|
||||||
|
if isinstance(remote, str):
|
||||||
remote = str_to_timedelta(remote)
|
remote = str_to_timedelta(remote)
|
||||||
else:
|
else:
|
||||||
remote = timedelta()
|
remote = timedelta()
|
||||||
|
@ -63,6 +63,9 @@
|
|||||||
<th rowspan="2">N° sagex</th>
|
<th rowspan="2">N° sagex</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="day-dates"></tr>
|
<tr class="day-dates"></tr>
|
||||||
|
<tr class="day-totals">
|
||||||
|
<th colspan="2">Total Productive</th>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
Reference in New Issue
Block a user