1 | function preProcessData (data, callback) { |
||
2 | const runIds = [] |
||
3 | const planIds = [] |
||
4 | data.forEach(function (element) { |
||
5 | runIds.push(element.id) |
||
6 | planIds.push(element.plan) |
||
7 | }) |
||
8 | |||
9 | // get tags for all objects |
||
10 | const tagsPerRun = {} |
||
11 | jsonRPC('Tag.filter', { run__in: runIds }, function (tags) { |
||
12 | tags.forEach(function (element) { |
||
13 | if (tagsPerRun[element.run] === undefined) { |
||
14 | tagsPerRun[element.run] = [] |
||
15 | } |
||
16 | |||
17 | // push only if unique |
||
18 | if (tagsPerRun[element.run].indexOf(element.name) === -1) { |
||
19 | tagsPerRun[element.run].push(element.name) |
||
20 | } |
||
21 | }) |
||
22 | |||
23 | jsonRPC('Product.filter', { plan__in: planIds }, function (products) { |
||
24 | products = arrayToDict(products) |
||
25 | |||
26 | // augment data set with additional info |
||
27 | data.forEach(function (element) { |
||
28 | if (element.id in tagsPerRun) { |
||
29 | element.tag = tagsPerRun[element.id] |
||
30 | } else { |
||
31 | element.tag = [] |
||
32 | } |
||
33 | |||
34 | element.product_name = products[element.plan__product].name |
||
35 | }) |
||
36 | |||
37 | callback({ data: data }) // renders everything |
||
38 | }) |
||
39 | }) |
||
40 | } |
||
41 | |||
42 | $(document).ready(function () { |
||
43 | const table = $('#resultsTable').DataTable({ |
||
44 | pageLength: $('#navbar').data('defaultpagesize'), |
||
45 | ajax: function (data, callback, settings) { |
||
0 ignored issues
–
show
|
|||
46 | const params = {} |
||
47 | |||
48 | if ($('#id_summary').val()) { |
||
49 | params.summary__icontains = $('#id_summary').val() |
||
50 | } |
||
51 | |||
52 | if ($('#id_after_start_date').val()) { |
||
53 | params.start_date__gte = $('#id_after_start_date').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00') |
||
54 | } |
||
55 | |||
56 | if ($('#id_before_start_date').val()) { |
||
57 | params.start_date__lte = $('#id_before_start_date').data('DateTimePicker').date().format('YYYY-MM-DD 23:59:59') |
||
58 | } |
||
59 | |||
60 | if ($('#id_after_stop_date').val()) { |
||
61 | params.stop_date__gte = $('#id_after_stop_date').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00') |
||
62 | } |
||
63 | |||
64 | if ($('#id_before_stop_date').val()) { |
||
65 | params.stop_date__lte = $('#id_before_stop_date').data('DateTimePicker').date().format('YYYY-MM-DD 23:59:59') |
||
66 | } |
||
67 | |||
68 | if ($('#id_after_planned_start').val()) { |
||
69 | params.planned_start__gte = $('#id_after_planned_start').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00') |
||
70 | } |
||
71 | |||
72 | if ($('#id_before_planned_start').val()) { |
||
73 | params.planned_start__lte = $('#id_before_planned_start').data('DateTimePicker').date().format('YYYY-MM-DD 23:59:59') |
||
74 | } |
||
75 | |||
76 | if ($('#id_after_planned_stop').val()) { |
||
77 | params.planned_stop__gte = $('#id_after_planned_stop').data('DateTimePicker').date().format('YYYY-MM-DD 00:00:00') |
||
78 | } |
||
79 | |||
80 | if ($('#id_before_planned_stop').val()) { |
||
81 | params.planned_stop__lte = $('#id_before_planned_stop').data('DateTimePicker').date().format('YYYY-MM-DD 23:59:59') |
||
82 | } |
||
83 | |||
84 | if ($('#id_plan').val()) { |
||
85 | params.plan = $('#id_plan').val() |
||
86 | } |
||
87 | |||
88 | if ($('#id_product').val()) { |
||
89 | params.plan__product = $('#id_product').val() |
||
90 | }; |
||
91 | |||
92 | if ($('#id_version').val()) { |
||
93 | params.plan__product_version = $('#id_version').val() |
||
94 | }; |
||
95 | |||
96 | if ($('#id_build').val()) { |
||
97 | params.build = $('#id_build').val() |
||
98 | }; |
||
99 | |||
100 | if ($('#id_manager').val()) { |
||
101 | params.manager__username__startswith = $('#id_manager').val() |
||
102 | }; |
||
103 | |||
104 | if ($('#id_default_tester').val()) { |
||
105 | params.default_tester__username__startswith = $('#id_default_tester').val() |
||
106 | }; |
||
107 | |||
108 | updateParamsToSearchTags('#id_tag', params) |
||
109 | |||
110 | params.stop_date__isnull = $('#id_running').is(':checked') |
||
111 | |||
112 | dataTableJsonRPC('TestRun.filter', params, callback, preProcessData) |
||
113 | }, |
||
114 | columns: [ |
||
115 | { data: 'id' }, |
||
116 | { |
||
117 | data: null, |
||
118 | render: function (data, type, full, meta) { |
||
0 ignored issues
–
show
|
|||
119 | result = '<a href="/runs/' + data.id + '/">' + escapeHTML(data.summary) + '</a>' |
||
120 | if (data.stop_date) { |
||
121 | result += '<p class="help-block">' + data.stop_date + '</p>' |
||
122 | } |
||
123 | return result |
||
124 | } |
||
125 | }, |
||
126 | { |
||
127 | data: null, |
||
128 | render: function (data, type, full, meta) { |
||
0 ignored issues
–
show
|
|||
129 | return '<a href="/plan/' + data.plan + '/">TP-' + data.plan + ': ' + escapeHTML(data.plan__name) + '</a>' |
||
130 | } |
||
131 | }, |
||
132 | { data: 'product_name' }, |
||
133 | { data: 'plan__product_version__value' }, |
||
134 | { data: 'build__name' }, |
||
135 | { data: 'manager__username' }, |
||
136 | { data: 'default_tester__username' }, |
||
137 | { data: 'tag' } |
||
138 | ], |
||
139 | dom: 't', |
||
140 | language: { |
||
141 | loadingRecords: '<div class="spinner spinner-lg"></div>', |
||
142 | processing: '<div class="spinner spinner-lg"></div>', |
||
143 | zeroRecords: 'No records found' |
||
144 | }, |
||
145 | order: [[0, 'asc']] |
||
146 | }) |
||
147 | |||
148 | hookIntoPagination('#resultsTable', table) |
||
149 | |||
150 | $('#btn_search').click(function () { |
||
151 | table.ajax.reload() |
||
152 | return false // so we don't actually send the form |
||
153 | }) |
||
154 | |||
155 | $('#id_product').change(function () { |
||
156 | updateVersionSelectFromProduct() |
||
157 | }) |
||
158 | |||
159 | $('#id_version').change(function () { |
||
160 | updateBuildSelectFromVersion(true) |
||
161 | }) |
||
162 | |||
163 | $('.bootstrap-switch').bootstrapSwitch() |
||
164 | |||
165 | $('.selectpicker').selectpicker() |
||
166 | }) |
||
167 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.