comparison Applications/StoneWebViewer/Plugin/Plugin.cpp @ 1713:aec45e0b2528

configuration option "DicomWebRoot"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2020 17:09:46 +0100
parents 2931f5e15320
children c6139e08132b
comparison
equal deleted inserted replaced
1712:fb57536fcc5f 1713:aec45e0b2528
25 25
26 #include <Logging.h> 26 #include <Logging.h>
27 #include <SystemToolbox.h> 27 #include <SystemToolbox.h>
28 #include <Toolbox.h> 28 #include <Toolbox.h>
29 29
30
31 static const std::string STONE_WEB_VIEWER_ROOT = "/stone-webviewer";
32
33
30 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType, 34 OrthancPluginErrorCode OnChangeCallback(OrthancPluginChangeType changeType,
31 OrthancPluginResourceType resourceType, 35 OrthancPluginResourceType resourceType,
32 const char* resourceId) 36 const char* resourceId)
33 { 37 {
34 try 38 try
171 OrthancPluginSendMethodNotAllowed(context, output, "GET"); 175 OrthancPluginSendMethodNotAllowed(context, output, "GET");
172 } 176 }
173 else 177 else
174 { 178 {
175 static const char* CONFIG_SECTION = "StoneWebViewer"; 179 static const char* CONFIG_SECTION = "StoneWebViewer";
180 static const char* ORTHANC_API_ROOT = "OrthancApiRoot";
181 static const char* DICOM_WEB_ROOT = "DicomWebRoot";
176 182
177 Json::Value config = Json::objectValue; 183 Json::Value config = Json::objectValue;
178 184
179 OrthancPlugins::OrthancConfiguration orthanc; 185 OrthancPlugins::OrthancConfiguration orthanc;
180 if (orthanc.IsSection(CONFIG_SECTION)) 186 if (orthanc.IsSection(CONFIG_SECTION))
200 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat, 206 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat,
201 "Cannot read the default configuration"); 207 "Cannot read the default configuration");
202 } 208 }
203 } 209 }
204 210
205 config[CONFIG_SECTION]["OrthancApiRoot"] = ".."; 211 assert(config[CONFIG_SECTION].type() == Json::objectValue);
206 212
213 // Assume that the Stone Web viewer is mapped at "/stone-webviewer" in the REST API
214 config[CONFIG_SECTION][ORTHANC_API_ROOT] = "..";
215
216 if (!config[CONFIG_SECTION].isMember(DICOM_WEB_ROOT))
217 {
218 config[CONFIG_SECTION][DICOM_WEB_ROOT] = "../dicom-web";
219 }
220
207 const std::string s = config.toStyledString(); 221 const std::string s = config.toStyledString();
208 OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json"); 222 OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json");
209 } 223 }
210 } 224 }
211 225
241 Orthanc::EmbeddedResources::GetFileResource( 255 Orthanc::EmbeddedResources::GetFileResource(
242 explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); 256 explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
243 OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); 257 OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());
244 258
245 OrthancPlugins::RegisterRestCallback<ServeConfiguration> 259 OrthancPlugins::RegisterRestCallback<ServeConfiguration>
246 ("/stone-webviewer/configuration.json", true); 260 (STONE_WEB_VIEWER_ROOT + "/configuration.json", true);
247 261
248 OrthancPlugins::RegisterRestCallback 262 OrthancPlugins::RegisterRestCallback
249 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_WASM> > 263 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_WASM> >
250 ("/stone-webviewer/StoneWebViewer.wasm", true); 264 (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.wasm", true);
251 265
252 OrthancPlugins::RegisterRestCallback 266 OrthancPlugins::RegisterRestCallback
253 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_JS> > 267 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WEB_VIEWER_JS> >
254 ("/stone-webviewer/StoneWebViewer.js", true); 268 (STONE_WEB_VIEWER_ROOT + "/StoneWebViewer.js", true);
255 269
256 OrthancPlugins::RegisterRestCallback 270 OrthancPlugins::RegisterRestCallback
257 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WRAPPER> > 271 <ServeEmbeddedFile<Orthanc::EmbeddedResources::STONE_WRAPPER> >
258 ("/stone-webviewer/stone.js", true); 272 (STONE_WEB_VIEWER_ROOT + "/stone.js", true);
259 273
260 OrthancPlugins::RegisterRestCallback 274 OrthancPlugins::RegisterRestCallback
261 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::IMAGES> > 275 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::IMAGES> >
262 ("/stone-webviewer/img/(.*)", true); 276 (STONE_WEB_VIEWER_ROOT + "/img/(.*)", true);
263 277
264 OrthancPlugins::RegisterRestCallback 278 OrthancPlugins::RegisterRestCallback
265 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_CSS> > 279 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_CSS> >
266 ("/stone-webviewer/css/(.*)", true); 280 (STONE_WEB_VIEWER_ROOT + "/css/(.*)", true);
267 281
268 OrthancPlugins::RegisterRestCallback 282 OrthancPlugins::RegisterRestCallback
269 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_JS> > 283 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_JS> >
270 ("/stone-webviewer/js/(.*)", true); 284 (STONE_WEB_VIEWER_ROOT + "/js/(.*)", true);
271 285
272 OrthancPlugins::RegisterRestCallback 286 OrthancPlugins::RegisterRestCallback
273 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_WEBFONTS> > 287 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::LIBRARIES_WEBFONTS> >
274 ("/stone-webviewer/webfonts/(.*)", true); 288 (STONE_WEB_VIEWER_ROOT + "/webfonts/(.*)", true);
275 289
276 OrthancPlugins::RegisterRestCallback 290 OrthancPlugins::RegisterRestCallback
277 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::WEB_APPLICATION> > 291 <ServeEmbeddedFolder<Orthanc::EmbeddedResources::WEB_APPLICATION> >
278 ("/stone-webviewer/(.*)", true); 292 (STONE_WEB_VIEWER_ROOT + "/(.*)", true);
279 293
280 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); 294 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
281 } 295 }
282 catch (...) 296 catch (...)
283 { 297 {