diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js index 3ab03152c31e4ded41881b7805fe888c97901095..db44631bd0f3b82c1089b2cd9760318cf566ba0d 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js @@ -69,6 +69,14 @@ $.extend(DefaultProfile.prototype, { "isEnabled" : false }; + this.getDefaultDataStoreURL = function() { + var dataStoreURL = null; + if(this.allDataStores.length > 0) { + var dataStoreURL = this.allDataStores[0].downloadUrl + } + return dataStoreURL; + } + this.getStoragePropertyGroup = function(storagePropertyGroupDisplayName) { if(!this.storagesConfiguration["isEnabled"]) { return null; diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js index 31fa37e819d566265d56edae2534d1a550a98995..d19bd1e6f90ee6bed65c6657e2b88284e14802ae 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js @@ -30,4 +30,8 @@ function SampleFormController(mainController, mode, sample) { this.isLoaded = function() { return this._sampleFormModel.isFormLoaded; } + + this.updateSample = function() { + + } } \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormModel.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormModel.js index 2ed2e70db95261cdedd9adb795ec063f2677284b..ae700027fcec7b7dc413ecbf4459fabf492b764a 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormModel.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormModel.js @@ -29,13 +29,11 @@ function SampleFormModel(mode, sample) { this.isELNSubExperiment = false; } - - this.storages = []; - this.dataSetViewer = null; - // // TO-DO: Legacy code to be refactored // + this.storages = []; + this.dataSetViewer = null; this.sampleLinksParents = null; this.sampleLinksChildren = null; } \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js index a390362eb0376f0bd745d4d76cbe9a690321683b..932b1ae0e77420e7e3e3f524dafd11d8dc19bb22 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js @@ -41,7 +41,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { var sampleTypeDefinitionsExtension = profile.sampleTypeDefinitionsExtension[this._sampleFormModel.sampleTypeCode]; // - // Title + // TITLE // var $formTitle = null; @@ -60,6 +60,9 @@ function SampleFormView(sampleFormController, sampleFormModel) { var $formTitle = $("<h2>").append(title + " "); + // + // TITLE BUTTONS + // if(this._sampleFormModel.mode !== FormMode.CREATE) { $formTitle.append(FormUtil.getPINButton(this._sampleFormModel.sample.permId)); @@ -80,12 +83,27 @@ function SampleFormView(sampleFormController, sampleFormModel) { $formColumn.append($formTitle); - $formColumn.append($("<legend>").append("Identification Info")); + // + // PREVIEW IMAGE + // + if(this._sampleFormModel.mode !== FormMode.CREATE) { + var $previewImage = $("<img>", { 'data-preview-loaded' : 'false', + 'class' : 'zoomableImage', + 'id' : 'preview-image', + 'src' : './img/image_loading.gif', + 'style' : 'height:300px; margin-right:20px; display:none;' + }); + $previewImage.click(function() { + Util.showImage($("#preview-image").attr("src")); + }); + + $formColumn.append($previewImage); + } // // SELECT EXPERIMENT/SPACE // - + $formColumn.append($("<legend>").append("Identification Info")); if(this._sampleFormModel.isELNSubExperiment) { $formColumn.append(FormUtil.getFieldForLabelWithText("Experiment", this._sampleFormModel.sample.experimentIdentifierOrNull)); } else { @@ -187,10 +205,10 @@ function SampleFormView(sampleFormController, sampleFormModel) { var $legend = $('<legend>'); $fieldset.append($legend); - if(propertyTypeGroup.name) { + if((propertyTypeGroup.name !== null) && (propertyTypeGroup.name !== "")) { $legend.text(propertyTypeGroup.name); - } else if(sampleType.propertyTypeGroups.length === 1) { //Only when there is only one group without name to render it with a default title. - $legend.text("Metadata Fields"); + } else if((i === 0) || ((i !== 0) && (sampleType.propertyTypeGroups[i-1].name !== null) && (sampleType.propertyTypeGroups[i-1].name !== ""))) { + $legend.text("Metadata"); } else { $legend.remove(); } @@ -269,6 +287,13 @@ function SampleFormView(sampleFormController, sampleFormModel) { $formColumn.append($updateBtn); } + // + // DATASETS + // + + var $dataSetViewerContainer = $("<div>", { 'id' : 'dataSetViewerContainer', 'style' : 'margin-top:10px;'}); + $formColumn.append($dataSetViewerContainer); + // // INIT // @@ -281,11 +306,54 @@ function SampleFormView(sampleFormController, sampleFormModel) { //Repaint parents and children after updating the property state to show the annotations this._sampleFormModel.sampleLinksParents.repaint(); this._sampleFormModel.sampleLinksChildren.repaint(); + + if(this._sampleFormModel.mode !== FormMode.CREATE) { + //Preview image + this._reloadPreviewImage(); + + // Dataset Viewer + this._sampleFormModel.dataSetViewer = new DataSetViewer("dataSetViewerContainer", profile, this._sampleFormModel.sample, mainController.serverFacade, profile.getDefaultDataStoreURL()); + this._sampleFormModel.dataSetViewer.init(); + } } // - // TO-DO: Legacy code to be refactored - Generate Children widget + // TO-DO: Legacy code to be refactored // + this._reloadPreviewImage = function() { + var _this = this; + var previewCallback = + function(data) { + if (data.result.length == 0) { + _this._updateLoadingToNotAvailableImage(); + } else { + var x = "123"; + var listFilesForDataSetCallback = + function(dataFiles) { + if(!dataFiles.result) { + //DSS Is not running probably + } else { + var elementId = 'preview-image'; + var downloadUrl = profile.getDefaultDataStoreURL() + '/' + data.result[0].code + "/" + dataFiles.result[1].pathInDataSet + "?sessionID=" + mainController.serverFacade.getSession(); + + var img = $("#" + elementId); + img.attr('src', downloadUrl); + img.attr('data-preview-loaded', 'true'); + img.show(); + } + }; + mainController.serverFacade.listFilesForDataSet(data.result[0].code, "/", true, listFilesForDataSetCallback); + } + }; + + mainController.serverFacade.searchDataSetsWithTypeForSamples("ELN_PREVIEW", [this._sampleFormModel.sample.permId], previewCallback); + } + + this._updateLoadingToNotAvailableImage = function() { + var notLoadedImages = $("[data-preview-loaded='false']"); + notLoadedImages.attr('src', "./img/image_unavailable.png"); + } + this._generateChildren = function() { var _this = this; // Utility self contained methods