Browse Source

Add Javalytics support to new batch window

Neal Wilson 7 years ago
parent
commit
fa80445dac
1 changed files with 56 additions and 5 deletions
  1. 56
    5
      config/Windows/newbatch.xml

+ 56
- 5
config/Windows/newbatch.xml View File

81
                         <label>Max:</label>
81
                         <label>Max:</label>
82
                         <line id="maxroastweight" writable="false" />
82
                         <line id="maxroastweight" writable="false" />
83
                     </layout>
83
                     </layout>
84
+                    <label>Degree of Roast</label>
85
+                    <label>Whole Bean:</label>
86
+                    <roastcoloredit id="wholecolor" />
87
+                    <label id="wholespec">-</label>
88
+                    <label>Ground:</label>
89
+                    <roastcoloredit id="groundcolor" />
90
+                    <label id="groundspec">-</label>
84
                     <label>Specification Details</label>
91
                     <label>Specification Details</label>
85
                     <textarea id="specnotes" />
92
                     <textarea id="specnotes" />
86
                     <layout type="horizontal">
93
                     <layout type="horizontal">
322
             });
329
             });
323
             var profilebutton = findChildObject(this, 'load');
330
             var profilebutton = findChildObject(this, 'load');
324
             profilebutton.setEnabled(false);
331
             profilebutton.setEnabled(false);
332
+            var wholespec = findChildObject(this, 'wholespec');
333
+            var groundspec = findChildObject(this, 'groundspec');
325
             roasted['currentIndexChanged(int)'].connect(function() {
334
             roasted['currentIndexChanged(int)'].connect(function() {
326
                 table.clear();
335
                 table.clear();
327
                 var query = new QSqlQuery();
336
                 var query = new QSqlQuery();
383
                         }
392
                         }
384
                     }
393
                     }
385
                 }
394
                 }
386
-                query.prepare("SELECT loss, tolerance, notes FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
395
+                query.prepare("SELECT loss, tolerance, notes, spec FROM roasting_specification WHERE item = :id1 AND time = (SELECT max(time) FROM roasting_specification WHERE item = :id2)");
387
                 query.bind(":id1", roasted.currentData());
396
                 query.bind(":id1", roasted.currentData());
388
                 query.bind(":id2", roasted.currentData());
397
                 query.bind(":id2", roasted.currentData());
389
                 query.exec();
398
                 query.exec();
405
                     }
414
                     }
406
                     lossspec.text = lossSpecDescription;
415
                     lossspec.text = lossSpecDescription;
407
                     specnotes.plainText = query.value(2);
416
                     specnotes.plainText = query.value(2);
417
+                    if(query.value(3).length > 0) {
418
+                        var spec = JSON.parse(query.value(3));
419
+                        var wholespectext = "";
420
+                        var groundspectext = "";
421
+                        if(spec.color.whole.expected != undefined) {
422
+                            wholespectext += spec.color.whole.expected;
423
+                            if(spec.color.whole.tolerance != undefined) {
424
+                                wholespectext += " +/- " + spec.color.whole.tolerance;
425
+                            }
426
+                            wholespec.text = wholespectext;
427
+                        } else {
428
+                            wholespec.text = "";
429
+                        }
430
+                        if(spec.color.ground.expected != undefined) {
431
+                            groundspectext += spec.color.ground.expected;
432
+                            if(spec.color.ground.tolerance != undefined) {
433
+                                groundspectext += " +/- " + spec.color.ground.tolerance;
434
+                            }
435
+                            groundspec.text = groundspectext;
436
+                        } else {
437
+                            groundspec.text = "";
438
+                        }
439
+                    } else {
440
+                        wholespec.text = "";
441
+                        groundspec.text = "";
442
+                    }
408
                 } else {
443
                 } else {
409
                     lossspec.text = "";
444
                     lossspec.text = "";
410
                     specnotes.plainText = "";
445
                     specnotes.plainText = "";
446
+                    wholespec.text = "";
447
+                    groundspec.text = "";
411
                 }
448
                 }
412
                 query = query.invalidate();
