changeset 12:6115cfbece79

added option "Configuration"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Jun 2023 08:45:44 +0200
parents 16b9f1ff491d
children 4ef286d0f78e
files Sources/Plugin.cpp
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Sources/Plugin.cpp	Sun Jun 18 15:27:50 2023 +0200
+++ b/Sources/Plugin.cpp	Mon Jun 19 08:45:44 2023 +0200
@@ -493,6 +493,7 @@
 
 
 static ResourcesCache               cache_;
+static std::string                  userConfiguration_;
 static std::string                  routerBasename_;
 static DataSource                   dataSource_;
 static bool                         preload_;
@@ -520,17 +521,16 @@
 
   if (uri == "app-config.js")
   {
-    std::string system, user;
+    std::string system;
     Orthanc::EmbeddedResources::GetFileResource(system, Orthanc::EmbeddedResources::APP_CONFIG_SYSTEM);
-    Orthanc::EmbeddedResources::GetFileResource(user, Orthanc::EmbeddedResources::APP_CONFIG_USER);
-    
+
     std::map<std::string, std::string> dictionary;
     dictionary["ROUTER_BASENAME"] = routerBasename_;
     dictionary["USE_DICOM_WEB"] = (dataSource_ == DataSource_DicomWeb ? "true" : "false");
 
     system = Orthanc::Toolbox::SubstituteVariables(system, dictionary);
 
-    std::string s = (user + "\n" + system);
+    std::string s = (userConfiguration_ + "\n" + system);
     OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json");
   }
   else if (uri == "" ||      // Study list
@@ -874,8 +874,9 @@
         globalConfiguration.GetSection(configuration, "OHIF");
       }
 
-      routerBasename_ = configuration.GetStringValue("RouterBasename", "/ohif");
+      routerBasename_ = configuration.GetStringValue("RouterBasename", "/ohif/");
       std::string s = configuration.GetStringValue("DataSource", "dicom-json");
+      std::string userConfigurationPath = configuration.GetStringValue("Configuration", "");
       preload_ = configuration.GetBooleanValue("Preload", true);
 
       if (s == "dicom-web")
@@ -893,6 +894,15 @@
                                         "\"dicomweb\" or \"dicom-json\", but found: " + s);
       }
 
+      if (userConfigurationPath.empty())
+      {
+        Orthanc::EmbeddedResources::GetFileResource(userConfiguration_, Orthanc::EmbeddedResources::APP_CONFIG_USER);
+      }
+      else
+      {
+        Orthanc::SystemToolbox::ReadFile(userConfiguration_, userConfigurationPath);
+      }
+
       // Make sure that the router basename ends with a trailing slash
       if (routerBasename_.empty() ||
           routerBasename_[routerBasename_.size() - 1] != '/')