diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/error.png b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/error.png new file mode 100644 index 0000000000000000000000000000000000000000..5c832c00dc0500c8e7a14961aa0088bcceabc6a1 Binary files /dev/null and b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/error.png differ diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/wait.png b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/wait.png new file mode 100644 index 0000000000000000000000000000000000000000..0fe45f49527805aa459580082564916ce59934d4 Binary files /dev/null and b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/img/wait.png differ diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/FlowCytometryTechnology.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/FlowCytometryTechnology.js index deffccd1f660a2758d8b84559276f18e4d8429f4..bd6a377e9d0a6ad004ad133e75c57b232bd3b8bd 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/FlowCytometryTechnology.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/FlowCytometryTechnology.js @@ -174,14 +174,14 @@ $.extend(FlowCytometryTechnology.prototype, ELNLIMSPlugin.prototype, { // Additional functionality renderParameterSelectionWidget: function ($container, model) { - // Clear the container - $container.empty(); - // Check that we ave the correct dataset type if (!model.dataSetV3.type.code.endsWith("_FCSFILE")) { return; } + // Clear the container + $container.empty(); + // // Retrieve the parameter info // diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js index bb9b5a7d4e2f5bd94e1e4dcd281de83f91ba9fbd..d0d3d304695147ff5716ba69fbf0b767dc535f28 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/plugins/MicroscopyTechnology.js @@ -1,105 +1,327 @@ function MicroscopyTechnology() { - this.init(); + this.init(); } $.extend(MicroscopyTechnology.prototype, ELNLIMSPlugin.prototype, { - init: function() { - - }, - forcedDisableRTF : [], - forceMonospaceFont : [], - sampleTypeDefinitionsExtension : { - "MICROSCOPY_SAMPLE_TYPE" : { - "SHOW_ON_NAV" : true, - "SHOW" : false, - "SAMPLE_CHILDREN_DISABLED" : true, - "SAMPLE_PARENTS_DISABLED" : true, - "TOOLBAR" : { CREATE : false, EDIT : true, MOVE : false, COPY : false, DELETE : false, PRINT : true, HIERARCHY_GRAPH : true, HIERARCHY_TABLE : true, UPLOAD_DATASET : false, UPLOAD_DATASET_HELPER : false, EXPORT_ALL : true, EXPORT_METADATA : true } - }, - "MICROSCOPY_EXPERIMENT" : { - "SHOW" : false, - "SAMPLE_CHILDREN_DISABLED" : false, - "SAMPLE_PARENTS_DISABLED" : false, - "SAMPLE_PARENTS_ANY_TYPE_DISABLED" : true, - "TOOLBAR" : { CREATE : false, EDIT : true, MOVE : false, COPY : false, DELETE : false, PRINT : true, HIERARCHY_GRAPH : true, HIERARCHY_TABLE : true, UPLOAD_DATASET : false, UPLOAD_DATASET_HELPER : false, EXPORT_ALL : true, EXPORT_METADATA : true }, - "SAMPLE_PARENTS_HINT" : [{ - "LABEL" : "Organization Units", - "TYPE": "ORGANIZATION_UNIT", - "ANNOTATION_PROPERTIES" : [] - }] - } - }, - dataSetTypeDefinitionsExtension : { - "MICROSCOPY_ACCESSORY_FILE" : { - "DATASET_PARENTS_DISABLED" : true, - "TOOLBAR" : { EDIT : true, MOVE : false, ARCHIVE : true, DELETE : false, HIERARCHY_TABLE : true, EXPORT_ALL : true, EXPORT_METADATA : true } - }, - "MICROSCOPY_IMG" : { - "DATASET_PARENTS_DISABLED" : true, - "TOOLBAR" : { EDIT : true, MOVE : false, ARCHIVE : true, DELETE : false, HIERARCHY_TABLE : true, EXPORT_ALL : true, EXPORT_METADATA : true } - }, - "MICROSCOPY_IMG_OVERVIEW" : { - "DATASET_PARENTS_DISABLED" : true, - "TOOLBAR" : { EDIT : true, MOVE : false, ARCHIVE : true, DELETE : false, HIERARCHY_TABLE : true, EXPORT_ALL : true, EXPORT_METADATA : true } - }, - "MICROSCOPY_IMG_THUMBNAIL" : { - "DATASET_PARENTS_DISABLED" : true, - "TOOLBAR" : { EDIT : true, MOVE : false, ARCHIVE : true, DELETE : false, HIERARCHY_TABLE : true, EXPORT_ALL : true, EXPORT_METADATA : true } - }, - "MICROSCOPY_IMG_CONTAINER" : { - "DATASET_PARENTS_DISABLED" : true, - "TOOLBAR" : { EDIT : true, MOVE : false, ARCHIVE : true, DELETE : false, HIERARCHY_TABLE : true, EXPORT_ALL : true, EXPORT_METADATA : true } - } - }, - sampleFormTop : function($container, model) { - if(model.datasets && model.datasets.length > 0) { - var imageViewerDataSets = []; - for(var dsIdx = 0; dsIdx < model.datasets.length; dsIdx++) { - if(profile.isImageViewerDataSetCode(model.datasets[dsIdx].dataSetTypeCode)) { - imageViewerDataSets.push(model.datasets[dsIdx].code); - } - } - - if(imageViewerDataSets.length > 0) { - require(["openbis-screening", "components/imageviewer/ImageViewerWidget" ], function(openbis, ImageViewerWidget) { - var screningFacade = new openbis(null); - screningFacade._internal.sessionToken = mainController.openbisV1._internal.sessionToken; - - // Create the image viewer component for the specific data sets - var widget = new ImageViewerWidget(screningFacade, imageViewerDataSets); - - // Render the component and add it to the page - $container.append($('<legend>').text('Microscopy Viewer')); - var $imageWidgetContainer = new $('<div>'); - $imageWidgetContainer.css("margin", "20px"); - $container.append($imageWidgetContainer); - $imageWidgetContainer.append(widget.render()); - }); - } - } - }, - sampleFormBottom : function($container, model) { - - }, - dataSetFormTop : function($container, model) { - if(model.dataSetV3 && profile.isImageViewerDataSetCode(model.dataSetV3.type.code)) { - require(["openbis-screening", "components/imageviewer/ImageViewerWidget" ], function(openbis, ImageViewerWidget) { - var screningFacade = new openbis(null); - screningFacade._internal.sessionToken = mainController.openbisV1._internal.sessionToken; - - // Create the image viewer component for the specific data sets - var widget = new ImageViewerWidget(screningFacade, [model.dataSetV3.permId.permId]); - - // Render the component and add it to the page - $container.append($('<legend>').text('Microscopy Viewer')); - var $imageWidgetContainer = new $('<div>'); - $imageWidgetContainer.css("margin", "20px"); - $container.append($imageWidgetContainer); - $imageWidgetContainer.append(widget.render()); - }); - } - }, - dataSetFormBottom : function($container, model) { - - } -}); + init: function () { + + }, + forcedDisableRTF: [], + forceMonospaceFont: [], + sampleTypeDefinitionsExtension: { + "MICROSCOPY_SAMPLE_TYPE": { + "SHOW_ON_NAV": true, + "SHOW": false, + "SAMPLE_CHILDREN_DISABLED": true, + "SAMPLE_PARENTS_DISABLED": true, + "TOOLBAR": { CREATE: false, EDIT: true, MOVE: false, COPY: false, DELETE: false, PRINT: true, HIERARCHY_GRAPH: true, HIERARCHY_TABLE: true, UPLOAD_DATASET: false, UPLOAD_DATASET_HELPER: false, EXPORT_ALL: true, EXPORT_METADATA: true } + }, + "MICROSCOPY_EXPERIMENT": { + "SHOW": false, + "SAMPLE_CHILDREN_DISABLED": false, + "SAMPLE_PARENTS_DISABLED": false, + "SAMPLE_PARENTS_ANY_TYPE_DISABLED": true, + "TOOLBAR": { CREATE: false, EDIT: true, MOVE: false, COPY: false, DELETE: false, PRINT: true, HIERARCHY_GRAPH: true, HIERARCHY_TABLE: true, UPLOAD_DATASET: false, UPLOAD_DATASET_HELPER: false, EXPORT_ALL: true, EXPORT_METADATA: true }, + "SAMPLE_PARENTS_HINT": [{ + "LABEL": "Organization Units", + "TYPE": "ORGANIZATION_UNIT", + "ANNOTATION_PROPERTIES": [] + }] + } + }, + dataSetTypeDefinitionsExtension: { + "MICROSCOPY_ACCESSORY_FILE": { + "DATASET_PARENTS_DISABLED": true, + "TOOLBAR": { EDIT: true, MOVE: false, ARCHIVE: true, DELETE: false, HIERARCHY_TABLE: true, EXPORT_ALL: true, EXPORT_METADATA: true } + }, + "MICROSCOPY_IMG": { + "DATASET_PARENTS_DISABLED": true, + "TOOLBAR": { EDIT: true, MOVE: false, ARCHIVE: true, DELETE: false, HIERARCHY_TABLE: true, EXPORT_ALL: true, EXPORT_METADATA: true } + }, + "MICROSCOPY_IMG_OVERVIEW": { + "DATASET_PARENTS_DISABLED": true, + "TOOLBAR": { EDIT: true, MOVE: false, ARCHIVE: true, DELETE: false, HIERARCHY_TABLE: true, EXPORT_ALL: true, EXPORT_METADATA: true } + }, + "MICROSCOPY_IMG_THUMBNAIL": { + "DATASET_PARENTS_DISABLED": true, + "TOOLBAR": { EDIT: true, MOVE: false, ARCHIVE: true, DELETE: false, HIERARCHY_TABLE: true, EXPORT_ALL: true, EXPORT_METADATA: true } + }, + "MICROSCOPY_IMG_CONTAINER": { + "DATASET_PARENTS_DISABLED": true, + "TOOLBAR": { EDIT: true, MOVE: false, ARCHIVE: true, DELETE: false, HIERARCHY_TABLE: true, EXPORT_ALL: true, EXPORT_METADATA: true } + } + }, + sampleFormTop: function ($container, model) { + if (model.sample && model.sample.sampleTypeCode == "MICROSCOPY_EXPERIMENT") { + this.displayExperimentThumbnails($container, model, model.sample); + } + if (model.datasets && model.datasets.length > 0) { + var imageViewerDataSets = []; + for (var dsIdx = 0; dsIdx < model.datasets.length; dsIdx++) { + if (profile.isImageViewerDataSetCode(model.datasets[dsIdx].dataSetTypeCode)) { + imageViewerDataSets.push(model.datasets[dsIdx].code); + } + } + + if (imageViewerDataSets.length > 0) { + require(["openbis-screening", "components/imageviewer/ImageViewerWidget"], function (openbis, ImageViewerWidget) { + var screningFacade = new openbis(null); + screningFacade._internal.sessionToken = mainController.openbisV1._internal.sessionToken; + + // Create the image viewer component for the specific data sets + var widget = new ImageViewerWidget(screningFacade, imageViewerDataSets); + + // Render the component and add it to the page + $container.append($('<legend>').text('Microscopy Viewer')); + var $imageWidgetContainer = new $('<div>'); + $imageWidgetContainer.css("margin", "20px"); + $container.append($imageWidgetContainer); + $imageWidgetContainer.append(widget.render()); + }); + } + } + }, + sampleFormBottom: function ($container, model) { + + }, + dataSetFormTop: function ($container, model) { + if (model.dataSetV3 && profile.isImageViewerDataSetCode(model.dataSetV3.type.code)) { + require(["openbis-screening", "components/imageviewer/ImageViewerWidget"], function (openbis, ImageViewerWidget) { + var screningFacade = new openbis(null); + screningFacade._internal.sessionToken = mainController.openbisV1._internal.sessionToken; + + // Create the image viewer component for the specific data sets + var widget = new ImageViewerWidget(screningFacade, [model.dataSetV3.permId.permId]); + + // Render the component and add it to the page + $container.append($('<legend>').text('Microscopy Viewer')); + var $imageWidgetContainer = new $('<div>'); + $imageWidgetContainer.css("margin", "20px"); + $container.append($imageWidgetContainer); + $imageWidgetContainer.append(widget.render()); + }); + } + }, + dataSetFormBottom: function ($container, model) { + + }, + + displayExperimentThumbnails: function ($container, model, microscopyExperimentSample) { + if (microscopyExperimentSample.sampleTypeCode !== "MICROSCOPY_EXPERIMENT") { + return; + } + + // Clear the container + $container.empty(); + + if (microscopyExperimentSample.children.length === 0) { + return; + } + + // Add legend + var legend = $("<legend>") + .text("File previews"); + $container.append(legend); + + // Prepare a div to host the thumbnails + var sampleView_div = $("<div>"); + $container.append(sampleView_div); + + var newThumbRow = null; + var numSample = 0; + + var thisObj = this; + + // Prepare the display + microscopyExperimentSample.children.forEach(function (sample) { + + // Keep track of the number of the sample + numSample++; + + // Add a new row for the next three thumbnails + if (numSample % 4 === 1) { + newThumbRow = $("<div />", { class: "row" }); + sampleView_div.append(newThumbRow); + } + + // Prepare the name to be shown + var name; + if (sample.properties.MICROSCOPY_SAMPLE_NAME) { + name = sample.properties.MICROSCOPY_SAMPLE_NAME; + } else { + name = sample.code; + } + + // Make sure it is not too long + var displayName; + var l = name.length; + if (l > 40) { + displayName = name.substring(0, 18) + "..." + name.substring(l - 18); + } else { + displayName = name; + } + + // If the size property exists (this was added later), retrieve it and display it as well + var datasetSize; + if (sample.properties.MICROSCOPY_SAMPLE_SIZE_IN_BYTES) { + datasetSize = thisObj.formatSizeForDisplay(sample.properties.MICROSCOPY_SAMPLE_SIZE_IN_BYTES); + } else { + datasetSize = ""; + } + + // A column to be added to current row that will store all + // elements related to current sample + var newThumbCol = $("<div />", + { + class: "col-md-3", + display: "inline", + "text-align": "center", + id: sample.code + }); + + // A div element to contain the thumbnail and its info + var thumbnailView = $("<div />") + .css("min-height", "320px") + .css("text-align", "center") + .css("padding-top", "10px") + .css("padding-bottom", "10px") + + // Link to the dataset (sample) viewer. + var link = FormUtil.getFormLink(displayName, "Sample", sample.permId, null); + + // Actual thumbnail. Initially we display a place holder. Later, + // we will replace it asynchronously. + var thumbnailImage = $("<img />", + { + src: "./img/wait.png", + class: "img-responsive", + display: "inline", + "text-align": "center", + id: "image_" + sample.code, + title: name + }); + + // Build the thumbnail viewer + thumbnailView.append(thumbnailImage); + thumbnailView.append($("<br />")); + thumbnailView.append(link); + if (datasetSize !== "") { + thumbnailView.append($("<br />")); + var spanSz = $("<span>").text(datasetSize); + thumbnailView.append(spanSz); + } + + // Add the thumbnail to the column and the row + newThumbCol.append(thumbnailView); + newThumbRow.append(newThumbCol); + + // Now retrieve the link to the thumbnail image asynchronously and update the <img> + thisObj.displayThumbnailForSample(model, sample, "image_" + sample.code); + + }); + }, + + formatSizeForDisplay: function (datasetSize) { + + // Output + var formattedDatasetSize = ""; + + // Cast datasetSize to float + var datasetSizeF = parseFloat(datasetSize); + + var sMB = datasetSizeF / 1024.0 / 1024.0; + if (sMB < 1024.0) { + formattedDatasetSize = sMB.toFixed(2) + " MiB"; + } else { + var sGB = sMB / 1024.0; + formattedDatasetSize = sGB.toFixed(2) + " GiB"; + } + + return formattedDatasetSize; + }, + + displayThumbnailForSample: function (model, sample, img_id) { + + require([ + "as/dto/sample/search/SampleSearchCriteria", + "as/dto/sample/fetchoptions/SampleFetchOptions", + "as/dto/dataset/search/DataSetSearchCriteria", + "dss/dto/datasetfile/search/DataSetFileSearchCriteria", + "dss/dto/datasetfile/fetchoptions/DataSetFileFetchOptions", + ], + + function ( + SampleSearchCriteria, + SampleFetchOptions, + DataSetSearchCriteria, + DataSetFileSearchCriteria, + DataSetFileFetchOptions) { + + // First retrieve the sample again but with the associated datasets + var criteria = new SampleSearchCriteria(); + criteria.withType().withCode().thatEquals(sample.sampleTypeCode); + criteria.withPermId().thatEquals(sample.permId); + var fetchOptions = new SampleFetchOptions(); + fetchOptions.withDataSets().withType(); + + // Query the server + mainController.openbisV3.searchSamples(criteria, fetchOptions).done(function (result) { + if (result.getTotalCount() == 0) { + return null; + } + var sample = result.getObjects()[0]; + for (var i = 0; i < sample.getDataSets().length; i++) { + var dataSet = sample.getDataSets()[i]; + + if (dataSet.getType().code === "MICROSCOPY_IMG_THUMBNAIL") { + + // Now retrieve the thumbnail and add display it + + // Get the file + var criteria = new DataSetFileSearchCriteria(); + var dataSetCriteria = criteria.withDataSet().withOrOperator(); + dataSetCriteria.withPermId().thatEquals(dataSet.permId.permId); + + var fetchOptions = new DataSetFileFetchOptions(); + + // Query the server + mainController.openbisV3.getDataStoreFacade().searchFiles(criteria, fetchOptions).done(function (result) { + + // Thumbnail + var imD = $("#" + img_id); + + // Make sure to reset the display attribute + imD.css("display", "inline"); + + if (result.getTotalCount() == 0) { + + // Thumbnail not found! + imD.attr("src", "./img/error.png"); + imD.attr("title", "Could not find a thumbnail for this dataset!"); + + return; + } + + // Extract the files + var datasetFiles = result.getObjects(); + + // Find the only fcs file and add its name and URL to the DynaTree + datasetFiles.forEach(function (f) { + + // Build the download URL + var url = f.getDataStore().getDownloadUrl() + "/datastore_server/" + + f.permId.dataSetId.permId + "/" + f.getPath() + "?sessionID=" + + mainController.serverFacade.openbisServer.getSession(); + + // Replace the image + var eUrl = encodeURI(url); + eUrl = eUrl.replace('+', '%2B'); + imD.attr("src", eUrl); + }); + }); + } + } + }); + }); + } +}); \ No newline at end of file