Skip to content

Commit

Permalink
Successfully had a JBrowse2 appear using a URL pointing to a config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
carolyncaron committed Apr 17, 2024
1 parent f9822e5 commit bdb4f91
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
38 changes: 23 additions & 15 deletions js/createJBrowseLinearGenomeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@ Drupal.behaviors.embedJBrowse = {
once('embedJBrowse', '#jbrowse_linear_genome_view', context).forEach(
function (element) {
console.log(drupalSettings.jbrowseUrl);
// import assembly from '/assembly.js'
// import tracks from '/tracks.js'
// const { createViewState, JBrowseLinearGenomeView } =
// JBrowseReactLinearGenomeView
// const { createElement } = React
// const { render } = ReactDOM
// const state = new createViewState({
// assembly,
// tracks,
// location: '1:100,987,269..100,987,368',
// })
// render(
// createElement(JBrowseLinearGenomeView, { viewState: state }),
// document.getElementById('jbrowse_linear_genome_view'),
// )
console.log((new Date()).toLocaleString());
Drupal.ajax({
headers: { "Content-Type": "application/json" },
url: drupalSettings.jbrowseUrl,
method: "GET",
success: function (data, status, xhr) {
console.log("Inside success!");
console.log(data);
const { createViewState, JBrowseLinearGenomeView } =
JBrowseReactLinearGenomeView
const { createElement } = React
const { render } = ReactDOM
const state = new createViewState({
assembly: data['assemblies'][0],
tracks: data['tracks'],
location: '1:100,987,269..100,987,368',
})
render(
createElement(JBrowseLinearGenomeView, { viewState: state }),
document.getElementById('jbrowse_linear_genome_view'),
)
}
}).execute();
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion tripal_jbrowse.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ react:
version: latest
js:
https://unpkg.com/react@16/umd/react.development.js: { type: external, minified: true }
https://unpkg.com/react-dom@16/umd/react-dom.development.js: { type: external, minified: true }
https://unpkg.com/react-dom@16.14.0/umd/react-dom.development.js: { type: external, minified: true }

jbrowse:
version: latest
Expand Down
3 changes: 3 additions & 0 deletions tripal_jbrowse.module
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ function template_preprocess_jbrowse_instance(array &$variables) {
$instance = $variables['elements']['#jbrowse_instance'];
$url = $instance->get('jbrowse_url')->getValue();
$variables['#attached']['drupalSettings']['jbrowseUrl'] = $url[0]['value'];

// Add our URL as an ajax trusted URL
$variables['#attached']['drupalSettings']['ajaxTrustedUrl'][$url[0]['value']] = TRUE;
}

/**
Expand Down

0 comments on commit bdb4f91

Please sign in to comment.