From 2c982b4ccf71823b82a3924234a4687543234b75 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 23 Nov 2020 09:35:08 +0300 Subject: [PATCH 1/5] Fix race condition; history and sharing capabilities --- programs/server/play.html | 92 ++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/programs/server/play.html b/programs/server/play.html index 22eea0002ca..eabeb6b71ad 100644 --- a/programs/server/play.html +++ b/programs/server/play.html @@ -30,17 +30,6 @@ It can be done in background, e.g. wait 100 ms after address/credentials change and do the check. Also it can provide visual indication that credentials are correct. - 3. Add history in localstorage. Integrate with history API. - There can be a counter in localstorage, that will be appended to location #fragment. - The 'back', 'forward' buttons in browser should work. - Also there should be UI element to list all the queries from history and select from the list. - - 4. Trivial sharing capabilities. - Sharing is only possible when system.query_log is accessible. Read the X-ClickHouse-QueryId from the response. - Share button will: - emit SYSTEM FLUSH LOGS if not readonly; - find the query in the query_log; - - generate an URL with the query id and: server address if not equal to the URL's host; user name if not default; - indication that password should be entered in case of non-empty password. - --> @@ -275,6 +292,8 @@
 (Ctrl+Enter) + + 🌑🌞
@@ -319,6 +338,9 @@ xhr.open('POST', url, true); xhr.send(query); + document.getElementById('check-mark').style.display = 'none'; + document.getElementById('hourglass').style.display = 'inline'; + xhr.onreadystatechange = function() { if (posted_request_num != request_num) { @@ -348,6 +370,8 @@ } function renderResponse(status, response) { + document.getElementById('hourglass').style.display = 'none'; + if (status === 200) { var json; try { json = JSON.parse(response); } catch (e) {} @@ -356,6 +380,7 @@ } else { renderUnparsedResult(response); } + document.getElementById('check-mark').style.display = 'inline'; } else { /// TODO: Proper rendering of network errors. renderError(response); @@ -390,7 +415,7 @@ post(); } - document.getElementById('query').onkeypress = function(event) + document.onkeypress = function(event) { /// Firefox has code 13 for Enter and Chromium has code 10. if (event.ctrlKey && (event.charCode == 13 || event.charCode == 10)) { @@ -412,6 +437,9 @@ document.getElementById('error').style.display = 'none'; document.getElementById('stats').innerText = ''; + + document.getElementById('hourglass').style.display = 'none'; + document.getElementById('check-mark').style.display = 'none'; } function renderResult(response) From f3e567b4b4d6602949e1969c8c65eb25a5e90c7f Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 23 Nov 2020 10:15:52 +0300 Subject: [PATCH 3/5] Update roadmap --- programs/server/play.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/programs/server/play.html b/programs/server/play.html index f7f9190884c..d78a60ff83b 100644 --- a/programs/server/play.html +++ b/programs/server/play.html @@ -22,11 +22,7 @@