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