Enhance validation, logging, and UI/UX improvements

## COMMIT MESSAGE GENERATED BY COPILOT

Added JSON validation to multiple endpoints, ensuring valid JSON requests and improved error handling. Updated logging to use `DateTime.Now` and append to `logs.log` for specific actions. Enhanced `/api/accounts/login` with JSON validation and refactored for consistency.  Improved admin and user interfaces with search functionality, better date localization, and CSS adjustments. Enhanced error handling and feedback in `login.html` and `signup.html`, and improved search functionality in `archives.html`.
This commit is contained in:
whoswhip
2024-09-07 13:59:33 -04:00
parent 0e2aa78b5c
commit f02e68b1d3
10 changed files with 660 additions and 395 deletions
+60 -36
View File
@@ -32,54 +32,59 @@
</body>
<script>
let searchTimeout;
function search() {
function search() {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(searchPastes, 200);
}
function searchPastes() {
}
function searchPastes() {
const searchInput = document.querySelector('.text-input');
if (searchInput.value.length < 3) return;
if (searchInput.value.length < 3 && searchInput.value.length != 0){
return;
}
else if (searchInput.value.length == 0) {
fetch(`/api/pastes/search?html=true`,{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: ''
})
})
.then(response => response.text())
.then(data => {
const pastesWrapper = document.querySelector('.pastes-wrapper');
if (data === '') {
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
return;
}
pastesWrapper.innerHTML = data;
});
return;
}
fetch(`/api/pastes/search?html=true`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: searchInput.value
query: searchInput.value
})
})
.then(response => response.text())
.then(data => {
const pastesWrapper = document.querySelector('.pastes-wrapper');
if (data === '') {
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
return;
}
pastesWrapper.innerHTML = data;
});
}
.then(response => response.text())
.then(data => {
const pastesWrapper = document.querySelector('.pastes-wrapper');
if (data === '') {
pastesWrapper.innerHTML = '<h1>no pastes found</h1>';
return;
}
pastesWrapper.innerHTML = data;
});
}
</script>
<style>
.text-input {
transition: border 300ms;
width: 90.62%;
height: 1.2rem;
padding: 10px;
margin: 10px;
border-radius: 5px;
border: #222222 2px solid;
background-color: #222222;
color: white;
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
}
.text-input:focus {
transition: border 300ms;
outline: none;
border: #3a3a3a 2px solid;
}
body {
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
font-weight: bold;
@@ -187,6 +192,25 @@
border: 2px solid #3a3a3a;
}
.text-input {
transition: border 300ms;
width: 90.62%;
height: 1.2rem;
padding: 10px;
margin: 10px;
border-radius: 5px;
border: #222222 2px solid;
background-color: #222222;
color: white;
font-family: "Noto Sans Mono", "Consolas", "SF Mono", monospace;
}
.text-input:focus {
transition: border 300ms;
outline: none;
border: #3a3a3a 2px solid;
}
.nav-div {
top: 0;
margin-top: 10px;