fix changed path & accessibility tweaks
[qcg-portal.git] / qcg / templates / qcg / jobs.html
1 {% extends 'qcg/base.html' %}
2 {% load staticfiles bootstrap3 query_string qcg_utils %}
3
4 {% block extra_css %}
5     <link href="{% static 'qcg/treegrid/css/jquery.treegrid.css' %}" rel="stylesheet">
6     <link href="{% static 'qcg/daterangepicker/daterangepicker-bs3.css' %}" rel="stylesheet" />
7
8     <style>
9         .treegrid-expander {
10             opacity: 0.5;
11         }
12
13         .treegrid-expander:hover {
14             opacity: 1;
15         }
16     </style>
17 {% endblock %}
18
19 {% block extra_js %}
20     <script src="{% static 'qcg/treegrid/js/jquery.treegrid.js' %}"></script>
21     <script src="{% static 'qcg/moment/moment.min.js' %}"></script>
22     <script src="{% static 'qcg/daterangepicker/daterangepicker.js' %}"></script>
23
24     <script>
25         $(function() {
26             $('.tree').treegrid({
27                 initialState: 'collapsed',
28                 expanderExpandedClass: 'glyphicon glyphicon-chevron-down small',
29                 expanderCollapsedClass: 'glyphicon glyphicon-chevron-right small',
30                 onChange: function() {
31                     $(this).find('.glyphicon-folder-open,.glyphicon-folder-close')
32                             .toggleClass('glyphicon-folder-open').toggleClass('glyphicon-folder-close');
33                 }
34             });
35
36             $('input[name="submission"],input[name="finish"]').daterangepicker({
37                 opens: 'center',
38                 format: 'DD.MM.YYYY',
39                 ranges: {
40                     'Dzisiaj': [moment(), moment()],
41                     'Wczoraj': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
42                     'Ostatnie 7 dni': [moment().subtract(6, 'days'), moment()],
43                     'Ostatnie 30 dni': [moment().subtract(29, 'days'), moment()]
44                 },
45                 locale: {
46                     applyLabel: 'OK',
47                     cancelLabel: 'Anuluj',
48                     fromLabel: 'Od',
49                     toLabel: 'Do',
50                     weekLabel: 'T',
51                     customRangeLabel: 'Zakres',
52                     daysOfWeek: moment.weekdaysMin(),
53                     monthNames: ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'],
54                     firstDay: 1
55                 }
56             });
57         });
58     </script>
59 {% endblock %}
60
61 {% block container %}
62     <form id="simple-form" action="." role="search" class="pull-right">
63         {% get_params_as_hidden 'host' 'submission' 'finish' %}
64         <div style="display: inline-block; vertical-align: middle;">
65             <div class="input-group">
66                 <input type="search" name="keywords" value="{{ filters.keywords.value|default:'' }}"
67                        maxlength="500" class="form-control" placeholder="Wyszukaj frazę">
68                 <span class="input-group-btn">
69                     <button class="btn btn-default" type="submit" title="Szukaj">
70                         <span class="glyphicon glyphicon-search"></span>
71                     </button>
72                 </span>
73             </div>
74         </div>
75         <div class="btn-group" data-toggle="buttons">
76             <label class="btn btn-default{% if checked_status.0 %} active{% endif %}" title="Aktywne">
77                 <input name="status" value="0" type="checkbox" {% if checked_status.0 %}checked{% endif %} onchange="this.form.submit()">
78                 <span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span>
79             </label>
80             <label class="btn btn-default{% if checked_status.1 %} active{% endif %}" title="Zakończone">
81                 <input name="status" value="1" type="checkbox" {% if checked_status.1 %}checked{% endif %} onchange="this.form.submit()">
82                 <span class="glyphicon glyphicon-saved" aria-hidden="true"></span>
83             </label>
84             <label class="btn btn-default{% if checked_status.2 %} active{% endif %}" title="Niepowodzenia">
85                 <input name="status" value="2" type="checkbox" {% if checked_status.2 %}checked{% endif %} onchange="this.form.submit()">
86                 <span class="glyphicon glyphicon-alert" aria-hidden="true"></span>
87             </label>
88         </div>
89         <a href="#advanced" data-toggle="modal" class="btn btn-default" title="Filtry zaawansowane" style="margin-left: 4px">
90             <span class="glyphicon glyphicon-option-horizontal"></span>
91         </a>
92     </form>
93
94     <h1 class="page-header">
95         {% block title %}Lista zadań{% endblock %}
96     </h1>
97
98     {% if selected_filters %}
99         <div class="row">
100             <div class="col-md-offset-1 col-md-10">
101                 <a href="." class="pull-right"><span class="text-muted small">Wyczyść wszystkie filtry</span></a>
102                 <strong>Wybrane filtry:</strong>
103                 {% for label, param, val in selected_filters %}
104                     <span class="label label-primary">{{ label }}&nbsp;<a href="{% query_string param-=val %}" style="color: white"><span class="glyphicon glyphicon-remove"></span></a></span>
105                 {% endfor %}
106             </div>
107         </div>
108
109         <hr>
110     {% endif %}
111
112     <nav class="text-center" style="margin-bottom: 15px">
113         <form action="." method="get" class="form-inline" role="form" style="display: inline-block">
114             <div class="input-group input-group-sm">
115                 <span class="input-group-btn">
116                     {% if page.has_previous %}
117                         <a href="{% query_string "page"=page.previous_page_number %}" class="btn btn-default">
118                     {% else %}
119                         <a href="#" class="btn btn-default disabled">
120                     {% endif %}
121                         <span class="glyphicon glyphicon-chevron-left"></span>
122                     </a>
123                 </span>
124                 <label class="sr-only" for="page">Strona</label>
125                 <input type="text" class="form-control text-center" id="page" name="page" value="{{ page.number }}" style="width: 50px">
126                 <span class="input-group-btn">
127                     {% if page.has_next %}
128                         <a href="{% query_string "page"=page.next_page_number %}" class="btn btn-default">
129                     {% else %}
130                         <a href="#" class="btn btn-default disabled">
131                     {% endif %}
132                         <span class="glyphicon glyphicon-chevron-right"></span>
133                     </a>
134                 </span>
135             </div>
136         </form>
137         &nbsp;z&nbsp;
138         <a href="{% query_string "page"=num_pages %}">{{ num_pages }}</a>
139     </nav>
140
141     <table class="table table-hover tree">
142         <thead>
143             <tr>
144                 <th style="width: 80px"></th>
145                 <th>Opis</th>
146                 <th>Wysłane</th>
147                 <th>Start</th>
148                 <th>Koniec</th>
149                 <th>Status</th>
150                 <th>Host</th>
151                 <th></th>
152 {#                <th>Uwagi</th>#}
153             </tr>
154         </thead>
155         <tbody>
156             {% regroup page by job as jobs %}
157
158             {% for job in jobs %}
159                 {% ifequal job.list|length 1 %}
160                     {% with job.list.0 as task %}
161                         <tr class="treegrid-{{ forloop.counter }}">
162                             <td>
163                                 <a href="{{ task.get_absolute_url }}">
164                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
165 {#                                    {{ task }}#}
166                                 </a>
167                             </td>
168                             <td>{{ task.note }}</td>
169                             <td>{{ task.submission_time|timesince }} temu</td>
170                             <td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
171                             <td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
172                             <td>{{ task.get_status_display }}</td>
173                             <td>{{ task.short_host_names|join:', ' }}</td>
174                             <td><a href="{{ task.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
175                         </tr>
176                     {% endwith %}
177                 {% else %}
178                     <tr class="treegrid-{{ forloop.counter }}">
179                         <td>
180                             <a href="{{ job.grouper.get_absolute_url }}">
181                                 <span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span>
182 {#                                {{ job.grouper }}#}
183                             </a>
184                         </td>
185                         <td>{{ job.grouper.note }}</td>
186                         <td>{{ job.grouper.submission_time|timesince  }} temu</td>
187                         <td>-</td>
188                         <td>{{ job.grouper.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
189                         <td>{{ job.grouper.get_status_display }}</td>
190                         <td>-</td>
191                         <td><a href="{{ job.grouper.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
192                     </tr>
193
194                     {% for task in job.list %}
195                         <tr class="treegrid-{{ forloop.parentloop.counter }}-{{ forloop.counter }} treegrid-parent-{{ forloop.parentloop.counter }}">
196                             <td>
197                                 <a href="{{ task.get_absolute_url }}">
198                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
199 {#                                    {{ task }}#}
200                                 </a>
201                             </td>
202                             <td>{{ task.note }}</td>
203                             <td>{{ task.submission_time|timesince  }} temu</td>
204                             <td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
205                             <td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
206                             <td>{{ task.get_status_display }}</td>
207                             <td>{{ task.short_host_names|join:', ' }}</td>
208                             <td><a href="{{ task.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
209                         </tr>
210                     {% endfor %}
211                 {% endifequal %}
212             {% endfor %}
213         </tbody>
214     </table>
215
216     {% if not page %}
217         <div class="alert alert-info">
218             <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
219             Brak zadań spełniających wybrane kryteria
220         </div>
221     {% endif %}
222
223     <nav class="text-center">
224         <ul class="pagination">
225             {% if page.has_previous %}
226                 <li>
227                     <a href="{% query_string "page"=page.previous_page_number %}" aria-label="Previous">
228                     <span aria-hidden="true"><span class="glyphicon glyphicon-chevron-left"></span>&nbsp;poprzednia</span>
229                 </a>
230             {% endif %}
231             </li>
232
233             <li{% ifequal page.number 1 %} class="active"{% endifequal %}>
234                 <a href="{% query_string "page"=1 %}">1</a>
235             </li>
236
237             {% if pages_range.0 > 2 %}
238                 <li class="disabled"><span aria-hidden="true"><strong>&hellip;</strong></span></li>
239             {% endif %}
240
241             {% for num in pages_range %}
242                 <li{% ifequal page.number num %} class="active"{% endifequal %}>
243                     <a href="{% query_string "page"=num %}">{{ num }}</a>
244                 </li>
245             {% endfor %}
246
247             <li class="disabled"><span aria-hidden="true"><strong>z</strong></span></li>
248             <li><a href="{% query_string "page"=num_pages %}">{{ num_pages }}</a></li>
249
250             {% if page.has_next %}
251                 <li>
252                     <a href="{% query_string "page"=page.next_page_number %}" aria-label="Next">
253                     <span aria-hidden="true">następna&nbsp;<span class="glyphicon glyphicon-chevron-right"></span></span>
254                 </a>
255             {% endif %}
256             </li>
257         </ul>
258     </nav>
259
260     <!-- Modal -->
261     <div class="modal fade" id="advanced" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
262         <div class="modal-dialog modal-lg">
263             <div class="modal-content">
264                 <div class="modal-header">
265                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
266                     <h4 class="modal-title" id="modal-label">Filtry zaawansowane</h4>
267                 </div>
268                 <div class="modal-body">
269                     <form id="advanced-form" action="." class="form-horizontal">
270                         {% bootstrap_field filters.keywords layout='horizontal' bound_css_class=' ' %}
271                         <div class="form-group">
272                             <label class="col-sm-3 col-md-4 control-label">Status</label>
273                             <div class="col-sm-9 col-md-6">
274                                 <div class="btn-group" data-toggle="buttons">
275                                     {% for choice in filters.status %}
276                                         <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
277                                             <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
278                                                    {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
279                                         </label>
280                                     {% endfor %}
281                                 </div>
282                             </div>
283                         </div>
284
285                         <div class="form-group">
286                             <label class="col-sm-3 col-md-4 control-label">Host</label>
287                             <div class="col-sm-9 col-md-6">
288                                 <div class="btn-group" data-toggle="buttons">
289                                     {% for choice in filters.host %}
290                                         <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
291                                             <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
292                                                    {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
293                                         </label>
294                                     {% endfor %}
295                                 </div>
296                             </div>
297                         </div>
298                         {% bootstrap_field filters.submission layout='horizontal' bound_css_class=' ' %}
299                         {% bootstrap_field filters.finish layout='horizontal' bound_css_class=' ' %}
300                     </form>
301                 </div>
302                 <div class="modal-footer">
303                     <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
304                     <a href="." class="btn btn-warning">Wyczyść filtry</a>
305                     <button type="submit" class="btn btn-primary" form="advanced-form">Filtruj</button>
306                 </div>
307             </div>
308         </div>
309     </div>
310
311 {% endblock container %}