+
diff --git a/osinaweb/osinacore/urls.py b/osinaweb/osinacore/urls.py
index b16e43e1..0774d537 100644
--- a/osinaweb/osinacore/urls.py
+++ b/osinaweb/osinacore/urls.py
@@ -81,6 +81,7 @@ urlpatterns = [
path('recent-activities-page/', views.recent_activities_page, name='recentactivitiespage'),
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'),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py
index bd56454c..01148f64 100644
--- a/osinaweb/osinacore/views.py
+++ b/osinaweb/osinacore/views.py
@@ -868,7 +868,7 @@ def reset_password(request, uidb64, token):
-def fetch_projects_by_status(request, status):
+def fetch_projects_by_status(request, status=None):
user = request.user
if user.is_superuser:
@@ -881,12 +881,15 @@ def fetch_projects_by_status(request, status):
).distinct().order_by('-project_id')
# Fetch projects with their last status as "In Progress"
- filtered_projects = []
- for project in projects:
- last_status = ProjectStatus.objects.filter(project = project).last()
- if last_status.status == status:
- filtered_projects.append(project)
-
+ if status:
+ filtered_projects = []
+ for project in projects:
+ last_status = ProjectStatus.objects.filter(project = project).last()
+ if last_status.status == status:
+ filtered_projects.append(project)
+ else:
+ filtered_projects = projects
+
for project in projects:
total_time_seconds = 0
open_user_tasks_count = 0
diff --git a/osinaweb/static/images/before.png b/osinaweb/static/images/before.png
new file mode 100644
index 00000000..99ec1e30
Binary files /dev/null and b/osinaweb/static/images/before.png differ
diff --git a/osinaweb/static/js/calculate-all-projects-time.js b/osinaweb/static/js/calculate-all-projects-time.js
index 0b6d8d9b..8bbc13fe 100644
--- a/osinaweb/static/js/calculate-all-projects-time.js
+++ b/osinaweb/static/js/calculate-all-projects-time.js
@@ -23,17 +23,23 @@ function calculateProgress(startDate, endDate, progressBar) {
}
}
-const projectContainers = document.querySelectorAll(".projectContainer");
+function updateAllProjectProgress() {
+ const projectContainers = document.querySelectorAll(".projectContainer");
-// Loop through each project container
-projectContainers.forEach(projectContainer => {
- const startDateElement = projectContainer.querySelector(".startDate");
- const endDateElement = projectContainer.querySelector(".endDate");
+ // Loop through each project container
+ projectContainers.forEach(projectContainer => {
+ const startDateElement = projectContainer.querySelector(".startDate");
+ const endDateElement = projectContainer.querySelector(".endDate");
- const progressBar = projectContainer.querySelector(".progressBar");
+ const progressBar = projectContainer.querySelector(".progressBar");
- const startDate = new Date(startDateElement.textContent);
- const endDate = new Date(endDateElement.textContent);
+ const startDate = new Date(startDateElement.textContent);
+ const endDate = new Date(endDateElement.textContent);
- calculateProgress(startDate, endDate, progressBar);
-});
+ calculateProgress(startDate, endDate, progressBar);
+ });
+}
+
+
+updateAllProjectProgress();
+export { updateAllProjectProgress };
\ No newline at end of file
diff --git a/osinaweb/static/js/pop-modals.js b/osinaweb/static/js/pop-modals.js
index 4a53e1b2..db791de6 100644
--- a/osinaweb/static/js/pop-modals.js
+++ b/osinaweb/static/js/pop-modals.js
@@ -1,26 +1,30 @@
-document.addEventListener("DOMContentLoaded", function () {
- // Function to open a modal with dimensions
+function initializeModalButtons() {
+ // OPEN THE MODAL WITH DIMENSIONS
function openModalWithDimensions(url, width, height) {
const modalUrl = url;
openModal(modalUrl);
+ console.log('hii4');
const iframe = document.getElementById("popupModalFrame");
iframe.style.height = height;
iframe.style.width = width;
}
- // Function to open a modal
+ // OPEN MODAL
function openModal(url) {
const modalContainer = document.getElementById("popUpModal");
const iframe = document.getElementById("popupModalFrame");
const body = document.body;
body.style.overflow = "hidden";
+ console.log('hii1');
iframe.src = url;
+ console.log('hii2')
modalContainer.style.display = "flex";
+ console.log('hii3')
}
- // Function to close the modal
+ // CLOSE MODAL
function closeModal() {
const modalContainer = document.getElementById("popUpModal");
const iframe = document.getElementById("popupModalFrame");
@@ -38,11 +42,11 @@ document.addEventListener("DOMContentLoaded", function () {
button.addEventListener("click", () => {
const modalUrl = button.getAttribute("data-modal-url");
openModalWithDimensions(modalUrl, width, height);
+ console.log('hii5')
});
});
}
- // Add button click listeners with dimensions for specific class names
addButtonClickListener("addStatusButton", "450px", "200px");
addButtonClickListener("addNoteButton", "400px", "225px");
addButtonClickListener("addProjectNoteButton", "400px", "225px");
@@ -75,10 +79,6 @@ document.addEventListener("DOMContentLoaded", function () {
addButtonClickListener("editProjectStatusButton", "400px", "220px");
addButtonClickListener("editCustomerStatusButton", "400px", "160px");
addButtonClickListener("addProjectMemberModal", "400px", "230px");
-
-
-
-
// DELETE BUTTONS
addButtonClickListener("deleteCustomerButton", "400px", "140px");
@@ -92,10 +92,6 @@ document.addEventListener("DOMContentLoaded", function () {
addButtonClickListener("deleteTicketButton", "400px", "140px");
addButtonClickListener("deletePaymentButton", "400px", "140px");
addButtonClickListener("deletePaymentMethodButton", "400px", "140px");
-
-
-
-
const closeButton = document.getElementById("closeModalButton");
closeButton.addEventListener("click", () => {
@@ -108,4 +104,9 @@ document.addEventListener("DOMContentLoaded", function () {
closeModal();
}
});
-});
+}
+
+
+initializeModalButtons();
+export { initializeModalButtons };
+
diff --git a/osinaweb/static/js/projects-filtering.js b/osinaweb/static/js/projects-filtering.js
index d9988451..0b8246df 100644
--- a/osinaweb/static/js/projects-filtering.js
+++ b/osinaweb/static/js/projects-filtering.js
@@ -1,10 +1,12 @@
+import { initializeModalButtons } from '../js/pop-modals.js';
+import { updateAllProjectProgress } from '../js/calculate-all-projects-time.js';
+
document.addEventListener('DOMContentLoaded', function () {
const inProgressProjectsContainer = document.getElementById('inProgressProjectsContainer');
const projectsByStatusContainer = document.getElementById('projectsByStatusContainer');
const allProjectsContainer = document.getElementById('allProjectsContainer');
const projectLoader = document.getElementById('projectLoader');
-
- var statusesSelectTag = document.getElementById('statusesSelectTag');
+ const statusesSelectTag = document.getElementById('statusesSelectTag');
statusesSelectTag.addEventListener('change', function () {
var selectedStatus = statusesSelectTag.value;
@@ -14,17 +16,20 @@ document.addEventListener('DOMContentLoaded', function () {
projectsByStatusContainer.classList.add('hidden');
allProjectsContainer.classList.add('hidden');
- // Check if "All" is selected
if (selectedStatus === 'All') {
- allProjectsContainer.classList.remove('hidden');
- projectLoader.classList.add('hidden');
+ fetch('/all-projects/')
+ .then(response => response.text())
+ .then(data => {
+ projectsByStatusContainer.classList.remove('hidden');
+ $(projectsByStatusContainer).html(data);
+ projectLoader.classList.add('hidden');
+ initializeModalButtons();
+ updateAllProjectProgress();
+ })
+ .catch(error => console.error('Error:', error));
- // Check if "In Progress" is selected
- } else if (selectedStatus === 'In Progress') {
- inProgressProjectsContainer.classList.remove('hidden');
- projectsByStatusContainer.classList.add('hidden');
projectLoader.classList.add('hidden');
- allProjectsContainer.classList.add('hidden');
+
} else {
fetch('/projects/status/' + selectedStatus + '/')
.then(response => response.text())
@@ -32,8 +37,10 @@ document.addEventListener('DOMContentLoaded', function () {
projectsByStatusContainer.classList.remove('hidden');
$(projectsByStatusContainer).html(data);
projectLoader.classList.add('hidden');
+ initializeModalButtons();
+ updateAllProjectProgress();
})
.catch(error => console.error('Error:', error));
}
});
-});
\ No newline at end of file
+});