Files
signalk-plugin/plugin/telegram/commands/logs.js
Giuseppe Raffa c2c1598226 feat: Implement rulesets and layout management for kiosk plugin
- Added rulesets manager to handle various data types and updates via HTTP and WebSocket.
- Introduced layout store for managing kiosk layouts with caching and server synchronization.
- Enhanced dashboard and data routes to support new layout and ruleset features.
- Updated kiosk HTML and JavaScript to utilize new layout rendering and data binding.
- Removed obsolete map route and integrated map functionality into the new tile renderer.
- Improved Telegram commands to reflect changes in data structure and logging.
- Refactored weather fetching intervals to prevent multiple instances.
- Added SSE stream for real-time layout updates in the kiosk.
2026-05-12 10:17:54 +02:00

54 lines
1.9 KiB
JavaScript

const recorder = require('../../cores/logs.local');
const { closeButton } = require('../utility/close');
module.exports = {
command: 'logs',
handler: async (bot, msg) => {
const chatId = msg.chat.id;
const logs = await recorder.listLogs();
if (!logs || logs.length === 0) {
await bot.sendMessage(chatId, 'Nessun file di log disponibile.', {
reply_to_message_id: msg.message_id,
reply_markup: closeButton(msg.message_id)
});
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}` }]);
await bot.sendMessage(chatId, text, {
parse_mode: 'Markdown',
reply_to_message_id: msg.message_id,
reply_markup: { inline_keyboard: keyboard }
});
}
};