Commits

Chris Mutel committed 19061fb

Add report uploads

Comments (0)

Files changed (5)

         cpu_count = config.p.get("cpu_cores", None)
         report = SerializedLCAReport(fu, method, iterations, cpu_count)
         report.calculate()
+        if config.p.get("upload_reports", False) and \
+                config.p.get("report_server_url", None):
+            url = config.p["report_server_url"]
+            if url[-1] != "/":
+                url += "/"
+            r = requests.post(url + "upload",
+                data=JsonWrapper.dumps(report.report),
+                headers={'content-type': 'application/json'}
+                )
+            if r.status_code == 200:
+                report.report["metadata"]["online"] = url + "report/" + report.uuid
         report.write()
-        # TODO: upload?
         return report.uuid
 
 

bw2ui/web/templates/report.html

 {% endblock %}
 
 {% block body %}
+<div id="online-report"></div>
 <div class="span-15 colborder">
 	<h2 style="margin-bottom: 0">Functional unit:</h2>
 	<ul style="margin-bottom: 0" id="activity"></ul>
 </div>
 
 <script type="text/javascript">
-$(document).ready( function() {  
+$(document).ready( function() {
   var report_data = {{ data|safe }},
-    activity = "";  
+    activity = "";
 
   // Replace DOM elements with correct content
   $('#herfindahl').html(report_data.contribution.herfindahl.toPrecision(2));
   };
   $('#activity').html(activity);
 
+  if ("online" in report_data.metadata) {
+    $("#online-report").html('<p class="success">This report also available online: <a href="' + report_data.metadata.online + '">' + report_data.metadata.online + '</a></p>');
+  };
+
   // Insert graphics
   hinton_matrix(report_data.contribution.hinton.results, report_data.contribution.hinton.total, report_data.contribution.hinton.xlabels, report_data.contribution.hinton.ylabels, "#hinton", 560, 560, 10);
   stepped_histogram(report_data["monte carlo"], report_data.method.unit, "#ihist", 680, 300, 10);
   }
 });
 </script>
-{% endblock %}
+{% endblock %}

bw2ui/web/templates/select.html

         for (var i = data.length - 1; i >= 0; i--) {
             value.push([data[i][4], data[i][0]]);
         };
-        console.log(value);
         return value;
     }
 

bw2ui/web/templates/settings.html

       success: function (a) {
         $('form input[name=iterations]').attr("value", a);
         $("#speedtest").html("Test again");
-        console.log(a);
       }
     });
   });
 
 setup(
   name='bw2ui',
-  version="0.5",
+  version="0.5.1",
   packages=["bw2ui", "bw2ui.web"],
   package_data={'bw2ui.web': [
     "static/blueprint/*.css",
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.