www/js/profile_fermentation.js

changeset 689
499c4921a90f
parent 548
c67cd0d9249b
child 701
3ce3df681be0
equal deleted inserted replaced
688:0ce464e42d8b 689:499c4921a90f
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2019 2 * Copyright (C) 2019-2020
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of BMS 6 * This file is part of BMS
7 * 7 *
143 { name: 'resttime', type: 'float' }, 143 { name: 'resttime', type: 'float' },
144 { name: 'target_lo', type: 'float' }, 144 { name: 'target_lo', type: 'float' },
145 { name: 'target_hi', type: 'float' }, 145 { name: 'target_hi', type: 'float' },
146 { name: 'fridgemode', type: 'int' } 146 { name: 'fridgemode', type: 'int' }
147 ], 147 ],
148 addrow: function(rowid, rowdata, position, commit) { 148 addrow: function(rowid, rowdata, position, commit) { commit(true); },
149 commit(true); 149 deleterow: function(rowid, commit) { commit(true); }
150 },
151 deleterow: function(rowid, commit) {
152 commit(true);
153 }
154 }, 150 },
155 stepAdapter = new $.jqx.dataAdapter(stepSource); 151 stepAdapter = new $.jqx.dataAdapter(stepSource);
156 $('#grid').jqxGrid({ 152 $('#grid').jqxGrid({
157 width: 800, 153 width: 800,
158 height: 330, 154 height: 330,
238 height: 630, 234 height: 630,
239 source: dataAdapter, 235 source: dataAdapter,
240 theme: theme, 236 theme: theme,
241 showstatusbar: true, 237 showstatusbar: true,
242 renderstatusbar: function(statusbar) { 238 renderstatusbar: function(statusbar) {
243 var addButton, container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>'); 239 var container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
244 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' + 240 var addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
245 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>'); 241 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
246 container.append(addButton); 242 container.append(addButton);
247 statusbar.append(container); 243 statusbar.append(container);
248 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 244 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
249 // add new row. 245 // add new row.
261 }); 257 });
262 }, 258 },
263 filterable: false, 259 filterable: false,
264 columns: [ 260 columns: [
265 { text: 'Vergisting profiel', datafield: 'name' }, 261 { text: 'Vergisting profiel', datafield: 'name' },
266 { text: 'Min. start &deg;C', datafield: 'inittemp_lo', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 262 { text: 'Min. start &deg;C', datafield: 'inittemp_lo', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
267 { text: 'Max. start &deg;C', datafield: 'inittemp_hi', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 263 { text: 'Max. start &deg;C', datafield: 'inittemp_hi', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
264 { text: 'Sensor', datafield: 'fridgemode', align: 'right', width: 80,
265 cellsrenderer: function(row, columnfield, value, defaulthtml, column) {
266 if (value == 0)
267 return '<span style="margin: 3px; margin-top: 6px; float: right;">Bier</span>';
268 else
269 return '<span style="margin: 3px; margin-top: 6px; float: right;">Koelkast</span>';
270 }
271 },
268 { text: 'Stappen', datafield: 'totalsteps', width: 80, align: 'right', cellsalign: 'right' }, 272 { text: 'Stappen', datafield: 'totalsteps', width: 80, align: 'right', cellsalign: 'right' },
269 { text: 'Tijdsduur', datafield: 'duration', width: 150, align: 'right', 273 { text: 'Tijdsduur', datafield: 'duration', width: 150, align: 'right',
270 cellsrenderer: function(row, columnfield, value, defaulthtml, column) { 274 cellsrenderer: function(row, columnfield, value, defaulthtml, column) {
271 var show, days, hours; 275 var show, days, hours;
272 if (value < 24) { 276 if (value < 24) {
273 show = value + ' uur'; 277 show = value + ' uur';
274 } else { 278 } else {
275 days = Math.floor(value / 24); 279 days = Math.floor(value / 24);
276 hours = value % 24; 280 hours = value % 24;
277 if (days == 1) 281 if (days == 1)
278 show = days + ' dag, ' + hours + ' uur'; 282 show = days + ' dag, ' + hours + ' uur';
279 else 283 else
280 show = days + ' dagen, ' + hours + ' uur'; 284 show = days + ' dagen, ' + hours + ' uur';
281 } 285 }
282 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + show + '</span>'; 286 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + show + '</span>';
283 } 287 }
284 }, 288 },
285 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: 289 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer:
286 function() { 290 function() {
287 return 'Wijzig'; 291 return 'Wijzig';
288 }, buttonclick: function(row) { 292 }, buttonclick: function(row) {
289 editrow = row; 293 editrow = row;
290 // get the clicked row's data and initialize the input fields. 294 // get the clicked row's data and initialize the input fields.
291 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); 295 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
326 }); 330 });
327 } 331 }
328 $('#popupWindow').jqxWindow('hide'); 332 $('#popupWindow').jqxWindow('hide');
329 }); 333 });
330 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); 334 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
335 $('#Clone').jqxButton({ template: 'warning', width: '90px', theme: theme });
336 $('#Clone').click(function() {
337 var steprows = $('#grid').jqxGrid('getrows');
338 var row = {
339 record: -1,
340 name: $('#name').val() + ' kopie',
341 inittemp_lo: parseFloat($('#inittemp_lo').jqxNumberInput('decimal')),
342 inittemp_hi: parseFloat($('#inittemp_hi').jqxNumberInput('decimal')),
343 fridgemode: $('#fridgemode').val(),
344 steps: steprows
345 };
346 $('#jqxgrid').jqxGrid('addrow', null, row);
347 $('#popupWindow').jqxWindow('hide');
348 });
331 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); 349 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
332 // update the edited row when the user clicks the 'Save' button. 350 // update the edited row when the user clicks the 'Save' button.
333 $('#Save').click(function() { 351 $('#Save').click(function() {
334 var row, rowID = -1, steprows = $('#grid').jqxGrid('getrows'); 352 var row, rowID = -1, steprows = $('#grid').jqxGrid('getrows');
335 if (editrow >= 0) { 353 if (editrow >= 0) {

mercurial