11014: Check for PipelineIndex#index API to exist for rendering the compute node...
[arvados.git] / apps / workbench / app / views / projects / _show_dashboard.html.erb
1 <%
2   recent_procs = recent_processes(12)
3
4   wus = {}
5   outputs = []
6   recent_procs.each do |p|
7     wu = p.work_unit
8     wus[p] = wu
9     outputs << wu.outputs
10   end
11   outputs = outputs.flatten.uniq
12
13   collection_pdhs = outputs.select {|x| !(m = CollectionsHelper.match(x)).nil?}.uniq.compact
14   collection_uuids = outputs - collection_pdhs
15
16   if Rails.configuration.show_recent_collections_on_dashboard
17     recent_cs = recent_collections(8)
18     collection_uuids = collection_uuids + recent_cs[:collections].collect {|c| c.uuid}
19     collection_uuids.flatten.uniq
20   end
21
22   preload_collections_for_objects collection_uuids if collection_uuids.any?
23   preload_for_pdhs collection_pdhs if collection_pdhs.any?
24   preload_links_for_objects(collection_pdhs + collection_uuids)
25 %>
26
27 <%
28   if !PipelineInstance.api_exists?(:index)
29     recent_procs_title = 'Recent processes'
30     run_proc_title = 'Choose a workflow to run:'
31   else
32     recent_procs_title = 'Recent pipelines and processes'
33     run_proc_title = 'Choose a pipeline or workflow to run:'
34   end
35 %>
36
37   <div class="row">
38     <div class="col-md-6">
39       <div class="panel panel-default" style="min-height: 10.5em">
40         <div class="panel-heading">
41           <span class="panel-title"><%=recent_procs_title%></span>
42           <% if current_user.andand.is_active %>
43             <span class="pull-right recent-processes-actions">
44               <span>
45                 <%= link_to(
46                 choose_work_unit_templates_path(
47                   title: run_proc_title,
48                   action_name: 'Next: choose inputs <i class="fa fa-fw fa-arrow-circle-right"></i>',
49                   action_href: work_units_path,
50                   action_method: 'post',
51                   action_data: {'selection_param' => 'work_unit[template_uuid]', 'work_unit[owner_uuid]' => current_user.uuid, 'success' => 'redirect-to-created-object'}.to_json),
52                 { class: "btn btn-primary btn-xs", remote: true }) do %>
53                   <i class="fa fa-fw fa-gear"></i> Run a process...
54                 <% end %>
55               </span>
56               <span>
57                   <%= link_to all_processes_path, class: 'btn btn-default btn-xs' do %>
58                     All processes <i class="fa fa-fw fa-arrow-circle-right"></i>
59                   <% end %>
60               </span>
61             </span>
62           <% end %>
63         </div>
64
65         <div class="panel-body recent-processes">
66           <% if recent_procs.empty? %>
67             No recent pipelines or processes.
68           <% else %>
69           <% wus.each do |p, wu| %>
70             <% if wu.is_finished? %>
71             <div class="dashboard-panel-info-row row-<%=wu.uuid%>">
72               <div class="row">
73                 <div class="col-md-6 text-overflow-ellipsis">
74                   <%= link_to_if_arvados_object p, {friendly_name: true} %>
75                 </div>
76                 <div class="col-md-2">
77                   <span class="label label-<%=wu.state_bootstrap_class%>"><%=wu.state_label%></span>
78                 </div>
79                 <div class="col-md-4">
80                   <%= render_localized_date(wu.finished_at || wu.modified_at, "noseconds") %>
81                 </div>
82               </div>
83               <div class="row">
84                 <div class="col-md-12">
85                   <% if wu.started_at and wu.finished_at %>
86                     <% wu_time = wu.finished_at - wu.started_at %>
87                     Active for <%= render_runtime(wu_time, false) %>
88                   <% end %>
89
90                   <%= render partial: 'work_units/show_output', locals: {wu: wu, align: 'pull-right', include_icon: true} %>
91                 </div>
92               </div>
93
94             </div>
95             <% else %>
96             <div class="dashboard-panel-info-row row-<%=wu.uuid%>">
97               <div class="row">
98                 <div class="col-md-6">
99                   <%= link_to_if_arvados_object p, {friendly_name: true} %>
100                 </div>
101                 <% if wu.is_running? %>
102                 <div class="col-md-6">
103                   <div class="progress" style="margin-bottom: 0px">
104                     <% wu.progress %>
105                   </div>
106                 </div>
107                 <% else %>
108                 <div class="col-md-2">
109                   <span class="label label-<%=wu.state_bootstrap_class%>"><%=wu.state_label%></span>
110                 </div>
111                 <% end %>
112               </div>
113
114               <%
115                 children = wu.children
116                 running = children.select { |c| c.state_label == "Running" }
117                 queued = children.select { |c| c.state_label == "Queued" }
118               %>
119
120               <div class="clearfix">
121                 Started at <%= render_localized_date(wu.started_at || wu.created_at, "noseconds") %>.
122                 <% wu_time = Time.now - (wu.started_at || wu.created_at) %>
123                 Active for <%= render_runtime(wu_time, false) %>.
124
125                 <div class="pull-right">
126                   <% running.each do |r| %>
127                     <span class="label label-<%= r.state_bootstrap_class %>"> <%= r.label || r.state_label || 'Not ready' %> </span>
128                   <% end %>
129                   <% queued.each do |q| %>
130                     <span class="label label-<%= q.state_bootstrap_class %>"> <%= q.label || r.state_label || 'Not ready' %> </span>
131                   <% end %>
132                 </div>
133               </div>
134             </div>
135             <% end %>
136           <% end %>
137           <% end %>
138         </div>
139       </div>
140     </div>
141
142     <div class="col-md-6">
143       <% if PipelineInstance.api_exists?(:index) %>
144       <% nodes = Node.filter([["last_ping_at", ">", Time.now - 3600]]).results %>
145       <div class="panel panel-default" style="min-height: 10.5em">
146         <div class="panel-heading"><span class="panel-title">Compute node status</span>
147           <span class="pull-right compute-node-actions">
148             <% if current_user.andand.is_admin %>
149               <span>
150                 <%= link_to nodes_path, class: 'btn btn-default btn-xs' do %>
151                   All nodes <i class="fa fa-fw fa-arrow-circle-right"></i>
152                 <% end %>
153               </span>
154             <% end %>
155           </span>
156         </div>
157         <div class="panel-body compute-node-summary-pane">
158           <div>
159             <%= render partial: 'compute_node_summary', locals: {nodes: nodes} %>
160             <% active_nodes = [] %>
161             <% nodes.sort_by { |n| n.hostname || "" }.each do |n| %>
162               <% if n.crunch_worker_state.in? ["busy", "idle"] %>
163                 <% active_nodes << n %>
164               <% end %>
165             <% end %>
166             <% if active_nodes.any? %>
167               <div style="text-align: center">
168                 <a data-toggle="collapse" href="#compute_node_status">Details <span class="caret"></span></a>
169               </div>
170             <% end %>
171           </div>
172           <div id="compute_node_status" class="collapse">
173             <%= render partial: 'compute_node_status', locals: {nodes: active_nodes} %>
174           </div>
175         </div>
176       </div>
177       <% end %>
178       <% if Rails.configuration.show_recent_collections_on_dashboard %>
179       <div class="panel panel-default">
180         <div class="panel-heading"><span class="panel-title">Recent collections</span>
181           <span class="pull-right">
182             <%= link_to collections_path, class: 'btn btn-default btn-xs' do %>
183               All collections <i class="fa fa-fw fa-arrow-circle-right"></i>
184             <% end %>
185           </span>
186         </div>
187         <div class="panel-body">
188           <% recent_cs[:collections].each do |p| %>
189             <div class="dashboard-panel-info-row">
190               <div>
191                 <% if recent_cs[:owners][p[:owner_uuid]].is_a?(Group) %>
192                 <i class="fa fa-fw fa-folder-o"></i><%= link_to_if_arvados_object recent_cs[:owners][p[:owner_uuid]], friendly_name: true %>/
193                 <% end %>
194                 <span class="pull-right"><%= render_localized_date(p[:modified_at], "noseconds") %></span>
195               </div>
196               <div class="text-overflow-ellipsis" style="margin-left: 1em; width: 100%"><%= link_to_if_arvados_object p, {friendly_name: true, no_tags: true} %>
197               </div>
198             </div>
199           <% end %>
200         </div>
201       </div>
202       <% end %>
203     </div>
204   </div>