Skip to content

Commit

Permalink
Merge pull request galaxyproject#19151 from guerler/update_tiff_viewer
Browse files Browse the repository at this point in the history
Update tiff viewer to use script entry_point
  • Loading branch information
guerler authored Nov 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 747bced + f94b53e commit 65d807c
Showing 2 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE visualization SYSTEM "../../visualization.dtd">
<visualization name="Tiff Viewer">
<description>Basic Tiff Image visualization</description>
<description>Tiff Image Viewer</description>
<data_sources>
<data_source>
<model_class>HistoryDatasetAssociation</model_class>

<test type="isinstance" test_attr="datatype" result_type="datatype">images.Tiff</test>

<to_param param_attr="id">dataset_id</to_param>
</data_source>
</data_sources>
<params>
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param>
</params>
<entry_point entry_point_type="chart" src="script.js" css="script.css"/>
<entry_point entry_point_type="script" src="script.js" css="script.css"/>
</visualization>
29 changes: 11 additions & 18 deletions config/plugins/visualizations/tiffviewer/src/script.js
Original file line number Diff line number Diff line change
@@ -8,22 +8,15 @@ const App = (props) => {
return <TIFFViewer tiff={props.dataset_url} paginate="bottom" />;
};

/* This will be part of the charts/viz standard lib in 23.1 */
const slashCleanup = /(\/)+/g;
function prefixedDownloadUrl(root, path) {
return `${root}/${path}`.replace(slashCleanup, "/");
}
const { root, visualization_config } = JSON.parse(document.getElementById("app").dataset.incoming);

window.bundleEntries = window.bundleEntries || {};
window.bundleEntries.load = function (options) {
const dataset = options.dataset;
const url = prefixedDownloadUrl(options.root, dataset.download_url);
const root = createRoot(document.getElementById(options.target));
root.render(
<StrictMode>
<App dataset_url={url} />
</StrictMode>
);
options.chart.state("ok", "Done.");
options.process.resolve();
};
const datasetId = visualization_config.dataset_id;

const url = window.location.origin + root + "api/datasets/" + datasetId + "/display";

const rootElement = createRoot(document.getElementById("app"));
rootElement.render(
<StrictMode>
<App dataset_url={url} />
</StrictMode>
);

0 comments on commit 65d807c

Please sign in to comment.