Merge pull request #1 from curoverse/master
[arvados.git] / apps / workbench / app / views / projects / _show_dashboard.html.erb
index d80282544072e34e318c5c7c4709e1231e7920e8..437f05a4998f996c203cfca10a5b5cb4caeb3939 100644 (file)
@@ -1,98 +1,87 @@
 
   <div class="row">
     <div class="col-md-6">
-      <div class="panel panel-default" style="min-height: 10em">
+      <div class="panel panel-default" style="min-height: 10.5em">
         <div class="panel-heading"><span class="panel-title">Active pipelines</span>
+          <% if current_user.andand.is_active %>
           <span class="pull-right">
-    <%= link_to(
-         choose_pipeline_templates_path(
-           title: 'Choose a pipeline to run:',
-           action_name: 'Next: choose inputs <i class="fa fa-fw fa-arrow-circle-right"></i>',
-           action_href: pipeline_instances_path,
-           action_method: 'post',
-           action_data: {'selection_param' => 'pipeline_instance[pipeline_template_uuid]', 'pipeline_instance[owner_uuid]' => current_user.uuid, 'success' => 'redirect-to-created-object'}.to_json),
-         { class: "btn btn-primary btn-xs", remote: true, method: 'get' }) do %>
-      <i class="fa fa-fw fa-gear"></i> Run a pipeline...
-    <% end %>
-    </span>
+          <%= link_to(
+          choose_pipeline_templates_path(
+            title: 'Choose a pipeline to run:',
+            action_name: 'Next: choose inputs <i class="fa fa-fw fa-arrow-circle-right"></i>',
+            action_href: pipeline_instances_path,
+            action_method: 'post',
+            action_data: {'selection_param' => 'pipeline_instance[pipeline_template_uuid]', 'pipeline_instance[owner_uuid]' => current_user.uuid, 'success' => 'redirect-to-created-object'}.to_json),
+          { class: "btn btn-primary btn-xs", remote: true }) do %>
+            <i class="fa fa-fw fa-gear"></i> Run a pipeline...
+          <% end %>
+          </span>
+          <% end %>
         </div>
 
+        <% _running_pipelines = running_pipelines %>
+        <% _finished_pipelines = finished_pipelines(8) %>
+        <% lookup = preload_objects_for_dataclass PipelineTemplate, (_running_pipelines.map(&:pipeline_template_uuid) + _finished_pipelines.map(&:pipeline_template_uuid)) %>
+
         <div class="panel-body">
-          <% if running_pipelines.empty? %>
+          <% if _running_pipelines.empty? %>
             No pipelines are currently running.
-          <% end %>
-          <% running_pipelines.each do |p| %>
+          <% else %>
+          <% _running_pipelines.each do |p| %>
             <div class="dashboard-panel-info-row">
               <div class="clearfix">
-                <%= link_to_if_arvados_object p, friendly_name: true %>
+                <%= link_to_if_arvados_object p, {friendly_name: true, lookup: lookup} %>
 
                 <div class="pull-right" style="width: 40%">
                   <div class="progress" style="margin-bottom: 0px">
-                    <% running = [] %>
-                    <% failed = [] %>
-                    <% completed = [] %>
-                    <% queued = [] %>
                     <% p.components.each do |k, v| %>
                       <% if v.is_a? Hash and v[:job] %>
-                        <% if v[:job][:state] == "Running" %>
-                          <% running << k %>
-                        <% elsif v[:job][:state] == "Failed" or v[:job][:state] == "Cancelled" %>
-                          <% failed << k %>
-                        <% elsif v[:job][:state] == "Complete" %>
-                          <% completed << k %>
-                        <% elsif v[:job][:state] == "Queued" %>
-                          <% queued << k %>
-                        <% end %>
+                        <%= render partial: 'job_progress', locals: {:j => v[:job], :scaleby => (1.0/p.components.size)} %>
                       <% end %>
                     <% end %>
-                    <% completed_pct = (completed.size * 100) / p.components.size %>
-                    <% failed_pct = (failed.size * 100) / p.components.size %>
-                    <% running_pct = (running.size * 100) / p.components.size %>
-                    <% queued_pct = (queued.size * 100) / p.components.size %>
-
-                    <div class="progress-bar progress-bar-success" style="width: <%= completed_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-danger" style="width: <%= failed_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-primary" style="width: <%= running_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-default" style="width: <%= queued_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
                   </div>
                 </div>
               </div>
 
