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