From d3ab6c61df55ce66197940869ca294550a063c19 Mon Sep 17 00:00:00 2001 From: Yana Proskurina Date: Mon, 24 Oct 2016 08:40:56 +0100 Subject: [PATCH 1/5] help folder added --- help/LabelTemplates | 92 +++++++++++++++++++++++++++++++ help/nginx.conf | 131 ++++++++++++++++++++++++++++++++++++++++++++ help/readme | 13 +++++ 3 files changed, 236 insertions(+) create mode 100644 help/LabelTemplates create mode 100644 help/nginx.conf create mode 100644 help/readme diff --git a/help/LabelTemplates b/help/LabelTemplates new file mode 100644 index 0000000..7605d4e --- /dev/null +++ b/help/LabelTemplates @@ -0,0 +1,92 @@ + +//label_type for tubes + +{"data": + {"attributes": + {"name":"Tube", + "feed_value":"008", + "fine_adjustment":"22", + "pitch_length":"0430", + "print_width":"0300", + "print_length":"0400" + } + } +} + +//label template for tubes +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_tube", + "label_type_id": 5, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes": [ + {"x_origin":"0100", "y_origin":"0030", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"05", "font":"H", "space_adjustment":"02", "rotational_angles":"11"}, + {"x_origin":"0240", "y_origin":"0200", "field_name":"round_label", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0020", "y_origin":"0300", "field_name":"barcode", "barcode_type":"9", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":null, "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} + +//label_type for plates + +{"data" => + {"attributes" => + {"name":"Plate", + "feed_value":"008", + "fine_adjustment":"04", + "pitch_length":"0110", + "print_width":"0920", + "print_length":"0080" + } + } +} + +//label template plate +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_plate", + "label_type_id": 1, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes" : [ + {"x_origin":"0030", "y_origin":"0050", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0300", "y_origin":"0000", "field_name":"barcode", "barcode_type":"9", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":null, "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} + +//label template plate - suitable for small labels +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_plate_small", + "label_type_id": 1, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes" : [ + {"x_origin":"0160", "y_origin":"0050", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0400", "y_origin":"0010", "field_name":"barcode", "barcode_type":"9", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":null, "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} \ No newline at end of file diff --git a/help/nginx.conf b/help/nginx.conf new file mode 100644 index 0000000..8eff6e4 --- /dev/null +++ b/help/nginx.conf @@ -0,0 +1,131 @@ + +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + #gzip on; + + server { + + listen 8080; + server_name localhost; + + location / { + root ../../../../webapps/label_printer; + index index.html; + } + + location /pmb { + + proxy_pass http://localhost:9292/v1/; + + } + # listen 8080; + # server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + # location / { + # root html; + # index index.html index.htm; + # } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} + } + + + # another virtual host using mix of IP-, name-, and port-based configuration + # + #server { + # listen 8000; + # listen somename:8080; + # server_name somename alias another.alias; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + + + # HTTPS server + # + #server { + # listen 443 ssl; + # server_name localhost; + + # ssl_certificate cert.pem; + # ssl_certificate_key cert.key; + + # ssl_session_cache shared:SSL:1m; + # ssl_session_timeout 5m; + + # ssl_ciphers HIGH:!aNULL:!MD5; + # ssl_prefer_server_ciphers on; + + # location / { + # root html; + # index index.html index.htm; + # } + #} + include servers/*; +} diff --git a/help/readme b/help/readme new file mode 100644 index 0000000..03a65fd --- /dev/null +++ b/help/readme @@ -0,0 +1,13 @@ + + +nginx was installed by default in ~/homebrew/etc/nginx +file nginx.conf was there, I added lines 37-49 +if it is in another folder, root (line 41) should be changed +to start nginx run `nginx`, it runs on http://localhost:8080/ + +start pmb on http://localhost:9292 + +label templates and label types are in file 'LabelTemplates' + +to run tests open http://localhost:8080/SpecRunner.html + From b16b3d47702d6dc178f49d8f02c7699de5a63a1e Mon Sep 17 00:00:00 2001 From: Yana Proskurina Date: Fri, 25 Nov 2016 08:34:47 +0000 Subject: [PATCH 2/5] Added ability to print multiple copies --- public/index.html | 25 ++++++++++++++++++------- public/javascripts/PrepareForm.js | 30 +++++++++++++++++++++++++++++- public/javascripts/PrintJob.js | 11 +++++++---- public/javascripts/main.js | 4 ++-- test/spec/PrintJobSpec.js | 21 +++++++++++++++++---- 5 files changed, 73 insertions(+), 18 deletions(-) diff --git a/public/index.html b/public/index.html index 1afcdd3..97be4fc 100644 --- a/public/index.html +++ b/public/index.html @@ -20,14 +20,21 @@

