diff --git a/resources/js/socket_script.js b/resources/js/socket_script.js index 5736605..3d9f9b7 100644 --- a/resources/js/socket_script.js +++ b/resources/js/socket_script.js @@ -107,10 +107,11 @@ socket.on('info', (msg) => { socket.on('error', (msg) => { console.log(msg); Snackbar.show({ - text: msg, + text: 'Error: ' + msg, pos: 'bottom-right', - duration: 5000, - backgroundColor: '#E64A19' + duration: 8000, + backgroundColor: '#E64A19', + showAction: false }); }); @@ -147,40 +148,58 @@ function update_your_res(tsp_file, fitness) { // Update personal result socket.on('result', (res) => { - $("#resultModal").modal('show'); - res = JSON.parse(res); - $('#submission_info').show(); - res.forEach(e => { - if(e.name === "ulysses16.txt") { - my_res.ulysses16.fitness = e.fitness - my_res.ulysses16.solution = e.solution - update_your_res("ulysses16", e.fitness) - } - if(e.name === "att48.txt") { - my_res.att48.fitness = e.fitness - my_res.att48.solution = e.solution - update_your_res("att48", e.fitness) - } - if(e.name === "st70.txt") { - my_res.st70.fitness = e.fitness - my_res.st70.solution = e.solution - update_your_res("st70", e.fitness) - } - if(e.name === "a280.txt") { - my_res.a280.fitness = e.fitness - my_res.a280.solution = e.solution - update_your_res("a280", e.fitness) - } - if(e.name === "pcb442.txt") { - my_res.pcb442.fitness = e.fitness - my_res.pcb442.solution = e.solution - update_your_res("pcb442", e.fitness) - } - if(e.name === "dsj1000.txt") { - my_res.dsj1000.fitness = e.fitness - my_res.dsj1000.solution = e.solution - update_your_res("dsj1000", e.fitness) - } - }); + + $("#ulysses16_your").text('Error'); + $("#att48_your").text('Error'); + $("#st70_your").text('Error'); + $("#a280_your").text('Error'); + $("#pcb442_your").text('Error'); + $("#dsj1000_your").text('Error'); + + $("#ulysses16_your").removeClass('blink_me'); + $("#att48_your").removeClass('blink_me'); + $("#st70_your").removeClass('blink_me'); + $("#a280_your").removeClass('blink_me'); + $("#pcb442_your").removeClass('blink_me'); + $("#dsj1000_your").removeClass('blink_me'); + + if (res.length !== 0) { + + $("#resultModal").modal('show'); + $('#submission_info').show(); + + res.forEach(e => { + if(e.name === "ulysses16.txt") { + my_res.ulysses16.fitness = e.fitness + my_res.ulysses16.solution = e.solution + update_your_res("ulysses16", e.fitness) + } + if(e.name === "att48.txt") { + my_res.att48.fitness = e.fitness + my_res.att48.solution = e.solution + update_your_res("att48", e.fitness) + } + if(e.name === "st70.txt") { + my_res.st70.fitness = e.fitness + my_res.st70.solution = e.solution + update_your_res("st70", e.fitness) + } + if(e.name === "a280.txt") { + my_res.a280.fitness = e.fitness + my_res.a280.solution = e.solution + update_your_res("a280", e.fitness) + } + if(e.name === "pcb442.txt") { + my_res.pcb442.fitness = e.fitness + my_res.pcb442.solution = e.solution + update_your_res("pcb442", e.fitness) + } + if(e.name === "dsj1000.txt") { + my_res.dsj1000.fitness = e.fitness + my_res.dsj1000.solution = e.solution + update_your_res("dsj1000", e.fitness) + } + }); + } }); diff --git a/server.js b/server.js index df97ba5..8951f07 100644 --- a/server.js +++ b/server.js @@ -109,9 +109,9 @@ var update_leaderboard = (obj) => { var update_submission = (socket, sessionID) => { var output_dir = current_path.toString() + '/output/' + sessionID + '/' console.log(output_dir) + var res = [] if (output_dir.length != 0) { - var res = [] socket.emit('info', 'Got output') // Read output dir @@ -170,8 +170,11 @@ var update_submission = (socket, sessionID) => { res.push(obj) } }) - socket.emit('result', JSON.stringify(res)) }) + if (res.length === 0) { + socket.emit('error', 'Please check my_model.py') + } + socket.emit('result', JSON.stringify(res)) } else { console.log('no result')