+              <%
+                running = p.components.select { |k, c| c.is_a? Hash and c[:job].andand[:state] == "Running" }
+                queued = p.components.select { |k, c| c.is_a? Hash and c[:job].andand[:state] == "Queued" }
+                %>
+
               <div class="clearfix">
                 Started at <%= render_localized_date(p[:started_at] || p[:created_at], "noseconds") %>.
                 <% pipeline_time = Time.now - (p[:started_at] || p[:created_at]) %>
                 Active for <%= render_runtime(pipeline_time, false) %>.
 
                 <div class="pull-right">
-                  <% running.each do |k| %>
-                    <span class="label label-primary"><%= k %></span>
+                  <% running.each do |k,v| %>
+                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
                   <% end %>
-                  <% queued.each do |k| %>
-                    <span class="label label-default"><%= k %></span>
+                  <% queued.each do |k,v| %>
+                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
                   <% end %>
                 </div>
               </div>
             </div>
           <% end %>
+          <% end %>
           </div>
       </div>
 
       <div class="panel panel-default">
-        <div class="panel-heading"><span class="panel-title">Recently finished pipelines</span></div>
+        <div class="panel-heading"><span class="panel-title">Recently finished pipelines</span>
+          <span class="pull-right">
+            <%= link_to pipeline_instances_path, class: 'btn btn-default btn-xs' do %>
+              All pipelines <i class="fa fa-fw fa-arrow-circle-right"></i>
+            <% end %>
+          </span>
+        </div>
         <div class="panel-body">
-          <% finished_pipelines(8).each do |p| %>
+          <% _finished_pipelines.each do |p| %>
             <div class="dashboard-panel-info-row">
               <div class="row">
                 <div class="col-md-6 text-overflow-ellipsis">
-                  <%= link_to_if_arvados_object p, friendly_name: true %>
+                  <%= link_to_if_arvados_object p, {friendly_name: true, lookup: lookup} %>
                 </div>
                 <div class="col-md-2">
                   <%= render partial: "pipeline_status_label", locals: {p: p}%>
                     <% end %>
                   </div>
                 </div>
-              </div>              
+              </div>
             </div>
           <% end %>
         </div>
 
     <div class="col-md-6">
       <% nodes = Node.all %>
-      <div class="panel panel-default" style="min-height: 10em">
-        <div class="panel-heading"><span class="panel-title">Compute status</span></div>
+      <div class="panel panel-default" style="min-height: 10.5em">
+        <div class="panel-heading"><span class="panel-title">Compute and job status</span>
+          <span class="pull-right">
+            <%= link_to jobs_path, class: 'btn btn-default btn-xs' do %>
+              All jobs <i class="fa fa-fw fa-arrow-circle-right"></i>
+            <% end %>
+          </span>
+        </div>
         <div class="panel-body">
           <div>
             <%= render partial: 'compute_node_summary', locals: {nodes: nodes} %>
         </div>
       </div>
       <div class="panel panel-default">
-        <div class="panel-heading"><span class="panel-title">Recent collections</span></div>
+        <div class="panel-heading"><span class="panel-title">Recent collections</span>
+          <span class="pull-right">
+            <%= link_to collections_path, class: 'btn btn-default btn-xs' do %>
+              All collections <i class="fa fa-fw fa-arrow-circle-right"></i>
+            <% end %>
+          </span>
+        </div>
         <div class="panel-body">
           <% r = recent_collections(8) %>
           <% r[:collections].each do |p| %>
               <i class="fa fa-fw fa-folder-o"></i><%= link_to_if_arvados_object r[:owners][p[:owner_uuid]], friendly_name: true %>/
               <span class="pull-right"><%= render_localized_date(p[:modified_at], "noseconds") %></span>
             </div>
-            <div class="text-overflow-ellipsis" style="margin-left: 1em; width: 100%"><%= link_to_if_arvados_object p, friendly_name: true %>
+            <div class="text-overflow-ellipsis" style="margin-left: 1em; width: 100%"><%= link_to_if_arvados_object p, {friendly_name: true, no_tags: true} %>
             </div>
             </div>
           <% end %>