New changes.

main
nataly 2 years ago
parent 1824ee9a26
commit 7178e55391

Binary file not shown.

@ -9,6 +9,9 @@ from django.urls import reverse
from django.http import HttpResponse
from django.db.models import Q
from django.http import JsonResponse
from .models import Task, Epic
# Pages views
@ -59,18 +62,24 @@ def home(request, *args, **kwargs):
working_on_task_count = Task.objects.filter(assigned_to=request.user.staffprofile, status='Working On').count()
total_tasks = open_task_count + working_on_task_count
# Initialize last_note_color with a default color
last_note_color = 'black'
# Fetch the color of the last recent note
if recent_note:
last_note_color = recent_note.color
context = {
'notes': notes,
'recent_note': recent_note,
'tasks': tasks,
'total_tasks' :total_tasks,
'last_note_color': last_note_color,
}
return render(request, 'index.html', context)
@login_required
def my_projects(request, *args, **kwargs):
user = request.user
@ -355,10 +364,6 @@ def update_status_modal(request, *args, **kwargs):
#Save Functions
@login_required
def save_note(request):
@ -525,6 +530,26 @@ def save_task(request):
return redirect(redirect_url)
def fetch_related_tasks(request):
# Get the selected epic ID from the request
epic_id = request.GET.get("epic_id")
# Fetch tasks related to the selected epic along with their project
related_tasks = Task.objects.filter(epic_id=epic_id).select_related("project")
task_data = [
{
"name": task.name,
"status": task.status,
"start_date": task.formatted_start_date(),
"end_date": task.formatted_end_date(),
"extra": task.extra,
}
for task in related_tasks
]
return JsonResponse({"tasks": task_data})
@login_required
def save_business(request):

