-
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.
Por enquanto só funciona Login; Falta implementar para as demais ações
- Loading branch information
Showing
3 changed files
with
72 additions
and
41 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use classes\DatabaseConnection; | ||
|
||
require_once '../vendor/autoload.php'; | ||
|
||
function createDatabaseConnection() | ||
{ | ||
// global $client; // Usar o cliente de telemetria global | ||
try { | ||
$db = new DatabaseConnection(); | ||
$conn = $db->getConnection(); | ||
// echo"<script>console.log('ok')</script>"; | ||
|
||
return $conn; | ||
|
||
} catch (PDOException $e) { | ||
// $client->trackException($e); | ||
error_log("Error connecting to SQL Server: " . $e->getMessage()); | ||
die("Error connecting to SQL Server."); | ||
} | ||
} | ||
|
||
function getLogs() | ||
{ | ||
$conn = createDatabaseConnection(); | ||
$query = "SELECT * FROM Userlogs"; | ||
$stms = $conn->query($query); | ||
$stms->execute(); | ||
|
||
$results = $stms->fetchAll(PDO::FETCH_ASSOC); | ||
return $results; | ||
} | ||
|
||
if ($_SERVER['REQUEST_METHOD'] == 'GET') { | ||
// echo"<script>console.log('ok')</script>"; | ||
$responseArray = getLogs(); | ||
|
||
echo json_encode($responseArray); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Variáveis | ||
const logTableBody = document.getElementById('logTableBody'); | ||
|
||
// Event Listeners | ||
document.addEventListener('DOMContentLoaded', () => { | ||
buscaLogs(); | ||
}) | ||
|
||
|
||
const buscaLogs = async () => { | ||
const response = await fetch('../controllers/getLogs.php', { | ||
method: 'GET', | ||
}); | ||
|
||
|
||
if (!response.ok) | ||
throw new Error("Error"); | ||
|
||
const data = await response.json(); | ||
data.reverse(); | ||
|
||
data.forEach((item)=>{ | ||
var row = logTableBody.insertRow(); | ||
row.insertCell().textContent = item.log_date; | ||
row.insertCell().textContent = item.user_id; | ||
row.insertCell().textContent = item.action; | ||
row.insertCell().textContent = item.details; | ||
}); | ||
|
||
} |
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