Mercurial > hg > orthanc-webviewer
changeset 19:20af33af313a
is-stable-series
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 09 Apr 2015 16:41:49 +0200 |
parents | 54d5dd1df2e5 |
children | fcbc8e77cf8f |
files | Plugin/Plugin.cpp WebApplication/viewer.js |
diffstat | 2 files changed, 51 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/Plugin.cpp Tue Apr 07 17:09:25 2015 +0200 +++ b/Plugin/Plugin.cpp Thu Apr 09 16:41:49 2015 +0200 @@ -215,6 +215,53 @@ +static int32_t IsStableSeries(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + try + { + if (request->method != OrthancPluginHttpMethod_Get) + { + OrthancPluginSendMethodNotAllowed(context_, output, "GET"); + return 0; + } + + const std::string id = request->groups[0]; + Json::Value series; + + if (OrthancPlugins::GetJsonFromOrthanc(series, context_, "/series/" + id) && + series.type() == Json::objectValue) + { + bool value = (series["IsStable"].asBool() || + series["Status"].asString() == "Complete"); + std::string answer = value ? "true" : "false"; + OrthancPluginAnswerBuffer(context_, output, answer.c_str(), answer.size(), "application/json"); + } + else + { + OrthancPluginSendHttpStatusCode(context_, output, 404); + } + + return 0; + } + catch (Orthanc::OrthancException& e) + { + OrthancPluginLogError(context_, e.What()); + return -1; + } + catch (std::runtime_error& e) + { + OrthancPluginLogError(context_, e.what()); + return -1; + } + catch (boost::bad_lexical_cast&) + { + OrthancPluginLogError(context_, "Bad lexical cast"); + return -1; + } +} + extern "C" { @@ -328,6 +375,7 @@ /* Install the callbacks */ OrthancPluginRegisterRestCallback(context_, "/web-viewer/series/(.*)", ServeCache<CacheBundle_SeriesInformation>); + OrthancPluginRegisterRestCallback(context_, "/web-viewer/is-stable-series/(.*)", IsStableSeries); OrthancPluginRegisterRestCallback(context_, "/web-viewer/instances/(.*)", ServeCache<CacheBundle_DecodedImage>); OrthancPluginRegisterRestCallback(context, "/web-viewer/libs/(.*)", ServeEmbeddedFolder<EmbeddedResources::JAVASCRIPT_LIBS>);
--- a/WebApplication/viewer.js Tue Apr 07 17:09:25 2015 +0200 +++ b/WebApplication/viewer.js Thu Apr 09 16:41:49 2015 +0200 @@ -385,13 +385,12 @@ $.ajax({ type: 'GET', - url: '../../series/' + series, + url: '../is-stable-series/' + series, dataType: 'json', cache: false, async: true, - success: function(series) { - if (!series.IsStable && - series.Status != 'Complete') { + success: function(stable) { + if (!stable) { $('#unstable').show(); } }