htmx datafusion graphs via echarts3 - no custom scripts, only alpinejs
This commit is contained in:
@@ -404,11 +404,12 @@ fn render_result(result: &QueryOutput, chart_type: &str) -> Html<String> {
|
||||
}
|
||||
_ => return error_fragment("Unknown chart type"),
|
||||
};
|
||||
let safe_option = option.to_string().replace('<', "\\u003c");
|
||||
let option = escape_html(&option.to_string());
|
||||
|
||||
Html(format!(
|
||||
"<p class=\"result-meta\">{metadata}</p><div id=\"chart\" class=\"chart\"></div>\
|
||||
<script>echarts.init(document.getElementById('chart')).setOption({safe_option});</script>"
|
||||
"<p class=\"result-meta\">{metadata}</p>\
|
||||
<div class=\"chart\" data-option=\"{option}\" \
|
||||
x-init=\"echarts.init($el).setOption(JSON.parse($el.dataset.option))\"></div>"
|
||||
))
|
||||
}
|
||||
|
||||
@@ -429,9 +430,10 @@ fn render_catalog(catalog: &GetAnalyticsCatalogResponse) -> Html<String> {
|
||||
<details class=\"llm-context\">\
|
||||
<summary>LLM schema context</summary>\
|
||||
<p class=\"hint\">Copy this entire text and include it when asking an LLM to write a query.</p>\
|
||||
<textarea id=\"llm-schema\" readonly>{}</textarea>\
|
||||
<button type=\"button\" class=\"secondary\" data-copy=\"llm-schema\">Copy context</button>\
|
||||
<span id=\"copy-status\" class=\"hint\"></span>\
|
||||
<textarea x-ref=\"llmSchema\" readonly>{}</textarea>\
|
||||
<button type=\"button\" class=\"secondary\" \
|
||||
x-on:click=\"navigator.clipboard.writeText($refs.llmSchema.value); copied = true\">Copy context</button>\
|
||||
<span class=\"hint\" x-show=\"copied\" x-cloak>Copied</span>\
|
||||
</details>",
|
||||
catalog.tables.len(),
|
||||
escape_html(&llm_context),
|
||||
@@ -453,7 +455,8 @@ fn render_catalog_table(table: &AnalyticsTable) -> String {
|
||||
details.push_str(&format!(", rounding {}", column.rounding));
|
||||
}
|
||||
format!(
|
||||
"<li><button type=\"button\" class=\"column-name\" data-insert=\"{}\">{}</button><span>{}</span></li>",
|
||||
"<li><button type=\"button\" class=\"column-name\" data-insert=\"{}\" \
|
||||
x-on:click=\"$refs.sql.setRangeText($el.dataset.insert, $refs.sql.selectionStart, $refs.sql.selectionEnd, 'end'); sql = $refs.sql.value; $refs.sql.focus()\">{}</button><span>{}</span></li>",
|
||||
escape_html("e_identifier(&column.name)),
|
||||
escape_html(&column.name),
|
||||
escape_html(&details),
|
||||
@@ -489,7 +492,8 @@ fn render_catalog_table(table: &AnalyticsTable) -> String {
|
||||
format!(
|
||||
"<details class=\"catalog-table\">\
|
||||
<summary><code>{}</code>{currency}</summary>\
|
||||
<button type=\"button\" class=\"starter-query\" data-sql=\"{}\">Use starter query</button>\
|
||||
<button type=\"button\" class=\"starter-query\" data-sql=\"{}\" \
|
||||
x-on:click=\"sql = $el.dataset.sql; $refs.sql.focus()\">Use starter query</button>\
|
||||
<ul class=\"columns\">{columns}</ul>{links}\
|
||||
</details>",
|
||||
escape_html(&table.name),
|
||||
|
||||
Reference in New Issue
Block a user