|
@ -3,23 +3,23 @@ const emitter = require('../services/eventEmitter'); |
|
|
const configure = (socket) => { |
|
|
const configure = (socket) => { |
|
|
// Create a new listener for the download.start event
|
|
|
// Create a new listener for the download.start event
|
|
|
emitter.on('download.start', ({ url, filepath }) => { |
|
|
emitter.on('download.start', ({ url, filepath }) => { |
|
|
socket.emit('download.start', { message: 'Début de téléchargement' }); |
|
|
socket.emit('download.start', { event: 'download.start', message: 'Début de téléchargement' }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create a new listener for the download.end event
|
|
|
// Create a new listener for the download.end event
|
|
|
emitter.on('download.end', ({ url, filepath }) => { |
|
|
emitter.on('download.end', ({ url, filepath }) => { |
|
|
socket.emit('download.end', { message: 'Téléchargement terminé' }); |
|
|
socket.emit('download.end', { event: 'download.end', message: 'Téléchargement terminé' }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create a new listener for the download.error event
|
|
|
// Create a new listener for the download.error event
|
|
|
emitter.on('download.error', ({ url, filepath, error, type }) => { |
|
|
emitter.on('download.error', ({ url, filepath, error, type }) => { |
|
|
socket.emit('download.error', { error, type, message: 'Erreur lors du téléchargement' }); |
|
|
socket.emit('download.error', { event: 'download.error', error, type, message: 'Erreur lors du téléchargement' }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create a new listener for the download.progress event
|
|
|
// Create a new listener for the download.progress event
|
|
|
emitter.on('download.progress', ({ url, filepath, downloaded }) => { |
|
|
emitter.on('download.progress', ({ url, filepath, downloaded }) => { |
|
|
downloaded = (Math.floor(downloaded / 1024 / 1024 * 100) / 100).toLocaleString(); |
|
|
downloaded = (Math.floor(downloaded / 1024 / 1024 * 100) / 100).toLocaleString(); |
|
|
socket.emit('download.progress', { downloaded, message: `[${downloaded} Mo] téléchargés` }); |
|
|
socket.emit('download.progress', { event: 'download.progress', downloaded, message: `[${downloaded} Mo] téléchargés` }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -27,17 +27,17 @@ const configure = (socket) => { |
|
|
|
|
|
|
|
|
// Create a new listener for the parse start event
|
|
|
// Create a new listener for the parse start event
|
|
|
emitter.on('parse.start', ({ filepath, columns, headers, result }) => { |
|
|
emitter.on('parse.start', ({ filepath, columns, headers, result }) => { |
|
|
socket.emit('parse.start', { message: 'Début de traitement' }); |
|
|
socket.emit('parse.start', { event: 'parse.start', message: 'Début de traitement' }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create a new listener for the parse.end event
|
|
|
// Create a new listener for the parse.end event
|
|
|
emitter.on('parse.end', ({ filepath, columns, count, generated }) => { |
|
|
emitter.on('parse.end', ({ filepath, columns, count, generated }) => { |
|
|
socket.emit('parse.end', { message: 'Traitement terminé', generated }); |
|
|
socket.emit('parse.end', { event: 'parse.end', message: 'Traitement terminé', generated }); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Create a new listener for the parse.error event
|
|
|
// Create a new listener for the parse.error event
|
|
|
emitter.on('parse.error', ({ filepath, columns, error }) => { |
|
|
emitter.on('parse.error', ({ filepath, columns, error }) => { |
|
|
socket.emit('parse.error', { message: 'Erreur lors du traitement' }); |
|
|
socket.emit('parse.error', { event: 'parse.error', message: 'Erreur lors du traitement' }); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|