can personalize UI message
This commit is contained in:
parent
40d08e21ae
commit
b4a769c557
4 changed files with 30 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ npm start
|
|||
- `NTFY_PASSWORD`: Password for ntfy authentication (required)
|
||||
- `NTFY_TOPIC`: ntfy topic/channel to send messages to (optional, defaults to "emergencia")
|
||||
- `PORT`: Port to run the application on (optional, defaults to 3000)
|
||||
- `UI_MESSAGE`: Custom message to display in the UI (optional, defaults to "Emergency Message")
|
||||
|
||||
### Docker Registry Variables (Optional, needed to push to private registry)
|
||||
|
||||
|
|
@ -56,6 +57,7 @@ NTFY_URL=https://your-ntfy-server.com
|
|||
NTFY_USER=your-username
|
||||
NTFY_PASSWORD=your-password
|
||||
NTFY_TOPIC=emergencia
|
||||
UI_MESSAGE=Send an emergency message
|
||||
```
|
||||
|
||||
2. Run with Docker:
|
||||
|
|
@ -79,6 +81,7 @@ NTFY_URL=https://your-ntfy-server.com
|
|||
NTFY_USER=your-username
|
||||
NTFY_PASSWORD=your-password
|
||||
NTFY_TOPIC=emergencia
|
||||
UI_MESSAGE=Send an emergency message
|
||||
```
|
||||
4. Install dependencies:
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ NTFY_USER=your-username
|
|||
NTFY_PASSWORD=your-password
|
||||
NTFY_TOPIC=emergencia
|
||||
PORT=3000
|
||||
UI_MESSAGE=Send an emergency message
|
||||
|
||||
# Optional variables for Docker registry
|
||||
# DOCKER_REGISTRY=your-registry.com
|
||||
|
|
|
|||
|
|
@ -27,6 +27,23 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// Load UI configuration on page load
|
||||
async function loadConfig() {
|
||||
try {
|
||||
const response = await fetch('/api/config');
|
||||
const config = await response.json();
|
||||
|
||||
// Update the title and heading with the UI message
|
||||
document.title = config.uiMessage;
|
||||
document.querySelector('h1').textContent = config.uiMessage;
|
||||
} catch (error) {
|
||||
console.error('Error loading config:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Load config when page loads
|
||||
loadConfig();
|
||||
|
||||
document.getElementById('messageForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
|
|
|||
10
server.js
10
server.js
|
|
@ -10,7 +10,8 @@ const PORT = process.env.PORT || 3000;
|
|||
const NTFY_URL = process.env.NTFY_URL;
|
||||
const NTFY_USER = process.env.NTFY_USER;
|
||||
const NTFY_PASSWORD = process.env.NTFY_PASSWORD;
|
||||
const NTFY_TOPIC = process.env.NTFY_TOPIC || 'emergencia';
|
||||
const NTFY_TOPIC = process.env.NTFY_TOPIC;
|
||||
const UI_MESSAGE = process.env.UI_MESSAGE;
|
||||
|
||||
// Middleware
|
||||
app.use(express.json());
|
||||
|
|
@ -28,6 +29,13 @@ app.get('/', (req, res) => {
|
|||
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
||||
});
|
||||
|
||||
// Route to get UI configuration
|
||||
app.get('/api/config', (req, res) => {
|
||||
res.json({
|
||||
uiMessage: UI_MESSAGE || 'Emergency Message'
|
||||
});
|
||||
});
|
||||
|
||||
// Route to handle message submission
|
||||
app.post('/send-message', async (req, res) => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue