-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from diffra/admin
Admin
- Loading branch information
Showing
7 changed files
with
272 additions
and
9 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 @@ | ||
data/lard.db |
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
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
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,4 +1,6 @@ | ||
fastapi | ||
uvicorn | ||
configparser | ||
starlette | ||
starlette | ||
jinja2 | ||
bcrypt |
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,196 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Lard: A Redirect Daemon</title> | ||
<!-- CUSTOM CSS --> | ||
<style> | ||
@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400&family=Roboto:wght@300;400;500;700&display=swap'); | ||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
html,body{ | ||
background: #045D5D; | ||
font-family: 'Roboto', sans-serif; | ||
} | ||
.container{ | ||
max-width: 600px; | ||
margin: 120px auto; | ||
|
||
} | ||
.form-card{ | ||
background: #fff; | ||
padding:10px 20px 30px 20px; | ||
box-shadow: 2px 3px 11px 3px #00000069; | ||
} | ||
.form-card .text-center{ | ||
text-align: center; | ||
} | ||
.form-card .text-center h1{ | ||
margin:20px 0; | ||
} | ||
.input-group{ | ||
margin: 30px 0; | ||
} | ||
.input-group label{ | ||
padding: 10px 5px; | ||
} | ||
.input-group .form-control{ | ||
display: block; | ||
width: 100%; | ||
padding: 10px 5px; | ||
margin-top: 7px; | ||
|
||
} | ||
.submit-btn .btn-dark{ | ||
padding: 15px 35px; | ||
background: #045D5D; | ||
color: #fff; | ||
border: none; | ||
} | ||
#output { | ||
display: block; | ||
font-size: large; | ||
height: 20px; | ||
margin-top: 5px; | ||
text-align: center; | ||
} | ||
#output a { | ||
color: black; | ||
text-decoration: none; | ||
font-style: italic; | ||
} | ||
.modal { | ||
display: none; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0,0,0,0.6); | ||
} | ||
|
||
.modal-content { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
padding: 20px; | ||
background-color: #ffffff; | ||
width: 80%; | ||
max-width: 500px; | ||
} | ||
|
||
.close-btn { | ||
cursor: pointer; | ||
float: right; | ||
font-size: 28px; | ||
} | ||
#links { | ||
border-collapse: separate; | ||
border-spacing: 0; | ||
width: 100%; | ||
border-radius: 10px; | ||
overflow: hidden; /* For rounded corners */ | ||
} | ||
|
||
#links th, #links td { | ||
border: 1px solid #e0e0e0; /* Adjust this value to change the border color */ | ||
padding: 10px; /* Adjust this value to change the padding inside the cells */ | ||
text-align: left; | ||
} | ||
|
||
#links th { | ||
background-color: #f5f5f5; /* Adjust this value to change the header background color */ | ||
} | ||
|
||
#links tbody tr:hover { | ||
background-color: #f0f0f0; /* Adjust this value to change the row hover background color */ | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> | ||
<script> | ||
function deleteEntry(buttonElement) { | ||
// Getting the ID from the button's data-id attribute | ||
const entryId = buttonElement.getAttribute("data-id"); | ||
|
||
// Sending the DELETE request | ||
fetch('/delete/' + entryId, { | ||
method: 'DELETE', | ||
}) | ||
.then(response => { | ||
if (response.ok) { | ||
// Reloading the page on successful delete | ||
location.reload(); | ||
} else { | ||
throw new Error('Failed to delete entry'); | ||
} | ||
}) | ||
.catch(error => { | ||
// Popping a JS alert on failure | ||
alert('Failed to delete the entry: ' + error.message); | ||
}); | ||
} | ||
</script> | ||
<div id="url-shortner"> | ||
<!-- CONTAINER WITH MAX-WIDTH 600 --> | ||
<div class="container"> | ||
<!-- FORM CARD WITH WHITE BG --> | ||
<div class="form-card"> | ||
<div class="text-center"><h1>LARD: A Redirect Daemon</h1></div> | ||
<!-- FORM --> | ||
<!-- INPUT FOR URL --> | ||
<div class="input-group"> | ||
<table id="links"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Short URL</th> | ||
<th>Long URL</th> | ||
<th>Views</th> | ||
<th>Last Access</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for entry in entries %} | ||
<tr> | ||
<td data-colname="id">{{ entry[0] }}</td> <!-- ID --> | ||
<td data-colname="short">{{ entry[1] }}</td> <!-- Short URL --> | ||
<td data-colname="long">{{ entry[2] }}</td> <!-- Long URL --> | ||
<td data-colname="views">{{ entry[3] }}</td> <!-- Views --> | ||
<td data-colname="access">{{ entry[4] }}</td> <!-- Last Access --> | ||
<td> | ||
<button data-id="{{ entry[0] }}" onclick="deleteEntry(this)">Delete</button> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
|
||
</tbody> | ||
</table> | ||
|
||
</div> | ||
</div> <!-- FORM-CARD CLOSE --> | ||
</div> <!-- CONTAINER CLOSE --> | ||
|
||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
File renamed without changes.
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