eLabSDK2.Inventory
Hierarchy
-
default↳
Inventory↳↳
Equipment↳↳
Quantity↳↳
Sample↳↳
SampleType↳↳
StorageLayer↳↳
StorageUnit
Methods
addEventListener
Static addEventListener<T>(eventName, callback, id): void
Register event listener, eventName should be one of the available SDK events
Will not re-register when function is already linked to specified event.
Type parameters
| Name | Type |
|---|---|
T | Event |
Parameters
| Name | Type |
|---|---|
eventName | string |
callback | (e: T) => void |
id | string |
Returns
void
Inherited from
eLabSDK2.addEventListener
getCommonSDKStore
Static getCommonSDKStore(): VuexStoreInterface
Contains a reference to the 'common' store, containing
all application shared logic (groups, userinfo, usersettings)
Returns
VuexStoreInterface
Inherited from
eLabSDK2.getCommonSDKStore
goToAllSamplesPage
Static goToAllSamplesPage(): void
Navigate to the main "All Samples" page in the inventory browser.
This redirects the browser to the root inventory browser page, which displays the
"All Samples" list view. This is the main entry point for the inventory browser where
users can see all samples they have access to, search samples, and navigate to storage
locations. Use this to provide navigation back to the inventory home page or as a
starting point for inventory workflows.
Returns
void
Example
// Navigate to All Samples page
eLabSDK2.Inventory.goToAllSamplesPage();
Example
// Add "Back to Inventory" button
document.getElementById('back-to-inventory').addEventListener('click', () => {
eLabSDK2.Inventory.goToAllSamplesPage();
});
Example
// Navigate to inventory after completing workflow
async function completeWorkflow() {
await processSamples();
eLabSDK2.UI.Toast.showToast('Workflow complete', 2000);
eLabSDK2.Inventory.goToAllSamplesPage();
}
goToCompartment
Static goToCompartment(storageLayerID): void
Navigate to a specific compartment (storage layer) in the inventory browser.
This redirects the browser to the detail page of the specified storage layer, showing
the samples tab by default. Storage layers are compartments within storage units like
shelves in a freezer, drawers in a cabinet, or positions in a box. Use this to
programmatically navigate users to specific locations in the inventory for viewing
or managing samples.
Parameters
| Name | Type | Description |
|---|---|---|
storageLayerID | number | The numeric ID of the storage layer (compartment) to navigate to. |
Returns
void
Example
// Navigate to specific compartment
eLabSDK2.Inventory.goToCompartment(456);
Example
// Navigate to compartment from search results
const searchResults = await searchInventory('Sample-123');
if (searchResults.length > 0) {
const sample = searchResults[0];
eLabSDK2.Inventory.goToCompartment(sample.storageLayerID);
}
Example
// Add custom button to navigate to compartment
document.getElementById('goto-storage').addEventListener('click', () => {
const layerId = 789;
eLabSDK2.Inventory.goToCompartment(layerId);
});
goToInstrument
Static goToInstrument(storageLayerId, hasPlanner?): void
Navigate to a specific equipment/instrument detail page in the inventory browser.
This redirects the browser to the detail page of the specified equipment item. If the
equipment has a booking planner (hasPlanner = true), it opens the booking tab by default;
otherwise it opens the overview tab. Equipment includes laboratory instruments like
microscopes, centrifuges, incubators, thermocyclers, and other bookable devices. Use this
to programmatically navigate users to specific equipment pages for viewing details, making
bookings, or managing equipment information.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
storageLayerId | number | undefined | The numeric storage layer ID of the equipment/instrument to navigate to. |
hasPlanner? | boolean | true | Whether the equipment has a booking planner. If true, opens the booking tab; if false, opens the overview tab. Defaults to true. |
Returns
void
Example
// Navigate to equipment with planner (opens booking tab)
eLabSDK2.Inventory.goToInstrument(123, true);
Example
// Navigate to equipment without planner (opens overview tab)
eLabSDK2.Inventory.goToInstrument(456, false);
Example
// Navigate from search results
const equipment = await searchEquipment('Microscope');
if (equipment.length > 0) {
const microscope = equipment[0];
eLabSDK2.Inventory.goToInstrument(microscope.storageLayerID, microscope.hasPlanner);
}
Example
// Add custom button to view equipment
document.getElementById('view-equipment').addEventListener('click', () => {
const equipmentId = 789;
eLabSDK2.Inventory.goToInstrument(equipmentId);
});
inventoryBrowserActive
Static inventoryBrowserActive(): boolean
Check if the inventory browser (inventory rebuild) is currently active and displayed.
This returns true when the user is viewing any page within the inventory browser/rebuild
application. The inventory browser is the modern inventory interface for managing samples,
storage units, equipment, and storage layers. Use this to conditionally execute inventory-specific
code or determine the current application context.
Returns
boolean
True if the inventory browser is currently active, false otherwise.
Example
// Check if inventory is active
if (eLabSDK2.Inventory.inventoryBrowserActive()) {
console.log('User is in the inventory browser');
initializeInventoryFeatures();
} else {
console.log('User is not in the inventory browser');
}
Example
// Conditionally load inventory-specific code
if (eLabSDK2.Inventory.inventoryBrowserActive()) {
loadInventoryCustomizations();
}
onAfterPageLoad
Static onAfterPageLoad(callback, id): void
Register a callback to execute after the inventory browser application has fully loaded.
This event fires after the inventory browser Vue application has completed initialization,
mounted all components, and rendered the initial view. Use this to perform actions that
require the inventory interface to be fully available, such as manipulating DOM elements,
initializing third-party libraries, displaying notifications, or triggering workflows based
on the loaded inventory state. The callback receives detail information about the loaded context.
Parameters
| Name | Type | Description |
|---|---|---|
callback | Function | Function to execute after the inventory application loads. Receives detail information as parameter. |
id | string | Unique identifier for this callback registration. |
Returns
void
Example
// Initialize features after inventory loads
eLabSDK2.Inventory.onAfterPageLoad((detail) => {
console.log('Inventory loaded successfully', detail);
initializeInventoryFeatures();
displayWelcomeMessage();
}, 'init-features');
Example
// Track page load performance
eLabSDK2.Inventory.onAfterPageLoad(() => {
const loadTime = Date.now() - window.inventoryLoadStartTime;
console.log(`Inventory loaded in ${loadTime}ms`);
trackAnalytics('inventory_load_time', loadTime);
}, 'track-load-time');
Example
// Attach event listeners after load
eLabSDK2.Inventory.onAfterPageLoad(() => {
document.querySelectorAll('.sample-row').forEach(row => {
row.addEventListener('click', handleSampleClick);
});
}, 'attach-listeners');
Example
// Display notification after load
eLabSDK2.Inventory.onAfterPageLoad(() => {
if (window.hasInventoryUpdate) {
eLabSDK2.UI.Toast.showToast('New samples available', 3000);
}
}, 'show-notifications');
Overrides
eLabSDK2.onAfterPageLoad
onBeforePageExit
Static onBeforePageExit(callback, id): void
Triggers the callback prior to leaving the page. (soft or hard route)
Parameters
| Name | Type | Description |
|---|---|---|
callback | Function | :Function |
id | string |
Returns
void
Inherited from
eLabSDK2.onBeforePageExit
onBeforePageLoad
Static onBeforePageLoad(callback, id): void
Register a callback to execute before the inventory browser application loads.
This event fires before the inventory browser Vue application initializes and mounts,
allowing you to perform setup tasks, configure settings, register customizations, or
prepare data before the inventory interface becomes available to the user. This is the
earliest point to initialize inventory-specific features. The callback receives detail
information about the loading context.
Parameters
| Name | Type | Description |
|---|---|---|
callback | Function | Function to execute before the inventory application loads. Receives detail information as parameter. |
id | string | Unique identifier for this callback registration. |
Returns
void
Example
// Initialize inventory customizations before load
eLabSDK2.Inventory.onBeforePageLoad((detail) => {
console.log('Inventory loading...', detail);
registerInventoryCustomizations();
loadUserPreferences();
}, 'init-inventory');
Example
// Track page load timing
const inventoryLoadStart = Date.now();
eLabSDK2.Inventory.onBeforePageLoad(() => {
console.log('Inventory load started');
window.inventoryLoadStartTime = Date.now();
}, 'track-load-start');
Example
// Configure inventory settings before load
eLabSDK2.Inventory.onBeforePageLoad(() => {
configureInventoryTreeNodes();
registerCustomActions();
}, 'configure-inventory');
Overrides
eLabSDK2.onBeforePageLoad
onTreeReady
Static onTreeReady(callback, id): void
Register a callback to execute when the inventory tree navigator is fully loaded and ready.
This event fires when the inventory browser's tree navigator (the hierarchical view showing
storage units, storage layers, and samples) has finished initial rendering and is ready for
interaction. Use this to perform actions that depend on the tree structure being available,
such as highlighting specific nodes, expanding paths, or injecting custom tree content.
Parameters
| Name | Type | Description |
|---|---|---|
callback | any | Function to execute when the tree is ready. |
id | any | Unique identifier for this callback registration. |
Returns
void
Example
// Initialize tree customizations after it's ready
eLabSDK2.Inventory.onTreeReady(() => {
console.log('Inventory tree is ready');
expandDefaultTreePaths();
highlightFavoriteUnits();
}, 'init-tree-features');
Example
// Track tree load time
const treeLoadStart = Date.now();
eLabSDK2.Inventory.onTreeReady(() => {
const loadTime = Date.now() - treeLoadStart;
trackAnalytics('inventory_tree_load_time', loadTime);
}, 'track-tree-load');
openHeatmap
Static openHeatmap(storageLayerID): Promise<void>
Open a heatmap visualization for a specific storage layer showing sample distribution.
This displays a modal dialog with a visual heatmap representation of the specified storage
layer, showing which positions are occupied by samples and which are empty. The heatmap
provides a quick visual overview of storage layer capacity and sample distribution. This
is particularly useful for storage layers with grid layouts like freezer boxes, microtiter
plates, or shelving units. Returns a promise that resolves when the heatmap modal is opened.
Parameters
| Name | Type | Description |
|---|---|---|
storageLayerID | number | The numeric ID of the storage layer to visualize. |
Returns
Promise<void>
A Promise that resolves when the heatmap modal is opened.
Example
// Open heatmap for a specific storage layer
await eLabSDK2.Inventory.openHeatmap(789);
console.log('Heatmap opened');
Example
// Open heatmap from custom action
eLabSDK2.Inventory.StorageLayer.StorageLayerDetail.registerAction({
id: 'view-heatmap',
label: 'View Heatmap',
icon: 'fas fa-th',
onClick: () => {
const layerId = eLabSDK2.Inventory.StorageLayer.getActiveStorageLayerID();
if (layerId) {
eLabSDK2.Inventory.openHeatmap(layerId);
}
}
});
Example
// Get layer ID from detail page and open heatmap
const layer = eLabSDK2.Inventory.StorageLayer.StorageLayerDetail.getStorageLayer();
if (layer && layer.storageLayerID) {
await eLabSDK2.Inventory.openHeatmap(layer.storageLayerID);
}
pickEquipment
Static pickEquipment(config): Promise<StorageUnit[]>
Open a modal dialog to select one or more equipment items from the inventory.
This displays an interactive modal with the equipment browser, allowing the user to browse
and select equipment/instruments. Equipment includes items like microscopes, centrifuges,
incubators, thermocyclers, and other laboratory instruments. The modal can be configured
with custom title, width, and pre-selected equipment. Returns a promise that resolves with
an array of selected equipment objects (as StorageUnit objects) when the user confirms.
This is useful for booking equipment, linking equipment to experiments, or performing bulk
equipment operations.
Parameters
| Name | Type | Description |
|---|---|---|
config | PickEquipmentConfig | { title?: string, width?: string, selectedEquipment?: Equipment[] } |
Returns
Promise<StorageUnit[]>
A Promise that resolves with an array of selected StorageUnit objects representing the equipment.
Example
// Pick equipment with default settings
const equipment = await eLabSDK2.Inventory.pickEquipment({});
if (equipment.length > 0) {
console.log(`Selected equipment: ${equipment[0].name}`);
await bookEquipment(equipment[0].storageID, startTime, endTime);
}
Example
// Pick equipment with custom modal title and width
const equipment = await eLabSDK2.Inventory.pickEquipment({
title: 'Select Lab Equipment',
width: '900px'
});
console.log(`${equipment.length} equipment items selected`);
await linkEquipmentToExperiment(experimentId, equipment.map(e => e.storageID));
Example
// Pick equipment with pre-selected items
const currentEquipment = [
{ id: 1, name: 'Microscope A', description: 'Confocal', status: 'available', icon: 'fa-microscope' }
];
const equipment = await eLabSDK2.Inventory.pickEquipment({
selectedEquipment: currentEquipment,
title: 'Add More Equipment'
});
if (equipment.length > 0) {
console.log('Selected equipment:', equipment.map(e => e.name));
}
Example
// Handle cancellation
try {
const equipment = await eLabSDK2.Inventory.pickEquipment({});
processEquipmentSelection(equipment);
} catch (error) {
console.log('User cancelled equipment selection');
}
pickLocation
Static pickLocation(options?): Promise<{ positions: number[] ; storageLayer: StorageLayer }>
Open a modal dialog to select a storage layer (compartment/location) from the inventory.
This displays an interactive modal with the inventory tree navigator, allowing the user
to browse storage units and select a specific storage layer (compartment) within them.
Storage layers are specific locations like shelves in a freezer, drawers in a cabinet,
or positions in a box. The modal can be configured with various options including starting
location, position validation, equipment blocking, and custom titles. Returns a promise that
resolves with an object containing the selected storage layer and positions when the user confirms.
Parameters
| Name | Type | Description |
|---|---|---|
options? | PickerModalProps | { maxSelectionSize?: number, startingStorageLayerID?: number, forbiddenSamples?: DeepPartial[], forbiddenPositions?: number[], validatePositions?: boolean, ableToSelectSeries?: boolean, ableToSelectOtherSampleType?: boolean, allowedSampleTypeId?: number, ableToSelectSamplesOfASeries?: boolean, onlySelectFromCurrentSeries?: boolean, preSelectedSampleIDs?: number[], moveCompartment?: boolean, clearedLocations?: ClearLocationInterface[], standAlone?: boolean, blockGridLocations?: boolean, blockEquipment?: boolean, modalTitle?: string } |
Returns
Promise<{ positions: number[] ; storageLayer: StorageLayer }>
A Promise that resolves with an object containing the selected StorageLayer and an array of selected position numbers.
Example
// Open location picker starting at root
const result = await eLabSDK2.Inventory.pickLocation();
console.log(`Selected: ${result.storageLayer.name}`);
console.log(`ID: ${result.storageLayer.storageLayerID}`);
console.log(`Positions: ${result.positions}`);
Example
// Open location picker with custom title and blocking equipment
const result = await eLabSDK2.Inventory.pickLocation({
startingStorageLayerID: 123,
blockEquipment: true,
modalTitle: 'Select Sample Storage Location'
});
if (result) {
await moveSampleToLocation(sampleId, result.storageLayer.storageLayerID);
}
Example
// Pick location for moving samples with position validation
const result = await eLabSDK2.Inventory.pickLocation({
moveCompartment: true,
forbiddenPositions: [1, 2, 3],
validatePositions: true,
maxSelectionSize: 5
});
console.log(`User selected storage layer: ${result.storageLayer.storageLayerID}`);
console.log(`Selected ${result.positions.length} positions:`, result.positions);
pickSamples
Static pickSamples(options?): Promise<number[]>
Open a modal dialog to select one or more samples from the inventory.
This displays an interactive modal with the inventory browser, allowing the user to browse
samples and select one or multiple samples. The modal can be configured with various options
such as starting location, selection limits, filters, sample type restrictions, and more. Returns
a promise that resolves with an array of selected sample IDs when the user confirms their selection.
This is useful for workflows that require sample selection, such as linking samples to experiments,
creating sample groups, or batch operations.
Parameters
| Name | Type | Description |
|---|---|---|
options? | PickerModalProps | { maxSelectionSize?: number, startingStorageLayerID?: number, forbiddenSamples?: DeepPartial[], forbiddenPositions?: number[], validatePositions?: boolean, ableToSelectSeries?: boolean, ableToSelectOtherSampleType?: boolean, allowedSampleTypeId?: number, ableToSelectSamplesOfASeries?: boolean, onlySelectFromCurrentSeries?: boolean, preSelectedSampleIDs?: number[], moveCompartment?: boolean, clearedLocations?: ClearLocationInterface[], standAlone?: boolean, blockGridLocations?: boolean, blockEquipment?: boolean, modalTitle?: string } |
Returns
Promise<number[]>
A Promise that resolves with an array of selected sample IDs (numbers).
Example
// Pick a single sample (maxSelectionSize defaults to unlimited)
const sampleIds = await eLabSDK2.Inventory.pickSamples();
if (sampleIds.length > 0) {
console.log(`Selected sample ID: ${sampleIds[0]}`);
await linkSampleToExperiment(experimentId, sampleIds[0]);
}
Example
// Pick up to 5 samples with maxSelectionSize
const sampleIds = await eLabSDK2.Inventory.pickSamples({ maxSelectionSize: 5 });
console.log(`${sampleIds.length} samples selected (max 5)`);
await addSamplesToGroup(groupId, sampleIds);
Example
// Pick samples of specific type only
const sampleIds = await eLabSDK2.Inventory.pickSamples({
startingStorageLayerID: 456,
allowedSampleTypeId: 789,
modalTitle: 'Select DNA Samples'
});
if (sampleIds.length > 0) {
await exportSamples(sampleIds);
}
Example
// Pick samples with pre-selection and restrictions
const sampleIds = await eLabSDK2.Inventory.pickSamples({
preSelectedSampleIDs: [100, 101, 102],
forbiddenSamples: [{ sampleID: 200 }],
maxSelectionSize: 10,
ableToSelectSeries: true
});
selectStorageLayer
Static selectStorageLayer(startingStorageLayerID?): Promise<{ positions: number[] ; storageLayer: StorageLayer }>
DEPRECATED: Select a storage layer in the inventory browser.
This method is deprecated. Use pickLocation() instead.
Opens a modal dialog allowing the user to browse and select a storage layer (compartment)
from the inventory tree. Optionally starts at a specific storage layer. Returns a promise
that resolves with an object containing the selected storage layer and positions when the user makes a selection.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
startingStorageLayerID? | number | 0 | Optional starting storage layer ID to begin browsing from. Defaults to 0 (root level). |
Returns
Promise<{ positions: number[] ; storageLayer: StorageLayer }>
A Promise that resolves with an object containing the selected StorageLayer and positions.
Deprecated
Use pickLocation() instead for better flexibility and options support.
Example
// DEPRECATED - Use pickLocation() instead
const result = await eLabSDK2.Inventory.selectStorageLayer(123);
console.log(result.storageLayer.storageLayerID);
// RECOMMENDED - Use pickLocation() instead:
const result = await eLabSDK2.Inventory.pickLocation({ startingStorageLayerID: 123 });
console.log(result.storageLayer.storageLayerID);
© 2023 eLabNext
Updated about 6 hours ago