# HG changeset patch # User Sebastien Jodogne # Date 1687016705 -7200 # Node ID e8e7ba4371e3d50c3ba59dd4913523e9b10cca09 # Parent 8c1fe0ca24f57f36d476e713dc5f682f27b9abf8 fix access to OHIF study list diff -r 8c1fe0ca24f5 -r e8e7ba4371e3 Sources/OrthancExplorer.js --- a/Sources/OrthancExplorer.js Fri Jun 16 15:51:40 2023 +0200 +++ b/Sources/OrthancExplorer.js Sat Jun 17 17:45:05 2023 +0200 @@ -53,3 +53,31 @@ } }); }); + + +if (${USE_DICOM_WEB}) { + $('#lookup').live('pagebeforeshow', function() { + $('#open-ohif-study-list').remove(); + + var b = $('
') + .attr('id', 'open-ohif-study-list') + .addClass('ui-grid-b') + .append($('
') + .addClass('ui-block-a')) + .append($('
') + .addClass('ui-block-b') + .append($('') + .attr('id', 'coucou') + .attr('data-role', 'button') + .attr('href', '#') + .attr('data-icon', 'forward') + .attr('data-theme', 'a') + .text('Open OHIF study list') + .button() + .click(function(e) { + window.open('../ohif/'); + }))); + + b.insertAfter($('#lookup-result')); + }); +} diff -r 8c1fe0ca24f5 -r e8e7ba4371e3 Sources/Plugin.cpp --- a/Sources/Plugin.cpp Fri Jun 16 15:51:40 2023 +0200 +++ b/Sources/Plugin.cpp Sat Jun 17 17:45:05 2023 +0200 @@ -345,7 +345,11 @@ OrthancPluginSetHttpHeader(context, output, "Cross-Origin-Opener-Policy", "same-origin"); OrthancPluginSetHttpHeader(context, output, "Cross-Origin-Resource-Policy", "same-origin"); - const std::string uri = request->groups[0]; + std::string uri; + if (request->groupsCount > 0) + { + uri = request->groups[0]; + } if (uri == "app-config.js") { @@ -362,8 +366,12 @@ std::string s = (user + "\n" + system); OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json"); } - else if (uri == "viewer") - { + else if (uri == "" || // Study list + uri == "tmtv" || // Total metabolic tumor volume + uri == "viewer") // Default viewer (including MPR) + { + // Those correspond to the different modes of the OHIF platform: + // https://v3-docs.ohif.org/platform/modes/ cache_.Answer(context, output, "index.html"); } else @@ -545,27 +553,6 @@ } -static OrthancPluginErrorCode RedirectRoot(OrthancPluginRestOutput* output, - const char* url, - const OrthancPluginHttpRequest* request) -{ - OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); - - if (request->method != OrthancPluginHttpMethod_Get) - { - OrthancPluginSendMethodNotAllowed(context, output, "GET"); - } - else - { - // TODO - Is there a better way to go to the list of studies in DICOMweb? - // TODO - What if not using DICOMweb? - OrthancPluginRedirect(context, output, "ohif/viewer?StudyInstanceUIDs="); - } - - return OrthancPluginErrorCode_Success; -} - - OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, OrthancPluginResourceType resourceType, const char* resourceId) @@ -644,9 +631,16 @@ routerBasename_ = configuration.GetStringValue("RouterBasename", "/ohif"); useDicomWeb_ = configuration.GetBooleanValue("DicomWeb", false); + // Make sure that the router basename ends with a trailing slash + if (routerBasename_.empty() || + routerBasename_[routerBasename_.size() - 1] != '/') + { + routerBasename_ += "/"; + } + OrthancPluginSetDescription(context, "OHIF plugin for Orthanc."); - OrthancPluginRegisterRestCallback(context, "/ohif", RedirectRoot); + OrthancPlugins::RegisterRestCallback("/ohif", true); OrthancPlugins::RegisterRestCallback("/ohif/(.*)", true); OrthancPlugins::RegisterRestCallback("/ohif-source/(.*)", true);