Add collection search box on home page.
[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 raw("Show all jobs &rarr;"), jobs_path, class: 'pull-right' %>
5     <% if not current_user.andand.is_active or @my_jobs.empty? %>
6       <br/>(None)
7     <% else %>
8       <table class="table table-bordered table-condensed table-fixedlayout">
9         <colgroup>
10           <col width="28%" />
11           <col width="38%" />
12           <col width="7%" />
13           <col width="15%" />
14           <col width="12%" />
15         </colgroup>
16
17         <tr>
18           <th>Script</th>
19           <th>Output</th>
20           <th>Log</th>
21           <th>Age</th>
22           <th>Status</th>
23         </tr>
24
25         <% @my_jobs[0..6].each do |j| %>
26           <tr>
27             <td>
28               <small>
29                 <%= link_to j.script[0..31], job_path(j.uuid) %>
30               </small>
31             </td>
32
33             <td>
34               <small>
35                 <% if j.success %>
36
37                   <a href="<%= collection_path(j.output) %>">
38                     <% Collection.limit(1).where(uuid: j.output).each do |c|
39                          c.files.each do |file| %>
40                       <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
41                     <% end %>
42                 <% end %>
43                 </a>
44
45         <% end %>
46         </small>
47 </td>
48
49 <td>
50   <small>
51     <% if j.log %>
52       <a href="<%= collection_path(j.log) %>">Log</a>
53     <% end %>
54   </small>
55 </td>
56
57 <td>
58   <small>
59     <%= raw(distance_of_time_in_words(j.created_at, Time.now).sub('about
60 ','~').sub(' ','&nbsp;')) if j.created_at %>
61   </small>
62 </td>
63
64 <td>
65   <% if j.success %>
66     <span class="label label-success">finished</span>
67   <% elsif j.success == false %>
68     <span class="label label-danger">failed</span>
69   <% elsif j.running and j.started_at and not j.finished_at %>
70     <% percent_total_tasks = 100 / (j.tasks_summary[:running] + j.tasks_summary[:done] + j.tasks_summary[:todo]) rescue 0 %>
71     <div class="progress" style="margin-bottom: 0">
72       <div class="bar bar-success" style="width: <%= j.tasks_summary[:done] * percent_total_tasks rescue 0 %>%;"></div>
73       <div class="bar" style="width: <%= j.tasks_summary[:running] * percent_total_tasks rescue 0 %>%; opacity: 0.3"></div>
74     </div>
75   <% else %>
76     <span class="label">queued</span>
77   <% end %>
78 </td>
79
80 </tr>
81 <% end %>
82 </table>
83 <% end %>
84 </div>
85
86 <div>
87   <strong>Recent pipeline instances</strong>
88   <%= link_to raw("Show all pipeline instances &rarr;"), jobs_path, class: 'pull-right' %>
89   <% if not current_user.andand.is_active or @my_pipelines.empty? %>
90     <br/>(None)
91   <% else %>
92     <table class="table table-bordered table-condensed table-fixedlayout">
93       <colgroup>
94         <col width="73%" />
95         <col width="15%" />
96         <col width="12%" />
97       </colgroup>
98
99       <tr>
100         <th>Pipeline template</th>
101         <th>Age</th>
102         <th>Status</th>
103       </tr>
104
105       <% @my_pipelines[0..6].each do |p| %>
106         <tr>
107           <td>
108             <small>
109               <% PipelineTemplate.limit(1).where(uuid: p.pipeline_template_uuid).each do |i| %>
110                 <%= link_to i.name, pipeline_instance_path(p.uuid) %>
111               <% end %>
112             </small>
113           </td>
114
115           <td>
116             <small>
117               <%= raw(distance_of_time_in_words(p.created_at, Time.now).sub('about
118 ','~').sub(' ','&nbsp;')) if p.created_at %>
119             </small>
120           </td>
121
122           <td>
123             <% if p.success %>
124               <span class="label label-success">finished</span>
125             <% elsif p.success == false %>
126               <span class="label label-danger">failed</span>
127             <% elsif p.active %>
128               <span class="label label-info">running</span>
129             <% else %>
130               <span class="label">queued</span>
131             <% end %>
132           </td>
133
134         </tr>
135       <% end %>
136     </table>
137   <% end %>
138 </div>
139
140 <div>
141   <strong>Recent collections</strong>
142   <%= link_to raw("Show all collections &rarr;"), collections_path, class: 'pull-right' %>
143   <div class="pull-right" style="padding-right: 1em">
144     <%= form_tag collections_path,
145           method: 'get',
146           class: 'form-search small-form-margin' do %>
147     <div class="input-append">
148       <%= text_field_tag :search, params[:search], class: 'search-query search-mini' %>
149       <%= submit_tag "Search", name: nil, class: 'btn btn-mini btn-info' %>
150     </div>  
151     <% end %>
152   </div>
153   <% if not current_user.andand.is_active or @my_collections.empty? %>
154     <br/>(None)
155   <% else %>
156     <table class="table table-bordered table-condensed table-fixedlayout">
157       <colgroup>
158         <col width="46%" />
159         <col width="27%" />
160         <col width="27%" />
161       </colgroup>
162
163       <tr>
164         <th>Contents</th>
165         <th>Tags</th>
166         <th>Age</th>
167       </tr>
168
169       <% @my_collections[0..6].each do |c| %>
170         <tr>
171           <td>
172             <small>
173               <a href="<%= collection_path(c.uuid) %>">
174                 <% c.files.each do |file| %>
175                   <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
176                 <% end %>
177               </a>
178             </small>
179           </td>
180           <td>
181             <% if @my_tag_links[c.uuid] %>
182             <small>
183               <%= @my_tag_links[c.uuid].collect(&:name).join(", ") %>
184             </small>
185             <% end %>
186           </td>
187           <td>
188             <small>
189               <%= raw(distance_of_time_in_words(c.created_at, Time.now).sub('about
190 ','~').sub(' ','&nbsp;')) if c.created_at %>
191             </small>
192           </td>
193         </tr>
194       <% end %>
195     </table>
196   <% end %>
197 </div>
198
199 <% else %>
200   <%= image_tag "dax.png", style: "max-width=40%" %>
201 <% end %>