- Add config.py for environment configuration management - Add utils.py with utility functions - Add .env.example for environment variable reference - Add routes_example.py as route reference - Add login.html template for authentication - Update server.py with enhancements - Update all dashboard and log templates - Move documentation to 'explanations and old code' directory - Update database schema
263 lines
9.3 KiB
HTML
263 lines
9.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Unique Devices</title>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
<style>
|
|
body {
|
|
background-color: #f8f9fa;
|
|
font-family: Arial, sans-serif;
|
|
display: flex;
|
|
}
|
|
.sidebar {
|
|
width: 250px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 20px;
|
|
height: calc(100vh - 56px);
|
|
position: fixed;
|
|
top: 56px;
|
|
left: -250px;
|
|
transition: left 0.3s ease;
|
|
overflow-y: auto;
|
|
z-index: 1000;
|
|
}
|
|
.sidebar.active {
|
|
left: 0;
|
|
}
|
|
.sidebar-header {
|
|
font-size: 18px;
|
|
font-weight: bold;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
.sidebar-content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
}
|
|
.sidebar-btn {
|
|
background-color: rgba(255,255,255,0.2);
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 15px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
text-align: left;
|
|
transition: background-color 0.3s;
|
|
font-size: 13px;
|
|
text-decoration: none;
|
|
display: block;
|
|
}
|
|
.sidebar-btn:hover {
|
|
background-color: rgba(255,255,255,0.4);
|
|
color: white;
|
|
}
|
|
.toggle-btn {
|
|
position: fixed;
|
|
left: 20px;
|
|
top: 20px;
|
|
background-color: #667eea;
|
|
color: white;
|
|
border: none;
|
|
padding: 10px 15px;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
z-index: 1001;
|
|
font-size: 18px;
|
|
}
|
|
.main-content {
|
|
margin-left: 0;
|
|
width: 100%;
|
|
transition: margin-left 0.3s ease;
|
|
padding-top: 60px;
|
|
padding-left: 20px;
|
|
padding-right: 20px;
|
|
max-width: 100%;
|
|
overflow-x: hidden;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #343a40;
|
|
}
|
|
.container {
|
|
max-width: 1200px;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
.table-container {
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
padding: 20px;
|
|
}
|
|
.table {
|
|
margin-bottom: 0;
|
|
table-layout: fixed; /* Ensures consistent column widths */
|
|
width: 100%; /* Makes the table take up the full container width */
|
|
}
|
|
.table th, .table td {
|
|
text-align: center;
|
|
word-wrap: break-word; /* Ensures long text wraps within the cell */
|
|
}
|
|
.table th:nth-child(1), .table td:nth-child(1) {
|
|
width: 25%; /* Hostname column */
|
|
}
|
|
.table th:nth-child(2), .table td:nth-child(2) {
|
|
width: 25%; /* Device IP column */
|
|
}
|
|
.table th:nth-child(3), .table td:nth-child(3) {
|
|
width: 25%; /* Last Log column */
|
|
}
|
|
.table th:nth-child(4), .table td:nth-child(4) {
|
|
width: 25%; /* Event Description column */
|
|
}
|
|
.back-button {
|
|
margin-bottom: 20px;
|
|
text-align: center;
|
|
}
|
|
.search-container {
|
|
margin-bottom: 20px;
|
|
}
|
|
.search-input {
|
|
max-width: 400px;
|
|
margin: 0 auto;
|
|
}
|
|
.no-results {
|
|
display: none;
|
|
text-align: center;
|
|
color: #6c757d;
|
|
font-style: italic;
|
|
padding: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- User Header -->
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark" style="position: fixed; top: 0; width: 100%; z-index: 999;">
|
|
<div class="container-fluid">
|
|
<button class="toggle-btn" onclick="toggleSidebar()"><i class="fas fa-chevron-right"></i></button>
|
|
<span class="navbar-brand" style="margin-left: 40px;">🖥️ Server Monitoring</span>
|
|
<div class="ms-auto d-flex align-items-center gap-3">
|
|
<span class="text-white">Welcome, <strong>{{ current_user.username }}</strong></span>
|
|
<a href="/logout" class="btn btn-sm btn-danger">Logout</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="sidebar" id="sidebar">
|
|
<div class="sidebar-header">
|
|
Quick Actions
|
|
<button onclick="toggleSidebar()" style="background: none; border: none; color: white; font-size: 20px; cursor: pointer;">×</button>
|
|
</div>
|
|
<div class="sidebar-content">
|
|
<a href="/dashboard" class="sidebar-btn"><i class="fas fa-tachometer-alt"></i> Dashboard</a>
|
|
<a href="/unique_devices" class="sidebar-btn"><i class="fas fa-laptop"></i> Unique Devices</a>
|
|
<a href="/device_management" class="sidebar-btn"><i class="fas fa-tools"></i> Device Management</a>
|
|
<a href="/server_logs" class="sidebar-btn"><i class="fas fa-server"></i> Server Logs</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="main-content">
|
|
<div class="container mt-5">
|
|
<h1 class="mb-4">Unique Devices</h1>
|
|
|
|
|
|
<!-- Search Filter -->
|
|
<div class="search-container">
|
|
<div class="search-input">
|
|
<input type="text" id="searchInput" class="form-control" placeholder="Search devices by hostname, IP, or event description...">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="table-container">
|
|
<table class="table table-striped table-bordered" id="devicesTable">
|
|
<thead class="table-dark">
|
|
<tr>
|
|
<th>Hostname</th>
|
|
<th>Device IP</th>
|
|
<th>Last Log</th>
|
|
<th>Event Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for device in devices %}
|
|
<tr>
|
|
<!-- Make the Hostname column clickable -->
|
|
<td>
|
|
<a href="/hostname_logs/{{ device[0] }}">{{ device[0] }}</a>
|
|
</td>
|
|
<td>{{ device[1] }}</td> <!-- Device IP -->
|
|
<td>{{ device[2] }}</td> <!-- Last Log -->
|
|
<td>{{ device[3] }}</td> <!-- Event Description -->
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
<div id="noResults" class="no-results">
|
|
No devices found matching your search criteria.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- JavaScript for filtering -->
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const searchInput = document.getElementById('searchInput');
|
|
const table = document.getElementById('devicesTable');
|
|
const tableBody = table.getElementsByTagName('tbody')[0];
|
|
const noResultsDiv = document.getElementById('noResults');
|
|
|
|
searchInput.addEventListener('keyup', function() {
|
|
const filter = this.value.toLowerCase();
|
|
const rows = tableBody.getElementsByTagName('tr');
|
|
let visibleRowCount = 0;
|
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
const row = rows[i];
|
|
const cells = row.getElementsByTagName('td');
|
|
let found = false;
|
|
|
|
// Search through all cells in the row
|
|
for (let j = 0; j < cells.length; j++) {
|
|
const cellText = cells[j].textContent || cells[j].innerText;
|
|
if (cellText.toLowerCase().indexOf(filter) > -1) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (found) {
|
|
row.style.display = '';
|
|
visibleRowCount++;
|
|
} else {
|
|
row.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Show/hide "no results" message
|
|
if (visibleRowCount === 0 && filter !== '') {
|
|
noResultsDiv.style.display = 'block';
|
|
} else {
|
|
noResultsDiv.style.display = 'none';
|
|
}
|
|
});
|
|
});
|
|
function toggleSidebar() {
|
|
document.getElementById('sidebar').classList.toggle('active');
|
|
}
|
|
</script>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
<p class="text-center mt-4">© 2023 Unique Devices Dashboard. All rights reserved.</p>
|
|
</footer>
|
|
</body>
|
|
</html> |