Add config UI interface and update app.py with config card functionality

- Copied config.py with FreeSimpleGUI configuration interface to root folder
- Added load_config() function to launch config UI when card 12886709 is inserted
- Config UI allows setting hostname and work table (Loc De Munca)
- Automatic printer configuration and hostname updates
- System reboot after configuration changes
- Added config.py to version control
This commit is contained in:
RPI User
2025-12-19 14:38:39 +02:00
parent c3a55a89c3
commit 6b199a0e41
12 changed files with 594 additions and 33 deletions

69
data/html/Screen.html Executable file
View File

@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device Not Configured</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
body {
overflow: hidden;
background-color: #000;
font-family: Arial, sans-serif;
}
#container {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #000;
}
img {
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
object-fit: contain;
}
#fallback {
display: none;
color: white;
text-align: center;
font-size: 24px;
}
</style>
</head>
<body>
<div id="container">
<img id="mainImage" src="file:///home/pi/Desktop/Prezenta/data/html/harting_background.jpg" alt="Harting Module" />
<div id="fallback">
<h1>Device Not Configured</h1>
<p>Please scan the configuration RFID card</p>
</div>
</div>
<script>
document.getElementById('mainImage').onerror = function() {
console.error('Image failed to load, showing fallback');
document.getElementById('mainImage').style.display = 'none';
document.getElementById('fallback').style.display = 'block';
};
// Log when image loads successfully
document.getElementById('mainImage').onload = function() {
console.log('Image loaded successfully');
};
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 KiB

125
data/html/index.html Normal file
View File

@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Device Configuration Required</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100vh;
overflow: hidden;
font-family: Arial, sans-serif;
background-color: #000;
margin: 0;
padding: 0;
}
.container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #000;
position: relative;
}
.image-wrapper {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #000;
position: absolute;
top: 0;
left: 0;
}
img {
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
object-fit: contain;
}
.overlay {
position: absolute;
bottom: 30px;
left: 0;
right: 0;
text-align: center;
background: rgba(0, 0, 0, 0.7);
padding: 20px;
color: white;
font-size: 18px;
z-index: 100;
}
.status {
margin: 10px 0;
font-size: 16px;
}
.time {
font-size: 14px;
color: #ccc;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="image-wrapper">
<img src="file:///home/pi/Desktop/Prezenta/data/html/harting_background.jpg" alt="Harting Module" onerror="handleImageError()">
</div>
<div class="overlay">
<div class="status">
<strong>Device Not Configured</strong>
</div>
<div class="status">
Please scan the configuration RFID card to initialize this device
</div>
<div class="time" id="time"></div>
</div>
</div>
<script>
function updateTime() {
const now = new Date();
document.getElementById('time').innerHTML = now.toLocaleString();
}
function handleImageError() {
console.error('Failed to load image');
const img = document.querySelector('img');
img.alt = 'Image not available';
img.style.display = 'none';
const wrapper = document.querySelector('.image-wrapper');
wrapper.innerHTML = '<div style="color: white; text-align: center;"><h2>Image Loading Failed</h2><p>Please check internet connection</p></div>';
}
// Update time immediately and then every second
updateTime();
setInterval(updateTime, 1000);
// Prevent screensaver/screen blanking
document.addEventListener('mousemove', () => {
// Keep screen active
});
document.addEventListener('keypress', () => {
// Keep screen active
});
</script>
</body>
</html>

BIN
data/html/myimage.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

BIN
data/html/myimage.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 794 KiB