Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial testing of submitting bug through chrome index tool - User Story 2 #60

Open
wants to merge 1 commit into
base: sprint2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/controllers/admin/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ exports.submitBug = async (req, res) => {
}

try {
const bug = { title, description, dateSubmitted: new Date().toISOString() };
const bug = { title, description, submittedBy: req.uid, dateSubmitted: new Date().toISOString() };
bugArchive.push(bug);
res.status(200).json({ message: 'Bug submitted successfully' });
} catch (error) {
Expand All @@ -416,6 +416,8 @@ exports.submitBug = async (req, res) => {
// Get Bug Archive Handler
exports.getBugArchive = async (req, res) => {
console.log('im hereeeeeeeeeeee');
console.log(bugArchive); // Log the bug archive before sending it
// res.json(bugArchive);
try {
// Render the 'bug-archive' template with the in-memory bug data
res.render('admin/dashboard/bug-archive', {
Expand Down
35 changes: 16 additions & 19 deletions src/views/admin/dashboard/bug-archive.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,22 @@

function fetchBugArchive() {
console.log('Fetching bug archive...');
fetch('/api/admin/dashboard/bug-archive')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
bugArchiveBody.innerHTML = '';
if (data.archive && data.archive.length > 0) {
data.archive.forEach(bug => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${bug.title}</td>
<td>${bug.description}</td>
<td>${bug.submittedBy}</td>
<td>${bug.dateSubmitted}</td>
`;
bugArchiveBody.appendChild(row);
fetch('/api/admin/get-bug-archive') // Adjust endpoint as necessary
.then(response => response.json())
.then(data => {
const bugArchiveBody = document.getElementById('bug-archive-body');
bugArchiveBody.innerHTML = ''; // Clear existing data

if (data.archive && data.archive.length > 0) {
data.archive.forEach(bug => {
const row = document.createElement('tr');
row.innerHTML = `
<td>${validator.escape(bug.title)}</td>
<td>${validator.escape(bug.description)}</td>
<td>${bug.submittedBy || 'Unknown'}</td> <!-- Display submittedBy -->
<td>${new Date(bug.dateSubmitted).toLocaleString()}</td>
`;
bugArchiveBody.appendChild(row)
});
} else {
const row = document.createElement('tr');
Expand Down