Printio/templates/index.html
2025-03-20 00:07:07 -07:00

158 lines
5.2 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Printio</title>
<link rel="icon" type="image/x-icon" href="/static/images/favicon.ico">
<link rel="stylesheet" href="/static/css/styles.css">
<link rel="stylesheet" href="/static/fontawesome/css/all.min.css">
<style>
.header-img {
margin-top: 30px;
margin-bottom: 30px;
width: auto;
height: 100px;
}
h2 {
margin-top: 0;
font-size: 24px;
color: #565656;
}
table {
border-collapse: collapse;
width: 100%;
margin-top: 20px;
box-sizing: border-box;
}
th, td {
border: 1px solid #ccc;
padding: 10px;
text-align: left;
box-sizing: border-box;
}
th {
background-color: #f8f8f8;
}
.button-red {
padding: 5px 10px;
background-color: #f44336;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.button-test {
padding: 5px 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.placeholder-img {
position: absolute;
top: 20px;
right: 20px;
}
.placeholder-img img {
top: 20px;
width: 60px;
height: 60px;
}
/* Styles for the message log */
#messageLog {
display: none;
margin-top: 20px;
width: 100%;
height: 350px;
box-sizing: border-box;
resize: none;
overflow: auto;
white-space: nowrap;
}
.toggle-button {
margin-top: 20px;
background-color: #007BFF;
color: white;
border: none;
padding: 3px 20px;
cursor: pointer;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="navbar"></div>
<script>
fetch('/static/html/nav.html')
.then(response => response.text())
.then(data => {
document.getElementById('navbar').innerHTML = data;
});
</script>
<div class="content-wrapper">
<div class="content">
<img src="/static/images/printio_logo.png" alt="Printio" class="header-img">
<h2>Active Printers</h2>
<table border="1">
<tr>
<th>Printer Name</th>
<th>Status</th>
<th>Prints Left</th>
<th>Actions</th>
</tr>
{% for printer in printers %}
<tr>
<td>{{ printer.name }}</td>
<td>{{ printer.state }}</td>
<td>{{ printer.prints_left_message }}</td>
<td>
<form action="{{ url_for('cancel_all_jobs', printer_name=printer.name) }}" method="post" style="display:inline;">
<button type="submit" class="button-red">Kill Jobs</button>
</form>
<form action="{{ url_for('test_print', printer_name=printer.name) }}" method="post" style="display:inline;">
<button type="submit" class="button-test">Test Print</button>
</form>
</td>
</tr>
{% endfor %}
</table>
<!-- Button to toggle the message log -->
<button class="toggle-button" onclick="toggleMessageLog()">Job History</button>
<!-- Hidden textarea for the message log -->
<textarea id="messageLog" placeholder="Job Status Log..." readonly></textarea>
</div>
</div>
<script>
// Toggles the visibility of the message log textarea
function toggleMessageLog() {
var messageLog = document.getElementById('messageLog');
if (messageLog.style.display === '' || messageLog.style.display === 'none') {
messageLog.style.display = 'block';
loadPrinterJobs(); // Load job messages when showing the textarea
} else {
messageLog.style.display = 'none';
}
}
// Load the printer job information and show in the textarea
function loadPrinterJobs() {
var messageLog = document.getElementById('messageLog');
var jobs = {{ job_history | tojson | safe }};
var logText = "";
jobs.forEach(function(job, index) {
logText += "Job: " + job.job_id + ", Time: " + job.time + ", Size: " + job.job_size + ", Printer: " + job.printer_name + ", State: " + job.job_state + ', Reason: ' + job.job_reason + "\r\n";
});
// Set the value of the textarea to display the job information
messageLog.value = logText;
}
</script>
</body>
</html>