UNPKG

@pantheon-systems/pcc-cli

Version:
59 lines (48 loc) 9.37 kB
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Content Publisher Webhook Logs</title> </head> <style> html { height: 100%; width: 100%; font-family: "Tablet Gothic", Frutiger, "Frutiger Linotype", Univers, HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; } </style> <style> /* * Sourced from JSON Tree Viewer * http://github.com/summerstyle/jsonTreeViewer * * Copyright 2017 Vera Lobacheva (http://iamvera.com) * Released under the MIT license (LICENSE.txt) */ .jsontree_bg{background:#fff}.jsontree_tree{font-size:14px}.jsontree_child-nodes{display:none;margin-bottom:5px;line-height:2}.jsontree_node_expanded>.jsontree_value-wrapper>.jsontree_value>.jsontree_child-nodes{display:block}.jsontree_label-wrapper{float:left;margin-right:8px}.jsontree_label{font-weight:400;vertical-align:top;color:#000;position:relative;padding:1px;border-radius:4px;cursor:default}.jsontree_node_marked>.jsontree_label-wrapper>.jsontree_label{background:#fff2aa}.jsontree_value-wrapper{display:block;overflow:hidden}.jsontree_node_complex>.jsontree_value-wrapper{overflow:inherit}.jsontree_value{vertical-align:top;display:inline}.jsontree_value_null{color:#777;font-weight:700}.jsontree_value_string{color:#025900;font-weight:700}.jsontree_value_number{color:#000e59;font-weight:700}.jsontree_value_boolean{color:#600100;font-weight:700}.jsontree_expand-button{position:absolute;top:3px;left:-15px;display:block;width:11px;height:11px;background-image:url('icons.svg')}.jsontree_node_expanded>.jsontree_label-wrapper>.jsontree_label>.jsontree_expand-button{background-position:0 -11px}.jsontree_node_complex>.jsontree_label-wrapper>.jsontree_label,.jsontree_show-more{cursor:pointer}.jsontree_node_expanded>.jsontree_value-wrapper>.jsontree_value>.jsontree_show-more{display:none}.jsontree_node_empty>.jsontree_label-wrapper>.jsontree_label>.jsontree_expand-button,.jsontree_node_empty>.jsontree_value-wrapper>.jsontree_value>.jsontree_show-more{display:none!important}.jsontree_node_empty>.jsontree_label-wrapper>.jsontree_label{cursor:default!important} </style> <body> <div id="wrapper">{{ logs }}</div> </body> <script> /** * Sourced from JSON Tree library (a part of jsonTreeViewer) * http://github.com/summerstyle/jsonTreeViewer * * Copyright 2017 Vera Lobacheva (http://iamvera.com) * Released under the MIT license (LICENSE.txt) */ var jsonTree=function(){var e,t={getClass:function(e){return Object.prototype.toString.call(e)},getType:function(e){if(null===e)return"null";switch(typeof e){case"number":return"number";case"string":return"string";case"boolean":return"boolean"}switch(t.getClass(e)){case"[object Array]":return"array";case"[object Object]":return"object"}throw Error("Bad type: "+t.getClass(e))},forEachNode:function(e,n){var s;switch(t.getType(e)){case"array":s=e.length-1,e.forEach((function(e,t){n(t,e,t===s)}));break;case"object":var o=Object.keys(e).sort();s=o.length-1,o.forEach((function(t,o){n(t,e[t],o===s)}))}},inherits:(e=function(){},function(t,n){e.prototype=n.prototype,t.prototype=new e,t.prototype.constructor=t}),isValidRoot:function(e){switch(t.getType(e)){case"object":case"array":return!0;default:return!1}},extend:function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}};function n(e,s,o){var r=t.getType(s);if(r in n.CONSTRUCTORS)return new n.CONSTRUCTORS[r](e,s,o);throw Error("Bad type: "+t.getClass(s))}function s(e,t,n){if(this.constructor===s)throw Error("This is abstract class");var o,r=this,i=document.createElement("li");r.label=e,r.isComplex=!1,i.classList.add("jsontree_node"),i.innerHTML=(o=t,' <span class="jsontree_label-wrapper"> <span class="jsontree_label">"'+e+'"</span> : </span> <span class="jsontree_value-wrapper"> <span class="jsontree_value jsontree_value_'+r.type+'">'+o+"</span>"+(n?"":",")+"</span>"),r.el=i,i.querySelector(".jsontree_label").addEventListener("click",(function(e){if(!e.altKey)return e.shiftKey?(document.getSelection().removeAllRanges(),void alert(r.getJSONPath())):void 0;r.toggleMarked()}),!1)}function o(e,t,n){this.type="boolean",s.call(this,e,t,n)}function r(e,t,n){this.type="number",s.call(this,e,t,n)}function i(e,t,n){this.type="string",s.call(this,e,'"'+t+'"',n)}function a(e,t,n){this.type="null",s.call(this,e,t,n)}function l(e,s,o){if(this.constructor===l)throw Error("This is abstract class");var r,i,a,c,d,h,p=this,u=document.createElement("li"),f=[];p.label=e,p.isComplex=!0,u.classList.add("jsontree_node"),u.classList.add("jsontree_node_complex"),u.innerHTML=(c=e,d=p.sym,h=' <div class="jsontree_value-wrapper"> <div class="jsontree_value jsontree_value_'+p.type+'"> <b>'+d[0]+'</b> <span class="jsontree_show-more">&hellip;</span> <ul class="jsontree_child-nodes"></ul> <b>'+d[1]+"</b></div>"+(o?"":",")+"</div>",null!==c&&(h=' <span class="jsontree_label-wrapper"> <span class="jsontree_label"><span class="jsontree_expand-button"></span>"'+c+'"</span> : </span>'+h),h),r=u.querySelector(".jsontree_child-nodes"),null!==e?(i=u.querySelector(".jsontree_label"),a=u.querySelector(".jsontree_show-more"),i.addEventListener("click",(function(e){if(!e.altKey)return e.shiftKey?(document.getSelection().removeAllRanges(),void alert(p.getJSONPath())):void p.toggle(e.ctrlKey||e.metaKey);p.toggleMarked()}),!1),a.addEventListener("click",(function(e){p.toggle(e.ctrlKey||e.metaKey)}),!1),p.isRoot=!1):(p.isRoot=!0,p.parent=null,u.classList.add("jsontree_node_expanded")),p.el=u,p.childNodes=f,p.childNodesUl=r,t.forEachNode(s,(function(e,t,s){p.addChild(new n(e,t,s))})),p.isEmpty=!Boolean(f.length),p.isEmpty&&u.classList.add("jsontree_node_empty")}function c(e,t,n){this.sym=["{","}"],this.type="object",l.call(this,e,t,n)}function d(e,t,n){this.sym=["[","]"],this.type="array",l.call(this,e,t,n)}function h(e,t){this.wrapper=document.createElement("ul"),this.wrapper.className="jsontree_tree clearfix",this.rootNode=null,this.sourceJSONObj=e,this.loadData(e),this.appendTo(t)}return n.CONSTRUCTORS={boolean:o,number:r,string:i,null:a,object:c,array:d},s.prototype={constructor:s,mark:function(){this.el.classList.add("jsontree_node_marked")},unmark:function(){this.el.classList.remove("jsontree_node_marked")},toggleMarked:function(){this.el.classList.toggle("jsontree_node_marked")},expandParent:function(e){this.parent&&(this.parent.expand(),this.parent.expandParent(e))},getJSONPath:function(e){var t;return this.isRoot?"$":(t="array"===this.parent.type?"["+this.label+"]":e?"."+this.label:"['"+this.label+"']",this.parent.getJSONPath(e)+t)}},t.inherits(o,s),t.inherits(r,s),t.inherits(i,s),t.inherits(a,s),t.inherits(l,s),t.extend(l.prototype,{constructor:l,addChild:function(e){this.childNodes.push(e),this.childNodesUl.appendChild(e.el),e.parent=this},expand:function(e){!this.isEmpty&&(this.isRoot||this.el.classList.add("jsontree_node_expanded"),e&&this.childNodes.forEach((function(t,n){t.isComplex&&t.expand(e)})))},collapse:function(e){!this.isEmpty&&(this.isRoot||this.el.classList.remove("jsontree_node_expanded"),e&&this.childNodes.forEach((function(t,n){t.isComplex&&t.collapse(e)})))},toggle:function(e){if(!this.isEmpty&&(this.el.classList.toggle("jsontree_node_expanded"),e)){var t=this.el.classList.contains("jsontree_node_expanded");this.childNodes.forEach((function(n,s){n.isComplex&&n[t?"expand":"collapse"](e)}))}},findChildren:function(e,t,n){!this.isEmpty&&this.childNodes.forEach((function(s,o){e(s)&&t(s),s.isComplex&&n&&s.findChildren(e,t,n)}))}}),t.inherits(c,l),t.inherits(d,l),h.prototype={constructor:h,loadData:function(e){t.isValidRoot(e)?(this.sourceJSONObj=e,this.rootNode=new n(null,e,"last"),this.wrapper.innerHTML="",this.wrapper.appendChild(this.rootNode.el)):alert("The root should be an object or an array")},appendTo:function(e){e.appendChild(this.wrapper)},expand:function(e){this.rootNode.isComplex&&("function"==typeof e?this.rootNode.childNodes.forEach((function(t,n){t.isComplex&&e(t)&&t.expand()})):this.rootNode.expand("recursive"))},collapse:function(){"function"==typeof this.rootNode.collapse&&this.rootNode.collapse("recursive")},toSourceJSON:function(e){if(!e)return JSON.stringify(this.sourceJSONObj);var t="[%^$#$%^%]",n=JSON.stringify(this.sourceJSONObj,null,t);return(n=n.split("\n").join("<br />")).split(t).join("&nbsp;&nbsp;&nbsp;&nbsp;")},findAndHandle:function(e,t){this.rootNode.findChildren(e,t,"isRecursive")},unmarkAll:function(){this.rootNode.findChildren((function(e){return!0}),(function(e){e.unmark()}),"isRecursive")}},{create:function(e,t){return new h(e,t)}}}(); var wrapper = document.getElementById("wrapper"); var logData = wrapper.innerText; var logs = JSON.parse(logData); wrapper.innerHTML = ""; var logTree = jsonTree.create(logs, wrapper); var expandCount = 3; logTree.expand(function (node) { return node.isRoot || expandCount-- > 0; }); </script> </html>