@ -43,6 +43,8 @@ urlpatterns = [
path('createtaskepic/', views.createtask_epic, name='createtaskepic'),
path('taskdetails/<str:task_id>/', views.detailed_task, name='detailed-task'),
path("fetch_related_tasks/", views.fetch_related_tasks, name="fetch_related_tasks"),
# Modals urls
path('addstatus/', views.add_status_modal, name='addstatus'),

@ -646,6 +646,15 @@ video {
position: relative;
}
.inset-x-0 {
left: 0px;
right: 0px;
}
.bottom-0 {
bottom: 0px;
}
.right-0 {
right: 0px;
}
@ -783,6 +792,10 @@ video {
height: 100px;
}
.h-\[13px\] {
height: 13px;
}
.h-\[150px\] {
height: 150px;
}
@ -795,10 +808,6 @@ video {
height: 2px;
}
.h-\[300px\] {
height: 300px;
}
.h-\[30px\] {
height: 30px;
}
@ -860,6 +869,10 @@ video {
width: 120px;
}
.w-\[13px\] {
width: 13px;
}
.w-\[14\%\] {
width: 14%;
}
@ -988,10 +1001,6 @@ video {
width: 60px;
}
.w-\[70px\] {
width: 70px;
}
.w-\[74\.5\%\] {
width: 74.5%;
}
@ -1000,10 +1009,6 @@ video {
width: 80%;
}
.w-\[90px\] {
width: 90px;
}
.w-\[95\%\] {
width: 95%;
}
@ -1171,6 +1176,10 @@ video {
border-bottom-left-radius: 0.375rem;
}
.rounded-bl-xl {
border-bottom-left-radius: 0.75rem;
}
.rounded-br-md {
border-bottom-right-radius: 0.375rem;
}
@ -1702,6 +1711,12 @@ video {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.shadow-sm {
--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.shadow-xl {
--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);

@ -7,7 +7,12 @@
<div class="w-full flex justify-between items-center">
<div>
<p class="text-base text-gray-500">Recent Note:</p>
<p class="text-slate-700">{{recent_note.text}}</p>
<div class="flex justify-start items-center gap-2">
<div class="w-[13px] h-[13px] bg-red-200 rounded-full" style="background-color: {{ last_note_color }};">
</div>
<p class="text-slate-700">{{recent_note.text}}</p>
</div>
</div>
<div class="flex justify-end items-center gap-4">
<button
@ -27,7 +32,7 @@
id="notesContainer">
{% for note in notes %}
<div class="w-[16.33%] h-[150px] shadow-xl p-5" style="background-color: {{note.color}}">
<div class="w-[16.33%] h-[150px] shadow-sm p-5 rounded-bl-xl" style="background-color: {{note.color}}">
<p class="text-base text-slate-800">{{note.text}}</p>
</div>
{% endfor %}
@ -86,13 +91,13 @@
</div>
{% endif %}
<div class="w-[15%] flex justify-center items-center border-r border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.status}}</p>
<p class="text-slate-700">{{task.status}}</p>
</div>
<div class="w-[15%] flex justify-center items-center border-r border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.formatted_start_date}}</p>
<p class="text-slate-700">{{task.formatted_start_date}}</p>
</div>
<div class="w-[15%] flex justify-center items-center border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.formatted_end_date}}</p>
<p class="text-slate-700">{{task.formatted_end_date}}</p>
</div>
</div>

@ -154,9 +154,8 @@
</div>
<!-- Footer -->
<div class="w-full h-fit bg-slate-800 flex flex-col items-center justify-center gap-2 py-2">
<div class="w-[300px] h-fit bg-slate-800 flex flex-col items-center justify-center gap-2 py-2 fixed bottom-0 inset-x-0">
<div class="w-full flex flex-col justify-center items-center">
<!-- <img src="{% static 'images/footer-logo.png' %}" alt="Ositcom Web Development in Lebanon" class="w-[90px] h-[50px]"> -->
<p class="text-gray-500 font-light text-sm">Powered By Ositcom</p>
<p class="text-gray-500 font-light text-sm">Copyrights © 2023 All Rights Reserved</p>
</div>

@ -181,7 +181,7 @@
<p class="text-gray-500 text-xl">Project Details:</p>
<div class="w-full px-8">
<p class="text-gray-500">
{{project.details}}
{{project.details}}
</p>
</div>
</div>
@ -311,21 +311,24 @@
<div class="w-full mt-5">
<div class="w-full bg-slate-300 rounded-md shadow-md h-fit p-5 flex justify-between items-center">
<div>
<form method="GET" action="{% url 'detailed-project' project.project_id %}">
<select id="epicSelect" name="epic_id"
class="w-[250px] rounded-md border border-gray-300 p-3 outline-none text-gray-500 cursor-pointer">
<option selected disabled>EPICS</option>
{% for epic in epics %}
<option value="{{ epic.id }}" data-start-date="{{ epic.start_date }}" data-end-date="{{ epic.end_date }}">{{epic.title}}</option>
{% endfor %}
</select>
</form>
<form method="POST" action="{% url 'save_task' %}">
<select id="epicSelect" name="epic_id"
class="w-[250px] rounded-md border border-gray-300 p-3 outline-none text-gray-500 cursor-pointer">
<option selected disabled>EPICS</option>
{% for epic in epics %}
<option value="{{ epic.id }}" data-start-date="{{ epic.start_date }}"
data-end-date="{{ epic.end_date }}">{{epic.title}}</option>
{% endfor %}
</select>
</form>
</div>
<div class="w-full flex justify-end gap-[3%] pl-5">
<div class="w-[50%] justify-start items-center gap-2 hidden" id="epicDetails">
<p class="text-gray-500 font-light">Start Date: <span id="startDate" class="text-slate-800"></span>
<p class="text-gray-500 font-light">Start Date: <span id="startDate"
class="text-slate-800"></span>
</p>
<p class="text-gray-500 font-light">End Date: <span id="endDate" class="text-slate-800"></span>
<p class="text-gray-500 font-light">End Date: <span id="endDate"
class="text-slate-800"></span>
</p>
</div>
<div class="w-[50%] flex justify-end items-center gap-2">
@ -368,109 +371,140 @@
</div>
<div class="w-full px-4 hidden" id="epicRelatedTasks">
<div class="w-full p-3 bg-white rounded-md shadow-lg">
<p class="text-gray-500 text-xl">Related Tasks:</p>
<!-- TASK 1 -->
{% for task in related_tasks %}
<div class="w-full bg-white h-fit rounded-md border border-gray-300 mt-3">
<!-- TABLE HEADER -->
<div class="w-full flex h-[70px] rounded-t-md">
<div
class="w-[55%] flex justify-center items-center border-r border-b border-gray-300 bg-green-700 rounded-tl-md">
<p class="text-xl text-white">{{task.name}}</p>
</div>
<div class="w-[15%] flex justify-center items-center border-r border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.status}}</p>
</div>
<div class="w-[15%] flex justify-center items-center border-r border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.start_date}}</p>
</div>
<div class="w-[15%] flex justify-center items-center border-b border-gray-300">
<p class="text-xl text-slate-700">{{task.end_date}}</p>
</div>
</div>
<!-- TABLE BODY -->
<div class="w-full h-fit flex">
<!-- LEFT SIDE OF TABLE BODY -->
<div class="w-[55%] h-fit bg-white p-3 rounded-bl-md">
<!-- 1st row -->
<div class="w-full flex flex-col gap-2">
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Project:</p>
<p class="text-slate-700 text-base">Osina Project</p>
</div>
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Epic:</p>
<p class="text-slate-700 text-base">epic</p>
</div>
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Assigned To:</p>
<p class="text-slate-700 text-base">Nataly</p>
</div>
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Files:</p>
<p class="text-slate-700 text-base">Documentation.pdf, Project.doc
</p>
</div>
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Tags:</p>
<p class="text-slate-700 text-base">Live Streaming, Media Streaming
</p>
</div>
<div class="flex justify-start items-center gap-2">
<p class="text-gray-400 text-base">Extra:</p>
<p class="text-slate-700 text-base">Yes</p>
</div>
</div>
</div>
<!-- RIGHT SIDE OF TABLE BODY -->
<div class="w-[45%] h-fit bg-white flex flex-wrap justify-start rounded-br-md">
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Close</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500"
id="updateStatusButton">Update
Status</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500"
id="addTimeButton">Add
Time</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-red-500 text-white"
id="deleteTaskButton">Delete</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-blue-500 text-white">Update</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500"
id="showPointsButton">Show
Points</button>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500"
id="addPointButton">Add
Point</button>
<a href="./task-details.html" class="w-[33.33%]">
<button
class="w-full p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Details</button>
</a>
<button
class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500 rounded-br-md"
id="timelineButton">Timline</button>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
var epicSelect = document.getElementById("epicSelect");
var epicRelatedTasks = document.getElementById("epicRelatedTasks");
epicSelect.addEventListener("change", function () {
// Get the selected option element
var selectedOption = epicSelect.options[epicSelect.selectedIndex];
// Check if an option other than the default "EPICS" is selected
if (selectedOption.value !== "") {
// Get the data attributes (start-date and end-date) from the selected option
var startDate = selectedOption.getAttribute("data-start-date");
var endDate = selectedOption.getAttribute("data-end-date");
// Fetch related tasks based on the selected epic ID
fetchTasks(selectedOption.value, startDate, endDate);
} else {
// Hide the related tasks container when the default "EPICS" option is selected
epicRelatedTasks.style.display = "none";
}
});
// Function to fetch and display related tasks
function fetchTasks(epicId, startDate, endDate) {
// Send an AJAX request to fetch related tasks
fetch("/fetch_related_tasks/?epic_id=" + epicId)
.then(function (response) {
return response.json();
})
.then(function (data) {
// Build the HTML for the related tasks
var tasksHtml = buildTasksHtml(data.tasks);
// Update the content of the epicRelatedTasks container with the fetched tasks
epicRelatedTasks.innerHTML = tasksHtml;
epicRelatedTasks.style.display = "block";
})
.catch(function (error) {
console.error("Error fetching tasks:", error);
});
}
// Function to build the HTML for related tasks
function buildTasksHtml(tasks) {
// Initialize the HTML with the table header
var html = '<p class="text-gray-500 text-xl">Related Tasks: </p>';
html += '<div class="w-full bg-white h-fit rounded-md border border-gray-300 mt-3 flex flex-col gap-4 p-3">';
// Build HTML for each task
tasks.forEach(function (task) {
// TABLE HEADER
html += '<div class="w-full h-fit border border gray-300 rounded-t-md">';
html += '<div class="w-full flex h-[70px] rounded-t-md border-b border-gray-300">';
if (task.status == 'Open') {
html += '<div class="w-[55%] flex justify-center items-center border-r border-gray-300 bg-green-700 rounded-tl-md">';
} else if (task.status == 'Working On') {
html += '<div class="w-[55%] flex justify-center items-center border-r border-gray-300 bg-yellow-400 rounded-tl-md">';
} else {
html += '<div class="w-[55%] flex justify-center items-center border-r border-gray-300">';
}
html += '<p class="text-xl text-white">' + task.name + '</p>';
html += '</div>';
html += '<div class="w-[15%] flex justify-center items-center border-r border-gray-300">';
html += '<p class="text-slate-700">' + task.status + '</p>';
html += '</div>';
html += '<div class="w-[15%] flex justify-center items-center border-r border-gray-300">';
html += '<p class="text-slate-700">' + task.start_date + '</p>';
html += '</div>';
html += '<div class="w-[15%] flex justify-center items-center border-gray-300">';
html += '<p class="text-slate-700">' + task.end_date + '</p>';
html += '</div>';
html += '</div>';
// TABLE BODY
html += '<div class="w-full h-fit flex">';
// Left side of the table
html += '<div class="w-[55%] h-fit bg-white p-3 rounded-bl-md">';
html += '<div class="w-full flex flex-col gap-2">';
html += '<div class="flex justify-start items-center gap-2">';
html += '<p class="text-gray-400 text-base"> Assigned To:</p>';
html += '<p class="text-slate-800 text-base"> nataly </p>';
html += '</div>';
html += '<div class="flex justify-start items-center gap-2">';
html += '<p class="text-gray-400 text-base">Files:</p>';
html += '<p class="text-slate-800 text-base"> pdf, docx </p>';
html += '</div>';
html += '<div class="flex justify-start items-center gap-2">';
html += '<p class="text-gray-400 text-base">Tags:</p>';
html += '<p class="text-slate-800 text-base"> tasg test </p>';
html += '</div>';
html += '<div class="flex justify-start items-center gap-2">';
html += '<p class="text-gray-400 text-base">Extra:</p>';
html += '<p class="text-slate-800 text-base">' + task.extra + '</p>';
html += '</div>';
html += '</div>';
html += '</div>';
// Right Side
html += '<div class="w-[45%] h-fit bg-white flex flex-wrap justify-start rounded-br-md">';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Close</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Update Status</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Add Time</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-red-500 text-white">Delete</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-blue-500 text-white">Update</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Show Points</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Add Point</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500">Details</button>';
html += '<button class="w-[33.33%] p-2 border border-gray-200 text-base h-[70px] bg-gray-300 text-gray-500 rounded-br-md">Timelines</button>';
html += '</div>';
html += '</div>';
html += '</div>';
});
html += '</div>';
return html;
}
});
</script>
<div class="mt-10 flex flex-col justify-center items-center w-full">
<p class="text-xl text-gray-500">Total Extra Task Time : <span class="text-slate-800 font-semibold">46
hrs and 50 min</span></p>

Loading…
Cancel
Save