Compare commits
2 Commits
main
...
feat/balan
Author | SHA1 | Date | |
---|---|---|---|
64d9bbbad2 | |||
9156142c04 |
12
.idea/dataSources.xml
generated
12
.idea/dataSources.xml
generated
@ -1,20 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="db" uuid="77a8092c-4d7c-43f6-806c-af3a9c288eeb">
|
||||
<data-source source="LOCAL" name="Django default" uuid="5554f55f-0dda-4059-8562-7321c41658f9">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<imported>true</imported>
|
||||
<remarks>$PROJECT_DIR$/TimeDispatcher/settings.py</remarks>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db.sqlite3</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
<libraries>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.45.1/org/xerial/sqlite-jdbc/3.45.1.0/sqlite-jdbc-3.45.1.0.jar</url>
|
||||
</library>
|
||||
<library>
|
||||
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.45.1/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar</url>
|
||||
</library>
|
||||
</libraries>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
2
.idea/discord.xml
generated
2
.idea/discord.xml
generated
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="ASK" />
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
<option name="applicationTheme" value="default" />
|
||||
<option name="iconsTheme" value="default" />
|
||||
|
6
.idea/httpClient.xml
generated
Normal file
6
.idea/httpClient.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="HttpClientEndpointsTabState">
|
||||
<option name="requestToText" value="<CachedHttpClientTabRequests> <entry key="da376d1083f024ef0956ab871581b6fa09ce0fda" value="###&#10;POST http://localhost:8000/projects/{{id}}/set_parent/" /> </CachedHttpClientTabRequests>" />
|
||||
</component>
|
||||
</project>
|
99
.idea/icon.svg
generated
Normal file
99
.idea/icon.svg
generated
Normal file
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="64"
|
||||
height="64"
|
||||
viewBox="0 0 64 64"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="logo.svg"
|
||||
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="true"
|
||||
inkscape:zoom="11.559708"
|
||||
inkscape:cx="31.012894"
|
||||
inkscape:cy="41.047749"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1">
|
||||
<inkscape:grid
|
||||
id="grid1"
|
||||
units="px"
|
||||
originx="0"
|
||||
originy="0"
|
||||
spacingx="1"
|
||||
spacingy="1"
|
||||
empcolor="#0099e5"
|
||||
empopacity="0.30196078"
|
||||
color="#0099e5"
|
||||
opacity="0.14901961"
|
||||
empspacing="8"
|
||||
enabled="true"
|
||||
visible="true" />
|
||||
</sodipodi:namedview>
|
||||
<defs
|
||||
id="defs1">
|
||||
<inkscape:path-effect
|
||||
effect="fillet_chamfer"
|
||||
id="path-effect3"
|
||||
is_visible="true"
|
||||
lpeversion="1"
|
||||
nodesatellites_param="F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,0,1,0,2,0,1 @ F,0,1,1,0,2,0,1 @ F,0,1,1,0,2,0,1"
|
||||
radius="0"
|
||||
unit="px"
|
||||
method="auto"
|
||||
mode="F"
|
||||
chamfer_steps="1"
|
||||
flexible="false"
|
||||
use_knot_distance="true"
|
||||
apply_no_radius="true"
|
||||
apply_with_radius="true"
|
||||
only_selected="false"
|
||||
hide_knots="false" />
|
||||
</defs>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g4">
|
||||
<path
|
||||
style="fill:#69c935;fill-opacity:1;stroke-width:6;stroke-linecap:square;stroke:none"
|
||||
d="m 8,10 v 4 a 2,2 45 0 0 2,2 h 7 a 2,2 45 0 1 2,2 v 36 a 2,2 45 0 0 2,2 h 4 a 2,2 135 0 0 2,-2 V 18 a 2,2 135 0 1 2,-2 h 7 a 2,2 135 0 0 2,-2 V 10 A 2,2 45 0 0 36,8 H 10 a 2,2 135 0 0 -2,2 z"
|
||||
id="path1"
|
||||
sodipodi:nodetypes="ccccccccc"
|
||||
inkscape:path-effect="#path-effect3"
|
||||
inkscape:original-d="m 8,8 v 8 h 11 v 40 h 8 V 16 H 38 V 8 Z" />
|
||||
<g
|
||||
id="g3"
|
||||
style="stroke:#61ba31;stroke-opacity:1;fill:none">
|
||||
<path
|
||||
id="path2"
|
||||
style="fill:none;stroke:#61ba31;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 44.834929,13.274537 C 51.52452,17.296808 56,24.625752 56,33 56,45.702549 45.702549,56 33,56"
|
||||
sodipodi:nodetypes="csc" />
|
||||
<path
|
||||
style="fill:none;stroke:#61ba31;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 44,47 33,33 38,26"
|
||||
id="path3" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.2 KiB |
3
TimeDispatcher/config.py
Normal file
3
TimeDispatcher/config.py
Normal file
@ -0,0 +1,3 @@
|
||||
class Config:
|
||||
# Number of hours in an off-day
|
||||
WORKING_HOURS_PER_OFF_DAY = 8.2
|
@ -1,3 +1,4 @@
|
||||
from TimeDispatcher.config import Config
|
||||
from TimeDispatcher.settings import APP_VERSION, DEBUG
|
||||
|
||||
|
||||
@ -16,4 +17,11 @@ def navbar_links(request):
|
||||
{'view': 'parents', 'label': 'Parents'},
|
||||
{'view': 'import', 'label': 'Import'},
|
||||
]
|
||||
}
|
||||
|
||||
def app_config(request):
|
||||
return {
|
||||
"config": {
|
||||
"WORKING_HOURS_PER_OFF_DAY": Config.WORKING_HOURS_PER_OFF_DAY
|
||||
}
|
||||
}
|
@ -17,9 +17,9 @@ from dotenv import load_dotenv
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
APP_VERSION = "0.1.3"
|
||||
APP_VERSION = "0.1.0"
|
||||
|
||||
load_dotenv(BASE_DIR / ".env")
|
||||
load_dotenv(BASE_DIR / ".env", override=True)
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
|
||||
@ -68,8 +68,9 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'context_processors.version',
|
||||
'context_processors.navbar_links'
|
||||
'TimeDispatcher.context_processors.app_config',
|
||||
'TimeDispatcher.context_processors.version',
|
||||
'TimeDispatcher.context_processors.navbar_links'
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -1,6 +1,16 @@
|
||||
from django.apps import AppConfig
|
||||
from django.utils.autoreload import autoreload_started
|
||||
|
||||
from TimeDispatcher.settings import BASE_DIR
|
||||
|
||||
|
||||
def watchdog(sender, **kwargs):
|
||||
sender.watch_dir(BASE_DIR, ".env")
|
||||
|
||||
|
||||
class DispatcherConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'dispatcher'
|
||||
|
||||
def ready(self):
|
||||
autoreload_started.connect(watchdog)
|
||||
|
@ -53,3 +53,20 @@ class RealSageXHours(models.Model):
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["parent", "date"], name="unique_monthly_sagex")
|
||||
]
|
||||
|
||||
|
||||
class FullTimeMonthlyHours(models.Model):
|
||||
date = models.DateField(unique=True)
|
||||
hours = models.DurationField(default=timedelta)
|
||||
|
||||
|
||||
class EmploymentRate:
|
||||
rate = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
start_date = models.DateField()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=["start_date"])
|
||||
]
|
||||
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
:root {
|
||||
--invalid-col: #f1232394;
|
||||
}
|
||||
|
||||
#table {
|
||||
border-collapse: collapse;
|
||||
font-size: 80%;
|
||||
@ -53,11 +49,6 @@
|
||||
border-top: solid #71717185 1px;
|
||||
td {
|
||||
padding: 0.4em;
|
||||
font-style: italic;
|
||||
&.invalid {
|
||||
background-color: var(--invalid-col);
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,17 +85,6 @@
|
||||
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 {
|
||||
background-color: var(--dark3);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ class Table {
|
||||
this.weekNames = elmt.querySelector(".week-names")
|
||||
this.dayNames = elmt.querySelector(".day-names")
|
||||
this.dayDates = elmt.querySelector(".day-dates")
|
||||
this.dayTotals = elmt.querySelector(".day-totals")
|
||||
this.columns = elmt.querySelector(".columns")
|
||||
|
||||
this.timeInputTemplate = getTemplate("time-input")
|
||||
@ -23,7 +22,6 @@ class Table {
|
||||
this.endDate = today
|
||||
|
||||
this.totalProjects = 0
|
||||
this.dailyTotals = []
|
||||
this.clockingTotals = []
|
||||
this.clockingRemotes = []
|
||||
|
||||
@ -69,7 +67,6 @@ class Table {
|
||||
this.weekNames.querySelectorAll("td").forEach(c => c.remove())
|
||||
this.dayNames.querySelectorAll("td").forEach(c => c.remove())
|
||||
this.dayDates.innerHTML = ""
|
||||
this.dayTotals.querySelectorAll("td").forEach(c => c.remove())
|
||||
this.times.querySelectorAll("tr.project").forEach(r => r.remove())
|
||||
this.nDays = 0
|
||||
}
|
||||
@ -115,7 +112,6 @@ class Table {
|
||||
this.addClockings(date)
|
||||
let dayName = this.dayNames.insertCell(this.nDays + 2)
|
||||
let dayDate = this.dayDates.insertCell(this.nDays)
|
||||
this.dayTotals.insertCell(this.nDays + 1)
|
||||
let weekDay = (date.getDay() + 6) % 7
|
||||
dayName.innerText = DAYS_SHORT[weekDay]
|
||||
dayDate.innerText = `${dayPadded}/${monthPadded}`
|
||||
@ -215,46 +211,37 @@ class Table {
|
||||
displayData(data) {
|
||||
this.displayClockings(data.clockings)
|
||||
this.totalProjects = 0
|
||||
this.dailyTotals = Array(this.nDays).fill(0)
|
||||
data.parents.forEach(parent => {
|
||||
let parentDurations = Array(this.nDays).fill(0)
|
||||
|
||||
let projects = parent.projects.map(project => {
|
||||
let durations = Array(this.nDays).fill("")
|
||||
let total = 0
|
||||
project.tasks.forEach(task => {
|
||||
let date = new Date(task.date)
|
||||
let i = Math.floor((date.valueOf() - this.startDate.valueOf()) / DAY_MS)
|
||||
let hours = task.duration / 60
|
||||
durations[i] = hours
|
||||
total += hours
|
||||
parentDurations[i] += hours
|
||||
if (parent.is_productive) {
|
||||
this.dailyTotals[i] += hours
|
||||
}
|
||||
})
|
||||
return {
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
durations: durations,
|
||||
total: total
|
||||
durations: durations
|
||||
}
|
||||
})
|
||||
|
||||
if (parentDurations.reduce((a, b) => a + b, 0) !== 0) {
|
||||
this.addProject(
|
||||
parent.id,
|
||||
parent.name,
|
||||
parent.project_num,
|
||||
parentDurations.map(v => v === 0 ? "" : v),
|
||||
true,
|
||||
parent.is_productive
|
||||
)
|
||||
this.addProject(
|
||||
parent.id,
|
||||
parent.name,
|
||||
parent.project_num,
|
||||
parentDurations.map(v => v === 0 ? "" : v),
|
||||
true,
|
||||
parent.is_productive
|
||||
)
|
||||
|
||||
projects.filter(p => p.total !== 0).forEach(project => {
|
||||
this.addProject(project.id, project.name, "", project.durations)
|
||||
})
|
||||
}
|
||||
projects.forEach(project => {
|
||||
this.addProject(project.id, project.name, "", project.durations)
|
||||
})
|
||||
})
|
||||
this.updateTotals()
|
||||
}
|
||||
@ -347,24 +334,6 @@ class Table {
|
||||
let sagexTime = imputedTimeRatio * totalClockings
|
||||
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) {
|
||||
|
@ -6,6 +6,9 @@
|
||||
<title>{% block title %}Title{% endblock %}</title>
|
||||
<link rel="shortcut icon" href="{% static "logo.svg" %}" type="image/x-svg">
|
||||
<link rel="stylesheet" href="{% static "base.css" %}">
|
||||
<script type="application/javascript">
|
||||
const Config = {{ config|safe }}
|
||||
</script>
|
||||
<script src="{% static "base.js" %}"></script>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
|
@ -63,9 +63,6 @@
|
||||
<th rowspan="2">N° sagex</th>
|
||||
</tr>
|
||||
<tr class="day-dates"></tr>
|
||||
<tr class="day-totals">
|
||||
<th colspan="2">Total Productive</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user