forked from CMU-17313Q/cmu-17313q-f24-nodebb-f24-NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Latifa Al-Hitmi
authored and
Latifa Al-Hitmi
committed
Oct 19, 2024
1 parent
fcdfdbe
commit 795a0b5
Showing
1 changed file
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,59 @@ | ||
'use strict'; | ||
|
||
define('admin/dashboard/bug-logs', ['jquery', 'api'], ($, api) => { | ||
const BugLogs = {}; | ||
|
||
BugLogs.init = () => { | ||
// Fetch and display bug logs | ||
fetchBugLogs(); | ||
|
||
// Handle bug report submission | ||
$('#submit-bug-report').on('click', submitBugReport); | ||
}; | ||
|
||
function fetchBugLogs() { | ||
api.get('/api/admin/get-bug-log') | ||
.then((data) => { | ||
const bugLogsContainer = $('#bug-logs-container'); | ||
bugLogsContainer.empty(); | ||
|
||
if (data.bugLogs && data.bugLogs.length > 0) { | ||
data.bugLogs.forEach((log) => { | ||
const logElement = $('<div>').addClass('bug-log'); | ||
logElement.append($('<p>').text(`User: ${log.user}`)); | ||
logElement.append($('<p>').text(`Description: ${log.description}`)); | ||
logElement.append($('<p>').text(`Timestamp: ${log.timestamp}`)); | ||
bugLogsContainer.append(logElement); | ||
}); | ||
} else { | ||
bugLogsContainer.append($('<p>').text('No bug logs found.')); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error('Error fetching bug logs:', err); | ||
$('#bug-logs-container').append($('<p>').text('Error fetching bug logs.')); | ||
}); | ||
} | ||
|
||
function submitBugReport() { | ||
const description = $('#bug-report-description').val().trim(); | ||
|
||
if (!description) { | ||
alert('Description is required'); | ||
return; | ||
} | ||
|
||
api.post('/api/admin/submit-bug-report', { description }) | ||
.then(() => { | ||
alert('Bug report submitted successfully'); | ||
$('#bug-report-description').val(''); | ||
fetchBugLogs(); | ||
}) | ||
.catch((err) => { | ||
console.error('Error submitting bug report:', err); | ||
alert('Error submitting bug report'); | ||
}); | ||
} | ||
|
||
return BugLogs; | ||
}); | ||
const BugLogs = {}; | ||
|
||
BugLogs.init = () => { | ||
// Fetch and display bug logs | ||
fetchBugLogs(); | ||
|
||
// Handle bug report submission | ||
$('#submit-bug-report').on('click', submitBugReport); | ||
}; | ||
|
||
function fetchBugLogs() { | ||
api.get('/api/admin/get-bug-log') | ||
.then((data) => { | ||
const bugLogsContainer = $('#bug-logs-container'); | ||
bugLogsContainer.empty(); | ||
|
||
if (data.bugLogs && data.bugLogs.length > 0) { | ||
data.bugLogs.forEach((log) => { | ||
const logElement = $('<div>').addClass('bug-log'); | ||
logElement.append($('<p>').text(`User: ${log.user}`)); | ||
logElement.append($('<p>').text(`Description: ${log.description}`)); | ||
logElement.append($('<p>').text(`Timestamp: ${log.timestamp}`)); | ||
bugLogsContainer.append(logElement); | ||
}); | ||
} else { | ||
bugLogsContainer.append($('<p>').text('No bug logs found.')); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error('Error fetching bug logs:', err); | ||
$('#bug-logs-container').append($('<p>').text('Error fetching bug logs.')); | ||
}); | ||
} | ||
|
||
function submitBugReport() { | ||
const description = $('#bug-report-description').val().trim(); | ||
|
||
if (!description) { | ||
alert('Description is required'); | ||
return; | ||
} | ||
|
||
api.post('/api/admin/submit-bug-report', { description }) | ||
.then(() => { | ||
alert('Bug report submitted successfully'); | ||
$('#bug-report-description').val(''); | ||
fetchBugLogs(); | ||
}) | ||
.catch((err) => { | ||
console.error('Error submitting bug report:', err); | ||
alert('Error submitting bug report'); | ||
}); | ||
} | ||
|
||
return BugLogs; | ||
}); |