From a1ebd69efccdc633aaaeeb65d4b8f284fe8a001f Mon Sep 17 00:00:00 2001 From: emile Date: Wed, 14 May 2025 15:22:01 +0300 Subject: [PATCH] new --- osinaweb/db.sqlite3 | Bin 2142208 -> 2142208 bytes .../__pycache__/urls.cpython-313.pyc | Bin 6621 -> 6733 bytes .../__pycache__/views.cpython-313.pyc | Bin 39651 -> 40696 bytes .../templates/projects-dashboard.html | 117 ++++++++++++++++++ osinaweb/osinacore/urls.py | 1 + osinaweb/osinacore/views.py | 56 ++++++++- osinaweb/static/dist/output.css | 24 ++++ osinaweb/static/js/projects-dashboard.js | 61 +++++++++ 8 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 osinaweb/osinacore/templates/projects-dashboard.html create mode 100644 osinaweb/static/js/projects-dashboard.js diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index d41890e51262ed88bab77d11a288e5b65f4a12a0..ee6afeeb21b423416ad5363aea3171aac1b878d6 100644 GIT binary patch delta 456 zcmZp8(8SmP#1o_$D<{f0GgfX)c$pw#s%vPXU}$J%U}9xpre|(wWMO7D`9P9nb6H}0 zSt274GXXI(5VHU=D-g2*G5hwiM2vdGLbD=js*D9SD`OqzasFUJ-yH_K8-D?@XaV$*!b z$V4BD^umaUjQB$H>`V*aNSBJ@68}ICi!?KD|CC_ecxPQ#BLgE-T?12HBMW3#8(UhK zwQt(X0mPg@%mu{UK+FTgyga>pxRC z(<#=8T?Y&&0KrFVsmrK0- zC}Y-i)(hfSnRp*;zjHy{otyE%^n?EyWwtxq5ns+IiNhz1O>OtY+wMuU-IHv)C)IXO Ty6v7!+dbK~dveR}$zK8hl;xxd delta 276 zcmZp8(8SmP#1o_$%O=V=GnQ>kc$pw#qHAcPU}$J%Vqs-qq-S7iZfayS`9P9nb6H}0 zSt274GXXI(5VHU=D-g2*G5hwiM2?( zYPIOlSY7qZ7bPpJf4A=&F_V2m$gczPrrCu;i6jOo*1AuO0$WXVK(1amxd zIt%|Lmii0&~TyOdhaB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i3f)2Z*WR%?GPFi-=7 z_yq}VR_MT_lwgVp3^-Y%=PUV-#m(YQFCD8vCqq{`if`rZL=Gi#)~z`N9^PSL2B^>_?MRUPEWkMR!zEE4bl diff --git a/osinaweb/osinacore/__pycache__/views.cpython-313.pyc b/osinaweb/osinacore/__pycache__/views.cpython-313.pyc index 9375ab1bb35bc1df52802d434f263b442f36094b..19d2e764062f7a9e2e6639635d98659de161e62f 100644 GIT binary patch delta 1426 zcmZuwZA@EL7(VCTwznU*^!o#tvp`!cg%;UxqT6&?wgSaXcfE^AP3nbq6l5*lTTCR; zcK$FZTd*7><5yXtgJnO2kR{V($^IB)%#zj`+f!^yAfs@H2E{$$=hR)5G=c zpRRok;Vo?N!`tY=5>LGd(JB8k39{=i(G*xP~o@*&8ju% zUe1he@%shZB+D)v!i&Lc>3ZpjkCA!j8)y@i{6pzM)bbJE4 zn@5ci>9Y3`+KL<_)FDL1+<-hp&fq|ADI$h? z6uPqLMBf-K_${%PMtoBFA3w_}IYpxjGMa427YJID3{O8*uO#4-JafT@I*wXeX-+i+ zu~+eb-i(4{WUsR6b>Li8Q!~~oH3s?j`P#)G#i`|7CaI3#tlHrLr{N(_@oG*R*uNLu zIq^FjBK}Q;hwNbuf(#J782VtRy z5j0GYl?X2pWcNOe*hg@4kgBdhdnzVXHJI6@OLzdOHXs?Ts&7Q31?f$xs+Avvy&!1- zdOUB+m>cY|wa#Ar3a2iSFVl%Z7Ccq~qhl%aVWw>8EE+mX26uLNhjo@&SCMsnmJ_*Kc8`bNW8Qmr?W42&Pchq#>{Ezu$hxRX? zkksN51^1%-(gFoT6rK?Z&-mBmPd)b;S4=Jp5}*9CmzQz%=I^~n85!4t1+MgqFs`5c zvOknbgK4tE1iQ`Ky3!dL4JOO=*f5zgPW~7yHF-h}r#DkDcPNtqV;*y~ILL7z5XunD z6UuDL4B@FTX!80M&0}O>C<+CN6wL>*7J!I_AYu`SSPUYTOrAC|Oqi#L9i&PXM63h} zb1+Q)HPMJ|6^OkV>@v?u!dzQ`+*+Uw#ZM>oHBX*8DTmolGjX%zjNeS$t3fK)gNQAY n9cN2%odPm}h@rS-bL#92W)UGqAI8tj3`}AlnLx}UBcL1r%9Luc diff --git a/osinaweb/osinacore/templates/projects-dashboard.html b/osinaweb/osinacore/templates/projects-dashboard.html new file mode 100644 index 00000000..942ae031 --- /dev/null +++ b/osinaweb/osinacore/templates/projects-dashboard.html @@ -0,0 +1,117 @@ +{% extends "main.html" %} +{% load static %} +{% block content %} + + + + +
+
+

Projects Dashboard

+
+ +
+
+
+
+

From:

+ +
+
+

To:

+ +
+
+ +
+
+

Projects

+ +
+ +
+

Staff

+ +
+
+ + +
+
+ +
+ + + + + + + + + + + {% for task in tasks %} + + + + + + + {% endfor %} + +
ProjectStatusDateStaff
{{ task.project.name }}{{ task.status }}{{ task.start_date }}{{ task.assigned_to.user.first_name }} {{ task.assigned_to.user.last_name }}
+
+
+ + + +{% endblock content %} \ No newline at end of file diff --git a/osinaweb/osinacore/urls.py b/osinaweb/osinacore/urls.py index 0809ef37..20175249 100644 --- a/osinaweb/osinacore/urls.py +++ b/osinaweb/osinacore/urls.py @@ -91,6 +91,7 @@ urlpatterns = [ path('fetch_epics/', views.fetch_epics, name='fetch_epics'), path('projects/status//', views.fetch_projects_by_status, name='projects_by_status'), path('all-projects/', views.fetch_projects_by_status, name='all_projects'), + path('projects-dashboard/', views.projects_dashboard, name='projects_dashboard'), ] diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 65dfdf00..482e9dd7 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -893,10 +893,6 @@ def addressbookdetails(request, addressbook_id): @staff_login_required def prospecting_lists(request): Country.objects.get_or_create(name='Lebanon') - Group.objects.get_or_create(name='Test Group 1') - Group.objects.get_or_create(name='Test Group 2') - Group.objects.get_or_create(name='Test Group 3') - Group.objects.get_or_create(name='Test Group 4') query = request.GET.get('q', '') lists = ProspectingList.objects.all() @@ -910,3 +906,55 @@ def prospecting_lists(request): 'lists': lists, } return render(request, 'listing_pages/prospecting-lists.html', context) + + +from django.utils.dateparse import parse_date +from django.shortcuts import render + + +@staff_login_required +def projects_dashboard(request): + # Get all projects and staff for the dropdowns + all_projects = Project.objects.all() + all_staff = StaffProfile.objects.all() + + # Initialize variables + selected_project_ids = [] + selected_staff_ids = [] + start_date = None + end_date = None + + # Get filter parameters from GET request + if request.method == 'GET': + selected_project_ids = request.GET.getlist('projects', []) + selected_staff_ids = request.GET.getlist('staff', []) + start_date_str = request.GET.get('start_date', '') + end_date_str = request.GET.get('end_date', '') + + # Parse dates + start_date = parse_date(start_date_str) if start_date_str else None + end_date = parse_date(end_date_str) if end_date_str else None + + # Filter tasks based on parameters + tasks = Task.objects.all() + + if selected_project_ids: + tasks = tasks.filter(project__id__in=selected_project_ids) + + if selected_staff_ids: + tasks = tasks.filter(assigned_to__id__in=selected_staff_ids) + + if start_date and end_date: + tasks = tasks.filter(end_date__range=[start_date, end_date]) + + context = { + 'projects': all_projects, + 'staffs': all_staff, # Changed from 'staff' to match your template + 'tasks': tasks, + 'selected_projects': [int(id) for id in selected_project_ids if id], + 'selected_staff': [int(id) for id in selected_staff_ids if id], + 'start_date': start_date_str if start_date else '', + 'end_date': end_date_str if end_date else '', + } + + return render(request, "projects-dashboard.html", context) \ No newline at end of file diff --git a/osinaweb/static/dist/output.css b/osinaweb/static/dist/output.css index d8f19388..d0b91e2c 100644 --- a/osinaweb/static/dist/output.css +++ b/osinaweb/static/dist/output.css @@ -1473,6 +1473,10 @@ video { max-width: 48rem; } +.max-w-\[300px\] { + max-width: 300px; +} + .max-w-\[80\%\] { max-width: 80%; } @@ -1501,6 +1505,10 @@ video { flex-grow: 0; } +.table-auto { + table-layout: auto; +} + .border-collapse { border-collapse: collapse; } @@ -1619,6 +1627,10 @@ video { resize: both; } +.list-inside { + list-style-position: inside; +} + .list-disc { list-style-type: disc; } @@ -1753,6 +1765,10 @@ video { align-self: flex-end; } +.self-center { + align-self: center; +} + .justify-self-end { justify-self: end; } @@ -1819,6 +1835,10 @@ video { border-radius: 0px; } +.rounded-xl { + border-radius: 0.75rem; +} + .rounded-b-md { border-bottom-right-radius: 0.375rem; border-bottom-left-radius: 0.375rem; @@ -3791,6 +3811,10 @@ video { width: 480px; } + .lg\:flex-row { + flex-direction: row; + } + .lg\:text-\[48px\] { font-size: 48px; } diff --git a/osinaweb/static/js/projects-dashboard.js b/osinaweb/static/js/projects-dashboard.js new file mode 100644 index 00000000..5f643fbb --- /dev/null +++ b/osinaweb/static/js/projects-dashboard.js @@ -0,0 +1,61 @@ +document.addEventListener('DOMContentLoaded', function () { + // Initialize TomSelect for Projects + new TomSelect('#projects', { + create: false, // Disable creating new options + sortField: 'text', + onChange: function(values) { + updateTasks(); // Update tasks on value change + } + }); + + // Initialize TomSelect for Staff + new TomSelect('#staff', { + create: false, + sortField: 'text', + onChange: function(values) { + updateTasks(); // Update tasks on value change + } + }); + + // Update tasks based on filters + function updateTasks() { + const projectIds = Array.from(document.getElementById('projects').selectedOptions).map(option => option.value); + const staffIds = Array.from(document.getElementById('staff').selectedOptions).map(option => option.value); + const startDate = document.getElementById('start-date').value; + const endDate = document.getElementById('end-date').value; + + // Construct the query parameters without brackets around the projectIds + let queryParams = `?projects=${projectIds.join(',')}&staff=${staffIds.join(',')}&start_date=${startDate}&end_date=${endDate}`; + + // Perform AJAX request + fetch(`/projects-dashboard/${queryParams}`, { + method: 'GET', + headers: { + 'X-Requested-With': 'XMLHttpRequest', + }, + }) + .then(response => response.json()) + .then(data => { + // Update table body with new data + const tbody = document.getElementById('status-table-body'); + tbody.innerHTML = ''; // Clear the existing table rows + data.tasks_data.forEach(task => { + const tr = document.createElement('tr'); + tr.innerHTML = ` + ${task.project_name} + ${task.status} + ${task.start_date} + ${task.staff} + `; + tbody.appendChild(tr); + }); + }) + .catch(error => { + console.error('Error updating tasks:', error); + }); + } + + // Trigger update when date range changes + document.getElementById('start-date').addEventListener('change', updateTasks); + document.getElementById('end-date').addEventListener('change', updateTasks); + });