myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3719] branches/packs: embedded checklist and add


From: noreply
Subject: [myexperiment-hackers] [3719] branches/packs: embedded checklist and added option for multiple checklists
Date: Wed, 25 Sep 2013 15:33:01 +0000 (UTC)

Revision
3719
Author
dgc
Date
2013-09-25 15:33:01 +0000 (Wed, 25 Sep 2013)

Log Message

embedded checklist and added option for multiple checklists

Modified Paths

Added Paths

Diff

Modified: branches/packs/app/controllers/packs_controller.rb (3718 => 3719)


--- branches/packs/app/controllers/packs_controller.rb	2013-09-25 01:19:48 UTC (rev 3718)
+++ branches/packs/app/controllers/packs_controller.rb	2013-09-25 15:33:01 UTC (rev 3719)
@@ -4,6 +4,8 @@
 # See license.txt for details.
 
 require 'wf4ever/transformation-client'
+require 'open-uri'
+require 'nokogiri'
 
 class PacksController < ApplicationController
   include ApplicationHelper
@@ -471,6 +473,23 @@
     end
   end
 
+  def update_checklist
+
+    entry = Conf.research_object_checklists[params[:minim]]
+
+    checklist_uri = url_with_params(entry["service"],
+      "RO" => @pack.research_object.uri.to_s,
+#     "RO" => "http://alpha2.myexperiment.org/rodl/ROs/Pack15/",
+      "minim" => entry["minim"],
+      "purpose" => entry["purpose"])
+
+#   @results = scrape_checklist_results(File.read("checklist2.html"))
+    @results = scrape_checklist_results(open(checklist_uri))
+    @context = @pack
+
+    render "research_objects/checklist"
+  end
+
   protected
   
   # Check that a protocol is specified in the URI; prepend HTTP:// otherwise
@@ -507,6 +526,7 @@
       "tag"              => "view",
       "update"           => "edit",
       "update_item"      => "edit",
+      "update_checklist" => "edit",
       "snapshot"         => "edit"
     }
 
@@ -658,4 +678,34 @@
     ro.create_folder_entry(relative_uri(resource_uri, @pack.research_object.uri), folder.path, user_path(current_user))
   end
 
+  # This is a stop-gap solution.  Yes, really.
+
+  def scrape_checklist_results(html)
+
+    doc = Nokogiri::HTML(html)
+
+    classes = {
+      "trafficlight small fail should" => { :colour => :red,   :score => 0 },
+      "trafficlight small fail must"   => { :colour => :amber, :score => 1 },
+      "trafficlight small pass"        => { :colour => :green, :score => 2 }
+    }
+
+    score     = 0
+    max_score = 0
+
+    sub_results = doc.xpath("//address@hidden'sub_result']").map do |tr|
+      tds = tr.xpath("td")
+
+      score += classes[tds[1].attributes["class"].to_s][:score]
+      max_score += 2
+
+      {
+        :text   => tds[2].text,
+        :colour => classes[tds[1].attributes["class"].to_s][:colour]
+      }
+    end
+
+    { :score => score, :max_score => max_score, :sub_results => sub_results }
+  end
+
 end

Modified: branches/packs/app/views/packs/_checklist.html.erb (3718 => 3719)


--- branches/packs/app/views/packs/_checklist.html.erb	2013-09-25 01:19:48 UTC (rev 3718)
+++ branches/packs/app/views/packs/_checklist.html.erb	2013-09-25 15:33:01 UTC (rev 3719)
@@ -1,10 +1,16 @@
 <div class="contribution_section_box">
 	<p class="heading">
-		<%= info_icon_with_tooltip("The unique list of tags that items within this pack have been tagged with") %>
-		Checklist evaluator
+		<%= info_icon_with_tooltip("These are the results from checklists that measure the health of this pack") %>
+		Checklist evaluation
   </p>
