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
@ -26,60 +26,55 @@ window.plugin.rawdata.setupCallback = function() {
|
||||
}
|
||||
|
||||
window.plugin.rawdata.addLink = function(d) {
|
||||
var guidString = JSON.stringify(window.selectedPortal, null, 2);
|
||||
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>');
|
||||
$('.linkdetails').append('<aside><a onclick="window.plugin.rawdata.showPortalData(\''+window.selectedPortal+'\')" 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) {
|
||||
if (!window.portals[guid]) {
|
||||
console.warn ('Error: failed to find portal details for guid '+guid+' - failed to show debug data');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var d = window.portals[guid].options.details;
|
||||
var ts = window.portals[guid].options.timestamp;
|
||||
|
||||
var title = 'Raw portal data: ' + (d.portalV2.descriptiveText.TITLE || '<no title>') + ' ('+guid+')';
|
||||
|
||||
var body =
|
||||
'<b>Portal GUID</b>: <code>'+guid+'</code><br />' +
|
||||
'<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: 'Raw Data: '+
|
||||
title +
|
||||
' (' +
|
||||
decodeURIComponent(guid) +
|
||||
')',
|
||||
html: '<pre>' +
|
||||
decodeURIComponent(guid) + '\n' +
|
||||
decodeURIComponent(details) + '\n\n' +
|
||||
decodeURIComponent(links) + '\n\n' +
|
||||
decodeURIComponent(fields) + '\n\n' +
|
||||
'</pre>',
|
||||
title: title,
|
||||
html: body,
|
||||
id: 'dialog-rawdata',
|
||||
dialogClass: 'ui-dialog-rawdata',
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user