eLabSDK.Label

Functions

NameDescription
renderLabel(data)Render a custom label with the provided data.

This is a base method for rendering label content. Currently it accesses the contents
property from the data object. Use this as a foundation for custom label rendering
implementations or extend this class to create specialized label types.
renderExperimentLabel(config) | Open a dialog for printing a barcode label for an experiment.

This displays a modal dialog containing a DYMO label printer interface for the specified
experiment. The label includes experiment information like the experiment ID (as a barcode),
name, and optionally the author. The dialog loads the label printing interface in an iframe,
allowing users to print physical labels for their experiments using a DYMO label printer.
Use this to enable users to create physical labels for experiment tracking and organization.

renderLabel(data)

Render a custom label with the provided data.

This is a base method for rendering label content. Currently it accesses the contents
property from the data object. Use this as a foundation for custom label rendering
implementations or extend this class to create specialized label types.

Kind: global function

ParamTypeDescription
dataObjectConfiguration object for the label
data.contentsstringThe content to render in the label

Example

// Basic label rendering
var label = new eLabSDK.Label();
label.renderLabel({
  contents: 'Sample Label Content'
});

Example

// Custom label with HTML content
var label = new eLabSDK.Label();
label.renderLabel({
  contents: '<strong>Sample ID:</strong> 12345<br><strong>Date:</strong> 2024-11-27'
});

renderExperimentLabel(config)

Open a dialog for printing a barcode label for an experiment.

This displays a modal dialog containing a DYMO label printer interface for the specified
experiment. The label includes experiment information like the experiment ID (as a barcode),
name, and optionally the author. The dialog loads the label printing interface in an iframe,
allowing users to print physical labels for their experiments using a DYMO label printer.
Use this to enable users to create physical labels for experiment tracking and organization.

Kind: global function

ParamTypeDefaultDescription
configObjectConfiguration object for the experiment label
config.experimentIDnumberThe numeric ID of the experiment to create a label for
[config.hideAuthor]booleanfalseWhether to hide the author name on the label

Example

// Print label for an experiment
var label = new eLabSDK.Label();
label.renderExperimentLabel({
  experimentID: 1234
});

Example

// Print label without author information
var label = new eLabSDK.Label();
label.renderExperimentLabel({
  experimentID: 5678,
  hideAuthor: true
});

Example

// Add custom button to print experiment label
eLabSDK.ready(function() {
  var printLabelBtn = new eLabSDK.GUI.Button({
    label: 'Print Label',
    icon: 'fa-barcode',
    action: function() {
      var experimentId = getExperimentIdFromPage();
      var label = new eLabSDK.Label();
      label.renderExperimentLabel({
        experimentID: experimentId
      });
    }
  });
  
  var page = new eLabSDK.Page();
  page.addButton(printLabelBtn);
});

Example

// Print labels for multiple experiments
var experimentIds = [101, 102, 103];
var label = new eLabSDK.Label();

experimentIds.forEach(function(expId) {
  label.renderExperimentLabel({
    experimentID: expId,
    hideAuthor: false
  });
});

© 2023 eLabNext