[ARVADOS] updated: 52838f7dfc576e8a11411fd9f1710a758573a6e7
git at public.curoverse.com
git at public.curoverse.com
Wed Feb 26 11:57:24 EST 2014
Summary of changes:
.../app/assets/javascripts/application.js | 4 +-
apps/workbench/app/assets/javascripts/selection.js | 49 ++++++++++------
.../app/assets/stylesheets/application.css.scss | 11 +---
.../app/controllers/application_controller.rb | 1 +
apps/workbench/app/helpers/application_helper.rb | 61 ++++++++++++++++++++
apps/workbench/app/helpers/collections_helper.rb | 4 +
apps/workbench/app/helpers/provenance_helper.rb | 2 +-
apps/workbench/app/models/pipeline_instance.rb | 2 +-
.../app/views/layouts/application.html.erb | 3 +-
.../pipeline_instances/_show_components.html.erb | 22 ++++++-
10 files changed, 121 insertions(+), 38 deletions(-)
via 52838f7dfc576e8a11411fd9f1710a758573a6e7 (commit)
from da2803a65e696bf85883e82a0bda6ef81dda5429 (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 52838f7dfc576e8a11411fd9f1710a758573a6e7
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Feb 26 11:58:38 2014 -0500
Pipeline parameter editing supports selection box for choosing from workbench persistent selection list. Actually committing changes not tested yet.
Also changed layout of selection dropdown and added "clear selections" button.
diff --git a/apps/workbench/app/assets/javascripts/application.js b/apps/workbench/app/assets/javascripts/application.js
index bcedc4b..e7884b9 100644
--- a/apps/workbench/app/assets/javascripts/application.js
+++ b/apps/workbench/app/assets/javascripts/application.js
@@ -21,7 +21,7 @@
//= require bootstrap3-editable/bootstrap-editable
//= require_tree .
-(function($){
+jQuery(function($){
$.ajaxSetup({
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
@@ -140,4 +140,4 @@
fixer.duplicateTheadTr();
fixer.fixThead();
});
-})(jQuery);
+});
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index 5d0900a..29c52d6 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -3,27 +3,31 @@
/** Javascript for local persistent selection. */
+get_selection_list = null;
+
(function($){
- var get_storage = function() {
- if (!sessionStorage.persistentSelection) {
- sessionStorage.persistentSelection = JSON.stringify([]);
+ var storage = localStorage; // sessionStorage
+
+ get_selection_list = function() {
+ if (!storage.persistentSelection) {
+ storage.persistentSelection = JSON.stringify([]);
}
- return JSON.parse(sessionStorage.persistentSelection);
+ return JSON.parse(storage.persistentSelection);
}
var put_storage = function(lst) {
- sessionStorage.persistentSelection = JSON.stringify(lst);
+ storage.persistentSelection = JSON.stringify(lst);
}
var add_selection = function(uuid, name, href, type) {
- var lst = get_storage();
+ var lst = get_selection_list();
lst.push({"uuid": uuid, "name": name, "href": href, "type": type});
put_storage(lst);
update_count();
};
var remove_selection = function(uuid) {
- var lst = get_storage();
+ var lst = get_selection_list();
for (var i = 0; i < lst.length; i++) {
if (lst[i].uuid == uuid) {
lst.splice(i, 1);
@@ -35,34 +39,42 @@
};
var remove_selection_click = function(e) {
- remove_selection($(this).attr('name'));
+ //remove_selection($(this).attr('name'));
+ remove_selection($(this).val());
};
+ var clear_selections = function() {
+ put_storage([]);
+ update_count();
+ }
+
var update_count = function(e) {
- var lst = get_storage();
+ var lst = get_selection_list();
$("#persistent-selection-count").text(lst.length);
- $('#persistent-selection-list > li > table').empty();
if (lst.length > 0) {
+ $('#persistent-selection-list').html('<li><a href="#" class="btn pull-right" id="clear_selections_button">Clear selections</a></li>'
+ +'<li class="notification"><table style="width: 100%"></table></li>');
for (var i = 0; i < lst.length; i++) {
$('#persistent-selection-list > li > table').append("<tr>"
- + "<td style=\"vertical-align: top\">"
- + "<span style=\"padding-right: 1em\">" + lst[i].type + "</span>"
+ + "<td>"
+ + "<form>"
+ + "<input class='remove-selection' type='checkbox' value='" + lst[i].uuid + "' checked='true'></input>"
+ + "</form>"
+ "</td>"
+ "<td>"
- + "<span><a href=\"" + lst[i].href + "\">" + lst[i].name + "</a></span>"
+ + "<span style='padding-left: 1em'><a href=\"" + lst[i].href + "\">" + lst[i].name + "</a></span>"
+ "</td>"
- + "<td>"
- + "<a href=\"#\" class=\"remove-selection\" name=\"" + lst[i].uuid + "\">"
- + "<span class=\"glyphicon glyphicon-trash pull-right\"></span>"
- + "</a></span>"
+ + "<td style=\"vertical-align: top\">"
+ + "<span style=\"padding-right: 1em\">" + lst[i].type + "</span>"
+ "</td>"
+
+ "</tr>");
}
} else {
- $('#persistent-selection-list > li > table').html("<tr><td>No selections.</td></tr>");
+ $('#persistent-selection-list').html("<li class='notification empty'>No selections.</li>");
}
var checkboxes = $('.persistent-selection:checkbox');
@@ -79,6 +91,7 @@
}
$('.remove-selection').on('click', remove_selection_click);
+ $('#clear_selections_button').on('click', clear_selections);
};
$(document).
diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss
index 2bbff9b..be54dd0 100644
--- a/apps/workbench/app/assets/stylesheets/application.css.scss
+++ b/apps/workbench/app/assets/stylesheets/application.css.scss
@@ -189,15 +189,6 @@ table.table-fixed-header-row tbody {
width: 500px;
}
-#persistent-selection-list li {
- margin-left: 1em;
- padding: 3px 20px;
- font-weight: normal;
- line-height: 1.42857;
- color: rgb(51, 51, 51);
-
-}
-
#persistent-selection-list li table tr {
- border-bottom: 1px solid rgb(221, 221, 221);
+ border-top: 1px solid rgb(221, 221, 221);
}
diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 2817735..412f86c 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -24,6 +24,7 @@ class ApplicationController < ActionController::Base
def unprocessable(message=nil)
@errors ||= []
+
@errors << message if message
render_error status: 422
end
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 48b6bb4..b669042 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -3,6 +3,10 @@ module ApplicationHelper
controller.current_user
end
+ def self.match_uuid(uuid)
+ /^([0-9a-z]{5})-([0-9a-z]{5})-([0-9a-z]{15})$/.match(uuid.to_s)
+ end
+
def current_api_host
Rails.configuration.arvados_v1_base.gsub /https?:\/\/|\/arvados\/v1/,''
end
@@ -100,4 +104,61 @@ module ApplicationHelper
:class => "editable"
}.merge(htmloptions)
end
+
+ def render_editable_subattribute(object, attr, subattr, template, htmloptions={})
+ attrvalue = object.send(attr)
+ subattr.each do |k|
+ attrvalue = attrvalue[k]
+ end
+
+ datatype = nil
+ if template
+ if template.is_a? Hash
+ if template[:output_of]
+ return "Output of \"#{template[:output_of]}\""
+ elsif template[:datatype]
+ datatype = template[:datatype]
+ end
+ elsif attrvalue == nil
+ attrvalue = template
+ end
+ end
+
+ return attrvalue if !object.attribute_editable? attr
+
+ if not datatype
+ dataclass = ArvadosBase.resource_class_for_uuid(attrvalue)
+ if dataclass
+ datatype = 'select'
+ else
+ if /^\d+$/.match(attrvalue)
+ datatype = 'number'
+ elsif
+ datatype = 'text'
+ end
+ end
+ end
+
+ subattr.insert(0, attr)
+ id = "#{object.uuid}-#{subattr.join('-')}"
+
+ lt = link_to attrvalue, '#', {
+ "data-emptytext" => "none",
+ "data-placement" => "bottom",
+ "data-type" => datatype,
+ "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
+ "data-title" => "Update #{subattr[-1].to_s.titleize}",
+ "data-name" => subattr.to_json,
+ "data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
+ :class => "editable",
+ :id => id
+ }.merge(htmloptions)
+
+ lt += raw(%{
+<script>
+ $('##{id}').editable({source: select_#{dataclass}_source});
+</script>})
+
+ lt
+ end
end
diff --git a/apps/workbench/app/helpers/collections_helper.rb b/apps/workbench/app/helpers/collections_helper.rb
index b2eee48..df0ba22 100644
--- a/apps/workbench/app/helpers/collections_helper.rb
+++ b/apps/workbench/app/helpers/collections_helper.rb
@@ -4,4 +4,8 @@ module CollectionsHelper
{source: x.tail_uuid, target: x.head_uuid, type: x.name}
end
end
+
+ def self.match(uuid)
+ /^([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?$/.match(uuid.to_s)
+ end
end
diff --git a/apps/workbench/app/helpers/provenance_helper.rb b/apps/workbench/app/helpers/provenance_helper.rb
index 6d6ae55..8278d37 100644
--- a/apps/workbench/app/helpers/provenance_helper.rb
+++ b/apps/workbench/app/helpers/provenance_helper.rb
@@ -9,7 +9,7 @@ module ProvenanceHelper
end
def self.collection_uuid(uuid)
- m = /^([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?$/.match(uuid.to_s)
+ m = CollectionsHelper.match(uuid)
if m
#if m[2]
return m[1]
diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb
index da6116e..14eb89a 100644
--- a/apps/workbench/app/models/pipeline_instance.rb
+++ b/apps/workbench/app/models/pipeline_instance.rb
@@ -18,7 +18,7 @@ class PipelineInstance < ArvadosBase
end
def attribute_editable?(attr)
- attr == 'name'
+ attr.to_sym == :name || (attr.to_sym == :components and self.active == nil)
end
def attributes_for_display
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 1d6a468..2128515 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -115,14 +115,13 @@
</li>
-->
- <li class="dropdown">
+ <li class="dropdown notification-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-paperclip"></span>
<span class="badge" id="persistent-selection-count"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu" id="persistent-selection-list">
- <li><table style="width:100%"></table></li>
</ul>
</li>
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index 1785f6a..395ef77 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -23,6 +23,19 @@ table.pipeline-components-table td {
<% end %>
+<% content_for :js do %>
+ function select_Collection_source() {
+ var ret = [];
+ var lst = get_selection_list();
+ for (var i = 0; i < lst.length; i++) {
+ if (lst[i].type == 'Collection') {
+ ret.push({text: lst[i].name, value: lst[i].uuid})
+ }
+ }
+ return ret;
+ };
+<% end %>
+
<% if @object.active != nil %>
<table class="table pipeline-components-table">
<colgroup>
@@ -113,7 +126,8 @@ setInterval(function(){$('a.refresh').click()}, 30000);
</tr>
</thead>
<tbody>
- <% @object.components.each do |k, v| %>
+ <% template = PipelineTemplate.find(@object.pipeline_template_uuid) %>
+ <% template.components.each do |k, v| %>
<% sp = v[:script_parameters].collect do |k, v| [k, v] end %>
@@ -129,7 +143,7 @@ setInterval(function(){$('a.refresh').click()}, 30000);
</td>
<td>
- <%= sp[0][1] %>
+ <%= render_editable_subattribute @object, :components, [k, :script_parameters, sp[0][0].to_sym], sp[0][1] %>
</td>
</tr>
@@ -139,8 +153,8 @@ setInterval(function(){$('a.refresh').click()}, 30000);
<td style="border-top: none"></td>
<% sp[1..-1].each do |p| %>
- <td style="border-top: none"><%= p[0] %></td>
- <td style="border-top: none"><%= p[1] %></td>
+ <td><%= p[0] %></td>
+ <td><%= p[1] %></td>
<% end %>
</tr>
<% end %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list