d9bc667cbb8b71e5a3ffc085846d9dfbb81a655c
[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 action="." class="pull-right">
74         {% get_params_as_hidden 'host' 'submission' 'finish' %}
75         <div class="btn-toolbar" role="toolbar">
76             <div class="btn-group" role="group">
77                 <div class="input-group">
78                     <input type="search" name="keywords" value="{{ filters.keywords.value|default:'' }}"
79                            maxlength="500" class="form-control" placeholder="Wyszukaj frazę">
80                     <span class="input-group-btn">
81                         <button class="btn btn-default" type="submit" title="Szukaj">
82                             <span class="glyphicon glyphicon-search"></span>
83                         </button>
84                     </span>
85                 </div>
86             </div>
87             <div class="btn-group" data-toggle="buttons">
88                 <label class="btn btn-default{% if checked_status.0 %} active{% endif %}" title="Aktywne">
89                     <input name="status" value="0" type="checkbox" {% if checked_status.0 %}checked{% endif %} onchange="this.form.submit()">
90                     <span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span>
91                 </label>
92                 <label class="btn btn-default{% if checked_status.1 %} active{% endif %}" title="Zakończone">
93                     <input name="status" value="1" type="checkbox" {% if checked_status.1 %}checked{% endif %} onchange="this.form.submit()">
94                     <span class="glyphicon glyphicon-saved" aria-hidden="true"></span>
95                 </label>
96                 <label class="btn btn-default{% if checked_status.2 %} active{% endif %}" title="Niepowodzenia">
97                     <input name="status" value="2" type="checkbox" {% if checked_status.2 %}checked{% endif %} onchange="this.form.submit()">
98                     <span class="glyphicon glyphicon-alert" aria-hidden="true"></span>
99                 </label>
100             </div>
101             <div class="btn-group" role="group">
102                 <a href="#advanced" data-toggle="modal" class="btn btn-default" title="Filtry zaawansowane">
103                     <span class="glyphicon glyphicon-option-horizontal"></span>
104                 </a>
105             </div>
106             <div class="btn-group" role="group">
107                 <a href="#columns" data-toggle="modal" class="btn btn-default" title="Kolumny">
108                     <span class="glyphicon glyphicon-list"></span>
109                 </a>
110             </div>
111         </div>
112     </form>
113
114     <h1 class="page-header">
115         {% block title %}Lista zadań{% endblock %}
116     </h1>
117
118     {% if selected_filters %}
119         <div class="row">
120             <div class="col-md-offset-1 col-md-10">
121                 <a href="." class="pull-right"><span class="text-muted small">Wyczyść wszystkie filtry</span></a>
122                 <strong>Wybrane filtry:</strong>
123                 {% for label, param, val in selected_filters %}
124                     <span class="label label-primary">{{ label }}&nbsp;<a href=".{% query_string param-=val %}" style="color: white"><span class="glyphicon glyphicon-remove"></span></a></span>
125                 {% endfor %}
126             </div>
127         </div>
128
129         <hr>
130     {% endif %}
131
132     <nav class="text-center" style="margin-bottom: 15px">
133         <form action="." method="get" class="form-inline" role="form" style="display: inline-block">
134             <div class="input-group input-group-sm">
135                 <span class="input-group-btn">
136                     {% if page.has_previous %}
137                         <a href="{% query_string "page"=page.previous_page_number %}" class="btn btn-default">
138                     {% else %}
139                         <a href="#" class="btn btn-default disabled">
140                     {% endif %}
141                         <span class="glyphicon glyphicon-chevron-left"></span>
142                     </a>
143                 </span>
144                 <label class="sr-only" for="page">Strona</label>
145                 <input type="text" class="form-control text-center" id="page" name="page" value="{{ page.number }}" style="width: 50px">
146                 <span class="input-group-btn">
147                     {% if page.has_next %}
148                         <a href="{% query_string "page"=page.next_page_number %}" class="btn btn-default">
149                     {% else %}
150                         <a href="#" class="btn btn-default disabled">
151                     {% endif %}
152                         <span class="glyphicon glyphicon-chevron-right"></span>
153                     </a>
154                 </span>
155             </div>
156         </form>
157         &nbsp;z&nbsp;
158         <a href="{% query_string "page"=num_pages %}">{{ num_pages }}</a>
159     </nav>
160
161     <table class="table table-hover tree">
162         <thead>
163             <tr>
164                 <th{% if columns.JOB_ID not in displayed %} style="width: 80px"{% endif %}></th>
165                 {% if columns.DESCRIPTION in displayed %}<th>Opis</th>{% endif %}
166                 {% if columns.SUBMISSION in displayed %}<th>Wysłane</th>{% endif %}
167                 {% if columns.START in displayed %}<th>Start</th>{% endif %}
168                 {% if columns.END in displayed %}<th>Koniec</th>{% endif %}
169                 {% if columns.STATUS in displayed %}<th>Status</th>{% endif %}
170                 {% if columns.HOST in displayed %}<th>Host</th>{% endif %}
171                 <th></th>
172 {#                <th>Uwagi</th>#}
173             </tr>
174         </thead>
175         <tbody>
176             {% regroup page by job as jobs %}
177
178             {% for job in jobs %}
179                 {% ifequal job.list|length 1 %}
180                     {% with job.list.0 as task %}
181                         <tr class="treegrid-{{ forloop.counter }}">
182                             <td>
183                                 <a href="{{ task.get_absolute_url }}">
184                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
185                                     {% if columns.JOB_ID in displayed %}{{ task }}{% endif %}
186                                 </a>
187                             </td>
188                             {% if columns.DESCRIPTION in displayed %}<td>{{ task.note }}</td>{% endif %}
189                             {% if columns.SUBMISSION in displayed %}<td>{{ task.submission_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
190                             {% if columns.START in displayed %}<td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
191                             {% if columns.END in displayed %}<td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
192                             {% if columns.STATUS in displayed %}<td>{{ task.get_status_display }}</td>{% endif %}
193                             {% if columns.HOST in displayed %}<td>{{ task.short_host_names|join:', ' }}</td>{% endif %}
194                             <td><a href="{{ task.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
195                         </tr>
196                     {% endwith %}
197                 {% else %}
198                     <tr class="treegrid-{{ forloop.counter }}">
199                         <td>
200                             <a href="{{ job.grouper.get_absolute_url }}">
201                                 <span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span>
202                                 {% if columns.JOB_ID in displayed %}{{ job.grouper }}{% endif %}
203                             </a>
204                         </td>
205                         {% if columns.DESCRIPTION in displayed %}<td>{{ job.grouper.note }}</td>{% endif %}
206                         {% if columns.SUBMISSION in displayed %}<td>{{ job.grouper.submission_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
207                         {% if columns.START in displayed %}<td>-</td>{% endif %}
208                         {% if columns.END in displayed %}<td>{{ job.grouper.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
209                         {% if columns.STATUS in displayed %}<td>{{ job.grouper.get_status_display }}</td>{% endif %}
210                         {% if columns.HOST in displayed %}<td>-</td>{% endif %}
211                         <td><a href="{{ job.grouper.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
212                     </tr>
213
214                     {% for task in job.list %}
215                         <tr class="treegrid-{{ forloop.parentloop.counter }}-{{ forloop.counter }} treegrid-parent-{{ forloop.parentloop.counter }}">
216                             <td>
217                                 <a href="{{ task.get_absolute_url }}">
218                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
219                                     {% if columns.JOB_ID in displayed %}{{ task }}{% endif %}
220                                 </a>
221                             </td>
222                             {% if columns.DESCRIPTION in displayed %}<td>{{ task.note }}</td>{% endif %}
223                             {% if columns.SUBMISSION in displayed %}<td>{{ task.submission_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
224                             {% if columns.START in displayed %}<td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
225                             {% if columns.END in displayed %}<td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>{% endif %}
226                             {% if columns.STATUS in displayed %}<td>{{ task.get_status_display }}</td>{% endif %}
227                             {% if columns.HOST in displayed %}<td>{{ task.short_host_names|join:', ' }}</td>{% endif %}
228                             <td><a href="{{ task.get_absolute_url }}">szczegóły&nbsp;&rsaquo;</a></td>
229                         </tr>
230                     {% endfor %}
231                 {% endifequal %}
232             {% endfor %}
233         </tbody>
234     </table>
235
236     {% if not page %}
237         <div class="alert alert-info">
238             <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
239             Brak zadań spełniających wybrane kryteria
240         </div>
241     {% endif %}
242
243     <nav class="text-center">
244         <ul class="pagination">
245             {% if page.has_previous %}
246                 <li>
247                     <a href="{% query_string "page"=page.previous_page_number %}" aria-label="Previous">
248                     <span aria-hidden="true"><span class="glyphicon glyphicon-chevron-left"></span>&nbsp;poprzednia</span>
249                 </a>
250             {% endif %}
251             </li>
252
253             <li{% ifequal page.number 1 %} class="active"{% endifequal %}>
254                 <a href="{% query_string "page"=1 %}">1</a>
255             </li>
256
257             {% if pages_range.0 > 2 %}
258                 <li class="disabled"><span aria-hidden="true"><strong>&hellip;</strong></span></li>
259             {% endif %}
260
261             {% for num in pages_range %}
262                 <li{% ifequal page.number num %} class="active"{% endifequal %}>
263                     <a href="{% query_string "page"=num %}">{{ num }}</a>
264                 </li>
265             {% endfor %}
266
267             <li class="disabled"><span aria-hidden="true"><strong>z</strong></span></li>
268             <li><a href="{% query_string "page"=num_pages %}">{{ num_pages }}</a></li>
269
270             {% if page.has_next %}
271                 <li>
272                     <a href="{% query_string "page"=page.next_page_number %}" aria-label="Next">
273                     <span aria-hidden="true">następna&nbsp;<span class="glyphicon glyphicon-chevron-right"></span></span>
274                 </a>
275             {% endif %}
276             </li>
277         </ul>
278     </nav>
279
280     <!-- Modal -->
281     <div class="modal fade" id="advanced" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
282         <div class="modal-dialog modal-lg">
283             <div class="modal-content">
284                 <div class="modal-header">
285                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
286                     <h4 class="modal-title" id="modal-label">Filtry zaawansowane</h4>
287                 </div>
288                 <div class="modal-body">
289                     <form id="advanced-form" action="." class="form-horizontal">
290                         {% bootstrap_field filters.keywords layout='horizontal' bound_css_class=' ' %}
291                         <div class="form-group">
292                             <label class="col-sm-3 col-md-4 control-label">Status</label>
293                             <div class="col-sm-9 col-md-6">
294                                 <div class="btn-group" data-toggle="buttons">
295                                     {% for choice in filters.status %}
296                                         <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
297                                             <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
298                                                    {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
299                                         </label>
300                                     {% endfor %}
301                                 </div>
302                             </div>
303                         </div>
304
305                         <div class="form-group">
306                             <label class="col-sm-3 col-md-4 control-label">Host</label>
307                             <div class="col-sm-9 col-md-6">
308                                 <div class="btn-group" data-toggle="buttons">
309                                     {% for choice in filters.host %}
310                                         <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
311                                             <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
312                                                    {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
313                                         </label>
314                                     {% endfor %}
315                                 </div>
316                             </div>
317                         </div>
318                         {% bootstrap_field filters.submission layout='horizontal' bound_css_class=' ' %}
319                         {% bootstrap_field filters.finish layout='horizontal' bound_css_class=' ' %}
320                     </form>
321                 </div>
322                 <div class="modal-footer">
323                     <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
324                     <a href="." class="btn btn-warning">Wyczyść filtry</a>
325                     <button type="submit" class="btn btn-primary" form="advanced-form">Filtruj</button>
326                 </div>
327             </div>
328         </div>
329     </div>
330
331     {# Column selection modal #}
332     <div class="modal fade" id="columns" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
333         <div class="modal-dialog">
334             <div class="modal-content">
335                 <div class="modal-header">
336                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
337                     <h4 class="modal-title" id="modal-label">Wybór kolumn</h4>
338                 </div>
339                 <div class="modal-body">
340                     <form id="columns-form" action=".">
341                         {% bootstrap_field columns.columns %}
342                     </form>
343                 </div>
344                 <div class="modal-footer">
345                     <button type="button" class="btn btn-default" data-dismiss="modal">Anuluj</button>
346                     <a id="select-all-columns" class="btn btn-success">Wybierz wszystkie</a>
347                     <a id="default-columns" class="btn btn-warning">Domyślne</a>
348                     <button type="submit" class="btn btn-primary" form="columns-form">Zapisz</button>
349                 </div>
350             </div>
351         </div>
352     </div>
353
354 {% endblock container %}