diff --git a/resources/css/style.css b/resources/css/style.css index 541082c..13e9bb4 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -2,6 +2,7 @@ body { font-size: 18px; height: 100%; background-color: #FFF; + min-width:555px; } /*-------- Navbar --------*/ diff --git a/resources/index.html b/resources/index.html index 1f6c726..fef7869 100644 --- a/resources/index.html +++ b/resources/index.html @@ -246,7 +246,7 @@ Your Solution Best Solution Download - + Submit @@ -254,8 +254,10 @@ ulysses16 - Inf - - txt    json + +
+ txt    json +
@@ -265,8 +267,10 @@ att48 - Inf - - txt    json + +
+ txt    json +
@@ -276,8 +280,10 @@ st70 - Inf - - txt    json + +
+ txt    json +
@@ -287,8 +293,10 @@ a280 - Inf - - txt    json + +
+ txt    json +
@@ -298,8 +306,10 @@ pcb442 - Inf - - txt    json + +
+ txt    json +
@@ -309,8 +319,10 @@ dsj1000 - Inf - - txt    json + +
+ txt    json +
@@ -337,6 +349,18 @@
+
+ + +
+
+ + +
+
+ + +
diff --git a/resources/js/script.js b/resources/js/script.js index 68c411a..6b39872 100644 --- a/resources/js/script.js +++ b/resources/js/script.js @@ -48,12 +48,12 @@ $( document ).ready( () => { $('#pcb442_download').hide(); $('#dsj1000_download').hide(); - $('#ulysses16_submit').hide(); - $('#att48_submit').hide(); - $('#st70_submit').hide(); - $('#a280_submit').hide(); - $('#pcb442_submit').hide(); - $('#dsj1000_submit').hide(); + $('#ulysses16_submit').prop('disabled', true); + $('#att48_submit').prop('disabled', true); + $('#st70_submit').prop('disabled', true); + $('#a280_submit').prop('disabled', true); + $('#pcb442_submit').prop('disabled', true); + $('#dsj1000_submit').prop('disabled', true); $( "#ulysses16_submit" ).click(function() { if (check_submit_info()) @@ -104,6 +104,39 @@ $( document ).ready( () => { } }); + // User option + var user_option = {}; + user_option.easy = true; + user_option.medium = false; + user_option.difficult = false; + + $('#inlineCheckbox1').change(function() { + if (this.checked) { + user_option.easy = true; + } else { + user_option.easy = false; + } + socket.emit('option', user_option); + }); + + $('#inlineCheckbox2').change(function() { + if (this.checked) { + user_option.medium = true; + } else { + user_option.medium = false; + } + socket.emit('option', user_option); + }); + + $('#inlineCheckbox3').change(function() { + if (this.checked) { + user_option.difficult = true; + } else { + user_option.difficult = false; + } + socket.emit('option', user_option); + }); + // Initialize file uploader // initialize with defaults // $("#uploadfile").fileinput(); @@ -149,15 +182,18 @@ $( document ).ready( () => { $("#btnSubmit").click((event) => { // stop submit the form, we will post it manually. event.preventDefault(); + // Hide submit - $('#ulysses16_submit').hide(); - $('#att48_submit').hide(); - $('#st70_submit').hide(); - $('#a280_submit').hide(); - $('#pcb442_submit').hide(); - $('#dsj1000_submit').hide(); + $('#ulysses16_submit').prop('disabled', true); + $('#att48_submit').prop('disabled', true); + $('#st70_submit').prop('disabled', true); + $('#a280_submit').prop('disabled', true); + $('#pcb442_submit').prop('disabled', true); + $('#dsj1000_submit').prop('disabled', true); + $("#submit_name").val(''); $("#submit_desc").val(''); + // Hide Download $('#ulysses16_download').hide(); $('#att48_download').hide(); @@ -194,14 +230,12 @@ function check_submit_info() { } function disable_btn(btn) { - btn.show(); btn.removeClass('btn-primary'); btn.text('Submitted'); btn.prop('disabled', true); } function enable_btn(btn) { - btn.show(); btn.addClass('btn-primary'); btn.text('Submit'); btn.prop('disabled', false); diff --git a/resources/js/socket_script.js b/resources/js/socket_script.js index 3d9f9b7..7d75943 100644 --- a/resources/js/socket_script.js +++ b/resources/js/socket_script.js @@ -150,12 +150,12 @@ socket.on('result', (res) => { res = JSON.parse(res); - $("#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").text('-'); + $("#att48_your").text('-'); + $("#st70_your").text('-'); + $("#a280_your").text('-'); + $("#pcb442_your").text('-'); + $("#dsj1000_your").text('-'); $("#ulysses16_your").removeClass('blink_me'); $("#att48_your").removeClass('blink_me'); diff --git a/server.js b/server.js index 4124953..a4a005e 100644 --- a/server.js +++ b/server.js @@ -181,7 +181,16 @@ var update_submission = (socket, sessionID) => { var check_time = 0 -var docker_build = (socket, sessionID) => { +var docker_build = (socket, sessionID, option) => { + + options = "" + if (option.easy) + options += " -e " + if (option.medium) + options += " -m " + if (option.difficult) + options += " -d " + check_time = 0 console.log('[server][start]', sessionID) socket.emit('start') @@ -198,7 +207,8 @@ var docker_build = (socket, sessionID) => { '/uploads/' + sessionID.toString() + '/my_model.py:/tsp/model/my_model.py', "/output/" + sessionID.toString() + "/:/output/" ] - } + }, + Cmd: ['/bin/bash', '-c', 'python main.py' + options + '; mkdir -p /output && cp -r output/* /output'] }) .then( (container) => { // Start container @@ -295,6 +305,7 @@ var docker_build = (socket, sessionID) => { var clients = 0 io.on('connection', (socket) => { + // New client connected const sessionID = socket.id console.log('[client][connection]', sessionID) @@ -307,6 +318,17 @@ io.on('connection', (socket) => { // console.log(leaderboard) socket.emit('leaderboard', leaderboard) + user_option = {} + user_option.easy = true + user_option.medium = false + user_option.difficult = false + + // Client change build option + socket.on('option', (option) => { + console.log('[client][option]', option) + user_option = option + }) + // Client disconnected socket.on('disconnect', () => { clients = clients - 1 @@ -317,7 +339,7 @@ io.on('connection', (socket) => { // Client request a build socket.on('build', () => { console.log('[client][build]', sessionID) - docker_build(socket, sessionID) + docker_build(socket, sessionID, user_option) }) // Client submited a new result