[ARVADOS] updated: 3716ba580adb3d9ddd5452daa8e8fdfd5b3edcc0
git at public.curoverse.com
git at public.curoverse.com
Fri Jan 31 16:42:50 EST 2014
Summary of changes:
.../workbench/app/assets/javascripts/provenance.js | 47 ++++++++++++++++++++
.../app/controllers/collections_controller.rb | 2 +-
apps/workbench/app/controllers/jobs_controller.rb | 39 ++++++++++------
.../controllers/pipeline_instances_controller.rb | 4 +-
apps/workbench/app/helpers/provenance_helper.rb | 3 +-
.../app/views/application/_svg_div.html.erb | 33 ++++++++++++++
apps/workbench/app/views/collections/show.html.erb | 46 +++----------------
apps/workbench/app/views/jobs/index.html.erb | 6 ++-
apps/workbench/app/views/jobs/show.html.erb | 5 ++
.../app/views/pipeline_instances/show.html.erb | 18 +++++++-
10 files changed, 144 insertions(+), 59 deletions(-)
create mode 100644 apps/workbench/app/assets/javascripts/provenance.js
create mode 100644 apps/workbench/app/views/application/_svg_div.html.erb
via 3716ba580adb3d9ddd5452daa8e8fdfd5b3edcc0 (commit)
via a231a2dd4bf47b519e214329ab71e06b6f99d310 (commit)
from 74f663c4d31f8b09a945c256b8f40c4ebfdaea67 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 3716ba580adb3d9ddd5452daa8e8fdfd5b3edcc0
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Fri Jan 31 16:43:36 2014 -0500
Working on javascript magic to resize svg div so scrolling works nicely. Seems to work pretty well except when the svg div is the last thing on the page.
diff --git a/apps/workbench/app/assets/javascripts/provenance.js b/apps/workbench/app/assets/javascripts/provenance.js
index 51ce77f..39a1bbe 100644
--- a/apps/workbench/app/assets/javascripts/provenance.js
+++ b/apps/workbench/app/assets/javascripts/provenance.js
@@ -1,16 +1,47 @@
-function provenance_sizing_fixup(divId) {
+function provenance_sizing_fixup(divId, svgId) {
var a = document.getElementById(divId);
- //a.style.height = String(window.innerHeight - (a.getBoundingClientRect().top + window.scrollY) - 2) + "px";
- a.style.width = String(window.innerWidth - 25) + "px";
+ var b = document.getElementById("_" + divId + "_padding");
+ var c = document.getElementById("_" + divId + "_center");
+ var g = document.getElementById(svgId);
+
+ var h = window.innerHeight - a.getBoundingClientRect().top - 2;
+ var max = window.innerHeight - 100;
+ var gh = parseFloat(g.getAttribute("height"));
+ //var sh = (a.scrollTopMax > 0) ? a.scrollHeight : 0;
+ //gh = (gh > sh) ? gh : sh;
+ gh += 5;
+ if (h < 0) { h = max; }
+ var height;
+ if (gh < h) {
+ if (gh > max) { gh = max; }
+ height = String(gh) + "px";
+ }
+ else {
+ if (h > max) { h = max; }
+ height = String(h) + "px";
+ }
+ a.style.height = height;
+ b.style.paddingTop = height;
+
+ w = window.innerWidth - 25;
+ a.style.width = String(w) + "px";
+ gw = parseFloat(g.getAttribute("width"));
+ if (gw < w) {
+ c.style.paddingLeft = String((w - gw)/2.0) + "px";
+ }
+ else {
+ c.style.paddingLeft = "0px";
+ }
}
function graph_zoom(divId, svgId, scale) {
- var pg = document.getElementById(divId);
- vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
- hcenter = (pg.scrollLeft + (pg.scrollWidth - pg.scrollLeftMax)/2.0) / pg.scrollWidth;
- var g = document.getElementById(svgId);
- g.setAttribute("height", parseFloat(g.getAttribute("height")) * scale);
- g.setAttribute("width", parseFloat(g.getAttribute("width")) * scale);
- pg.scrollTop = (vcenter * pg.scrollHeight) - (pg.scrollHeight - pg.scrollTopMax)/2.0;
- pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0;
- }
+ var pg = document.getElementById(divId);
+ vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
+ hcenter = (pg.scrollLeft + (pg.scrollWidth - pg.scrollLeftMax)/2.0) / pg.scrollWidth;
+ var g = document.getElementById(svgId);
+ g.setAttribute("height", parseFloat(g.getAttribute("height")) * scale);
+ g.setAttribute("width", parseFloat(g.getAttribute("width")) * scale);
+ pg.scrollTop = (vcenter * pg.scrollHeight) - (pg.scrollHeight - pg.scrollTopMax)/2.0;
+ pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0;
+ provenance_sizing_fixup(divId, svgId);
+}
diff --git a/apps/workbench/app/controllers/jobs_controller.rb b/apps/workbench/app/controllers/jobs_controller.rb
index 061db6d..e6179ff 100644
--- a/apps/workbench/app/controllers/jobs_controller.rb
+++ b/apps/workbench/app/controllers/jobs_controller.rb
@@ -1,24 +1,33 @@
class JobsController < ApplicationController
+
+ def generate_provenance(jobs)
+ nodes = []
+ collections = []
+ jobs.each do |j|
+ nodes << j
+ collections << j[:output]
+ collections.concat(ProvenanceHelper::find_collections(j[:script_parameters]))
+ nodes << {:uuid => j[:script_version]}
+ end
+
+ Collection.where(uuid: collections).each do |c|
+ nodes << c
+ end
+
+ @svg = ProvenanceHelper::create_provenance_graph nodes, "provenance_svg", {:all_script_parameters => true, :script_version_nodes => true}
+ end
+
def index
@svg = ""
if params[:uuid]
- @jobs = Job.where(uuid: params[:uuid])
- nodes = []
- collections = []
- @jobs.each do |j|
- nodes << j
- collections << j[:output]
- collections.concat(ProvenanceHelper::find_collections(j[:script_parameters]))
- nodes << {:uuid => j[:script_version]}
- end
-
- Collection.where(uuid: collections).each do |c|
- nodes << c
- end
-
- @svg = ProvenanceHelper::create_provenance_graph(nodes, {:all_script_parameters => true, :script_version_nodes => true})
+ @jobs = Job.where(uuid: params[:uuid])
+ generate_provenance(@jobs)
else
@jobs = Job.all
end
end
+
+ def show
+ generate_provenance([@object])
+ end
end
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index 6e7bc98..55ee02b 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -44,9 +44,9 @@ class PipelineInstancesController < ApplicationController
n = n << 1
end
- puts pips
+ #puts pips
- @prov_svg = ProvenanceHelper::create_provenance_graph provenance, {
+ @prov_svg = ProvenanceHelper::create_provenance_graph provenance, "provenance_svg", {
:all_script_parameters => true,
:combine_jobs => :script_and_version,
:script_version_nodes => true,
diff --git a/apps/workbench/app/views/application/_svg_div.html.erb b/apps/workbench/app/views/application/_svg_div.html.erb
index 90b7ae4..f3f6a71 100644
--- a/apps/workbench/app/views/application/_svg_div.html.erb
+++ b/apps/workbench/app/views/application/_svg_div.html.erb
@@ -1,13 +1,33 @@
-<div>
+<%= content_for :css do %>
+#<%= divId %> {
+ padding-left: 3px;
+ overflow: auto;
+ border: solid;
+ border-width: 1px;
+ border-color: gray;
+ position: absolute;
+ left: 1px;
+
+}
+<% end %>
+
+<div id="_<%= divId %>_container" style="padding-top: 41px; margin-top: -41px">
<script>
- $(window).resize(function () { provenance_sizing_fixup("<%= divId %>") } );
+ (function() {
+ var fn = function () { graph_zoom("<%= divId %>", "<%=svgId %>", 1) };
+ $(window).resize(fn);
+ $(window).load(fn);
+ $(window).scroll(fn);
+ })();
</script>
<div style="text-align: right">
- <a href="#"><span class="icon-zoom-out" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', .9)"></span></a>
- <a href="#"><span class="icon-zoom-in" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', 1./.9)"></span></a>
+ <a style="cursor: pointer"><span class="icon-zoom-out" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', .9)"></span></a>
+ <a style="cursor: pointer"><span class="icon-zoom-in" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', 1./.9)"></span></a>
</div>
<div id="<%= divId %>">
+ <span id="_<%= divId %>_center" style="padding-left: 300px"/>
<%= raw(svg) %>
</div>
+ <div id="_<%= divId %>_padding" style="padding-bottom: 1em" />
</div>
diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb
index b3adbf4..120af6f 100644
--- a/apps/workbench/app/views/collections/show.html.erb
+++ b/apps/workbench/app/views/collections/show.html.erb
@@ -11,15 +11,7 @@
.label a {
color: inherit;
}
-#provenance_graph {
- padding-left: 3px;
- overflow:auto;
- border:solid;
- border-width:1px;
- border-color: gray;
- position: absolute;
- left: 1px;
-}
+
<% end %>
<%#= render :partial => 'nav' %>
@@ -146,7 +138,7 @@
<div id="provenance2" class="tab-pane fade">
<script>
$(function() {
- $('#prov-tab').on('shown', function() { provenance_sizing_fixup("provenance_graph"); });
+ $('#prov-tab').on('shown', function() { provenance_sizing_fixup("provenance_graph", "provenance_svg"); });
})
</script>
<%= render partial: 'application/svg_div', locals: {
diff --git a/apps/workbench/app/views/jobs/index.html.erb b/apps/workbench/app/views/jobs/index.html.erb
index 2c473eb..d394f6d 100644
--- a/apps/workbench/app/views/jobs/index.html.erb
+++ b/apps/workbench/app/views/jobs/index.html.erb
@@ -136,4 +136,8 @@
</tbody>
</table>
-<%= raw(@svg) %>
+<%= render partial: 'application/svg_div', locals: {
+ divId: "provenance_graph",
+ svgId: "provenance_svg",
+ svg: @svg } %>
+
diff --git a/apps/workbench/app/views/jobs/show.html.erb b/apps/workbench/app/views/jobs/show.html.erb
index 9079085..5022b8b 100644
--- a/apps/workbench/app/views/jobs/show.html.erb
+++ b/apps/workbench/app/views/jobs/show.html.erb
@@ -1 +1,6 @@
<%= render :partial => 'application/arvados_object' %>
+
+<%= render partial: 'application/svg_div', locals: {
+ divId: "provenance_graph",
+ svgId: "provenance_svg",
+ svg: @svg } %>
diff --git a/apps/workbench/app/views/pipeline_instances/show.html.erb b/apps/workbench/app/views/pipeline_instances/show.html.erb
index 2745e76..f9c9c1a 100644
--- a/apps/workbench/app/views/pipeline_instances/show.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/show.html.erb
@@ -1,3 +1,10 @@
+<% content_for :css do %>
+ .pipeline_color_legend {
+ padding-left: 1em;
+ padding-right: 1em;
+ }
+<% end %>
+
<table class="table table-condensed table-hover topalign">
<thead>
</thead>
@@ -29,7 +36,16 @@
</tbody>
</table>
-<%= raw(@prov_svg) %>
+<div style="text-align: center">
+<span class="pipeline_color_legend" style="background: #88ff88">This pipeline</span>
+<span class="pipeline_color_legend" style="background: #8888ff">Comparison pipeline</span>
+<span class="pipeline_color_legend" style="background: #88ffff">Shared by both pipelines</span>
+</div>
+
+ <%= render partial: 'application/svg_div', locals: {
+ divId: "provenance_graph",
+ svgId: "provenance_svg",
+ svg: @prov_svg } %>
<pre>
<%= JSON.pretty_generate(@object.attributes) rescue nil %>
commit a231a2dd4bf47b519e214329ab71e06b6f99d310
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Fri Jan 31 12:48:57 2014 -0500
Refactored code for managing divs containing svg (manages scrollbars, zoom buttons).
diff --git a/apps/workbench/app/assets/javascripts/provenance.js b/apps/workbench/app/assets/javascripts/provenance.js
new file mode 100644
index 0000000..51ce77f
--- /dev/null
+++ b/apps/workbench/app/assets/javascripts/provenance.js
@@ -0,0 +1,16 @@
+function provenance_sizing_fixup(divId) {
+ var a = document.getElementById(divId);
+ //a.style.height = String(window.innerHeight - (a.getBoundingClientRect().top + window.scrollY) - 2) + "px";
+ a.style.width = String(window.innerWidth - 25) + "px";
+}
+
+function graph_zoom(divId, svgId, scale) {
+ var pg = document.getElementById(divId);
+ vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
+ hcenter = (pg.scrollLeft + (pg.scrollWidth - pg.scrollLeftMax)/2.0) / pg.scrollWidth;
+ var g = document.getElementById(svgId);
+ g.setAttribute("height", parseFloat(g.getAttribute("height")) * scale);
+ g.setAttribute("width", parseFloat(g.getAttribute("width")) * scale);
+ pg.scrollTop = (vcenter * pg.scrollHeight) - (pg.scrollHeight - pg.scrollTopMax)/2.0;
+ pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0;
+ }
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 8ba12d9..62e513d 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -99,7 +99,7 @@ class CollectionsController < ApplicationController
end
Collection.where(uuid: @object.uuid).each do |u|
- @prov_svg = ProvenanceHelper::create_provenance_graph u.provenance, {:direction => :bottom_up, :combine_jobs => :script_only}
+ @prov_svg = ProvenanceHelper::create_provenance_graph u.provenance, "provenance_svg", {:direction => :bottom_up, :combine_jobs => :script_only}
end
end
diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb
index 15474ba..73b4a47 100644
--- a/apps/workbench/app/helpers/provenance_helper.rb
+++ b/apps/workbench/app/helpers/provenance_helper.rb
@@ -251,7 +251,7 @@ module ProvenanceHelper
end
- def self.create_provenance_graph(pdata, opts={})
+ def self.create_provenance_graph(pdata, svgId, opts={})
if pdata.is_a? Array or pdata.is_a? ArvadosResourceList
p2 = {}
pdata.each do |k|
@@ -300,6 +300,7 @@ edge [fontsize=8];
svg = svg.sub(/<\?xml.*?\?>/m, "")
svg = svg.sub(/<!DOCTYPE.*?>/m, "")
+ svg = svg.sub(/<svg /, "<svg id=\"#{svgId}\" ")
end
def self.find_collections(sp)
diff --git a/apps/workbench/app/views/application/_svg_div.html.erb b/apps/workbench/app/views/application/_svg_div.html.erb
new file mode 100644
index 0000000..90b7ae4
--- /dev/null
+++ b/apps/workbench/app/views/application/_svg_div.html.erb
@@ -0,0 +1,13 @@
+<div>
+ <script>
+ $(window).resize(function () { provenance_sizing_fixup("<%= divId %>") } );
+ </script>
+ <div style="text-align: right">
+ <a href="#"><span class="icon-zoom-out" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', .9)"></span></a>
+ <a href="#"><span class="icon-zoom-in" onclick="graph_zoom('<%= divId %>', '<%= svgId %>', 1./.9)"></span></a>
+ </div>
+
+ <div id="<%= divId %>">
+ <%= raw(svg) %>
+ </div>
+</div>
diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb
index 8c6e83e..b3adbf4 100644
--- a/apps/workbench/app/views/collections/show.html.erb
+++ b/apps/workbench/app/views/collections/show.html.erb
@@ -144,37 +144,15 @@
</table>
</div>
<div id="provenance2" class="tab-pane fade">
- <script>
- function provenance_sizing_fixup() {
- var a = document.getElementById("provenance_graph");
- a.style.height = String(window.innerHeight - (a.getBoundingClientRect().top + window.scrollY) - 2) + "px";
- a.style.width = String(window.innerWidth - 10) + "px";
- }
- $(window).resize(provenance_sizing_fixup);
-
- function graph_zoom(scale) {
- var pg = document.getElementById("provenance_graph");
- vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
- hcenter = (pg.scrollLeft + (pg.scrollWidth - pg.scrollLeftMax)/2.0) / pg.scrollWidth;
- var g = document.getElementById("graph1").parentNode;
- g.setAttribute("height", parseFloat(g.getAttribute("height")) * scale);
- g.setAttribute("width", parseFloat(g.getAttribute("width")) * scale);
- pg.scrollTop = (vcenter * pg.scrollHeight) - (pg.scrollHeight - pg.scrollTopMax)/2.0;
- pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0;
- }
-
+<script>
$(function() {
- $('#prov-tab').on('shown', provenance_sizing_fixup);
+ $('#prov-tab').on('shown', function() { provenance_sizing_fixup("provenance_graph"); });
})
- </script>
- <div style="text-align: right">
- <a href="#"><span class="icon-zoom-out" onclick="graph_zoom(.9)"></span></a>
- <a href="#"><span class="icon-zoom-in" onclick="graph_zoom(1./.9)"></span></a>
- </div>
-
- <div id="provenance_graph">
- <%= raw(@prov_svg) %>
- </div>
+</script>
+ <%= render partial: 'application/svg_div', locals: {
+ divId: "provenance_graph",
+ svgId: "provenance_svg",
+ svg: @prov_svg } %>
</div>
<div id="jobs" class="tab-pane fade">
<table class="topalign table table-bordered">
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list