-	
-  <p>
-    <%= link_to("Checklist evaluation", "http://sandbox.wf4ever-project.org/roevaluate/evaluate/trafficlight_html?RO=#{CGI::escape(@pack.research_object.uri.to_s)}&minim=http%3A%2F%2Fwf4ever.github.io%2Fro-catalogue%2Fv0.1%2FTimbus-demo-test%2FTimbus-demo-minim.rdf&purpose=complete") -%>
-  </p>
+
+  <% if Authorization.check('edit', @pack, current_user) %>
+    <p>
+      <% form_tag(update_checklist_pack_path(@pack), :method => :post) do -%>
+        <%= select_tag("minim", options_for_select(Conf.research_object_checklists.keys )) -%>
+        <%= submit_tag("Run") -%>
+      <% end %>
+    </p>
+  <% end %>
+
 </div>

Added: branches/packs/app/views/research_objects/checklist.html.erb (0 => 3719)


--- branches/packs/app/views/research_objects/checklist.html.erb	                        (rev 0)
+++ branches/packs/app/views/research_objects/checklist.html.erb	2013-09-25 15:33:01 UTC (rev 3719)
@@ -0,0 +1,24 @@
+
+<h1>Checklist result for: <%=h @context.label -%></h1>
+
+<table class="checklist simple">
+  <% @results[:sub_results].each do |sub_result| %>
+    <tr>
+      <td class="<%= sub_result[:colour] -%>">
+        <% case sub_result[:colour]; when :red %>
+          <%= image_tag('famfamfam_silk/cross.png') -%>
+        <% when :amber %>
+          <%= image_tag('amber_cross.png') -%>
+        <% when :green %>
+          <%= image_tag('famfamfam_silk/tick.png') -%>
+        <% end %>
+      </td>
+      <td><%=h sub_result[:text] -%></td>
+    </tr>
+  <% end %>
+</table>
+
+<% if false %>
+  <h2>Debug</h2>
+<pre><%=h @results.to_yaml -%></pre>
+<% end %>

Modified: branches/packs/config/default_settings.yml (3718 => 3719)


--- branches/packs/config/default_settings.yml	2013-09-25 01:19:48 UTC (rev 3718)
+++ branches/packs/config/default_settings.yml	2013-09-25 15:33:01 UTC (rev 3719)
@@ -2087,3 +2087,17 @@
     image: /images/famfamfam_silk/page_white_gear.png
     label: Taverna 2 workflow
 
+research_object_checklists:
+
+  Workflow:
+
+    service: "http://sandbox.wf4ever-project.org/roevaluate/evaluate/trafficlight_html"
+    minim:   "http://wf4ever.github.io/ro-catalogue/v0.1/Timbus-demo-test/Timbus-demo-minim.rdf"
+    purpose: complete
+
+  Workflow and Services:
+
+    service: "http://sandbox.wf4ever-project.org/roevaluate/evaluate/trafficlight_html"
+    minim:   "http://wf4ever.github.io/ro-catalogue/v0.1/Timbus-demo-test/Timbus-demo-minim.rdf"
+    purpose: complete
+

Modified: branches/packs/config/routes.rb (3718 => 3719)


--- branches/packs/config/routes.rb	2013-09-25 01:19:48 UTC (rev 3718)
+++ branches/packs/config/routes.rb	2013-09-25 15:33:01 UTC (rev 3719)
@@ -64,6 +64,7 @@
                  :quick_add => :post,
                  :resolve_link => :post,
                  :snapshot => :post,
+                 :update_checklist => :post,
                  :items => :get } do |pack|
     pack.resources :comments, :collection => { :timeline => :get }
     pack.resources :relationships, :collection => { :edit_relationships => :get }

Added: branches/packs/public/images/amber_cross.png


(Binary files differ)
Property changes on: branches/packs/public/images/amber_cross.png ___________________________________________________________________

Added: svn:executable

Added: svn:mime-type

Modified: branches/packs/public/stylesheets/styles.css (3718 => 3719)


--- branches/packs/public/stylesheets/styles.css	2013-09-25 01:19:48 UTC (rev 3718)
+++ branches/packs/public/stylesheets/styles.css	2013-09-25 15:33:01 UTC (rev 3719)
@@ -2710,3 +2710,6 @@
   padding: 8px;
 }
 
+TABLE.checklist {
+  margin: 32px auto;
+}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]