|
|
@ -1,6 +1,7 @@ |
|
|
|
import $ from 'jquery'; |
|
|
|
import 'bootstrap'; |
|
|
|
import toastr from 'toastr'; |
|
|
|
import io from 'socket.io-client'; |
|
|
|
|
|
|
|
/*********************************************** |
|
|
|
* MAIN JS FILE |
|
|
@ -113,7 +114,42 @@ const initSubmitForm = () => { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const initSocket = () => { |
|
|
|
const socket = io(); |
|
|
|
|
|
|
|
socket.on('connect', function() { |
|
|
|
console.log('Connected to server'); |
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('disconnect', function() { |
|
|
|
console.log('Disconnected from server'); |
|
|
|
}); |
|
|
|
|
|
|
|
const events = [ |
|
|
|
'download.start', |
|
|
|
'download.started', |
|
|
|
'download.end', |
|
|
|
'download.error', |
|
|
|
'download.progress', |
|
|
|
'parse.start', |
|
|
|
'parse.end', |
|
|
|
'parse.error' |
|
|
|
]; |
|
|
|
for(let event of events) { |
|
|
|
socket.on(event, function(data) { |
|
|
|
if (event.includes('error')) { |
|
|
|
toastr.error(data.message); |
|
|
|
return; |
|
|
|
} |
|
|
|
toastr.info(data.message); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
$(document).ready(function() { |
|
|
|
initColumnsChoices(); |
|
|
|
initSubmitForm(); |
|
|
|
|
|
|
|
initSocket(); |
|
|
|
}); |
|
|
|