Skip to content

Commit

Permalink
logout - front, identa codigo e implementa layout cabeçalho, estabili…
Browse files Browse the repository at this point in the history
…za(?) thead no index.html, identa inserePub
  • Loading branch information
Ajnus committed Nov 24, 2023
1 parent 7b01447 commit af79948
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 16 deletions.
18 changes: 13 additions & 5 deletions frontend/public/cabecalho.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
<!DOCTYPE html>
<html lang="pt-BR">

<head>
<script src="javascript/autenticacao.js"></script>
<script src="javascript/constantes.js"></script>
<style>
#unlogged, #logged, #identificacao {
display: inline-block; /* Set to inline-block for horizontal alignment */
margin-right: 10px; /* Adjust the margin as needed for spacing */
#unlogged,
#logged,
#identificacao {
display: inline-block;
/* Set to inline-block for horizontal alignment */
margin-right: 10px;
/* Adjust the margin as needed for spacing */
}
</style>
</head>

<body>
<a href="/" target="_top">Home</a>
<div id="unlogged" class="visivel">
| <a href="login.html" target="_top">Login</a>
| <a href="login.html" target="_top">Login</a>
</div>
<div id="logged" class="invisivel">
| <a href="logout.html" target="_top">Logout</a>
</div>
| Você é <div id="identificacao" class="mesmaLinha">visitante</div>
<a style="color: white;">| Você é <div id="identificacao" class="mesmaLinha">visitante</div>
</a>
<hr>
</body>

</html>
2 changes: 1 addition & 1 deletion frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1 style="color: #00FF41;"> The Forum </h1>
<!--h1 style="color: white;">Publicações:</h1-->
<form action="" method="get">
<table border="1" style="color: white;">
<thead>
<thead table-layout:fixed>
<tr>
<td>Publicação</td>
<td>Texto</td>
Expand Down
28 changes: 18 additions & 10 deletions frontend/public/inserePub.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand All @@ -17,15 +18,22 @@
<iframe src="cabecalho.html" frameborder="0" width="100%" height="50"></iframe>
<h1 style="color: white;">Inserir Publicação</h1>
<form id="meuFormulario">
<table>
<tbody>
<tr><td style="color: white;" align="right">Titulo:</td><td><input type="text" name="titulo" id="titulo"></td></tr>
<tr><td style="color: white;" align="right">Text:</td><td><input type="text" name="texto" id="texto"></td></tr>
</tbody>
</table>
<td></td>
<button id="insere" name="insere" value="Insere" style="margin-top: 10px;">Inserir</button>
<table>
<tbody>
<tr>
<td style="color: white;" align="right">Titulo:</td>
<td><input type="text" name="titulo" id="titulo"></td>
</tr>
<tr>
<td style="color: white;" align="right">Text:</td>
<td><input type="text" name="texto" id="texto"></td>
</tr>
</tbody>
</table>
<td></td>
<button id="insere" name="insere" value="Insere" style="margin-top: 10px;">Inserir</button>
</form>
<div id="mensagem"></div>
</body>
</body>

</html>
22 changes: 22 additions & 0 deletions frontend/public/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Document</title>
<script src="javascript/logout.js"></script>
<script src="javascript/constantes.js"></script>
</head>

<body>
<iframe src="cabecalho.html" frameborder="0" width="100%" height="50" id="cabecalho"></iframe>
<p>
Confirme logout clicando
<button type="button" id="logout">aqui</button>.
</p>
<div id="mensagem"></div>
</body>

</html>

25 changes: 25 additions & 0 deletions frontend/typescript/logout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
onload = (evento) => {
(document.getElementById('logout') as HTMLInputElement).addEventListener('click', (evento) => {
console.log("Clickei!")
const token = localStorage.getItem('token');
fetch(backendAddress + 'accounts/token-auth/', {
method: 'DELETE',
headers: {
'Authorization': 'Token ' + token,
'Content-Type': 'application/json'
}
})
.then(response => {
const mensagem = document.getElementById('mensagem') as HTMLDivElement;
if (response.ok) {
window.location.assign('/');
} else {
mensagem.innerHTML = 'Erro ' + response.status;
}
})
.catch(erro => {
console.log(erro);
});
});
}

0 comments on commit af79948

Please sign in to comment.