Merge branch 'master' into 2060-edit-tags-in-workbench
[arvados.git] / apps / workbench / app / views / users / _tables.html.erb
1 <% if current_user.andand.is_active %>
2   <div>
3     <strong>Recent jobs</strong>
4     <%= link_to '(refresh)', request.fullpath, class: 'refresh', remote: true, method: 'get' %>
5     <%= link_to raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
6     <% if not current_user.andand.is_active or @my_jobs.empty? %>
7       <p>(None)</p>
8     <% else %>
9       <table class="table table-bordered table-condensed table-fixedlayout">
10         <colgroup>
11           <col width="20%" />
12           <col width="20%" />
13           <col width="20%" />
14           <col width="13%" />
15           <col width="27%" />
16         </colgroup>
17
18         <tr>
19           <th>Script</th>
20           <th>Output</th>
21           <th>Log</th>
22           <th>Age</th>
23           <th>Status</th>
24         </tr>
25
26         <% @my_jobs[0..6].each do |j| %>
27           <tr>
28             <td>
29               <small>
30                 <%= link_to j.script[0..31], job_path(j.uuid) %>
31               </small>
32             </td>
33
34             <td>
35               <small>
36                 <% if j.success %>
37
38                   <a href="<%= collection_path(j.output) %>">
39                     <% Collection.limit(1).where(uuid: j.output).each do |c| %>
40                          <% c.files.each do |file| %>
41                       <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
42                     <% end %>
43                 <% end %>
44                 </a>
45
46         <% end %>
47         </small>
48 </td>
49
50 <td>
51   <small>
52     <% if j.log %>
53       <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(j.log)%>
54       <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
55         <% c.files.each do |file| %>
56           <a href="<%= collection_path(j.log) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">Log</a>
57         <% end %>
58       <% end %>
59     <% elsif j.respond_to? :log_buffer and j.log_buffer %>
60       <% buf = j.log_buffer.strip.split("\n").last %>
61       <span title="<%= buf %>"><%= buf %></span>
62     <% end %>
63   </small>
64 </td>
65
66 <td>
67   <small>
68     <%= raw(distance_of_time_in_words(j.created_at, Time.now).sub('about
69 ','~').sub(' ','&nbsp;')) if j.created_at %>
70   </small>
71 </td>
72
73 <td>
74   <% if j.success %>
75     <span class="label label-success">finished</span>
76   <% elsif j.success == false %>
77     <span class="label label-danger">failed</span>
78   <% elsif j.finished_at %>
79     <span class="label">finished?</span>
80   <% elsif j.started_at %>
81     <span class="label label-info">running</span>
82   <% else %>
83     <span class="label">queued</span>
84   <% end %>
85   <% percent_total_tasks = 100 / (j.tasks_summary[:running] + j.tasks_summary[:done] + j.tasks_summary[:todo]) rescue 0 %>
86   <div class="inline-progress-container pull-right">
87     <div class="progress">
88       <span class="progress-bar progress-bar-success" style="width: <%= j.tasks_summary[:done] * percent_total_tasks rescue 0 %>%;">
89       </span>
90       <span class="progress-bar" style="width: <%= j.tasks_summary[:running] * percent_total_tasks rescue 0 %>%;">
91       </span>
92       <% if j.success == false %>
93       <span class="progress-bar progress-bar-danger" style="width: <%= tasks_summary[:failed] * percent_total_tasks rescue 0 %>%;">
94       </span>
95       <% end %>
96     </div>
97   </div>
98 </td>
99
100 </tr>
101 <% end %>
102 </table>
103 <% end %>
104 </div>
105
106 <div>
107   <strong>Recent pipeline instances</strong>
108   <%= link_to '(refresh)', request.fullpath, class: 'refresh', remote: true, method: 'get' %>
109   <%= link_to raw("Show all pipeline instances &rarr;"), pipeline_instances_path, class: 'pull-right' %>
110   <% if not current_user.andand.is_active or @my_pipelines.empty? %>
111     <p>(None)</p>
112   <% else %>
113     <table class="table table-bordered table-condensed table-fixedlayout">
114       <colgroup>
115         <col width="30%" />
116         <col width="30%" />
117         <col width="13%" />
118         <col width="27%" />
119       </colgroup>
120
121       <tr>
122         <th>Instance</th>
123         <th>Template</th>
124         <th>Age</th>
125         <th>Status</th>
126       </tr>
127
128       <% @my_pipelines[0..6].each do |p| %>
129         <tr>
130           <td>
131             <small>
132               <%= link_to_if_arvados_object p.uuid, friendly_name: true %>
133             </small>
134           </td>
135
136           <td>
137             <small>
138               <%= link_to_if_arvados_object p.pipeline_template_uuid, friendly_name: true %>
139             </small>
140           </td>
141
142           <td>
143             <small>
144               <%= raw(distance_of_time_in_words(p.created_at, Time.now).sub('about
145 ','~').sub(' ','&nbsp;')) if p.created_at %>
146             </small>
147           </td>
148
149           <td>
150             <% if p.success %>
151               <span class="label label-success">finished</span>
152             <% elsif p.success == false %>
153               <span class="label label-danger">failed</span>
154             <% elsif p.active and p.modified_at < 30.minutes.ago %>
155               <span class="label label-info">stopped</span>
156             <% elsif p.active %>
157               <span class="label label-info">running</span>
158             <% else %>
159               <span class="label">queued</span>
160             <% end %>
161
162             <% summary = pipeline_summary p %>
163             <div class="inline-progress-container pull-right">
164               <div class="progress">
165                 <span class="progress-bar progress-bar-success" style="width: <%= summary[:percent_done] %>%;">
166                 </span>
167                 <% if p.success == false %>
168                 <span class="progress-bar progress-bar-danger" style="width: <%= 100.0 - summary[:percent_done] %>%;">
169                 </span>
170                 <% else %>
171                 <span class="progress-bar" style="width: <%= summary[:percent_running] %>%;">
172                 </span>
173                 <span class="progress-bar progress-bar-info" style="width: <%= summary[:percent_queued] %>%;">
174                 </span>
175                 <span class="progress-bar progress-bar-danger" style="width: <%= summary[:percent_failed] %>%;">
176                 </span>
177                 <% end %>
178               </div>
179             </div>
180           </td>
181
182         </tr>
183       <% end %>
184     </table>
185   <% end %>
186 </div>
187
188 <div>
189   <strong>Recent collections</strong>
190   <%= link_to '(refresh)', request.fullpath, class: 'refresh', remote: true, method: 'get' %>
191   <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
192   <div class="pull-right" style="padding-right: 1em; width: 30%;">
193     <%= form_tag collections_path,
194           method: 'get',
195           class: 'form-search small-form-margin' do %>
196     <div class="input-group input-group-sm">
197       <%= text_field_tag :search, params[:search], class: 'form-control', placeholder: 'Search' %>
198       <span class="input-group-btn">
199         <%= button_tag(class: 'btn btn-info') do %>
200         <span class="glyphicon glyphicon-search"></span>
201         <% end %>
202       </span>
203     </div>  
204     <% end %>
205   </div>
206   <% if not current_user.andand.is_active or @my_collections.empty? %>
207     <p>(None)</p>
208   <% else %>
209     <table class="table table-bordered table-condensed table-fixedlayout">
210       <colgroup>
211         <col width="46%" />
212         <col width="27%" />
213         <col width="27%" />
214       </colgroup>
215
216       <tr>
217         <th>Contents</th>
218         <th>Tags</th>
219         <th>Age</th>
220       </tr>
221
222       <% @my_collections[0..6].each do |c| %>
223         <tr>
224           <td>
225             <small>
226               <a href="<%= collection_path(c.uuid) %>">
227                 <% c.files.each do |file| %>
228                   <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
229                 <% end %>
230               </a>
231             </small>
232           </td>
233           <td>
234             <% if @my_tag_links[c.uuid] %>
235             <small>
236               <%= @my_tag_links[c.uuid].collect(&:name).join(", ") %>
237             </small>
238             <% end %>
239           </td>
240           <td>
241             <small>
242               <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about
243 ','~').sub(' ','&nbsp;')) if c.created_at %>
244             </small>
245           </td>
246         </tr>
247       <% end %>
248     </table>
249   <% end %>
250 </div>
251
252 <% else %>
253   <%= image_tag "dax.png", style: "max-width=40%" %>
254 <% end %>
255
256 <% content_for :js do %>
257 setInterval(function(){$('a.refresh:eq(0)').click()}, 60000);
258 <% end %>