• 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>
54 lines
1.8 KiB
JavaScript
54 lines
1.8 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) {
|
|
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}` }]);
|
|
|
|
bot.sendMessage(chatId, text, {
|
|
parse_mode: 'Markdown',
|
|
reply_to_message_id: msg.message_id,
|
|
reply_markup: { inline_keyboard: keyboard }
|
|
});
|
|
}
|
|
};
|