mirror of
https://github.com/simonw/datasette-vega.git
synced 2026-09-19 06:54:26 +02:00
Merge a391cbb902 into 1db45bd8f1
This commit is contained in:
commit
76849ef6df
2 changed files with 23 additions and 2 deletions
|
|
@ -27,3 +27,19 @@ def extra_css_urls():
|
|||
@hookimpl
|
||||
def extra_js_urls():
|
||||
return cached_filepaths_for_extension('js')
|
||||
|
||||
@hookimpl
|
||||
def extra_body_script(template, database, table, datasette):
|
||||
config = (
|
||||
datasette.plugin_config("datasette-vega", database=database, table=table)
|
||||
or {}
|
||||
)
|
||||
js = []
|
||||
value = config.get("container")
|
||||
if value:
|
||||
js.append(
|
||||
"window.DATASETTE_VEGA_{} = '{}';".format(
|
||||
"CONTAINER", value
|
||||
)
|
||||
)
|
||||
return "\n".join(js)
|
||||
|
|
|
|||
|
|
@ -47,8 +47,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
jsonUrl = jsonEl.getAttribute('href');
|
||||
// Create elements for adding graph tool to page
|
||||
visTool = document.createElement('div');
|
||||
let table = document.querySelector('table.rows-and-columns');
|
||||
table.parentNode.insertBefore(visTool, table);
|
||||
const container = window.DATASETTE_VEGA_CONTAINER;
|
||||
if (container && document.querySelector(container)) {
|
||||
document.querySelector(container).appendChild(visTool);
|
||||
} else {
|
||||
let table = document.querySelector('table.rows-and-columns');
|
||||
table.parentNode.insertBefore(visTool, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (jsonUrl) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue