filtering in job list view
[qcg-portal.git] / qcg / templates / qcg / jobs.html
1 {% extends 'qcg/base.html' %}
2 {% load staticfiles bootstrap3 %}
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/daterangepicker/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             $('#toggle-advanced').click(function() {
59                 if($('#advanced-filters').attr('aria-expanded') == "false")
60                     $(this).text('« mniej');
61                 else
62                     $(this).text('więcej »');
63             });
64         });
65     </script>
66 {% endblock %}
67
68 {% block container %}
69     <h1 class="page-header">
70         {% block title %}Lista zadań{% endblock %}
71     </h1>
72
73     <form action=".">
74         <div class="row">
75             <div class="col-lg-10 col-lg-offset-1">
76                 <div class="pull-right">
77                     <a id="toggle-advanced" href="#advanced-filters" data-toggle="collapse">
78                         {% if advanced %}
79                             &laquo;&nbsp;mniej
80                         {% else %}
81                             więcej&nbsp;&raquo;
82                         {% endif %}
83                     </a>
84                     &nbsp;
85                     <a href="." class="btn btn-default{% if not filters.data %} disabled{% endif %}">Wyczyść</a>
86                     <button type="submit" class="btn btn-default">Filtruj</button>
87                 </div>
88                 <div class="btn-toolbar">
89                     <div class="btn-group" data-toggle="buttons">
90                         {% for choice in filters.status %}
91                             <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
92                                 <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
93                                        {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
94                             </label>
95                         {% endfor %}
96                     </div>
97                     <div class="btn-group" data-toggle="buttons">
98                         {% for choice in filters.host %}
99                             <label class="btn btn-default{% if choice.is_checked %} active{% endif %}">
100                                 <input type="checkbox" name="{{ choice.name }}" value="{{ choice.choice_value }}"
101                                        {% if choice.is_checked %}checked{% endif %}> {{ choice.choice_label }}
102                             </label>
103                         {% endfor %}
104                     </div>
105                 </div>
106             </div>
107         </div>
108 {#        <div id="advanced-filters" class="form-horizontal collapse in" aria-expanded="true" style="margin-top: 10px">#}
109 {#            <div class="row">#}
110 {#                {% bootstrap_field filters.keywords layout='horizontal' horizontal_label_class='col-md-5' horizontal_field_class='col-md-4' bound_css_class=' ' %}#}
111 {#            </div>#}
112 {#            <div class="row">#}
113 {#                {% bootstrap_field filters.status_exact layout='horizontal' horizontal_label_class='col-md-5' horizontal_field_class='col-md-4' bound_css_class=' ' %}#}
114 {#            </div>#}
115 {#            <div class="row">#}
116 {#                {% bootstrap_field filters.submission layout='horizontal' horizontal_label_class='col-md-5' horizontal_field_class='col-md-4' bound_css_class=' ' %}#}
117 {#            </div>#}
118 {#            <div class="row">#}
119 {#                {% bootstrap_field filters.finish layout='horizontal' horizontal_label_class='col-md-5' horizontal_field_class='col-md-4' bound_css_class=' ' %}#}
120 {#            </div>#}
121 {#        </div>#}
122         <div id="advanced-filters" class="form-horizontal collapse{% if advanced %} in" aria-expanded="true"{% else %}" aria-expanded="false"{% endif %} style="margin-top: 10px">
123             <div class="row">
124                 <div class="col-ld-1"></div>
125                 {% bootstrap_field filters.keywords layout='horizontal' form_group_class='form-group row col-lg-5 col-md-6' horizontal_label_class='col-md-4' horizontal_field_class='col-md-8' bound_css_class=' ' %}
126                 {% bootstrap_field filters.status_exact layout='horizontal' form_group_class='form-group row col-lg-5 col-md-6' horizontal_label_class='col-md-4' horizontal_field_class='col-md-8' bound_css_class=' ' %}
127             </div>
128             <div class="row">
129                 <div class="col-ld-1"></div>
130                 {% bootstrap_field filters.submission layout='horizontal' form_group_class='form-group row col-lg-5 col-md-6' horizontal_label_class='col-md-4' horizontal_field_class='col-md-8' bound_css_class=' ' %}
131                 {% bootstrap_field filters.finish layout='horizontal' form_group_class='form-group row col-lg-5 col-md-6' horizontal_label_class='col-md-4' horizontal_field_class='col-md-8' bound_css_class=' ' %}
132             </div>
133         </div>
134     </form>
135
136     <hr />
137
138
139     <nav class="text-center" style="margin-bottom: 15px">
140         <form action="{{ request.path }}" method="get" class="form-inline" role="form" style="display: inline-block">
141             <div class="input-group input-group-sm">
142                 <span class="input-group-btn">
143                     {% if page.has_previous %}
144                         <a href="{{ request.path }}?page={{ page.previous_page_number }}" class="btn btn-default">
145                     {% else %}
146                         <a href="#" class="btn btn-default disabled">
147                     {% endif %}
148                         <span class="glyphicon glyphicon-chevron-left"></span>
149                     </a>
150                 </span>
151                 <label class="sr-only" for="page">Strona</label>
152                 <input type="text" class="form-control text-center" id="page" name="page" value="{{ page.number }}" style="width: 50px">
153                 <span class="input-group-btn">
154                     {% if page.has_next %}
155                         <a href="{{ request.path }}?page={{ page.next_page_number }}" class="btn btn-default">
156                     {% else %}
157                         <a href="#" class="btn btn-default disabled">
158                     {% endif %}
159                         <span class="glyphicon glyphicon-chevron-right"></span>
160                     </a>
161                 </span>
162             </div>
163         </form>
164         &nbsp;z&nbsp;
165         <a href="{{ request.path }}?page={{ num_pages }}">{{ num_pages }}</a>
166     </nav>
167
168     <table class="table table-hover tree">
169         <thead>
170             <tr>
171                 <th style="width: 80px"></th>
172                 <th>Opis</th>
173                 <th>Wysłane</th>
174                 <th>Start</th>
175                 <th>Koniec</th>
176                 <th>Status</th>
177                 <th>Host</th>
178 {#                <th>Uwagi</th>#}
179             </tr>
180         </thead>
181         <tbody>
182             {% regroup page by job as jobs %}
183
184             {% for job in jobs %}
185                 {% ifequal job.list|length 1 %}
186                     {% with job.list.0 as task %}
187                         <tr class="treegrid-{{ forloop.counter }}">
188                             <td>
189                                 <a href="{{ task.get_absolute_url }}">
190                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
191 {#                                    {{ task }}#}
192                                 </a>
193                             </td>
194                             <td>{{ task.note }}</td>
195                             <td>{{ task.submission_time|timesince }} temu</td>
196                             <td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
197                             <td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
198                             <td>{{ task.get_status_display }}</td>
199                             <td>{{ task.short_host_names|join:', ' }}</td>
200                         </tr>
201                     {% endwith %}
202                 {% else %}
203                     <tr class="treegrid-{{ forloop.counter }}">
204                         <td>
205                             <a href="{{ job.grouper.get_absolute_url }}">
206                                 <span class="glyphicon glyphicon-folder-close" aria-hidden="true"></span>
207 {#                                {{ job.grouper }}#}
208                             </a>
209                         </td>
210                         <td>{{ job.grouper.note }}</td>
211                         <td>{{ job.grouper.submission_time|timesince  }} temu</td>
212                         <td>-</td>
213                         <td>{{ job.grouper.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
214                         <td>{{ job.grouper.get_status_display }}</td>
215                         <td>-</td>
216                     </tr>
217
218                     {% for task in job.list %}
219                         <tr class="treegrid-{{ forloop.parentloop.counter }}-{{ forloop.counter }} treegrid-parent-{{ forloop.parentloop.counter }}">
220                             <td>
221                                 <a href="{{ task.get_absolute_url }}">
222                                     <span class="glyphicon glyphicon-file" aria-hidden="true"></span>
223 {#                                    {{ task }}#}
224                                 </a>
225                             </td>
226                             <td>{{ task.note }}</td>
227                             <td>{{ task.submission_time|timesince  }} temu</td>
228                             <td>{{ task.start_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
229                             <td>{{ task.finish_time|date:"CUSTOM_DATETIME_FORMAT" }}</td>
230                             <td>{{ task.get_status_display }}</td>
231                             <td>{{ task.short_host_names|join:', ' }}</td>
232                         </tr>
233                     {% endfor %}
234                 {% endifequal %}
235             {% endfor %}
236         </tbody>
237     </table>
238
239     {% if not page %}
240         <div class="alert alert-info">Brak elementów</div>
241     {% endif %}
242
243     <nav class="text-center">
244         <ul class="pagination">
245             {% if page.has_previous %}
246                 <li>
247                     <a href="{{ request.path }}?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="{{ request.path }}?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="{{ request.path }}?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="{{ request.path }}?page={{ num_pages }}">{{ num_pages }}</a></li>
269
270             {% if page.has_next %}
271                 <li>
272                     <a href="{{ request.path }}?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 {% endblock container %}