From fc3b90895d52166bae6e5772ed3ec422afd08b3e Mon Sep 17 00:00:00 2001
From: juanf <juanf@ethz.ch>
Date: Wed, 2 Nov 2022 13:01:45 +0100
Subject: [PATCH] SSDM-13033 : Improvement : XLS Sample Regitration/Update to
 use batch operations

---
 .../as/webapps/eln-lims/html/js/server/ServerFacade.js | 10 +++++-----
 .../html/js/views/SampleTable/SampleTableController.js |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index bc69441524b..75d243c29de 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -131,7 +131,7 @@ function ServerFacade(openbisServer) {
             "sessionKey" : sessionKey
         }, function(result) {
             callback(result)
-        }, false);
+        }, true);
     }
 
     this.deleteSpace = function(code, reason, callback) {
@@ -153,7 +153,7 @@ function ServerFacade(openbisServer) {
             "sessionKey" : sessionKey
         }, function(result) {
             callback(result)
-        }, false);
+        }, true);
     }
 
     this.getSamplesImportTemplate = function(allowedSampleTypes, templateType, importMode, callback) {
@@ -987,6 +987,7 @@ function ServerFacade(openbisServer) {
 		formData.append("sessionKeysNumber", 1);
 		formData.append("sessionKey_0", "sample-file-upload");
 		formData.append("sample-file-upload", file);
+		formData.append("keepOriginalFileName", "True");
 		formData.append("sessionID", this.openbisServer.getSession());
 
 		$.ajax({
@@ -3616,10 +3617,9 @@ function ServerFacade(openbisServer) {
                                     if(asyncWaitResult.details.error !== null) {
                                         Util.showError(asyncWaitResult.details.error.message);
                                     } else if(asyncWaitResult.details.results !== null) {
-                                        callbackFunction(result);
+                                        callbackFunction(asyncWaitResult.details.results[0]);
                                     } else {
-                                        console.log("waitUntilDone");
-                                        setTimeout(waitUntilDone, 200);
+                                        setTimeout(waitUntilDone, 1000);
                                     }
                                 }).fail(failureHander);
                            }
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
index 4cc88625e86..e488e8ba61b 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
@@ -175,7 +175,7 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
             Util.blockUI();
             mainController.serverFacade.fileUpload(file, function() {
                 mainController.serverFacade.registerSamples(selectedSampleTypes, experimentsByType, spacesByType,
-                        _this.getBarcodeValidationInfo(), "sample-file-upload", 
+                        _this.getBarcodeValidationInfo(), file.name,
                 function(result) {
                     _this._handleResult(result, "created", experimentIdentifier);
                 });
@@ -198,7 +198,7 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
             Util.blockUI();
             mainController.serverFacade.fileUpload(file, function() {
                 mainController.serverFacade.updateSamples(selectedSampleTypes,
-                        _this.getBarcodeValidationInfo(), "sample-file-upload", 
+                        _this.getBarcodeValidationInfo(), file.name,
                         function(result) {
                     _this._handleResult(result, "updated", experimentIdentifier);
                 });
@@ -227,7 +227,7 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
     }
 
     this._handleResult = function(result, verb, experimentIdentifier) {
-        Util.showSuccess(result[0].length + " " + ELNDictionary.Samples + " successfully " + verb, function() {
+        Util.showSuccess(result.result.length + " " + ELNDictionary.Samples + " successfully " + verb, function() {
             Util.unblockUI();
             var expIdOrNull = experimentIdentifier ? '"' + experimentIdentifier + '"' : null;
             mainController.changeView('showSamplesPage', encodeURIComponent('[' + expIdOrNull + ',false]'));
-- 
GitLab