Mon, 21 Jan 2019 20:45:18 +0100
Added design notes for the csv log format from fermenters. In bmsd configuration added the web_root entry. Switched fermenter DLOG messages to store the log in flat csv files instead of the database. This is much faster and the graphs look better.
12 | 1 | /***************************************************************************** |
13 | 2 | * Copyright (C) 2014-2018 |
12 | 3 | * |
4 | * Michiel Broek <mbroek at mbse dot eu> | |
5 | * | |
6 | * This file is part of BrewCloud | |
7 | * | |
8 | * This is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU General Public License as published by the | |
10 | * Free Software Foundation; either version 2, or (at your option) any | |
11 | * later version. | |
12 | * | |
13 | * BrewCloud is distributed in the hope that it will be useful, but | |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
20 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
21 | *****************************************************************************/ | |
22 | ||
23 | ||
24 | function createDelElements() { | |
25 | $('#eventWindow').jqxWindow({ | |
26 | theme: theme, | |
27 | position: { x: 490, y: 210 }, | |
28 | width: 300, | |
34 | 29 | height: 175, |
12 | 30 | resizable: false, |
31 | isModal: true, | |
32 | modalOpacity: 0.4, | |
33 | okButton: $('#delOk'), | |
34 | cancelButton: $('#delCancel'), | |
35 | initContent: function () { | |
36 | $('#delOk').jqxButton({ width: '65px', theme: theme }); | |
37 | $('#delCancel').jqxButton({ width: '65px', theme: theme }); | |
38 | $('#delCancel').focus(); | |
39 | } | |
40 | }); | |
41 | $('#eventWindow').jqxWindow('hide'); | |
42 | } | |
43 | ||
44 | ||
45 | $(document).ready(function () { | |
46 | var url = "includes/db_inventory_hops.php"; | |
47 | // prepare the data | |
48 | var source = { | |
49 | datatype: "json", | |
50 | cache: false, | |
51 | datafields: [ | |
52 | { name: 'record', type: 'number' }, | |
53 | { name: 'name', type: 'string' }, | |
54 | { name: 'alpha', type: 'float' }, | |
55 | { name: 'beta', type: 'float' }, | |
56 | { name: 'humulene', type: 'float' }, | |
57 | { name: 'caryophyllene', type: 'float' }, | |
58 | { name: 'cohumulone', type: 'float' }, | |
59 | { name: 'myrcene', type: 'float' }, | |
13 | 60 | { name: 'hsi', type: 'float' }, |
12 | 61 | { name: 'type', type: 'string' }, |
62 | { name: 'form', type: 'string' }, | |
63 | { name: 'notes', type: 'string' }, | |
64 | { name: 'origin', type: 'string' }, | |
65 | { name: 'substitutes', type: 'string' }, | |
66 | { name: 'always_on_stock', type: 'bool' }, | |
67 | { name: 'inventory', type: 'float' }, | |
68 | { name: 'cost', type: 'float' }, | |
69 | { name: 'production_date', type: 'string' }, | |
70 | { name: 'tht_date', type: 'string' }, | |
13 | 71 | { name: 'total_oil', type: 'float' } |
12 | 72 | ], |
73 | id: 'record', | |
74 | url: url, | |
75 | deleterow: function (rowid, commit) { | |
76 | // synchronize with the server - send delete command | |
77 | var data = "delete=true&" + $.param({ record: rowid }); | |
78 | $.ajax({ | |
79 | dataType: 'json', | |
80 | url: url, | |
81 | cache: false, | |
82 | data: data, | |
83 | success: function (data, status, xhr) { | |
84 | // delete command is executed. | |
85 | commit(true); | |
86 | }, | |
87 | error: function (jqXHR, textStatus, errorThrown) { | |
88 | commit(false); | |
89 | } | |
90 | }); | |
91 | }, | |
92 | addrow: function (rowid, rowdata, position, commit) { | |
93 | var data = "insert=true&" + $.param(rowdata); | |
94 | $.ajax({ | |
95 | dataType: 'json', | |
96 | url: url, | |
97 | cache: false, | |
98 | data: data, | |
99 | success: function (data, status, xhr) { | |
100 | commit(true); | |
101 | }, | |
102 | error: function(jqXHR, textStatus, errorThrown) { | |
103 | commit(false); | |
104 | } | |
105 | }); | |
106 | }, | |
107 | updaterow: function (rowid, rowdata, commit) { | |
108 | var data = "update=true&" + $.param(rowdata); | |
109 | $.ajax({ | |
110 | dataType: 'json', | |
111 | url: url, | |
112 | cache: false, | |
113 | data: data, | |
114 | success: function (data, status, xhr) { | |
115 | // update command is executed. | |
116 | commit(true); | |
117 | }, | |
118 | error: function(jqXHR, textStatus, errorThrown) { | |
119 | commit(false); | |
120 | } | |
121 | }); | |
122 | } | |
123 | }; | |
13 | 124 | // var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; // Only in recipes |
12 | 125 | var srcType = [ "Bittering", "Aroma", "Both" ]; |
126 | var srcForm = [ "Pellet", "Plug", "Leaf" ]; | |
127 | // initialize the input fields. | |
128 | $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); | |
129 | $("#alpha").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
130 | $("#beta").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
131 | $("#humulene").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
132 | $("#caryophyllene").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
133 | $("#cohumulone").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
134 | $("#myrcene").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
13 | 135 | $("#hsi").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); |
12 | 136 | |
13 | 137 | $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 90, height: 23, dropDownHeight: 95 }); |
138 | $("#form").jqxDropDownList({ theme: theme, source: srcForm, width: 90, height: 23, dropDownHeight: 95 }); | |
139 | $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); | |
12 | 140 | $("#origin").jqxInput({ theme: theme, width: 250, height: 23 }); |
141 | $("#substitutes").jqxInput({ theme: theme, width: 250, height: 23 }); | |
142 | $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); | |
143 | $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); | |
144 | $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); | |
145 | $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); | |
146 | $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); | |
13 | 147 | $("#total_oil").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); |
12 | 148 | var dataAdapter = new $.jqx.dataAdapter(source); |
149 | var editrow = -1; | |
150 | // initialize jqxGrid | |
151 | $("#jqxgrid").jqxGrid({ | |
152 | width: 1280, | |
153 | height: 630, | |
154 | source: dataAdapter, | |
155 | theme: theme, | |
156 | showstatusbar: true, | |
13 | 157 | localization: getLocalization(), |
12 | 158 | renderstatusbar: function (statusbar) { |
159 | var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); | |
34 | 160 | var addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); |
12 | 161 | container.append(addButton); |
162 | statusbar.append(container); | |
34 | 163 | addButton.jqxButton({ theme: theme, width: 120, height: 20 }); |
12 | 164 | // add new row. |
165 | addButton.click(function (event) { | |
166 | editrow = -1; | |
13 | 167 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); |
12 | 168 | $("#name").val(''); |
169 | $("#alpha").val(''); | |
170 | $("#beta").val(''); | |
171 | $("#humulene").val(''); | |
172 | $("#caryophyllene").val(''); | |
173 | $("#cohumulone").val(''); | |
174 | $("#myrcene").val(''); | |
13 | 175 | $("#hsi").val(''); |
12 | 176 | $("#type").val('Bittering'); |
177 | $("#form").val('Pellet'); | |
178 | $("#notes").val(''); | |
179 | $("#origin").val(''); | |
180 | $("#substitutes").val(''); | |
181 | $("#always_on_stock").val(''); | |
182 | $("#inventory").val(''); | |
183 | $("#cost").val(''); | |
184 | $("#production_date").val(''); | |
185 | $("#tht_date").val(''); | |
13 | 186 | $("#total_oil").val(''); |
12 | 187 | $("#popupWindow").jqxWindow('open'); |
188 | }); | |
189 | }, | |
190 | filterable: true, | |
191 | filtermode: 'excel', | |
192 | columns: [ | |
37
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
193 | { text: 'Herkomst', datafield: 'origin', align: 'center', cellsalign: 'center', width: 150 }, |
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
194 | { text: 'Hop Naam', datafield: 'name' }, |
30
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
195 | { text: 'Soort', datafield: 'type', align: 'center', cellsalign: 'center', width: 90 }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
196 | { text: 'Vorm', datafield: 'form', align: 'center', cellsalign: 'center', width: 90 }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
197 | { text: 'Alpha %', datafield: 'alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
198 | { text: 'Beta %', datafield: 'beta', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
199 | { text: 'Cohumuloon %%', datafield: 'cohumulone', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
200 | { text: 'HSI', datafield: 'hsi', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
201 | { text: 'Oogst datum', datafield: 'production_date', align: 'center', cellsalign: 'center', width: 100 }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
202 | { text: 'Voor, gr.', datafield: 'inventory', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
f5ab22446aa5
Inventory fermentables and hops to standard weight format.
Michiel Broek <mbroek@mbse.eu>
parents:
19
diff
changeset
|
203 | { text: 'Prijs /kg', datafield: 'cost', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'c2' }, |
37
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
34
diff
changeset
|
204 | { text: 'Wijzig', datafield: 'Wijzig', columntype: 'button', width: 120, align: 'center', cellsrenderer: function () { |
34 | 205 | return "Wijzig"; |
12 | 206 | }, buttonclick: function (row) { |
207 | // open the popup window when the user clicks a button. | |
208 | editrow = row; | |
13 | 209 | $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); |
12 | 210 | // get the clicked row's data and initialize the input fields. |
211 | var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); | |
212 | $("#name").val(dataRecord.name); | |
213 | $("#alpha").val(dataRecord.alpha); | |
214 | $("#beta").val(dataRecord.beta); | |
215 | $("#humulene").val(dataRecord.humulene); | |
216 | $("#caryophyllene").val(dataRecord.caryophyllene); | |
217 | $("#cohumulone").val(dataRecord.cohumulone); | |
218 | $("#myrcene").val(dataRecord.myrcene); | |
13 | 219 | $("#hsi").val(dataRecord.hsi); |
12 | 220 | $("#type").val(dataRecord.type); |
221 | $("#form").val(dataRecord.form); | |
222 | $("#notes").val(dataRecord.notes); | |
223 | $("#origin").val(dataRecord.origin); | |
224 | $("#substitutes").val(dataRecord.substitutes); | |
225 | $("#always_on_stock").val(dataRecord.always_on_stock); | |
226 | $("#inventory").val(dataRecord.inventory); | |
227 | $("#cost").val(dataRecord.cost); | |
228 | $("#production_date").val(dataRecord.production_date); | |
229 | $("#tht_date").val(dataRecord.tht_date); | |
13 | 230 | $("#total_oil").val(dataRecord.total_oil); |
12 | 231 | // show the popup window. |
232 | $("#popupWindow").jqxWindow('open'); | |
233 | } | |
234 | } | |
235 | ] | |
236 | }); | |
237 | // initialize the popup window and buttons. | |
238 | $("#popupWindow").jqxWindow({ | |
239 | width: 860, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 | |
240 | }); | |
241 | $("#popupWindow").on('open', function () { | |
242 | $("#name").jqxInput('selectAll'); | |
243 | }); | |
244 | $("#Delete").jqxButton({ theme: theme }); | |
245 | $("#Delete").click(function () { | |
246 | if (editrow >= 0) { | |
247 | // Open a popup to confirm this action. | |
248 | $('#eventWindow').jqxWindow('open'); | |
249 | $("#delOk").click(function () { | |
250 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
251 | $("#jqxgrid").jqxGrid('deleterow', rowID); | |
252 | }); | |
253 | } | |
254 | $("#popupWindow").jqxWindow('hide'); | |
255 | }); | |
256 | $("#Cancel").jqxButton({ theme: theme }); | |
257 | $("#Save").jqxButton({ theme: theme }); | |
258 | // update the edited row when the user clicks the 'Save' button. | |
259 | $("#Save").click(function () { | |
260 | if (editrow >= 0) { | |
261 | var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); | |
262 | var row = { | |
263 | record: rowID, | |
264 | name: $("#name").val(), | |
265 | alpha: parseFloat($("#alpha").jqxNumberInput('decimal')), | |
266 | beta: parseFloat($("#beta").jqxNumberInput('decimal')), | |
267 | humulene: parseFloat($("#humulene").jqxNumberInput('decimal')), | |
268 | caryophyllene: parseFloat($("#caryophyllene").jqxNumberInput('decimal')), | |
269 | cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), | |
270 | myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), | |
13 | 271 | hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), |
12 | 272 | type: $("#type").val(), |
273 | form: $("#form").val(), | |
274 | notes: $("#notes").val(), | |
275 | origin: $("#origin").val(), | |
276 | substitutes: $("#substitutes").val(), | |
277 | always_on_stock: $("#always_on_stock").val(), | |
278 | inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), | |
279 | cost: parseFloat($("#cost").jqxNumberInput('decimal')), | |
280 | production_date: $("#production_date").val(), | |
281 | tht_date: $("#tht_date").val(), | |
13 | 282 | total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) |
12 | 283 | }; |
284 | $('#jqxgrid').jqxGrid('updaterow', rowID, row); | |
285 | $("#popupWindow").jqxWindow('hide'); | |
286 | } else { | |
287 | // Insert a record | |
288 | var newrow = { | |
289 | record: -1, | |
290 | name: $("#name").val(), | |
291 | alpha: parseFloat($("#alpha").jqxNumberInput('decimal')), | |
292 | beta: parseFloat($("#beta").jqxNumberInput('decimal')), | |
293 | humulene: parseFloat($("#humulene").jqxNumberInput('decimal')), | |
294 | caryophyllene: parseFloat($("#caryophyllene").jqxNumberInput('decimal')), | |
295 | cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), | |
296 | myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), | |
13 | 297 | hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), |
12 | 298 | type: $("#type").val(), |
299 | form: $("#form").val(), | |
300 | notes: $("#notes").val(), | |
301 | origin: $("#origin").val(), | |
302 | substitutes: $("#substitutes").val(), | |
303 | always_on_stock: $("#always_on_stock").val(), | |
304 | inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), | |
305 | cost: parseFloat($("#cost").jqxNumberInput('decimal')), | |
306 | production_date: $("#production_date").val(), | |
307 | tht_date: $("#tht_date").val(), | |
13 | 308 | total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) |
12 | 309 | }; |
310 | $('#jqxgrid').jqxGrid('addrow', null, newrow); | |
311 | $("#popupWindow").jqxWindow('hide'); | |
312 | } | |
313 | }); | |
314 | createDelElements(); | |
315 | }); | |
316 |