Browse Source

Show file ID in new batch window

Neal Wilson 8 years ago
parent
commit
6baaacd719
2 changed files with 56 additions and 46 deletions
  1. 18
    9
      config/Windows/newbatch.xml
  2. 38
    37
      config/Windows/productionroaster.xml

+ 18
- 9
config/Windows/newbatch.xml View File

@@ -75,6 +75,10 @@
75 75
             </layout>
76 76
             <label>Specification Details</label>
77 77
             <textarea id="specnotes" />
78
+            <layout type="horizontal">
79
+                <label>File ID:</label>
80
+                <line id="filenofield" writable="false" />
81
+            </layout>
78 82
             <stretch />
79 83
         </layout>
80 84
     </layout>
@@ -528,6 +532,19 @@
528 532
                     }
529 533
                 }
530 534
             });
535
+            var filenofield = findChildObject(this, 'filenofield');
536
+            this.endBatch = function() {
537
+                var q = "INSERT INTO files (id, name, type, note, file) VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
538
+                var query = new QSqlQuery();
539
+                query.prepare(q);
540
+                query.bind(":name", timefield.text + " " + roasted.currentText);
541
+                query.bindFileData(":data", batch.tempData);
542
+                query.exec();
543
+                query.next();
544
+                filenofield.text = query.value(0);
545
+                var file = new QFile(batch.tempData);
546
+                file.remove();
547
+            }
531 548
             var doSubmit = function() {
532 549
                 checkQuery = new QSqlQuery();
533 550
                 checkQuery.exec("SELECT 1 FROM machine WHERE id = " + selectedRoasterID);
@@ -539,16 +556,8 @@
539 556
                     checkQuery.exec();
540 557
                 }
541 558
                 checkQuery = checkQuery.invalidate();
542
-                var q = "INSERT INTO files (id, name, type, note, file) VALUES(default, :name, 'profile', NULL, :data) RETURNING id";
543 559
                 query = new QSqlQuery();
544
-                query.prepare(q);
545
-                query.bind(":name", timefield.text + " " + roasted.currentText);
546
-                query.bindFileData(":data", batch.tempData);
547
-                query.exec();
548
-                query.next();
549
-                var fileno = query.value(0);
550
-                var file = new QFile(batch.tempData);
551
-                file.remove();
560
+                var fileno = Number(filenofield.text);
552 561
                 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) VALUES(:time, ";
553 562
                 q2 = q2 + table.columnArray(0, 32);
554 563
                 q2 = q2 + ", ";

+ 38
- 37
config/Windows/productionroaster.xml View File

@@ -937,38 +937,39 @@
937 937
 		QSettings.setValue("liveColumn", 1);
938 938
         var lc = 1;
939 939
         stop.clicked.connect(function() {
940
-			stop.enabled = false;
941
-			for(var i = 0; i < adapters.length; i++)
942
-			{
943
-				adapters[i].measurement.disconnect(log.newMeasurement);
944
-				adapters[i].measurement.disconnect(graph.newMeasurement);
945
-			}
946
-			for(var i = 0; i < rateadapters.length; i++)
947
-			{
948
-				rateadapters[i].measurement.disconnect(graph.newMeasurement);
949
-			}
940
+            stop.enabled = false;
941
+            for(var i = 0; i < adapters.length; i++)
942
+            {
943
+                adapters[i].measurement.disconnect(log.newMeasurement);
944
+                adapters[i].measurement.disconnect(graph.newMeasurement);
945
+            }
946
+            for(var i = 0; i < rateadapters.length; i++)
947
+            {
948
+                rateadapters[i].measurement.disconnect(graph.newMeasurement);
949
+            }
950 950
             if(typeof(currentBatchInfo) == 'undefined') { } else {
951 951
                 lc = Number(QSettings.value("liveColumn"));
952 952
                 var duration = log.lastTime(lc);
953 953
                 var durfield = findChildObject(currentBatchInfo, 'duration');
954 954
                 durfield.text = duration;
955 955
                 log.clearOutputColumns();
956
-				channelSkip = 0;
957
-				for(var i = 0; i < channels.length; i++) {
958
-					if(channelVisibility[i]) {
959
-						if(channelType[i] == "T") {
960
-							log.addOutputTemperatureColumn(lc + i - channelSkip);
961
-						}
962
-						else {
963
-							log.addOutputControlColumn(lc + i - channelSkip);
964
-						}
965
-					} else {
966
-						channelSkip++;
967
-					}
968
-				}
969
-				log.addOutputAnnotationColumn(lc + channels.length - channelSkip);
956
+                channelSkip = 0;
957
+                for(var i = 0; i < channels.length; i++) {
958
+                    if(channelVisibility[i]) {
959
+                        if(channelType[i] == "T") {
960
+                            log.addOutputTemperatureColumn(lc + i - channelSkip);
961
+                        }
962
+                        else {
963
+                            log.addOutputControlColumn(lc + i - channelSkip);
964
+                        }
965
+                    } else {
966
+                        channelSkip++;
967
+                    }
968
+                }
969
+                log.addOutputAnnotationColumn(lc + channels.length - channelSkip);
970 970
                 var filename = log.saveTemporary();
971 971
                 currentBatchInfo.tempData = filename;
972
+                currentBatchInfo.endBatch();
972 973
                 var notes = findChildObject(currentBatchInfo, 'annotation');
973 974
                 for(var i = 0; i < rangetimers.length; i++)
974 975
                 {
@@ -977,20 +978,20 @@
977 978
                 currentBatchInfo.raise();
978 979
                 currentBatchInfo.activateWindow();
979 980
             }
980
-			if(translationChannel >= 0)
981
-			{
982
-				offsets[offsetForChannel(translationChannel)].measurement.disconnect(currentDetector.newMeasurement);
983
-			}
984
-			start.enabled = true;
985
-			window.windowModified = false;
986
-			graph.setTimeIndicatorEnabled(false);
981
+            if(translationChannel >= 0)
982
+            {
983
+                offsets[offsetForChannel(translationChannel)].measurement.disconnect(currentDetector.newMeasurement);
984
+            }
985
+            start.enabled = true;
986
+            window.windowModified = false;
987
+            graph.setTimeIndicatorEnabled(false);
987 988
         });
988
-		stop.annotation.connect(function(note, tcol, ncol) {
989
-			for(var i = tcol; i < ncol; i++) {
990
-				log.newAnnotation(note, i, ncol);
991
-			}
992
-		});
993
-		var quitMenu = findChildObject(this, 'quit');
989
+        stop.annotation.connect(function(note, tcol, ncol) {
990
+            for(var i = tcol; i < ncol; i++) {
991
+                log.newAnnotation(note, i, ncol);
992
+            }
993
+        });
994
+        var quitMenu = findChildObject(this, 'quit');
994 995
         quitMenu.triggered.connect(function() {
995 996
             window.close();
996 997
             Application.quit();

Loading…
Cancel
Save