449
                 query = query.invalidate();
413
-				drawTag();
450
+                drawTag();
414
             });
451
             });
415
             var validateCapacity = function() {
452
             var validateCapacity = function() {
416
                 if(checkCapacity == "true") {
453
                 if(checkCapacity == "true") {
588
                 file.remove();
625
                 file.remove();
589
 				drawTag();
626
 				drawTag();
590
             }
627
             }
628
+            var wholecolor = findChildObject(this, 'wholecolor');
629
+            var groundcolor = findChildObject(this, 'groundcolor');
591
             var doSubmit = function() {
630
             var doSubmit = function() {
592
                 checkQuery = new QSqlQuery();
631
                 checkQuery = new QSqlQuery();
593
                 checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
632
                 checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
601
                 checkQuery = checkQuery.invalidate();
640
                 checkQuery = checkQuery.invalidate();
602
                 query = new QSqlQuery();
641
                 query = new QSqlQuery();
603
                 var fileno = Number(filenofield.text);
642
                 var fileno = Number(filenofield.text);
604
-                var q2 = "INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files, person) VALUES(:time, ";
643
+                var q2 = "INSERT INTO roasting_log (time, unroasted_id, unroasted_quantity, unroasted_total_quantity, roasted_id, roasted_quantity, transaction_type, annotation, machine, duration, approval, humidity, barometric, indoor_air, outdoor_air, files, person, additional_data) VALUES(:time, ";
605
                 q2 = q2 + table.columnArray(0, 32);
644
                 q2 = q2 + table.columnArray(0, 32);
606
                 q2 = q2 + ", ";
645
                 q2 = q2 + ", ";
607
                 for(var i = 0; table.data(i, 1, 0).value != ""; i++)
646
                 for(var i = 0; table.data(i, 1, 0).value != ""; i++)
619
                 q2 = q2 + selectedRoasterID;
658
                 q2 = q2 + selectedRoasterID;
620
                 q2 = q2 + ", :duration, :approval, NULL, NULL, NULL, NULL, '{";
659
                 q2 = q2 + ", :duration, :approval, NULL, NULL, NULL, NULL, '{";
621
                 q2 = q2 + fileno;
660
                 q2 = q2 + fileno;
622
-                q2 = q2 + "}', :user) RETURNING time";
661
+                q2 = q2 + "}', :user, :extradata) RETURNING time";
623
                 query2 = new QSqlQuery();
662
                 query2 = new QSqlQuery();
624
                 query2.prepare(q2);
663
                 query2.prepare(q2);
625
                 query2.bind(":time", timefield.text);
664
                 query2.bind(":time", timefield.text);
626
                 query2.bind(":annotation", notes.plainText);
665
                 query2.bind(":annotation", notes.plainText);
627
                 query2.bind(":duration", duration.text);
666
                 query2.bind(":duration", duration.text);
628
                 query2.bind(":approval", approval.checked);
667
                 query2.bind(":approval", approval.checked);
629
-				query2.bind(":user", Application.currentTypicaUser());
668
+                query2.bind(":user", Application.currentTypicaUser());
669
+                var extradata = new Object;
670
+                var colordata = new Object;
671
+                if(wholecolor.text.length > 0) {
672
+                    colordata.whole = wholecolor.text;
673
+                }
674
+                if(groundcolor.text.length > 0) {
675
+                    colordata.ground = groundcolor.text;
676
+                }
677
+                if(colordata.whole || colordata.ground) {
678
+                    extradata.color = colordata;
679
+                }
680
+                query2.bind(":extradata", JSON.stringify(extradata));
630
                 query2.exec();
681
                 query2.exec();
631
                 if(!query2.next()) {
682
                 if(!query2.next()) {
632
                     displayError(TTR("batchWindow", "Database Insert Failed"), TTR("batchWindow", "Failed to save batch to database. Please check inputs and connection and try again."));
683
                     displayError(TTR("batchWindow", "Database Insert Failed"), TTR("batchWindow", "Failed to save batch to database. Please check inputs and connection and try again."));

Loading…
Cancel
Save