Commit 238d9c7b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when there is a problem with uploading data then info in Gui appears

parent 96b3d0c1
.idea/workspace.xml
/dist/
/coverage/
/node_modules/
......
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/frontend-js.iml" filepath="$PROJECT_DIR$/.idea/frontend-js.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -4,6 +4,7 @@ var logger = require('./logger');
var Functions = require('./Functions');
var SecurityError = require('./SecurityError');
var NetworkError = require('./NetworkError');
/**
* This static global object contains set of functions that returns/set data in
......@@ -25,11 +26,11 @@ GuiConnector.yPos = 0;
* List of GET params passed via url.
*/
GuiConnector.init = function() {
GuiConnector.init = function () {
var self = this;
if (!String.prototype.endsWith) {
String.prototype.endsWith = function(pattern) {
String.prototype.endsWith = function (pattern) {
var d = this.length - pattern.length;
return d >= 0 && this.lastIndexOf(pattern) === d;
};
......@@ -40,7 +41,7 @@ GuiConnector.init = function() {
alert("This webpage works well with Chrome, Firefox and Safari.");
}
// bootstrap tab initialization
$("ul.nav-tabs a").click(function(e) {
$("ul.nav-tabs a").click(function (e) {
e.preventDefault();
$(this).tab('show');
});
......@@ -48,16 +49,17 @@ GuiConnector.init = function() {
self.getParams = [];
// find GuiConnector.getParams
window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
GuiConnector.getParams[decode(arguments[1])] = decode(arguments[2]);
});
// forser browser to update mouse coordinates whenever mouse move
jQuery(document).ready(function() {
$(document).mousemove(function(e) {
jQuery(document).ready(function () {
$(document).mousemove(function (e) {
GuiConnector.updateMouseCoordinates(e.pageX, e.pageY);
});
});
......@@ -69,7 +71,7 @@ GuiConnector.init = function() {
self.addWindowResizeEvent(window.onresize);
}
window.onresize = function() {
window.onresize = function () {
for (var i = 0; i < self._windowResizeEvents.length; i++) {
self._windowResizeEvents[i]();
}
......@@ -77,18 +79,18 @@ GuiConnector.init = function() {
}
};
GuiConnector.addWindowResizeEvent = function(handler) {
GuiConnector.addWindowResizeEvent = function (handler) {
this._windowResizeEvents.push(handler);
};
/**
* Returns name of the file with LCSB logo.
*
*
* @param bigLogo
* {@link Boolean} value determining if we want to have big logo or
* small one
*/
GuiConnector.getLcsbLogoImg = function(bigLogo) {
GuiConnector.getLcsbLogoImg = function (bigLogo) {
if (bigLogo) {
return 'lcsb_logo_mid.png';
} else {
......@@ -100,26 +102,26 @@ GuiConnector.getLcsbLogoImg = function(bigLogo) {
* Returns name of the file with image that should be presented when we are
* wainting for data to be loaded.
*/
GuiConnector.getLoadingImg = function() {
GuiConnector.getLoadingImg = function () {
return "icons/ajax-loader.gif";
};
/**
* Returns home directory for images in the application.
*/
GuiConnector.getImgPrefix = function() {
GuiConnector.getImgPrefix = function () {
return "resources/images/";
};
/**
* Updates coordinates of the mouse in the browser.
*/
GuiConnector.updateMouseCoordinates = function(x, y) {
GuiConnector.updateMouseCoordinates = function (x, y) {
this.xPos = x;
this.yPos = y;
};
GuiConnector.showProcessing = function(messageText) {
GuiConnector.showProcessing = function (messageText) {
var self = GuiConnector;
if (self._processingDialog === undefined) {
self._processingDialog = document.createElement("div");
......@@ -127,11 +129,11 @@ GuiConnector.showProcessing = function(messageText) {
self._processingDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._processingDialog);
$(self._processingDialog).dialog({
modal : true,
title : "PROCESSING",
width : "150px",
closeOnEscape : false,
open : function(event, ui) {
modal: true,
title: "PROCESSING",
width: "150px",
closeOnEscape: false,
open: function (event, ui) {
$(".ui-dialog-titlebar-close", ui).hide();
},
});
......@@ -140,8 +142,8 @@ GuiConnector.showProcessing = function(messageText) {
messageText = "PROCESSING";
}
var messageImg = Functions.createElement({
type : "img",
src : 'resources/images/icons/ajax-loader.gif',
type: "img",
src: 'resources/images/icons/ajax-loader.gif',
});
self._errorDialogContent.innerHTML = "";
self._errorDialogContent.style.textAlign = "center";
......@@ -152,12 +154,12 @@ GuiConnector.showProcessing = function(messageText) {
$(self._processingDialog).dialog("open");
};
GuiConnector.hideProcessing = function() {
GuiConnector.hideProcessing = function () {
var self = GuiConnector;
$(self._processingDialog).dialog("close");
};
GuiConnector.alert = function(error) {
GuiConnector.alert = function (error) {
var self = GuiConnector;
logger.error(error);
if (self._errorDialog === undefined) {
......@@ -166,18 +168,20 @@ GuiConnector.alert = function(error) {
self._errorDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._errorDialog);
$(self._errorDialog).dialog({
classes : {
"ui-dialog" : "ui-state-error"
classes: {
"ui-dialog": "ui-state-error"
},
modal : true,
title : "ERROR"
modal: true,
title: "ERROR"
}).siblings('.ui-dialog-titlebar').css("background", "red");
}
var message = error;
if (message instanceof SecurityError) {
message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resuorce</p>";
message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resource</p>";
} else if (message instanceof NetworkError && (error.message === "XHR error" || error.message === "Failed to fetch")) {
message = "File to big.<br>Please reduce file size or contact administrators.";
} else if (message instanceof Error) {
message = "Unexpected error occured:<p>" + error.message + "</p>";
message = "Unexpected error occurred:<p>" + error.message + "</p>";
}
self._errorDialogContent.innerHTML = message;
$(self._errorDialog).dialog("open");
......
......@@ -155,7 +155,7 @@ ServerConnector.sendPostRequest = function (url, params) {
form: params
}, function (error, response, body) {
if (error) {
reject(new NetworkError(error, {
reject(new NetworkError(error.message, {
content: body,
url: url
}));
......
......@@ -449,7 +449,7 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
}
}
if (fileContent === null) {
GuiConnector.alert("Neither file was selected nor data was enterd");
GuiConnector.alert("Neither file was selected nor data was entered");
} else {
var data = {
name: nameInput.value,
......@@ -466,15 +466,11 @@ OverlayPanel.prototype.openAddOverlayDialog = function () {
$(dialog).dialog("close");
}, function (error) {
GuiConnector.hideProcessing();
if (error instanceof NetworkError) {
if (error.statusCode === HttpStatus.BAD_REQUEST) {
var errorMessage = JSON.parse(error.content);
GuiConnector.alert("Problematic input: <br/>" + errorMessage.reason);
} else {
throw error;
}
if (error instanceof NetworkError && error.statusCode === HttpStatus.BAD_REQUEST) {
var errorMessage = JSON.parse(error.content);
GuiConnector.alert("Problematic input: <br/>" + errorMessage.reason);
} else {
throw error;
GuiConnector.alert(error);
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment