Merge branch '12315-exclude-child-procs'
authorTom Clegg <tclegg@veritasgenetics.com>
Tue, 27 Feb 2018 18:05:13 +0000 (13:05 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Tue, 27 Feb 2018 18:05:13 +0000 (13:05 -0500)
closes #12315

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

apps/workbench/app/assets/javascripts/filterable.js
apps/workbench/app/controllers/work_units_controller.rb
apps/workbench/app/views/work_units/_show_all_processes.html.erb
apps/workbench/test/controllers/work_units_controller_test.rb
apps/workbench/test/integration/work_units_test.rb

index 40df5c7174134986439d7379d1ea889311399091..e571e32db91560388167fed7c0a2725d649f678d 100644 (file)
 // data-example-attr="foo" are shown, and all others are hidden. When
 // the user selects the "Show all" option, all rows are shown.
 //
+// <input type="checkbox" data-on-value="{}" data-off-value="{}" ... />
+//
+// Merges on- or off-value with other params in query. Only works with
+// infinite-scroll.
+//
 // Notes:
 //
 // When multiple filterable-control widgets operate on the same
@@ -92,6 +97,21 @@ $(document).
             updateFilterableQueryNow($(this));
         });
     }).
+    on('change', 'input[type=checkbox].filterable-control', function(e) {
+        if (this != e.target) return;
+        var $target = $($(this).attr('data-filterable-target'));
+        var currentquery = $target.data('filterable-query');
+        if (currentquery === undefined) currentquery = '';
+        if ($target.is('[data-infinite-scroller]')) {
+            var datakey = 'infiniteContentParamsFrom'+this.id;
+            var whichvalue = $(this).is(':checked') ? 'on-value' : 'off-value';
+            if (JSON.stringify($target.data(datakey)) == JSON.stringify($(this).data(whichvalue)))
+                return;
+            $target.data(datakey, $(this).data(whichvalue));
+            updateFilterableQueryNow($target);
+            $target.trigger('refresh-content');
+        }
+    }).
     on('paste keyup input', 'input[type=text].filterable-control', function(e) {
         var regexp;
         if (this != e.target) return;
index 1e57e7caabe47e98a4d2a775769f457812d527cd..d2896821b28a16d90f62028a6644aded29e56496 100644 (file)
@@ -17,27 +17,36 @@ class WorkUnitsController < ApplicationController
     @limit = 20
     @filters = @filters || []
 
+    pipelines = []
+    jobs = []
+
     # get next page of pipeline_instances
     if PipelineInstance.api_exists?(:index)
       filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
       pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
     end
 
-    # get next page of jobs
-    if Job.api_exists?(:index)
-      filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
-      jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
+    if params[:show_children]
+      # get next page of jobs
+      if Job.api_exists?(:index)
+        filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
+        jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
+      end
     end
 
     # get next page of container_requests
     filters = @filters + [["uuid", "is_a", ["arvados#containerRequest"]]]
+    if !params[:show_children]
+     filters << ["requesting_container_uuid", "=", nil]
+    end
     crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters)
     @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit)
 
     if @objects.any?
       @next_page_filters = next_page_filters('<=')
       @next_page_href = url_for(partial: :all_processes_rows,
-                                filters: @next_page_filters.to_json)
+                                filters: @next_page_filters.to_json,
+                                show_children: params[:show_children])
       preload_links_for_objects(@objects.to_a)
     else
       @next_page_href = nil
index ed50e7c46eeeaf7a9a376a10682291e341ff246a..0d6d831699cffe82c850c590b073d8ecb8a81758 100644 (file)
@@ -2,16 +2,25 @@
 
 SPDX-License-Identifier: AGPL-3.0 %>
 
-<div class="container" style="width: 100%">
-  <div class="row">
-    <div class="pull-right">
-      <input type="text" class="form-control filterable-control recent-all-processes-filterable-control"
-             placeholder="Search all processes"
-             data-filterable-target="#all-processes-scroll"
-             value="<%= params[:search] %>">
-      </input>
-    </div>
+<div class="pull-right">
+  <div class="form-group">
+    <input type="text" class="form-control filterable-control recent-all-processes-filterable-control"
+           placeholder="Search all processes"
+           data-filterable-target="#all-processes-scroll"
+           value="<%= params[:search] %>" size="40" />
+  </div>
+  <div class="checkbox">
+    <label>
+      <input id="IncludeChildProcs" type="checkbox" class="filterable-control"
+            data-on-value="{&quot;show_children&quot;:true}"
+            data-off-value="{}"
+            data-filterable-target="#all-processes-scroll" />
+      Show child processes
+    </label>
   </div>
+</div>
+
+<div>
   <div>
     <div>
       <table class="table table-condensed table-fixedlayout arv-recent-all-processes">
@@ -47,6 +56,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
         </thead>
 
         <tbody data-infinite-scroller="#all-processes-scroll" id="all-processes-scroll"
+               data-infinite-content-params-from-exclude-child-procs="{}"
                data-infinite-content-href="<%= url_for partial: :all_processes_rows %>" >
         </tbody>
       </table>
index 342cd7a9383d35bd2cb7f5910994c865e3a7a7bc..a698b8df3c773c4b0f66e5b4625b3f255d42780d 100644 (file)
@@ -32,7 +32,7 @@ class WorkUnitsControllerTest < ActionController::TestCase
        '/container_requests/zzzzz-xvhdp-cr4completedcr2']],
   ].each do |search_filter, expected_min, expected_max, expected, not_expected|
     test "all_processes page for search filter '#{search_filter}'" do
-      work_units_index(filters: [['any','@@', search_filter]])
+      work_units_index(filters: [['any','@@', search_filter]], show_children: true)
       assert_response :success
 
       # Verify that expected number of processes are found
index 511e5119dbe1a8548f34d6208560ad2e45b22d9e..5f6ef9988bab245ad054e78f13da5b6d65462850 100644 (file)
@@ -12,21 +12,34 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
     need_javascript
   end
 
-  test "scroll all_processes page" do
-      expected_min, expected_max, expected, not_expected = [
-        25, 100,
-        ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
-         '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
-         '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
-         '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
-         '/container_requests/zzzzz-xvhdp-cr4completedcr2',
-         '/container_requests/zzzzz-xvhdp-cr4requestercn2'],
-        ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
-         '/container_requests/zzzzz-xvhdp-oneof60crs00001']
-      ]
-
+  [[true, 25, 100,
+    ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
+     '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+     '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
+     '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+     '/container_requests/zzzzz-xvhdp-cr4completedcr2',
+     '/container_requests/zzzzz-xvhdp-cr4requestercn2'],
+    ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
+     '/container_requests/zzzzz-xvhdp-oneof60crs00001']],
+   [false, 25, 100,
+    ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
+     '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
+     '/container_requests/zzzzz-xvhdp-cr4completedcr2'],
+    ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
+     '/container_requests/zzzzz-xvhdp-oneof60crs00001',
+     '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
+     '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
+     '/container_requests/zzzzz-xvhdp-cr4requestercn2'
+    ]]
+  ].each do |show_children, expected_min, expected_max, expected, not_expected|
+    test "scroll all_processes page with show_children=#{show_children}" do
       visit page_with_token('active', "/all_processes")
 
+      if show_children
+        find('#IncludeChildProcs').click
+        wait_for_ajax
+      end
+
       page_scrolls = expected_max/20 + 2
       within('.arv-recent-all-processes') do
         (0..page_scrolls).each do |i|
@@ -43,13 +56,13 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
       found_count = found_items.count
       if expected_min == expected_max
         assert_equal(true, found_count == expected_min,
-          "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
+                     "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
         assert page.has_no_text? 'request failed'
       else
         assert_equal(true, found_count>=expected_min,
-          "Found too few items. Expected at least #{expected_min} and found #{found_count}")
+                     "Found too few items. Expected at least #{expected_min} and found #{found_count}")
         assert_equal(true, found_count<=expected_max,
-          "Found too many items. Expected at most #{expected_max} and found #{found_count}")
+                     "Found too many items. Expected at most #{expected_max} and found #{found_count}")
       end
 
       # verify that all expected uuid links are found
@@ -61,6 +74,7 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
       not_expected.each do |link|
         assert_no_selector "a[href=\"#{link}\"]"
       end
+    end
   end
 
   [