debug plugin: moved the data formatting into the function called after click, to avoid the need to search all links/fields unless the dialog is opened
also reformatted the data
This commit is contained in:
parent
bb35383ac9
commit
3839358a7c
@ -22,82 +22,77 @@
|
|||||||
window.plugin.rawdata = function() {};
|
window.plugin.rawdata = function() {};
|
||||||
|
|
||||||
window.plugin.rawdata.setupCallback = function() {
|
window.plugin.rawdata.setupCallback = function() {
|
||||||
addHook('portalDetailsUpdated', window.plugin.rawdata.addLink);
|
addHook('portalDetailsUpdated', window.plugin.rawdata.addLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.rawdata.addLink = function(d) {
|
window.plugin.rawdata.addLink = function(d) {
|
||||||
var guidString = JSON.stringify(window.selectedPortal, null, 2);
|
$('.linkdetails').append('<aside><a onclick="window.plugin.rawdata.showPortalData(\''+window.selectedPortal+'\')" title="Display raw data of the portal">Raw Data</a></aside>');
|
||||||
guidString = encodeURIComponent('"guid": ' + guidString);
|
|
||||||
|
|
||||||
var detailsString = JSON.stringify(d.portalDetails, null, 2);
|
|
||||||
detailsString = encodeURIComponent('"portalDetails": ' + detailsString);
|
|
||||||
|
|
||||||
var linksString = "";
|
|
||||||
$.each(window.links, function(it, link) {
|
|
||||||
var guid = link.options.guid;
|
|
||||||
link = link.options.data;
|
|
||||||
if (link.edge.destinationPortalGuid == window.selectedPortal ||
|
|
||||||
link.edge.originPortalGuid == window.selectedPortal) {
|
|
||||||
linksString += encodeURIComponent('"' + guid + '": ' + JSON.stringify(link, null, 2) + '\n');
|
|
||||||
if (it != guid) { // assertion
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var fieldsString = "";
|
|
||||||
$.each(window.fields, function(it, field) {
|
|
||||||
var guid = field.options.guid;
|
|
||||||
field = field.options.data;
|
|
||||||
if (field.capturedRegion.vertexA.guid == window.selectedPortal ||
|
|
||||||
field.capturedRegion.vertexB.guid == window.selectedPortal ||
|
|
||||||
field.capturedRegion.vertexC.guid == window.selectedPortal) {
|
|
||||||
fieldsString += encodeURIComponent('"' + guid + '": ' + JSON.stringify(field, null, 2) + '\n');
|
|
||||||
if (it != guid) { // assertion
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var linkParam = '\'' + d.portalDetails.portalV2.descriptiveText.TITLE + '\',' +
|
|
||||||
'\''+ guidString + '\',' +
|
|
||||||
'\'' + detailsString + '\',' +
|
|
||||||
'\'' + linksString + '\',' +
|
|
||||||
'\'' + fieldsString + '\'';
|
|
||||||
$('.linkdetails').append('<aside><a onclick="window.plugin.rawdata.getRawData('+ linkParam + ')" title="Display raw data of the portal">Raw Data</a></aside>');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.plugin.rawdata.getRawData = function(title, guid, details, links, fields) {
|
window.plugin.rawdata.showPortalData = function(guid) {
|
||||||
dialog({
|
if (!window.portals[guid]) {
|
||||||
title: 'Raw Data: '+
|
console.warn ('Error: failed to find portal details for guid '+guid+' - failed to show debug data');
|
||||||
title +
|
return;
|
||||||
' (' +
|
}
|
||||||
decodeURIComponent(guid) +
|
|
||||||
')',
|
|
||||||
html: '<pre>' +
|
var d = window.portals[guid].options.details;
|
||||||
decodeURIComponent(guid) + '\n' +
|
var ts = window.portals[guid].options.timestamp;
|
||||||
decodeURIComponent(details) + '\n\n' +
|
|
||||||
decodeURIComponent(links) + '\n\n' +
|
var title = 'Raw portal data: ' + (d.portalV2.descriptiveText.TITLE || '<no title>') + ' ('+guid+')';
|
||||||
decodeURIComponent(fields) + '\n\n' +
|
|
||||||
'</pre>',
|
var body =
|
||||||
id: 'dialog-rawdata',
|
'<b>Portal GUID</b>: <code>'+guid+'</code><br />' +
|
||||||
dialogClass: 'ui-dialog-rawdata',
|
'<b>Entity timestamp</b>: <code>'+ts+'</code> - '+new Date(ts).toLocaleString()+'<br />' +
|
||||||
});
|
'<pre>'+JSON.stringify(d,null,2)+'</pre>';
|
||||||
|
|
||||||
|
body += '<p><b>Links referencing this portal</b></p>';
|
||||||
|
var haslinks = false;
|
||||||
|
for (var lguid in window.links) {
|
||||||
|
var l = window.links[lguid];
|
||||||
|
var ld = l.options.details;
|
||||||
|
if (ld.edge.originPortalGuid == guid || ld.edge.destinationPortalGuid == guid) {
|
||||||
|
body += '<b>Link GUID</b>: <code>'+l.options.guid+'</code><br /><pre>'+JSON.stringify(ld,null,2)+'</pre>';
|
||||||
|
haslinks = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!haslinks) body += '<p>No links to/from this portal</p>';
|
||||||
|
|
||||||
|
body += '<p><b>Fields referencing this portal</b></p>';
|
||||||
|
var hasfields = false;
|
||||||
|
for (var fguid in window.fields) {
|
||||||
|
var f = window.fields[fguid];
|
||||||
|
var fd = f.options.details;
|
||||||
|
if (fd.capturedRegion.vertexA.guid == guid ||
|
||||||
|
fd.capturedRegion.vertexB.guid == guid ||
|
||||||
|
fd.capturedRegion.vertexC.guid == guid) {
|
||||||
|
body += '<b>Field guid</b>: <code>'+f.options.guid+'</code><br /><pre>'+JSON.stringify(fd,null,2)+'</pre>';
|
||||||
|
hasfields = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hasfields) body += '<p>No fields linked to this portal</p>';
|
||||||
|
|
||||||
|
dialog({
|
||||||
|
title: title,
|
||||||
|
html: body,
|
||||||
|
id: 'dialog-rawdata',
|
||||||
|
dialogClass: 'ui-dialog-rawdata',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var setup = function () {
|
var setup = function () {
|
||||||
window.plugin.rawdata.setupCallback();
|
window.plugin.rawdata.setupCallback();
|
||||||
$('head').append('<style>' +
|
$('head').append('<style>' +
|
||||||
'.ui-dialog-rawdata {' +
|
'.ui-dialog-rawdata {' +
|
||||||
'width: auto !important;' +
|
'width: auto !important;' +
|
||||||
'min-width: 400px !important;' +
|
'min-width: 400px !important;' +
|
||||||
//'max-width: 600px !important;' +
|
//'max-width: 600px !important;' +
|
||||||
'}' +
|
'}' +
|
||||||
'#dialog-rawdata {' +
|
'#dialog-rawdata {' +
|
||||||
'overflow-x: auto;' +
|
'overflow-x: auto;' +
|
||||||
'overflow-y: auto;' +
|
'overflow-y: auto;' +
|
||||||
'}' +
|
'}' +
|
||||||
'</style>');
|
'</style>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user