Skip to content

Commit

Permalink
[IDC-2006] - optional mailTo for debugging extension. (#2027)
Browse files Browse the repository at this point in the history
* WIP debug dialog

* Rename the p10 downloader extension to debugger extension, add button to toolbar. Deactivate it by default.

* Fix unit tests

* WIP

* WIP

* Finish mailTo
  • Loading branch information
JamesAPetts authored Sep 17, 2020
1 parent 5a78da8 commit 42803b0
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 12 deletions.
5 changes: 5 additions & 0 deletions extensions/debugging/src/DebugReportModal.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
padding: 10px 0 10px;
color: var(--active-color);
}

.debug-report-modal-container {
display: flex;
flex-direction: column;
}
104 changes: 95 additions & 9 deletions extensions/debugging/src/DebugReportModal.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,108 @@
import React from 'react';
import { detect } from 'detect-browser';
import './DebugReportModal.css';
import { ToolbarButton } from '@ohif/ui';

const DubugReportModal = ({
viewports,
studies,
servers,
extensionManager,
mailTo,
}) => {
const mailToFunction = () => {
const StudyInstanceUID = Object.keys(studies.studyData)[0];

const subject = encodeURI(`Issue with Study: ${StudyInstanceUID}`);

let body = `Enter the description of your problem here: \n\n\n`;

body += `============= SESSION INFO =============\n\n`;

// App version

body += '== App ==\n';
body += `version\t${window.version}\n\n`;

// Extensions Versions

body += '== Extensions Versions ==\n';

const { registeredExtensionVesions } = extensionManager;

Object.keys(registeredExtensionVesions).forEach(extensionId => {
const version = registeredExtensionVesions[extensionId];

body += `${extensionId}\t${version}\n`;
});

body += '\n';

// Browser Info

const browser = detect();

const { name, os, type, version } = browser;

body += '== Browser Info ==\n';
body += `name\t ${name}\n`;
body += `os\t ${os}\n`;
body += `type\t ${type}\n`;
body += `version\t ${version}\n\n`;

// Study URL
body += '== URL ==\n';
body += `URL\t ${window.location.href}\n\n`;

// Layout

const { numRows, numColumns, viewportSpecificData } = viewports;

body += '== Viewport Layout ==\n';
body += `Rows\t${numRows}\n`;
body += `Columns\t${numColumns}\n\n`;

body += '== Viewports ==\n';

Object.keys(viewportSpecificData).forEach(viewportIndex => {
const vsd = viewportSpecificData[viewportIndex];

const [row, column] = _viewportIndexToViewportPosition(
viewportIndex,
numColumns
);

body += `[${row},${column}]\t${vsd.SeriesInstanceUID}\n`;
});

// TODO Text dump of rest of stuff.

body = encodeURI(body);

window.location.href = `mailto:${mailTo}?subject=${subject}&body=${body}`;
};

return (
<div>
<table>
{getAppVersion()}
{getExtensionVersions(extensionManager)}
{getBrowserInfo()}
{getCurrentStudyUrl()}
{getLayout(viewports)}
</table>
<div className="debug-report-modal-container">
{mailTo ? (
<div>
<ToolbarButton
label={'Send Bug Report'}
onClick={mailToFunction}
icon={'envelope-square'}
isActive={false}
/>
</div>
) : null}
<div>
<table>
{getAppVersion()}
{getExtensionVersions(extensionManager)}
{getBrowserInfo()}
{getCurrentStudyUrl()}
{getLayout(viewports)}
</table>
</div>
</div>
);
};
Expand All @@ -39,7 +125,7 @@ const getCurrentStudyUrl = () => {
return (
<React.Fragment>
<tr>
<th className="debugReportModalHeader">App</th>
<th className="debugReportModalHeader">URL</th>
</tr>
<tr>
<td>URL</td>
Expand Down
3 changes: 3 additions & 0 deletions extensions/debugging/src/commandsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import _downloadAndZip, { downloadInstances } from './downloadAndZip';
import DebugReportModal from './DebugReportModal';
import React from 'react';

import state from './state';

const {
utils: { Queue },
} = OHIF;
Expand Down Expand Up @@ -99,6 +101,7 @@ export function getCommands(context, servicesManager, extensionManager) {
studies={studies}
servers={servers}
extensionManager={extensionManager}
mailTo={state.mailTo}
/>
);
};
Expand Down
7 changes: 6 additions & 1 deletion extensions/debugging/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getDicomWebClientFromConfig } from './utils';
import { getCommands } from './commandsModule';
import { version } from '../package.json';
import toolbarModule from './toolbarModule';
import state from './state';

/**
* Constants
Expand Down Expand Up @@ -29,11 +30,15 @@ export default {
* LIFECYCLE HOOKS
*/

preRegistration({ appConfig }) {
preRegistration({ appConfig, configuration }) {
const dicomWebClient = getDicomWebClientFromConfig(appConfig);
if (dicomWebClient) {
sharedContext.dicomWebClient = dicomWebClient;
}

if (configuration && configuration.mailTo) {
state.mailTo = configuration.mailTo;
}
},

/**
Expand Down
3 changes: 3 additions & 0 deletions extensions/debugging/src/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const state = { mailTo: undefined };

export default state;
2 changes: 2 additions & 0 deletions platform/ui/src/elements/Icon/getIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import user from './icons/user.svg';
import youtube from './icons/youtube.svg';
import eye from './icons/eye.svg';
import eyeClosed from './icons/eye-closed.svg';
import envelopeSquare from './icons/envelope-square.svg';

const ICONS = {
eye,
Expand Down Expand Up @@ -176,6 +177,7 @@ const ICONS = {
lung,
liver,
save: saveRegular,
'envelope-square': envelopeSquare,
};

/**
Expand Down
10 changes: 10 additions & 0 deletions platform/ui/src/elements/Icon/icons/envelope-square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions platform/viewer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const appProps = {
OHIFDicomPDFExtension,
OHIFDicomSegmentationExtension,
OHIFDicomRtExtension,
OHIFDicomTagBrowserExtension,
//OHIFDebuggingExtension,
//[OHIFDebuggingExtension, { mailTo: '[email protected]' }],
//OHIFDicomTagBrowserExtension,
],
};

Expand Down

0 comments on commit 42803b0

Please sign in to comment.