From e21a57572681ef04305ede83f9afc29c2f060297 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sun, 24 Mar 2024 20:52:32 +1100 Subject: [PATCH] Update function editor response view, and add execution timer --- templates/function_editor.html | 80 +++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 30 deletions(-) diff --git a/templates/function_editor.html b/templates/function_editor.html index d5ae749..9c13dbc 100644 --- a/templates/function_editor.html +++ b/templates/function_editor.html @@ -179,6 +179,8 @@ }; var environment_info = editor_environment.getValue().trim(); + var startTime = Date.now(); // Start timing + // Send the code and request object to the server fetch("{{ url_for('execute_code', playground='true') }}", { method: 'POST', @@ -193,38 +195,56 @@ }) .then(text => { try { + var endTime = Date.now(); // End timing + const data = JSON.parse(text); // Try to parse the response as JSON const output_el = document.querySelector('#output') - let output_html = ` -
-
-
-
-
-
-
-
-

Response: ${data?.result?.status}

-
-
- ${data.status == 'SUCCESS' ? data.result.body : data.result} -
-
-
-
-
-
-
-
-
-

logs

-
-
- ${data.logs ? data.logs.map(log => `

${log}

`).join('\n') : ''} -
-
-
` + + let output_html = + `
+
+
+
+ + + + Logs ${data.logs ? `(${data.logs.length})` : ''} +
+
+ + + + + Browser Preview +
+
+ +
+ + + +
+
+
+
${data.status == 'SUCCESS' ? data.result.body : data.result}
+ +
+
+
+ Status: ${data?.result?.status || "Error"} + Time: ${endTime - startTime}ms +
+
+
` output_el.innerHTML = output_html; } catch (err) { @@ -338,7 +358,7 @@ -
+