aboutsummaryrefslogtreecommitdiff
path: root/app/templates
diff options
context:
space:
mode:
Diffstat (limited to 'app/templates')
-rw-r--r--app/templates/dashboard.html74
-rw-r--r--app/templates/signup.html13
2 files changed, 66 insertions, 21 deletions
diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html
index f1c98e3..c2c9ebc 100644
--- a/app/templates/dashboard.html
+++ b/app/templates/dashboard.html
@@ -7,9 +7,15 @@
</head>
<body>
<div>
- <!-- Create a small box that will hold the text for the users api key, next to the box should be a regenerate button -->
- <p>Your Username: <span id="api-key">{{ user }}</span></p>
- <button onclick="window.location.href='logout'">Logout</button>
+ <!-- Create a table with 5 columns with a total of 750px width -->
+ <table style="width: 750px; margin: 0 auto;">
+ <tr>
+ <th style="width: 150px;">ID</th>
+ <th style="width: 150px;">Timestamp</th>
+ <th style="width: 150px;">IP</th>
+ <th style="width: 150px;">Location</th>
+ <th style="width: 150px;">ISP</th>
+ </tr>
</div>
</body>
</html>
@@ -31,17 +37,55 @@
font-size: 25px;
color: #ccc;
}
+</style>
- button {
- display: block;
- margin: 10px auto;
- width: 200px;
- border-radius: 5px;
- padding: 15px;
- color: #ccc;
- background-color: #415eac;
- border: none;
- font-size: 17px;
- cursor: pointer;
+<script>
+
+ // Function to get a cookie by name
+ function getCookie(name) {
+ const value = `; ${document.cookie}`;
+ const parts = value.split(`; ${name}=`);
+ if (parts.length === 2) return parts.pop().split(';').shift();
+ return null;
+ }
+
+
+ // On window load
+ window.onload = async () => {
+ const data = await fetch('/api/links/3MY70/logs', {
+ method: 'GET',
+ });
+
+ const logs = await data.json();
+
+ const table = document.querySelector('table');
+
+ // For every log, add a row to the table
+ counter = 1;
+ logs.forEach(log => {
+ const row = document.createElement('tr');
+
+ let date = new Date(log.timestamp);
+ let readableDate = date.toLocaleTimeString('en-US', {
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ second: '2-digit',
+ hour12: false
+ }
+ );
+
+ row.innerHTML = `
+ <td>${counter++}</td>
+ <td>${readableDate}</td>
+ <td>${log.ip}</td>
+ <td>${log.location}</td>
+ <td>${log.isp}</td>
+ `;
+
+ table.appendChild(row);
+ });
}
-</style> \ No newline at end of file
+</script> \ No newline at end of file
diff --git a/app/templates/signup.html b/app/templates/signup.html
index 446aaeb..32962b7 100644
--- a/app/templates/signup.html
+++ b/app/templates/signup.html
@@ -91,21 +91,22 @@
// Prevent default form submission
event.preventDefault();
+ // Get form data
const formData = new FormData(this);
- // Send POST request to /signup containing form data
+
+ // Send POST request
const response = await fetch('/api/users/register', {
method: 'POST',
body: formData
});
if (response.status != 200) {
- const data = await response.json();
-
+ const data = await response.json()
+
document.getElementById('error').style.display = 'block';
document.getElementById('error').innerText = data.detail;
- }
- else {
- window.location.href = '/login';
+ } else {
+ window.location.href = '/dashboard';
}
});
</script> \ No newline at end of file