diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 105a02aca25e8d387fb4094c2696df48f88e142c..60d0ed4ea7d2908ea392fd8a1473735bcb83dd76 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 af8414813f5375fec2403025fc0809fee0925025..fa21874b4c0b6fd08458d72bd669ab9da2649e10 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) {