From 98c0b6f41a9524eaeb807563355788733f1ede26 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Mon, 29 May 2017 17:08:41 +0200
Subject: [PATCH] handling of onDataLoadStart and onDataLoadStop events added

---
 frontend-js/src/main/js/ServerConnector.js    | 19 +++++++++++++++++--
 .../src/test/js/ServerConnector-mock.js       |  2 +-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js
index 105a02aca2..60d0ed4ea7 100644
--- a/frontend-js/src/main/js/ServerConnector.js
+++ b/frontend-js/src/main/js/ServerConnector.js
@@ -28,7 +28,6 @@ var GuiConnector = require('./GuiConnector');
 
 var ObjectWithListeners = require('./ObjectWithListeners');
 
-
 /**
  * This object contains methods that will communicate with server.
  */
@@ -74,7 +73,23 @@ ServerConnector.getMaxOverlayColorInt = function() {
   });
 };
 
-ServerConnector.readFile = function(url) {
+ServerConnector.readFile = function(url, description) {
+  var self = this;
+  if (description === undefined) {
+    description = url;
+  }
+  var content;
+  return self.callListeners("onDataLoadStart", description).then(function() {
+    return self._readFile(url);
+  }).then(function(result) {
+    content = result;
+    return self.callListeners("onDataLoadStop", description);
+  }).then(function() {
+    return content;
+  })
+};
+
+ServerConnector._readFile = function(url) {
   return new Promise(function(resolve, reject) {
     request.get(url, function(error, response, body) {
       if (error) {
diff --git a/frontend-js/src/test/js/ServerConnector-mock.js b/frontend-js/src/test/js/ServerConnector-mock.js
index af8414813f..fa21874b4c 100644
--- a/frontend-js/src/test/js/ServerConnector-mock.js
+++ b/frontend-js/src/test/js/ServerConnector-mock.js
@@ -21,7 +21,7 @@ ServerConnectorMock.init = function() {
 };
 ServerConnectorMock.init();
 
-ServerConnectorMock.readFile = function(url) {
+ServerConnectorMock._readFile = function(url) {
   return new Promise(function(resolve, reject) {
     if (url.indexOf("http") === 0) {
       request.get(url, function(error, response, body) {
-- 
GitLab