Aggiunta stili CSS per Kiosk, struttura HTML per la Mappa e Riferimenti ai Sensori
• Creato un nuovo file CSS per gli stili del chiosco (kiosk) con variabili, stili per le schede (card) e animazioni. • Aggiunto un file HTML per l'interfaccia della mappa utilizzando Mapbox, inclusi gli stili e il JavaScript per le funzionalità della mappa. • Introdotto un file JSON per i riferimenti ai sensori, definendo percorsi ed elementi per i dati di temperatura, vento, onde, posizione, batteria, motore e sistema. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,53 +1,53 @@
|
||||
const realtime = require('../../realtime/core.js');
|
||||
const { config } = require('../../config.js');
|
||||
const recorder = require('../../cores/logs.local');
|
||||
const { closeButton } = require('../utility/close');
|
||||
|
||||
module.exports = {
|
||||
command: 'logs',
|
||||
description: 'Mostra lo stato della registrazione dati in tempo reale',
|
||||
pattern: /\/logs/,
|
||||
execute: async (bot, msg, { app }) => {
|
||||
handler: async (bot, msg) => {
|
||||
const chatId = msg.chat.id;
|
||||
try {
|
||||
const stats = realtime.getStats();
|
||||
const consoleUrl = config.cloudUrl || 'https://console.mebboat.it';
|
||||
const logs = await recorder.listLogs();
|
||||
|
||||
let statusIcon = '🔴';
|
||||
if (stats.status === 'connected') statusIcon = '🟢';
|
||||
else if (stats.status === 'error') statusIcon = '🟡';
|
||||
|
||||
let text = `📊 *Registrazione Dati Realtime*\n\n`;
|
||||
text += `Stato: ${statusIcon} *${stats.status}*\n`;
|
||||
text += `Sensore: \`${stats.sensorID}\`\n`;
|
||||
text += `Messaggi inviati: *${stats.sent}*\n`;
|
||||
text += `Frequenza: ogni *${stats.sentEveryMLS / 1000}s*\n`;
|
||||
|
||||
if (stats.buffered > 0) {
|
||||
text += `⚠️ Messaggi in buffer: *${stats.buffered}*\n`;
|
||||
}
|
||||
|
||||
if (stats.reconnections > 0) {
|
||||
text += `Riconnessioni: ${stats.reconnections}\n`;
|
||||
}
|
||||
|
||||
if (stats.firstSent) {
|
||||
text += `\nPrimo invio: ${stats.firstSent}\n`;
|
||||
}
|
||||
|
||||
text += `\n_I dati vengono inviati automaticamente al server ogni secondo._`;
|
||||
text += `\n_Consulta i log storici sulla console:_`;
|
||||
|
||||
await bot.sendMessage(chatId, text, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_markup: {
|
||||
inline_keyboard: [
|
||||
[{ text: '📈 Apri Console Log', url: `${consoleUrl}/logs` }],
|
||||
[{ text: '🔄 Aggiorna Stato', callback_data: 'logs-refresh' }]
|
||||
]
|
||||
}
|
||||
if (!logs || logs.length === 0) {
|
||||
bot.sendMessage(chatId, 'Nessun file di log disponibile.', {
|
||||
reply_to_message_id: msg.message_id,
|
||||
reply_markup: closeButton(msg.message_id)
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("[Telegram] Errore comando /logs:", error);
|
||||
bot.sendMessage(chatId, `❌ Errore: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const session = recorder.getSession();
|
||||
let text = '*Registrazioni dei Log*\n\n';
|
||||
|
||||
if (session) {
|
||||
text += `in corso: *${session.name}*\n`;
|
||||
text += `${session.elements} dati raccolti ogni ${session.delay}s\n\n`;
|
||||
}
|
||||
|
||||
text += `${logs.length} file disponibili:\n`;
|
||||
text += '_Selezionane uno per scaricarlo_';
|
||||
|
||||
// Bottoni per ogni file
|
||||
const keyboard = logs.map(log => {
|
||||
const date = new Date(log.created).toLocaleDateString('it-IT', {
|
||||
day: '2-digit', month: '2-digit', year: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
});
|
||||
|
||||
const isActive = session && session.name === log.name;
|
||||
const label = isActive ? `🔴 ${log.name} *[IN CORSO, NON DISPONIBILE]*` : `${date})`;
|
||||
const callback = isActive ? `logbusy:${log.name}` : `logfile:${log.name}:${msg.message_id}`;
|
||||
|
||||
return [{ text: label, callback_data: callback }];
|
||||
});
|
||||
|
||||
// Aggiungi il bottone chiudi
|
||||
keyboard.push([{ text: '<- Chiudi', callback_data: `close:${msg.message_id}` }]);
|
||||
|
||||
bot.sendMessage(chatId, text, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: msg.message_id,
|
||||
reply_markup: { inline_keyboard: keyboard }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user