Label printer

- - + + + +
+
+ +
- +
@@ -39,12 +46,16 @@

Label printer

- - + + +
+
+ +
- - + +
diff --git a/public/javascripts/PrepareForm.js b/public/javascripts/PrepareForm.js index e537ba6..fdd10bc 100644 --- a/public/javascripts/PrepareForm.js +++ b/public/javascripts/PrepareForm.js @@ -33,7 +33,35 @@ var removeFromAndTo = function(){ }; } +var removeBarcode = function(){ + if($(this).val().length ==0){ + $("label[for='barcode']").show(); + $('#barcode').show(); + } else { + $("label[for='barcode']").hide(); + $('#barcode').hide().val(''); + }; +} + var disableCheckboxIfTube = function () { $("label[for='size']").prop('hidden', this.value == 'tube'); $('#cbox').prop('hidden', this.value == 'tube').prop('checked', false); - } \ No newline at end of file + } + +var removeIrrelevantInputs = function () { + if (this.value =='with_barcode') { + $("label[for='barcode']").show(); + $('#barcode').show(); + $("label[for='from']").hide(); + $('#from').hide().val(''); + $("label[for='to']").hide(); + $('#to').hide().val(''); + } else { + $("label[for='barcode']").hide(); + $('#barcode').hide().val(''); + $("label[for='from']").show(); + $('#from').show(); + $("label[for='to']").show(); + $('#to').show(); + } +} \ No newline at end of file diff --git a/public/javascripts/PrintJob.js b/public/javascripts/PrintJob.js index 27a0bbc..b683400 100644 --- a/public/javascripts/PrintJob.js +++ b/public/javascripts/PrintJob.js @@ -2,8 +2,9 @@ PrintJob = function(data){ this.from = data['from']; this.to = data['to']; + this.number_of_copies = data['number_of_copies']; this.text = data['text']; - this.type = data['type']; + this.labware_type = data['labware_type']; this.printer_name = data['printer_name']; this.barcode = data['barcode']; this.size = (typeof data['size'] === 'undefined') ? '' : ('_' + data['size']); @@ -17,13 +18,15 @@ PrintJob.prototype.labels = function(){ var result = new Array(); for (i = this.from; i <= this.to; i++) { label = this.label(String(i)); - result.push(label) + for (j = 1; j <= this.number_of_copies; j++) { + result.push(label) + } } return {"body" : result} }; PrintJob.prototype.label = function(number){ - switch (this.type) { + switch (this.labware_type) { case 'plate': return this.labelPlate(number); break; @@ -59,7 +62,7 @@ PrintJob.prototype.execute=function(){ } PrintJob.prototype.labelTemplateUrl=function(){ - var label_template_name = 'multiple_labels_walk_up_' + this.type + this.size + var label_template_name = 'multiple_labels_walk_up_' + this.labware_type + this.size var label_template_url = baseUrl()+'label_templates?filter[name]=' + label_template_name return label_template_url }; diff --git a/public/javascripts/main.js b/public/javascripts/main.js index ea1e0a9..871adba 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -3,9 +3,9 @@ $(document).ready(function() { getPrinters() - $('#barcode').keyup(removeFromAndTo) + $('#labels_options').change(removeIrrelevantInputs) - $('#type').change(disableCheckboxIfTube); + $('#labware_type').change(disableCheckboxIfTube); $('form').submit(function(event) { refreshResult(); diff --git a/test/spec/PrintJobSpec.js b/test/spec/PrintJobSpec.js index 211b4b0..d5c8b2c 100755 --- a/test/spec/PrintJobSpec.js +++ b/test/spec/PrintJobSpec.js @@ -3,12 +3,12 @@ describe("PrintJob", function() { var label, labels, result, attributes; beforeEach(function() { - data = {'from': '1', 'to': '3', 'text': 'some_text', 'type': 'plate', 'printer_name': 'test', 'barcode': ''} + data = {'from': '1', 'to': '3', 'text': 'some_text', 'labware_type': 'plate', 'printer_name': 'test', 'barcode': '', 'number_of_copies': '1'} printJob = new PrintJob(data); }); it("should have attributes", function() { - expect(printJob.type).toEqual('plate'); + expect(printJob.labware_type).toEqual('plate'); expect(printJob.from).toEqual('1'); expect(printJob.to).toEqual('3'); expect(printJob.text).toEqual('some_text'); @@ -17,7 +17,7 @@ describe("PrintJob", function() { }); it("should have the right size attribute for small label", function(){ - data = {'from': '1', 'to': '3', 'text': 'some_text', 'type': 'plate', 'printer_name': 'test', 'barcode': '', 'size': 'small'} + data = {'from': '1', 'to': '3', 'text': 'some_text', 'labware_type': 'plate', 'printer_name': 'test', 'barcode': '', 'size': 'small', 'number_of_copies': '1'} printJob = new PrintJob(data); expect(printJob.size).toEqual('_small'); }); @@ -28,7 +28,7 @@ describe("PrintJob", function() { }); it("should create the right label for tube", function(){ - printJob.type = 'tube' + printJob.labware_type = 'tube' label = printJob.label(1); expect(label).toEqual({"main_label": {"middle_line": 'some_text 1', "round_label" : '1', 'barcode': ''}}); }); @@ -44,6 +44,19 @@ describe("PrintJob", function() { expect(labels).toEqual(result); }); + it("should create the right number of copies of each label", function(){ + data = {'from': '', 'to': '', 'text': 'some_text', 'labware_type': 'plate', 'printer_name': 'test', 'barcode': '123', 'number_of_copies': '3'} + printJob = new PrintJob(data); + labels = printJob.labels(); + result = {'body': + [{ 'main_label': { 'middle_line': 'some_text ', 'barcode': '123' }}, + { 'main_label': { 'middle_line': 'some_text ', 'barcode': '123' }}, + { 'main_label': { 'middle_line': 'some_text ', 'barcode': '123' }} + ] + } + expect(labels).toEqual(result); + }); + it("should create the right attributes", function(){ attributes = printJob.attributes(5); result = {"data": From d47eb3d37cffbf5f4c7f745eab9c2f31cf324642 Mon Sep 17 00:00:00 2001 From: Yana Proskurina Date: Tue, 29 Nov 2016 14:37:45 +0000 Subject: [PATCH 3/5] Changed length of barcode based on label length, some other minor changes --- public/index.html | 12 +-- public/javascripts/PrepareForm.js | 85 +++++++++++-------- public/javascripts/main.js | 8 +- test/spec/PrepareFormSpec.js | 33 +++++-- .../spec/javascripts/fixtures/AppFixture.html | 23 +++-- 5 files changed, 101 insertions(+), 60 deletions(-) diff --git a/public/index.html b/public/index.html index 97be4fc..b35ab2a 100644 --- a/public/index.html +++ b/public/index.html @@ -23,7 +23,7 @@

Label printer

@@ -43,15 +43,15 @@

Label printer

- +
- - + +
- - + +
diff --git a/public/javascripts/PrepareForm.js b/public/javascripts/PrepareForm.js index fdd10bc..c5be98d 100644 --- a/public/javascripts/PrepareForm.js +++ b/public/javascripts/PrepareForm.js @@ -1,3 +1,7 @@ +var tubeLabelBarcodeMaxlength = 2; +var plateLabelBarcodeMaxlength = 17; +var smallPlateLabelBarcodeMaxlength = 12; + var addPrinters = function(data){ var printers_names = new Array; @@ -19,49 +23,62 @@ var getPrinters = function(){ }) }; -var removeFromAndTo = function(){ - if($(this).val().length ==0){ - $("label[for='from']").show(); - $('#from').show(); - $("label[for='to']").show(); - $('#to').show(); - } else { - $("label[for='from']").hide(); - $('#from').hide().val(''); - $("label[for='to']").hide(); - $('#to').hide().val(''); - }; +var hideWalkUpInputs = function(){ + $("label[for='from']").hide(); + $('#from').hide().val(''); + $("label[for='to']").hide(); + $('#to').hide().val(''); +} + +var showWalkUpInputs = function(){ + $("label[for='from']").show(); + $('#from').show(); + $("label[for='to']").show(); + $('#to').show(); } -var removeBarcode = function(){ - if($(this).val().length ==0){ - $("label[for='barcode']").show(); - $('#barcode').show(); +var hideBarcodeInput = function(){ + $("label[for='barcode']").hide(); + $('#barcode').hide().val(''); +} + +var showBarcodeInput = function(){ + $("label[for='barcode']").show(); + $('#barcode').show(); +} + +var formSetup = function(){ + $("#labels_options").val('with_barcode') + hideWalkUpInputs() + $("#labware_type").val('plate') + $('#barcode').attr('maxlength', plateLabelBarcodeMaxlength); + getPrinters() +} + +var changeFormBasedOnLabwareType = function () { + $("label[for='size']").prop('hidden', this.value == 'tube'); + $('#cbox').prop('hidden', this.value == 'tube').prop('checked', false); + if (this.value =='tube') { + $('#barcode').attr('maxlength', tubeLabelBarcodeMaxlength) } else { - $("label[for='barcode']").hide(); - $('#barcode').hide().val(''); - }; + $('#barcode').attr('maxlength', plateLabelBarcodeMaxlength) + } } -var disableCheckboxIfTube = function () { - $("label[for='size']").prop('hidden', this.value == 'tube'); - $('#cbox').prop('hidden', this.value == 'tube').prop('checked', false); +var changeBarcodeLengthIfLabelSizeHasChanged = function() { + if ($('#cbox').prop('checked')) { + $('#barcode').attr('maxlength', smallPlateLabelBarcodeMaxlength) + } else { + $('#barcode').attr('maxlength', plateLabelBarcodeMaxlength) } +} var removeIrrelevantInputs = function () { if (this.value =='with_barcode') { - $("label[for='barcode']").show(); - $('#barcode').show(); - $("label[for='from']").hide(); - $('#from').hide().val(''); - $("label[for='to']").hide(); - $('#to').hide().val(''); + showBarcodeInput() + hideWalkUpInputs() } else { - $("label[for='barcode']").hide(); - $('#barcode').hide().val(''); - $("label[for='from']").show(); - $('#from').show(); - $("label[for='to']").show(); - $('#to').show(); + hideBarcodeInput() + showWalkUpInputs() } } \ No newline at end of file diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 871adba..6824669 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -1,11 +1,11 @@ $(document).ready(function() { - getPrinters() + formSetup() - $('#labels_options').change(removeIrrelevantInputs) - - $('#labware_type').change(disableCheckboxIfTube); + $('#labels_options').change(removeIrrelevantInputs); + $('#labware_type').change(changeFormBasedOnLabwareType); + $('#cbox').change(changeBarcodeLengthIfLabelSizeHasChanged); $('form').submit(function(event) { refreshResult(); diff --git a/test/spec/PrepareFormSpec.js b/test/spec/PrepareFormSpec.js index 0a6976d..128e6d5 100644 --- a/test/spec/PrepareFormSpec.js +++ b/test/spec/PrepareFormSpec.js @@ -67,21 +67,38 @@ describe("PrepareForm", function() { }); }); - it("should hide from and to if barcode is set", function(){ + it("should hide barcode if walk_up option was chosen", function(){ + loadFixtures( 'AppFixture.html'); + formSetup() + + expect($("#from")).toBeHidden(); + expect($("#to")).toBeHidden(); + expect($("#barcode")).toBeVisible(); + + var labels_options = $('#labels_options'); + labels_options.change(removeIrrelevantInputs) + labels_options.val('walk_up').change() expect($("#from")).toBeVisible(); expect($("#to")).toBeVisible(); + expect($("#barcode")).toBeHidden(); + }); - var barcode = $('#barcode'); - barcode.val('12345') - barcode.keyup(removeFromAndTo) - var event = jQuery.Event("keyup"); - barcode.trigger(event); + it("should hide small size option if tube was chosen", function(){ + loadFixtures( 'AppFixture.html'); + formSetup() + expect($("#cbox")).toBeVisible(); + expect($("#barcode").attr('maxlength')).toEqual('17'); + + var labware_type = $('#labware_type'); + labware_type.change(changeFormBasedOnLabwareType) + labware_type.val('tube').change() + + expect($("#cbox")).toBeHidden(); + expect($("#barcode").attr('maxlength')).toEqual('2'); - expect($("#from")).toBeHidden(); - expect($("#to")).toBeHidden(); }); }); \ No newline at end of file diff --git a/test/spec/javascripts/fixtures/AppFixture.html b/test/spec/javascripts/fixtures/AppFixture.html index d18ee32..157a70b 100644 --- a/test/spec/javascripts/fixtures/AppFixture.html +++ b/test/spec/javascripts/fixtures/AppFixture.html @@ -1,25 +1,32 @@
- - + + + +
+
+ +
- +
- +
- - + +
- - + +
\ No newline at end of file From c86a855912cfe116681aabf04252fc33bb1c3a8f Mon Sep 17 00:00:00 2001 From: Yana Proskurina Date: Tue, 31 Jan 2017 15:22:13 +0000 Subject: [PATCH 4/5] ean13 barcodes added --- help/LabelTemplates | 72 ++++++++++++++++++++++++++++++- help/nginx.conf | 2 +- public/index.html | 4 ++ public/javascripts/PrepareForm.js | 2 +- public/javascripts/PrintJob.js | 3 +- 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/help/LabelTemplates b/help/LabelTemplates index 7605d4e..ba858ce 100644 --- a/help/LabelTemplates +++ b/help/LabelTemplates @@ -14,7 +14,7 @@ } //label template for tubes -//check label_type_id +//check label_type_id (mine is 9) {"data": {"attributes": @@ -35,6 +35,29 @@ } } +//label template for tubes with ean13 barcode +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_tube_ean13", + "label_type_id": 5, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes": [ + {"x_origin":"0100", "y_origin":"0030", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"05", "font":"H", "space_adjustment":"02", "rotational_angles":"11"}, + {"x_origin":"0240", "y_origin":"0200", "field_name":"round_label", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0020", "y_origin":"0300", "field_name":"barcode", "barcode_type":"5", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":"2", "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} + + //label_type for plates {"data" => @@ -50,7 +73,7 @@ } //label template plate -//check label_type_id +//check label_type_id (mine is 8) {"data": {"attributes": @@ -70,6 +93,30 @@ } } +//label template plate with ean13 barcode +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_plate_ean13", + "label_type_id": 1, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes" : [ + {"x_origin":"0030", "y_origin":"0050", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0300", "y_origin":"0000", "field_name":"barcode", "barcode_type":"5", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":"2", "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} + + + + //label template plate - suitable for small labels //check label_type_id @@ -89,4 +136,25 @@ ] } } +} + +//label template plate - suitable for small labels - ean13 barcode +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_plate_small_ean13", + "label_type_id": 1, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes" : [ + {"x_origin":"0160", "y_origin":"0050", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0400", "y_origin":"0010", "field_name":"barcode", "barcode_type":"5", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":"2", "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } } \ No newline at end of file diff --git a/help/nginx.conf b/help/nginx.conf index 8eff6e4..54560e8 100644 --- a/help/nginx.conf +++ b/help/nginx.conf @@ -38,7 +38,7 @@ http { server_name localhost; location / { - root ../../../../webapps/label_printer; + root ../../../../webapps/label_printer/public; index index.html; } diff --git a/public/index.html b/public/index.html index b35ab2a..1efcbdb 100644 --- a/public/index.html +++ b/public/index.html @@ -37,6 +37,10 @@

Label printer

+
+ + +
diff --git a/public/javascripts/PrepareForm.js b/public/javascripts/PrepareForm.js index c5be98d..197bab0 100644 --- a/public/javascripts/PrepareForm.js +++ b/public/javascripts/PrepareForm.js @@ -1,6 +1,6 @@ var tubeLabelBarcodeMaxlength = 2; var plateLabelBarcodeMaxlength = 17; -var smallPlateLabelBarcodeMaxlength = 12; +var smallPlateLabelBarcodeMaxlength = 13; var addPrinters = function(data){ diff --git a/public/javascripts/PrintJob.js b/public/javascripts/PrintJob.js index b683400..9aae721 100644 --- a/public/javascripts/PrintJob.js +++ b/public/javascripts/PrintJob.js @@ -8,6 +8,7 @@ PrintJob = function(data){ this.printer_name = data['printer_name']; this.barcode = data['barcode']; this.size = (typeof data['size'] === 'undefined') ? '' : ('_' + data['size']); + this.ean13 = (typeof data['ean13'] === 'undefined') ? '' : ('_' + data['ean13']); }; PrintJob.prototype.attributes = function(label_template_id){ @@ -62,7 +63,7 @@ PrintJob.prototype.execute=function(){ } PrintJob.prototype.labelTemplateUrl=function(){ - var label_template_name = 'multiple_labels_walk_up_' + this.labware_type + this.size + var label_template_name = 'multiple_labels_walk_up_' + this.labware_type + this.size + this.ean13 var label_template_url = baseUrl()+'label_templates?filter[name]=' + label_template_name return label_template_url }; From c264dd8ea01f7fbbaff813ab001ec95cba5b8f81 Mon Sep 17 00:00:00 2001 From: Yana Proskurina Date: Wed, 13 Dec 2017 15:09:46 +0000 Subject: [PATCH 5/5] Some refactoring --- .gitignore | 2 +- help/LabelTemplates | 20 +++++++++++++++++++ public/index.html | 4 ++-- public/javascripts/Helpers.js | 2 +- public/javascripts/PrepareForm.js | 20 ++++++++++++++----- public/javascripts/PrintJob.js | 1 + public/javascripts/main.js | 3 ++- test/spec/PrepareFormSpec.js | 4 ++-- .../spec/javascripts/fixtures/AppFixture.html | 6 +++++- 9 files changed, 49 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 28d62e2..e6aff51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ .DS_Store -/help + diff --git a/help/LabelTemplates b/help/LabelTemplates index ba858ce..2004b9b 100644 --- a/help/LabelTemplates +++ b/help/LabelTemplates @@ -114,6 +114,26 @@ } } +//label template plate with ean13 12-digit barcode (UPC-A) +//check label_type_id + +{"data": + {"attributes": + {"name":"multiple_labels_walk_up_plate_ean13", + "label_type_id": 1, + "labels_attributes":[ + {"name": "main_label", + "bitmaps_attributes" : [ + {"x_origin":"0030", "y_origin":"0050", "field_name":"middle_line", "horizontal_magnification":"05", "vertical_magnification":"1", "font":"G", "space_adjustment":"00", "rotational_angles":"00"} + ], + "barcodes_attributes" : [ + {"x_origin":"0300", "y_origin":"0000", "field_name":"barcode", "barcode_type":"K", "one_module_width":"02", "height":"0070", "rotational_angle":null, "one_cell_width":null, "type_of_check_digit":"2", "bar_height":null, "no_of_columns":null} + ] + } + ] + } + } +} diff --git a/public/index.html b/public/index.html index 1efcbdb..da97336 100644 --- a/public/index.html +++ b/public/index.html @@ -35,11 +35,11 @@

Label printer

- +
- +
diff --git a/public/javascripts/Helpers.js b/public/javascripts/Helpers.js index 2919002..a188af4 100644 --- a/public/javascripts/Helpers.js +++ b/public/javascripts/Helpers.js @@ -7,7 +7,7 @@ var toObject = function(array){ } var baseUrl = function(){ - return '/pmb' + return '/pmb/' } var refreshResult = function(){ diff --git a/public/javascripts/PrepareForm.js b/public/javascripts/PrepareForm.js index 197bab0..d9849a0 100644 --- a/public/javascripts/PrepareForm.js +++ b/public/javascripts/PrepareForm.js @@ -56,9 +56,11 @@ var formSetup = function(){ } var changeFormBasedOnLabwareType = function () { - $("label[for='size']").prop('hidden', this.value == 'tube'); - $('#cbox').prop('hidden', this.value == 'tube').prop('checked', false); - if (this.value =='tube') { + $('#small').prop('checked', false); + $('#ean13').prop('checked', false); + if ($('#labware_type').val() == 'tube') { + $("label[for='size']").prop('hidden', true) + $('#small').prop('hidden', true) $('#barcode').attr('maxlength', tubeLabelBarcodeMaxlength) } else { $('#barcode').attr('maxlength', plateLabelBarcodeMaxlength) @@ -66,10 +68,18 @@ var changeFormBasedOnLabwareType = function () { } var changeBarcodeLengthIfLabelSizeHasChanged = function() { - if ($('#cbox').prop('checked')) { + if (this.checked) { $('#barcode').attr('maxlength', smallPlateLabelBarcodeMaxlength) } else { - $('#barcode').attr('maxlength', plateLabelBarcodeMaxlength) + changeFormBasedOnLabwareType(); + } +} + +var changeBarcodeLengthIfBarcodeTypeChanged = function() { + if (this.checked) { + $('#barcode').attr('maxlength', '13') + } else { + changeFormBasedOnLabwareType(); } } diff --git a/public/javascripts/PrintJob.js b/public/javascripts/PrintJob.js index 9aae721..51b3345 100644 --- a/public/javascripts/PrintJob.js +++ b/public/javascripts/PrintJob.js @@ -8,6 +8,7 @@ PrintJob = function(data){ this.printer_name = data['printer_name']; this.barcode = data['barcode']; this.size = (typeof data['size'] === 'undefined') ? '' : ('_' + data['size']); + //ean13 on my local for regular plates now is UPC-A (12 digits) this.ean13 = (typeof data['ean13'] === 'undefined') ? '' : ('_' + data['ean13']); }; diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 6824669..37b9d3f 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -5,7 +5,8 @@ $(document).ready(function() { $('#labels_options').change(removeIrrelevantInputs); $('#labware_type').change(changeFormBasedOnLabwareType); - $('#cbox').change(changeBarcodeLengthIfLabelSizeHasChanged); + $('#small').change(changeBarcodeLengthIfLabelSizeHasChanged); + $('#ean13').change(changeBarcodeLengthIfBarcodeTypeChanged); $('form').submit(function(event) { refreshResult(); diff --git a/test/spec/PrepareFormSpec.js b/test/spec/PrepareFormSpec.js index 128e6d5..fe9edf8 100644 --- a/test/spec/PrepareFormSpec.js +++ b/test/spec/PrepareFormSpec.js @@ -89,14 +89,14 @@ describe("PrepareForm", function() { loadFixtures( 'AppFixture.html'); formSetup() - expect($("#cbox")).toBeVisible(); + expect($("#small")).toBeVisible(); expect($("#barcode").attr('maxlength')).toEqual('17'); var labware_type = $('#labware_type'); labware_type.change(changeFormBasedOnLabwareType) labware_type.val('tube').change() - expect($("#cbox")).toBeHidden(); + expect($("#small")).toBeHidden(); expect($("#barcode").attr('maxlength')).toEqual('2'); }); diff --git a/test/spec/javascripts/fixtures/AppFixture.html b/test/spec/javascripts/fixtures/AppFixture.html index 157a70b..52a3138 100644 --- a/test/spec/javascripts/fixtures/AppFixture.html +++ b/test/spec/javascripts/fixtures/AppFixture.html @@ -15,7 +15,11 @@
- + +
+
+ +