Переглянути джерело

Adds configuration to dashboard

Caleb Fangmeier 6 роки тому
батько
коміт
46d3f728ce
2 змінених файлів з 26 додано та 7 видалено
  1. 11 7
      filval/plotting.py
  2. 15 0
      filval/templates/dashboard.j2

+ 11 - 7
filval/plotting.py

@@ -89,7 +89,8 @@ def decl_plot(fn):
     return f
 
 
-def generate_dashboard(plots, title, output='dashboard.html', template='dashboard.j2', source_file=None, ana_source=None):
+def generate_dashboard(plots, title, output='dashboard.html', template='dashboard.j2',
+                       source=None, ana_source=None, config=None):
     from jinja2 import Environment, PackageLoader, select_autoescape
     from os.path import join, isdir
     from os import mkdir
@@ -110,11 +111,13 @@ def generate_dashboard(plots, title, output='dashboard.html', template='dashboar
             yield objects[:n]
             objects = objects[n:]
 
-    if source_file is not None:
-        with open(source_file, 'r') as this_file:
-            source = this_file.read()
-    else:
-        source = "# Not supplied!!"
+    if source is not None:
+        with open(source, 'r') as f:
+            source = f.read()
+
+    if config is not None:
+        with open(config, 'r') as f:
+            config = f.read()
 
     if not isdir('output'):
         mkdir('output')
@@ -126,7 +129,8 @@ def generate_dashboard(plots, title, output='dashboard.html', template='dashboar
             plots=get_by_n(plots, 3),
             title=title,
             source=source,
-            ana_source=ana_source
+            ana_source=ana_source,
+            config=config
         ))
     return dashboard_path
 

+ 15 - 0
filval/templates/dashboard.j2

@@ -10,6 +10,7 @@
 
   <script src="https://tttt.fangmeier.tech/hl/shCore.js"         type="text/javascript"></script>
   <script src="https://tttt.fangmeier.tech/hl/shBrushPython.js" type="text/javascript"></script>
+    <script src="https://tttt.fangmeier.tech/hl/shBrushPlain.js" type="text/javascript"></script>
   <link href="https://tttt.fangmeier.tech/hl/shCore.css"          rel="stylesheet" type="text/css" />
   <link href="https://tttt.fangmeier.tech/hl/shThemeDefault.css"  rel="stylesheet" type="text/css" />
   <script src="https://tttt.fangmeier.tech/hl/shAutoloader.js" type="text/javascript"></script>
@@ -80,17 +81,31 @@ MathJax.Hub.Config({
       <div class="panel-group" id="accordion">
         <div class="panel-heading">
           <h4 class="panel-title" style="text-align:center">
+            {% if config %}
+            <button data-toggle="collapse" data-parent="#accordion" class="btn btn-default" href="#collapseConfig">Analysis Configuration</button>
+            {% endif %}
+            {% if source %}
             <button data-toggle="collapse" data-parent="#accordion" class="btn btn-default" href="#collapseSrc">Figure Source Code</button>
+            {% endif %}
             {% if ana_source %}
             <a class="btn btn-default" href="{{ ana_source }}" target="_blank">Analysis Source Code</a>
             {% endif %}
           </h4>
         </div>
+      {% if config %}
+          <div id="collapseConfig" class="panel-collapse collapse">
+              <div class="panel-body">
+                  <script type="syntaxhighlighter" class="brush: plain"><![CDATA[ {{ config|safe}} ]]></script>
+              </div>
+          </div>
+      {% endif %}
+      {% if source %}
         <div id="collapseSrc" class="panel-collapse collapse">
           <div class="panel-body">
 <script type="syntaxhighlighter" class="brush: python"><![CDATA[ {{ source|safe}} ]]></script>
           </div>
         </div>
+      {% endif %}
       </div>
     </div>
   </div>