diff --git a/shrine-webclient/src/main/html/js-i2b2/cells/SHRINE/EnhancedError.js b/shrine-webclient/src/main/html/js-i2b2/cells/SHRINE/EnhancedError.js
index 1004d7ce8..a86e85532 100644
--- a/shrine-webclient/src/main/html/js-i2b2/cells/SHRINE/EnhancedError.js
+++ b/shrine-webclient/src/main/html/js-i2b2/cells/SHRINE/EnhancedError.js
@@ -1,287 +1,288 @@
/**
* Created by ben on 10/13/15.
*/
var $hrine = window.$hrine = {};
$hrine.EnhancedError =
(function(){
var EnhancedError = {},
config = config || {
//@TODO:
};
+ /**
+ *
+ * @returns {{}}
+ */
function simulateI2b2Obj() {
var self = {},
errorObject = {
summary: "SHRINE Failed to Start",
description: "The SHRINE software is not running at the queried" +
" site. This error must be corrected at the queried site.Check network status or contact your local SHRINE administrator. For faster assistance, expand this window and provide all text below this line to your local SHRINE administrator.",
details: "There is a fatal syntax error in the remote site's" +
" shrine.conf or another .conf file. The remote site admin should check to make sure that there are no stray/missing quotes or brackets, and that URLs are entered correctly.",
codec: ""
};
self.errorObject = errorObject;
self.dispDIV = document.getElementById('infoQueryStatusText');
self.dispDIV.innerHTML =
'
Error Summary:
';
self.dispDIV.innerHTML += "
" +
"" + errorObject.summary + "";
return self;
}
/**
* Scope for error dialog.
*/
EnhancedError.createErrorDialogue = function (container, errorObjects) {
var anchors, btnExpand, btnContract, errorData, i2b2Obj;
//default error.
if(!container || !errorObjects) {
i2b2Obj = simulateI2b2Obj();
container = i2b2Obj.dispDIV;
errorObjects = [i2b2Obj.errorObject];
}
//this sets up the events.
anchors = container.getElementsByClassName('query-error-anchor');
//something's wrong captain, abandon ship!
if(!anchors.length|| !errorObjects.length) {
return;
}
addAnchorEvents();
function expandErrorDetailDiv (ev) {
- var errorDetailDiv = $('errorDetailDiv');
-
- //error summary and details.
- btnExpand.style.display = 'none';
- btnContract.style.display = 'inline';
- errorDetailDiv.innerHTML = '
Name:
' + errorData.summary + '
' +
- '
Description:
' + errorData.description + '
';
-
- //wiki codec
- errorDetailDiv.innerHTML +=
- '
';
-
- //exception details.
- errorDetailDiv.innerHTML +=
- '
Technical Details:
' + errorData.details + '
';
-
- //more exception details.
- errorDetailDiv.innerHTML += '
Stack Trace Name:
' + errorData.exception.name + '
' +
- '
Stack Trace Message:
' + errorData.exception.message + '
' +
- '
Stack Trace Details:
' + errorData.exception.stackTrace + '
';
-
+ var errorDetailDiv = $('errorDetailDiv');
+ btnExpand.style.display = 'none';
+ btnContract.style.display = 'inline';
+ errorDetailDiv.innerHTML = getExpandedHtml();
}
function retractErrorDetailDiv (ev) {
- var errorDetailDiv = $('errorDetailDiv');
-
- btnExpand.style.display = 'inline';
- btnContract.style.display = 'none';
-
- errorDetailDiv.innerHTML = '
Name:
' + errorData.summary + '
' +
- '
Description:
' + errorData.description + '
';
-
- //wiki codec
- errorDetailDiv.innerHTML +=
- '
';
+ var errorDetailDiv = $('errorDetailDiv');
+ btnExpand.style.display = 'inline';
+ btnContract.style.display = 'none';
+ errorDetailDiv.innerHTML = getRetractedHtml();
}
function onClick(event) {
-
event.preventDefault();
- errorData = event.currentTarget.__errorData__;
-
+ errorData = event.currentTarget.__errorData__;
btnExpand = document.getElementById('btnExpandErrorDetail');
btnContract = document.getElementById('btnContractErrorDetail');
// -- add event listeners for expand and contract as well --//
btnExpand.addEventListener('click', expandErrorDetailDiv, false);
btnContract.addEventListener('click', retractErrorDetailDiv, false);
showErrorDetail(errorData);
}
+ /**
+ *
+ * @param errorData
+ * @returns {string}
+ */
+ function getRetractedHtml () {
+ var retractedHtml = '
Summary:
'+
+ '
' + errorData.summary + '
' +
+ '
Description:
'+
+ '
' + errorData.description + '
' +
+ '
';
+ return retractedHtml;
+ }
+
+ /**
+ *
+ * @param errorData
+ * @returns {string}
+ */
+ function getExpandedHtml () {
+ var expandedHtml = getRetractedHtml() +
+ '
' +
+ '
Technical Details:
' + errorData.details + '
' +
+ '
Codec:
' + errorData.codec + '
' +
+ '
Stamp:
' + errorData.stamp + '
' +
+ '
Stack Trace Name:
' + errorData.exception.name + '
' +
+ '
Stack Trace Message:
' + errorData.exception.message + '
' +
+ '
Stack Trace Details:
' + errorData.exception.stackTrace + '
';
+ return expandedHtml;
+ }
+
+ /**
+ *
+ * @param detailObj
+ */
function showErrorDetail(detailObj) {
+
var handleCancel = function() {
this.cancel();
removeAllEvents();
retractErrorDetailDiv();
- };
+ }
var dialogErrorDetail = new YAHOO.widget.SimpleDialog("dialogErrorDetail", {
width: "820px",
fixedcenter: true,
constraintoviewport: true,
modal: true,
zindex: 700,
buttons: [ {
text: "Done",
handler: handleCancel,
isDefault: true
}]
});
-
dialogErrorDetail._doClose = function (e) {
e.preventDefault();
this.cancel();
removeAllEvents();
retractErrorDetailDiv();
}
-
$('dialogErrorDetail').show();
dialogErrorDetail.validate = function(){
return true;
};
dialogErrorDetail.render(document.body);
// / display the dialoge
dialogErrorDetail.center();
dialogErrorDetail.show();
- var errorDetailDiv = $('errorDetailDiv');
-
- errorDetailDiv.innerHTML = '
Name:
' + errorData.summary + '
' +
- '
Description:
' + errorData.description + '
';
-
- //wiki codec
- errorDetailDiv.innerHTML +=
- '
';
-
+ $('errorDetailDiv').innerHTML = getRetractedHtml();
}
+
function addAnchorEvents () {
var el, length = anchors.length;
// -- will need to iterate over these once they are created and add event listeners.
for(var i = 0; i < length; i ++) {
var el = anchors[i];
el.__errorData__ = errorObjects[i];
el.addEventListener('click', onClick, false);
}
}
function removeAllEvents () {
btnExpand.removeEventListener('click', expandErrorDetailDiv);
btnContract.removeEventListener('click', retractErrorDetailDiv);
}
}
/**
* Parse problem node.
* @param qriNode
* @returns {{exception: {}}}
*/
EnhancedError.parseProblem = function (qriNode) {
var problem = {
exception: {}
};
problem.codec = grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/problem/codec')
problem.summary = grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/problem/summary')
problem.description = grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/problem/description')
//unescape embedded html.
problem.details = i2b2.h.XPath(qriNode, 'descendant-or-self::query_status_type/problem/details')[0]
.innerHTML.unescapeHTML().replace(/(<([^>]+)>)/ig,"");
problem.exception.name = grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/problem/details/exception/name');
problem.exception.message = grabXmlNodeData(qriNode, 'descendant-or-self::query_status_type/problem/details/exception/message');
problem.exception.stackTrace = parseErrorException(qriNode);
return problem;
}
/**
* Replace all
and with
tags.
* @param node
* @returns {*}
*/
function parseErrorException(node) {
//no exception, abandon ship!
if(node.innerHTML.indexOf('') == -1){
return '';
}
var content, startIdx, endIdx;
//fish out the problem section.
content = node.innerHTML.split('')
.join()
.split('')
.join();
//fish out the first stack trace.
startIdx = content.indexOf('') + 12;
endIdx = content.indexOf('');
content = content.substring(startIdx, endIdx);
//remove all line tags and replace with line break.
content = content.split('')
.join('')
.split('')
.join()
//remove all exception tags
.split('')
.join('
')
.split('')
.join()
//remove all stacktrace tags
.split('')
.join('
')
.split('')
.join()
//remove all message tags.
.split('')
.join('
')
.split('')
.join();
return content;
}
/**
* Grab data for node, return empty string if none.
* @param node
* @param xPathString
* @returns {string}
*/
function grabXmlNodeData(node, xPathString){
var nodeVal = i2b2.h.XPath(node, xPathString);
return (nodeVal.length)? nodeVal[0].innerHTML : '';
}
return EnhancedError;
})();
\ No newline at end of file