changeset 1698:8805a6a01655

"DateFormat" configuration option
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 27 Nov 2020 10:13:15 +0100
parents c2802561d7f9
children 0598c87e1e88
files Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/configuration.json Applications/StoneWebViewer/WebApplication/index.html
diffstat 3 files changed, 38 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js	Fri Nov 27 09:47:46 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/app.js	Fri Nov 27 10:13:15 2020 +0100
@@ -321,8 +321,12 @@
         if (this.studies[i].selected) {
           if (s.length > 0)
             s += ', ';
-          s += (this.studies[i].tags[STUDY_DESCRIPTION] + ' [' +
-                this.studies[i].tags[STUDY_DATE] + ']');
+          s += this.studies[i].tags[STUDY_DESCRIPTION];
+
+          var date = this.studies[i].tags[STUDY_DATE];
+          if (date.length > 0) {
+            s += ' [' + this.FormatDate(date) + ']';
+          }
         }
       }
       if (s.length == 0) 
@@ -709,6 +713,26 @@
 
         this.showWindowing = true;
       }
+    },
+    
+    FormatDate(date) {
+      if (date === undefined ||
+          date.length == 0) {
+        return '';
+      }
+      else {
+        var format = this.globalConfiguration['DateFormat'];
+        if (format === undefined) {
+          // No configuration for the date format, use the DICOM tag as such
+          return date;
+        }
+        else {
+          var year = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$1');
+          var month = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$2');
+          var day = date.replace(/^([0-9]{4})([0-9]{2})([0-9]{2})$/, '$3');
+          return format.replace(/YYYY/g, year).replace(/MM/g, month).replace(/DD/g, day);
+        }
+      }
     }
   },
   
--- a/Applications/StoneWebViewer/WebApplication/configuration.json	Fri Nov 27 09:47:46 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/configuration.json	Fri Nov 27 10:13:15 2020 +0100
@@ -5,6 +5,13 @@
   "PrintEnabled" : true,
 
   /**
+   * Defines how dates are displayed in the UI. If this option is not
+   * set, the DICOM tags will be displayed as such. "DD" will be
+   * replaced by the day, "MM" by the month, and "YYYY" by the year.
+   **/
+  // "DateFormat" : "DD/MM/YYYY",
+  
+  /**
    * The allowed origin for messages corresponding to dynamic actions
    * triggered by another Web page using "window.postMessage()". The
    * special value "*" will allow any origin, which is an insecure
--- a/Applications/StoneWebViewer/WebApplication/index.html	Fri Nov 27 09:47:46 2020 +0100
+++ b/Applications/StoneWebViewer/WebApplication/index.html	Fri Nov 27 10:13:15 2020 +0100
@@ -143,6 +143,9 @@
                       @click="study.selected = !study.selected">
                     <a>
                       {{ study.tags['0008,1030'] }}
+                      <small v-if="study.tags['0008,0020'].length > 0">
+                        [{{ FormatDate(study.tags['0008,0020']) }}]
+                      </small>
                       <span v-if="study.selected">&nbsp;<i class="fa fa-check"></i></span>
                     </a> 
                   </li>
@@ -179,7 +182,7 @@
                       <!-- Title -->
                       {{ study.tags['0008,1030'] }}
                       <br/>
-                      <small>{{ study.tags['0008,0020'] }}</small>
+                      <small>{{ FormatDate(study.tags['0008,0020']) }}</small>
                     </div>
 
                     <div class="wvStudyIsland__main">
@@ -579,7 +582,7 @@
                   </div>
                   <div v-if="'tags' in series" class="wv-overlay-topright">
                     {{ series.tags['0008,1030'] }}<br/>
-                    {{ series.tags['0008,0020'] }}<br/>
+                    {{ app.FormatDate(series.tags['0008,0020']) }}<br/>
                     {{ series.tags['0020,0011'] }} | {{ series.tags['0008,103e'] }}
                   </div>
                   <div class="wv-overlay-timeline-wrapper wvPrintExclude">