Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
/help


92 changes: 90 additions & 2 deletions help/LabelTemplates
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

//label template for tubes
//check label_type_id
//check label_type_id (mine is 9)

{"data":
{"attributes":
Expand All @@ -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" =>
Expand All @@ -50,7 +73,7 @@
}

//label template plate
//check label_type_id
//check label_type_id (mine is 8)

{"data":
{"attributes":
Expand All @@ -70,6 +93,50 @@
}
}

//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 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}
]
}
]
}
}
}



//label template plate - suitable for small labels
//check label_type_id

Expand All @@ -89,4 +156,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}
]
}
]
}
}
}
2 changes: 1 addition & 1 deletion help/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ http {
server_name localhost;

location / {
root ../../../../webapps/label_printer;
root ../../../../webapps/label_printer/public;
index index.html;
}

Expand Down
33 changes: 24 additions & 9 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,46 @@
<h3>Label printer</h3>
<div class='result'></div>
<div>
<label for="printers">Labels for:</label>
<select name="type" id="type">
<label for="labels_options">Labels:</label>
<select name="labels_options" id="labels_options">
<option value="walk_up">walk up</option>
<option value="with_barcode">with barcode</option>
</select>
</div>
<div>
<label for="labware_type">Labels for:</label>
<select name="labware_type" id="labware_type">
<option value="plate">plates</option>
<option value="tube">tubes</option>
</select>
</div>
<div>
<label for="size">6mm</label>
<input type="checkbox" id="cbox" name="size" value="small">
<label for="size">small</label>
<input type="checkbox" id="small" name="size" value="small">
</div>
<div>
<label for="ean13">ean13</label>
<input type="checkbox" id="ean13" name="ean13" value="ean13">
</div>
<div>
<label for="txt">Text:</label>
<input type="text" id="text" name="text" required />
</div>
<div>
<label for="barcode">Barcode:</label>
<input type="text" id="barcode" name="barcode" />
<input type="text" id="barcode" name="barcode"/>
</div>
<div>
<label for="from" >from:</label>
<input type="number" id="from" name="from" min="1"/>
</div>
<div>
<label for="from">from:</label>
<input type="number" id="from" name="from" />
<label for="to" >to:</label>
<input type="number" id="to" name="to" min="1"/>
</div>
<div>
<label for="to">to:</label>
<input type="number" id="to" name="to" />
<label for="number_of_copies">Number of copies:</label>
<input type="number" id="number_of_copies" name="number_of_copies" min="1" value="1" />
</div>

<div>
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/Helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var toObject = function(array){
}

var baseUrl = function(){
return '/pmb'
return '/pmb/'
}

var refreshResult = function(){
Expand Down
85 changes: 70 additions & 15 deletions public/javascripts/PrepareForm.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
var tubeLabelBarcodeMaxlength = 2;
var plateLabelBarcodeMaxlength = 17;
var smallPlateLabelBarcodeMaxlength = 13;


var addPrinters = function(data){
var printers_names = new Array;
Expand All @@ -19,21 +23,72 @@ var getPrinters = function(){
})
};

var removeFromAndTo = function(){
if($(this).val().length ==0){
$("label[for='from']").show();
$('#from').show();
$("label[for='to']").show();
$('#to').show();
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 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 () {
$('#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 {
$("label[for='from']").hide();
$('#from').hide().val('');
$("label[for='to']").hide();
$('#to').hide().val('');
};
$('#barcode').attr('maxlength', plateLabelBarcodeMaxlength)
}
}

var changeBarcodeLengthIfLabelSizeHasChanged = function() {
if (this.checked) {
$('#barcode').attr('maxlength', smallPlateLabelBarcodeMaxlength)
} else {
changeFormBasedOnLabwareType();
}
}

var disableCheckboxIfTube = function () {
$("label[for='size']").prop('hidden', this.value == 'tube');
$('#cbox').prop('hidden', this.value == 'tube').prop('checked', false);
}
var changeBarcodeLengthIfBarcodeTypeChanged = function() {
if (this.checked) {
$('#barcode').attr('maxlength', '13')
} else {
changeFormBasedOnLabwareType();
}
}

var removeIrrelevantInputs = function () {
if (this.value =='with_barcode') {
showBarcodeInput()
hideWalkUpInputs()
} else {
hideBarcodeInput()
showWalkUpInputs()
}
}
13 changes: 9 additions & 4 deletions public/javascripts/PrintJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
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']);
//ean13 on my local for regular plates now is UPC-A (12 digits)
this.ean13 = (typeof data['ean13'] === 'undefined') ? '' : ('_' + data['ean13']);
};

PrintJob.prototype.attributes = function(label_template_id){
Expand All @@ -17,13 +20,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;
Expand Down Expand Up @@ -59,7 +64,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 + this.ean13
var label_template_url = baseUrl()+'label_templates?filter[name]=' + label_template_name
return label_template_url
};
Expand Down
9 changes: 5 additions & 4 deletions public/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

$(document).ready(function() {

getPrinters()
formSetup()

$('#barcode').keyup(removeFromAndTo)

$('#type').change(disableCheckboxIfTube);
$('#labels_options').change(removeIrrelevantInputs);
$('#labware_type').change(changeFormBasedOnLabwareType);
$('#small').change(changeBarcodeLengthIfLabelSizeHasChanged);
$('#ean13').change(changeBarcodeLengthIfBarcodeTypeChanged);

$('form').submit(function(event) {
refreshResult();
Expand Down
Loading