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