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