|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <style type="text/css"> |
| 5 | + #mynetwork { |
| 6 | + width: 100%; |
| 7 | + height: 100vh; |
| 8 | + border: 1px solid lightgray; |
| 9 | + } |
| 10 | + .body { |
| 11 | + font-family: Arial, Helvetica, sans-serif; |
| 12 | + } |
| 13 | + #filtersContainer { |
| 14 | + left: 0px; |
| 15 | + top: 0px; |
| 16 | + height: 100vh; |
| 17 | + width: 400px; |
| 18 | + background-color: rgba(80, 197, 251, 0.7); |
| 19 | + border: blue 4px; |
| 20 | + padding: 3px 3px 3px 3px; |
| 21 | + z-index: 2999; |
| 22 | + position: absolute; |
| 23 | + font-family: "Courier New", Courier, monospace; |
| 24 | + overflow: scroll; |
| 25 | + } |
| 26 | + </style> |
| 27 | + <script |
| 28 | + type="text/javascript" |
| 29 | + src="https://visjs.github.io/vis-network/standalone/umd/vis-network.min.js" |
| 30 | + ></script> |
| 31 | + |
| 32 | + <script type="text/javascript"> |
| 33 | + %DATA_JS% |
| 34 | + </script> |
| 35 | + |
| 36 | + <script type="text/javascript"> |
| 37 | + let network; |
| 38 | + const rule = { |
| 39 | + EventPattern: '{"source":["aws.events"]}', |
| 40 | + EventBusName: "default", |
| 41 | + Target: "MyFunction", |
| 42 | + Name: "AllAWSEvents -> MyFunction", |
| 43 | + InputPath: undefined, |
| 44 | + Input: undefined, |
| 45 | + InputTransformer: { |
| 46 | + InputPathsMap: { |
| 47 | + source: "$.source", |
| 48 | + detailType: "$.detail-type", |
| 49 | + time: "$.time", |
| 50 | + }, |
| 51 | + InputTemplate: |
| 52 | + '{"source": <source>, "detail-type": <detailType>, "time": <time> }', |
| 53 | + }, |
| 54 | + }; |
| 55 | + function preTitle(text) { |
| 56 | + const container = document.createElement("pre"); |
| 57 | + container.innerText = text; // You may also use innerHTML if your source is trusted. |
| 58 | + return container; |
| 59 | + } |
| 60 | + |
| 61 | + function draw() { |
| 62 | + // create a network |
| 63 | + var container = document.getElementById("mynetwork"); |
| 64 | + nodes.forEach((node => { |
| 65 | + node.title = preTitle(node.title); |
| 66 | + })); |
| 67 | + var data = { |
| 68 | + nodes: nodes, |
| 69 | + edges: edges, |
| 70 | + }; |
| 71 | + |
| 72 | + var options = { |
| 73 | + nodes: { |
| 74 | + shape: "dot", |
| 75 | + size: 16, |
| 76 | + }, |
| 77 | + edges: { |
| 78 | + arrows: { |
| 79 | + to: { |
| 80 | + enabled: true, |
| 81 | + imageHeight: undefined, |
| 82 | + imageWidth: undefined, |
| 83 | + scaleFactor: 1, |
| 84 | + src: undefined, |
| 85 | + type: "arrow", |
| 86 | + }, |
| 87 | + }, |
| 88 | + }, |
| 89 | + physics: { |
| 90 | + forceAtlas2Based: { |
| 91 | + gravitationalConstant: -26, |
| 92 | + centralGravity: 0.005, |
| 93 | + springLength: 230, |
| 94 | + springConstant: 0.18, |
| 95 | + }, |
| 96 | + maxVelocity: 146, |
| 97 | + solver: "forceAtlas2Based", |
| 98 | + timestep: 0.35, |
| 99 | + stabilization: { iterations: 150 }, |
| 100 | + }, |
| 101 | + }; |
| 102 | + network = new vis.Network(container, data, options); |
| 103 | + network.body.emitter.emit("_dataChanged"); |
| 104 | + } |
| 105 | + function populateFilters(conatainerName, data, checked, func) { |
| 106 | + var container = document.getElementById(conatainerName); |
| 107 | + if (!data.length) { |
| 108 | + container.style.visibility = "hidden"; |
| 109 | + } |
| 110 | + for (const name of data) { |
| 111 | + var checkbox = document.createElement("input"); |
| 112 | + checkbox.type = "checkbox"; |
| 113 | + checkbox.id = name; |
| 114 | + checkbox.checked = checked; |
| 115 | + checkbox.name = conatainerName; |
| 116 | + checkbox.value = name; |
| 117 | + checkbox.addEventListener("click", func); |
| 118 | + var label = document.createElement("label"); |
| 119 | + label.htmlFor = name; |
| 120 | + label.appendChild(document.createTextNode(name)); |
| 121 | + |
| 122 | + var br = document.createElement("br"); |
| 123 | + |
| 124 | + container.appendChild(checkbox); |
| 125 | + container.appendChild(label); |
| 126 | + container.appendChild(br); |
| 127 | + } |
| 128 | + } |
| 129 | + </script> |
| 130 | + </head> |
| 131 | + |
| 132 | + <body> |
| 133 | + <div id="mynetwork"></div> |
| 134 | + <div id="filtersContainer"> |
| 135 | + <div id="resource-types"> |
| 136 | + <strong>Include resource types:</strong><br /> |
| 137 | + </div> |
| 138 | + <div id="nested-stacks"> |
| 139 | + <hr /> |
| 140 | + <strong>Include nested stack(s):</strong><br /> |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + <script> |
| 144 | + window.onload = function (event) { |
| 145 | + if (!showSidebar) { |
| 146 | + document.getElementById("filtersContainer").hidden = true; |
| 147 | + } |
| 148 | + populateFilters("nested-stacks", nested, renderAll, (x) => { |
| 149 | + const ns = nodes.get({ filter: (p) => p.prefix === x.target.value }); |
| 150 | + for (const n of ns) { |
| 151 | + nodes.update({ id: n.id, hidden: !x.target.checked }); |
| 152 | + } |
| 153 | + network.redraw(); |
| 154 | + }); |
| 155 | + populateFilters("resource-types", types, true, (x) => { |
| 156 | + const ns = nodes.get({ filter: (p) => p.type === x.target.value }); |
| 157 | + for (const n of ns) { |
| 158 | + nodes.update({ id: n.id, hidden: !x.target.checked }); |
| 159 | + } |
| 160 | + network.redraw(); |
| 161 | + }); |
| 162 | + draw(); |
| 163 | + }; |
| 164 | + </script> |
| 165 | + </body> |
| 166 | +</html> |
0 commit comments