@@ -85,7 +86,6 @@ $(document).ready(function () {
})
.then(response => response.json())
.then(data => {
- console.log(data);
renderMyProjects(data.ownedProjects.projects);
renderSharedProjects(data.sharedProjects);
addRiskDonut(data.ownedProjects.riskCounts);
@@ -105,7 +105,7 @@ function renderMyProjects(data) {
width: '12%',
render: function(data, type, row) {
if (data == "done") {
- return "Complete";
+ return 'Complete
';
}
if (data == "inProgress") {
return "In Progress";
@@ -152,7 +152,12 @@ function renderMyProjects(data) {
$('#myProjectsTable').on('click', '.editBtn', function () {
var id = $(this).data('id');
- window.location.href = '/project/' + id;
+ window.location.href = '/project/' + id + "/projectDetails";
+ });
+
+ $('#myProjectsTable').on('click', '.viewOutput', function () {
+ var id = $(this).data('id');
+ window.location.href = '/project/' + id + "/";
});
$('#myProjectsTable').on('click', '.deleteBtn', function () {
@@ -234,102 +239,8 @@ function renderSharedProjects(data) {
$('#sharedProjectsTable').on('click', '.editBtn', function () {
var id = $(this).data('id');
- window.location.href = '/project/' + id;
- });
-}
-
-function addRiskDonut(riskCounts) {
- const ctx = document.getElementById('riskChart').getContext('2d');
- new Chart(ctx, {
- type: 'doughnut',
- data: {
- labels: Object.keys(riskCounts),
- datasets: [{
- label: 'Risk count',
- data: Object.values(riskCounts),
- backgroundColor: [
- 'rgba(200, 200, 200, 0.5)',
- 'rgba(255, 99, 132, 0.5)',
- 'rgba(255, 206, 86, 0.5)',
- 'rgba(54, 162, 235, 0.5)'
-
- ],
- borderColor: [
- 'rgba(200, 200, 200, 1)',
- 'rgba(255, 99, 132, 1)',
- 'rgba(255, 206, 86, 1)',
- 'rgba(54, 162, 235, 1)'
- ],
- borderWidth: 1
- }]
- },
- options: {
- aspectRatio: 2,
- responsive: true,
- plugins: {
- legend: {
- position: 'right',
- },
- title: {
- display: false,
- text: 'Risk Counts'
- }
- }
- }
+ window.location.href = '/project/' + id + "/projectDetails";
});
}
-function addAverages(averageScores) {
- const likelihoodBar = document.getElementById('likelihood-bar');
- likelihoodBar.style.width = (averageScores.likelihood / 3 * 100) + '%';
- likelihoodBar.innerText = averageScores.likelihood;
- likelihoodBar.style.backgroundColor = getColorForScore(averageScores.likelihood);
-
- const impactBar = document.getElementById('impact-bar');
- impactBar.style.width = (averageScores.impact / 3 * 100) + '%';
- impactBar.innerText = averageScores.impact;
- impactBar.style.backgroundColor = getColorForScore(averageScores.impact);
-
- const riskBar = document.getElementById('risk-bar');
- riskBar.style.width = (averageScores.riskScore / 9 * 100) + '%';
- riskBar.innerText = averageScores.riskScore;
- riskBar.style.backgroundColor = getColorForScore(averageScores.riskScore / 3);
-}
-
-function addTopRisks(topRisks) {
- const tableBody = document.getElementById('topRisksTableBody');
- tableBody.innerHTML = ''; // Clear existing rows
-
- topRisks.forEach(risk => {
- const row = tableBody.insertRow();
- const scoreText = getScoreText(risk.score/3);
- const scoreColor = getColorForScore(risk.score/3);
-
- row.innerHTML = `
-
${risk.consequence} |
-
${scoreText} |
-
View |
- `;
- });
-}
-
-function getScoreText(score) {
- if (score < 1) {
- return 'Low';
- } else if (score < 2) {
- return 'Medium';
- } else {
- return 'High';
- }
- }
-
-function getColorForScore(score) {
- if (score > 2) {
- return 'rgba(255, 99, 132, 0.75)';
- } else if (score >= 1 && score <= 2) {
- return 'rgba(255, 206, 86, 0.75)';
- } else {
- return 'rgba(54, 162, 235, 0.75)';
- }
-}
<%- include('../partials/footer') %>
\ No newline at end of file
diff --git a/views/pages/scan.ejs b/views/pages/scan.ejs
index c6a2739..f7e746c 100644
--- a/views/pages/scan.ejs
+++ b/views/pages/scan.ejs
@@ -213,6 +213,7 @@ function moveSubmitButton() {
}
async function sendDataToServer(inputObject) {
+ console.log(inputObject);
let url;
let method;
const form = document.getElementById("dataForm");
@@ -249,7 +250,9 @@ async function sendDataToServer(inputObject) {
if (quickNavAttributeValue === "true" && nextAttributeValue) {
quickNav(nextAttributeValue);
} else if (projectId && nextAttributeValue) {
- window.location.href = `/project/${projectId}/${nextAttributeValue}`;
+ window.location.href = `/project/${projectId}/${nextAttributeValue}`;
+ } else {
+ window.location.href = `/project/${projectId}/`;
}
} else {
console.error("Request failed with status:", response.status);
@@ -267,7 +270,7 @@ function extractDisabledFieldValues(formId) {
return;
}
- const disabledFields = form.querySelectorAll('input[disabled], select[disabled], textarea[disabled]');
+ const disabledFields = form.querySelectorAll('input.disabled, select.disabled, textarea.disabled');
if (disabledFields.length === 0) {
return;
@@ -275,10 +278,16 @@ function extractDisabledFieldValues(formId) {
disabledFields.forEach(field => {
const fieldValue = field.value;
- // Replace input field with a paragraph element containing the value
+
+ // Hide the original field
+ field.style.display = 'none';
+
+ // Create a new paragraph element to display the field value
const paragraphElement = document.createElement('p');
- paragraphElement.textContent = `${fieldValue}`;
- field.replaceWith(paragraphElement);
+ paragraphElement.textContent = fieldValue;
+
+ // Insert the new paragraph element after the original field
+ field.parentNode.insertBefore(paragraphElement, field.nextSibling);
});
}
diff --git a/views/partials/header.ejs b/views/partials/header.ejs
index d13ea4d..1208736 100644
--- a/views/partials/header.ejs
+++ b/views/partials/header.ejs
@@ -54,6 +54,7 @@
<% }); %>
+
Final report
<% } %>