From 01fba58718b3b7666e94ee0a2293685fbde8d9fe Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 18 Apr 2019 20:47:24 -0700 Subject: [PATCH 1/2] sharing in progress --- gradio/static/js/share.js | 36 ++++++++++++++++++----------- gradio/templates/base_template.html | 2 +- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/gradio/static/js/share.js b/gradio/static/js/share.js index f87af80f30..a26eb2859f 100644 --- a/gradio/static/js/share.js +++ b/gradio/static/js/share.js @@ -3,23 +3,33 @@ function enable_sharing() { let name = $("#share_name").val() let email = $("#share_email").val() if (name && email) { - $.post("https://gradio.app/send_email", { - "url": config["ngrok_socket_url"], - "name": name, - "email": email - }).done(function() { - $("#share_message").text("Shared successfully."); - }).fail(function() { - $("#share_message").text("Failed to share."); - }).always(function() { - $("#share_form").hide(); - $("#share_complete").show(); - }); + $.ajax({ + "url" : "https://gradio.app/send_email", + "type": "POST", + "crossDomain": true, + "data": JSON.stringify({ + "url": config["ngrok_socket_url"], + "name": name, + "email": email + }), + "success": function() { + $("#share_message").text("Shared successfully."); + $("#share_more").text("Share more"); + }, + "error": function() { + $("#share_message").text("Failed to share."); + $("#share_more").text("Try again"); + }, + "complete": function() { + $("#share_form").hide(); + $("#share_complete").show(); + } + }) } }) } $("#share_more").click(function (evt) { $("#share_form").show(); - $("#share_complete").hide(); + $("#share_complete").hide(); }) diff --git a/gradio/templates/base_template.html b/gradio/templates/base_template.html index ea87afd794..8d86c0b1f7 100644 --- a/gradio/templates/base_template.html +++ b/gradio/templates/base_template.html @@ -32,7 +32,7 @@
- +
From 30f9f56400737f0165a30783c4a79989b3e999b0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 18 Apr 2019 22:05:03 -0700 Subject: [PATCH 2/2] fix share and flagging --- gradio/static/css/style.css | 4 +- gradio/static/js/all_io.js | 10 ++--- gradio/static/js/load_interfaces.js | 3 +- gradio/static/js/share.js | 65 ++++++++++++++++------------- gradio/templates/base_template.html | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/gradio/static/css/style.css b/gradio/static/css/style.css index 30ce0a2d6e..f0dfd1610c 100644 --- a/gradio/static/css/style.css +++ b/gradio/static/css/style.css @@ -42,13 +42,13 @@ nav img { margin-left: 5px; } #share_row input[type=text] { - background-color: #F6F6F6; + background-color: #F6F6F6; } #share_email { flex-grow: 1; max-width: 400px; } -#share_complete { +#share_complete, #share_form { display: none; } #panels { diff --git a/gradio/static/js/all_io.js b/gradio/static/js/all_io.js index 8107334757..acf70522bd 100644 --- a/gradio/static/js/all_io.js +++ b/gradio/static/js/all_io.js @@ -19,15 +19,13 @@ var io_master = { 'action': 'input', 'data': data } - ws.send(JSON.stringify(ws_data), function(e) { - console.log(e) - }) + ws.send(JSON.stringify(ws_data)) }, output: function(data) { this.last_output = data; this.output_interface.output(data); }, - flag: function(input, output, message) { + flag: function(message) { var ws_data = { 'action': 'flag', 'data': { @@ -36,9 +34,7 @@ var io_master = { 'message' : message } } - ws.send(JSON.stringify(ws_data), function(e) { - console.log(e) - }) + ws.send(JSON.stringify(ws_data)) } } diff --git a/gradio/static/js/load_interfaces.js b/gradio/static/js/load_interfaces.js index 86ddcdc3bc..4ec65878cc 100644 --- a/gradio/static/js/load_interfaces.js +++ b/gradio/static/js/load_interfaces.js @@ -54,12 +54,11 @@ $.getJSON("static/config.json", function(data) { io_master.input_interface = input_interface; output_interface.io_master = io_master; io_master.output_interface = output_interface; - enable_sharing(); }); $('body').on('click', '.flag', function(e) { if (io_master.last_output) { $(".flag").addClass("flagged"); - io_master.flag($(".flag_message").text()); + io_master.flag($(".flag_message").val()); } }) diff --git a/gradio/static/js/share.js b/gradio/static/js/share.js index a26eb2859f..dc34b4a3a9 100644 --- a/gradio/static/js/share.js +++ b/gradio/static/js/share.js @@ -1,33 +1,38 @@ -function enable_sharing() { - $("#send_link").click(function(evt) { - let name = $("#share_name").val() - let email = $("#share_email").val() - if (name && email) { - $.ajax({ - "url" : "https://gradio.app/send_email", - "type": "POST", - "crossDomain": true, - "data": JSON.stringify({ - "url": config["ngrok_socket_url"], - "name": name, - "email": email - }), - "success": function() { - $("#share_message").text("Shared successfully."); - $("#share_more").text("Share more"); - }, - "error": function() { - $("#share_message").text("Failed to share."); - $("#share_more").text("Try again"); - }, - "complete": function() { - $("#share_form").hide(); - $("#share_complete").show(); - } - }) - } - }) -} +$("#share").click(function() { + $("#share").hide() + $("#share_form").css('display', 'flex') +}) + +$("#send_link").click(function(evt) { + let name = $("#share_name").val() + let email = $("#share_email").val() + if (name && email) { + $("#send_link").attr('disabled', true); + $.ajax({ + "url" : "https://gradio.app/api/send-email/", + "type": "POST", + "crossDomain": true, + "data": JSON.stringify({ + "url": config["ngrok_socket_url"], + "name": name, + "email": email + }), + "success": function() { + $("#share_message").text("Shared successfully."); + $("#share_more").text("Share more"); + }, + "error": function() { + $("#share_message").text("Failed to share."); + $("#share_more").text("Try again"); + }, + "complete": function() { + $("#share_form").hide(); + $("#share_complete").show(); + $("#send_link").attr('disabled', false); + } + }) + } +}) $("#share_more").click(function (evt) { $("#share_form").show(); diff --git a/gradio/templates/base_template.html b/gradio/templates/base_template.html index 8d86c0b1f7..d561f75c05 100644 --- a/gradio/templates/base_template.html +++ b/gradio/templates/base_template.html @@ -24,8 +24,8 @@
+
- Share this Interface: