ohif-viewer/docs/latest/deployment/recipes/embedded-viewer.md

102 lines
3.0 KiB
Markdown
Raw Normal View History

2019-04-28 18:52:10 +02:00
# Embedded Viewer
The quickest and easiest way to get the OHIF Viewer up and running is to embed
it into an existing web application. It allows us to forego a "build step", and
add a powerful medical imaging viewer to an existing web page using only a few
include tags. Here's how it works:
2019-04-28 19:44:33 +02:00
{% include "./../_embedded-viewer-diagram.md" %}
2019-04-28 18:52:10 +02:00
1. Create a new web page or template that includes the following external
dependencies:
<ul>
<li>
<a href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700&display=swap">
<code>Google Font: Roboto</code>
2019-04-28 18:52:10 +02:00
</a>
</li>
<li>
<a href="https://unpkg.com/react@16/umd/react.production.min.js">
<code>react@16.8.6</code>
</a>
</li>
<li>
<a href="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js">
<code>react-dom@16.8.6</code>
</a>
</li>
<li>
<a href="https://unpkg.com/@ohif/viewer">
<code>@ohif/viewer@latest</code>
2019-04-28 18:52:10 +02:00
</a>
</li>
</ul>
<ol start="2">
<li>Create a JS Object to hold the OHIF Viewer's configuration. Here are some
example values that would allow the viewer to hit our public PACS:</li>
</ol>
```js
2019-05-22 21:57:35 +02:00
// Set before importing `ohif-viewer`
window.config = {
// default: '/'
2019-04-28 18:52:10 +02:00
routerBasename: '/',
servers: {
dicomWeb: [
{
name: 'DCM4CHEE',
wadoUriRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/wado',
qidoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
wadoRoot: 'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs',
qidoSupportsIncludeField: true,
imageRendering: 'wadors',
thumbnailRendering: 'wadors',
requestOptions: {
requestFromBrowser: true,
},
},
],
},
};
2019-04-28 18:52:10 +02:00
```
2019-04-28 18:58:25 +02:00
<ol start="5"><li>
2019-04-28 18:52:10 +02:00
Render the viewer in the web page's target <code>div</code>
</li></ol>
```js
// Made available by the `@ohif/viewer` script included in step 1
var Viewer = window.OHIFStandaloneViewer.App;
var app = React.createElement(Viewer, window.config, null);
2019-04-28 18:52:10 +02:00
ReactDOM.render(app, document.getElementById('ohif-viewer-target'));
2019-04-28 18:52:10 +02:00
```
#### Tips & Tricks
> I'm having trouble getting this to work. Where can I go for help?
2019-05-28 16:06:54 +02:00
First, check out this fully functional [CodeSandbox][code-sandbox] example. If
you're still having trouble, feel free to search or GitHub issues. Can't find
anything related your problem? Create a new one.
2019-04-28 18:52:10 +02:00
> My application's styles are impacting the OHIF Viewer's look and feel. What
> can I do?
2019-04-28 18:52:10 +02:00
When you include stylesheets and scripts, they are added globally. This has the
potential of causing conflicts with other scripts and styles on the page. To
prevent this, `embed` the viewer in a new/empty web page. Have that working?
Good. Now `embed` that new page using an
2019-04-28 18:52:10 +02:00
[`<iframe>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
This should produce the expected result while also protecting your page from any
globally defined styles/scripts.
2019-05-28 16:06:54 +02:00
<!--
LINKS
-->
2019-05-28 16:06:54 +02:00
[code-sandbox]: https://codesandbox.io/s/ohif-viewer-script-tag-usage-b3st9