forked from yantrashala/loopback-component-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.ejs
205 lines (176 loc) · 4.81 KB
/
template.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!doctype html>
<html>
<head>
<title>Domain Model Visualizer</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.js" type="text/javascript"></script>
<link type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.css" rel="stylesheet">
<style type="text/css">
body {
height: 100%;
margin: 0;
font-family: 'helvetica neue', helvetica, arial, sans-serif;
font-size: "0.5em";
}
#visualizer_parent {
position: absolute;
top: 70px;
right: 0;
bottom: 0;
left: 0;
border: 1px solid orange;
font-size: small;
}
#element_properties {
text-align: left;
width: 250px;
position: absolute;
bottom: 0;
top: 0;
background: lightblue;
overflow: scroll;
}
#mynetwork {
right: 0;
left: 250px;
position: absolute;
bottom: 0;
top: 0;
border: 1px solid orange;
}
body #header {
background-color: #08592b !important;
position: fixed;
width: 100%;
top: 0;
font-family: 'helvetica neue', helvetica, arial, sans-serif !important;
color: white;
font-size: 1.5em;
font-weight: bold;
height: 60px;
padding-top: 10px;
}
body #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
color: white;
padding: 20px 0 20px 81px !important;
}
.black_overlay {
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index: 1001;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=80);
}
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 30%;
height: 50%;
padding: 20px;
border-radius: 5px;
background-color: white;
font-family: 'helvetica neue', helvetica, arial, sans-serif !important;
z-index: 1002;
overflow: auto;
}
.close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.close:hover {
color: #06D85F;
}
</style>
</head>
<body>
<div id="header">
<div class="swagger-ui-wrap">
<a id="logo">Domain Model Visualizer</a>
</div>
</div>
<div id="visualizer_parent">
<div id="element_properties"> </div>
<div id="mynetwork"></div>
</div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet(<%- JSON.stringify(nodes) %>);
// create an array with edges
var edges = new vis.DataSet(<%- JSON.stringify(edges) %>);
// create a network
var container = document.getElementById('mynetwork');
var data = {
nodes: nodes,
edges: edges
};
var options = {
nodes: {
shape: 'dot',
borderWidth: 1,
scaling: {
label: {
min: 2000
}
},
font: {
color: '#343434',
size: 15, // px
face: 'arial',
background: 'none',
strokeWidth: 0, // px
strokeColor: '#ffffff',
align: 'left'
}
},
layout: {
randomSeed: 2,
improvedLayout: true
}
}
var network = new vis.Network(container, data, options);
network.on("select", function (params) {
var element_properties;
if (params.nodes[0]) {
var selected_node_idx = params.nodes[0];
var node = data.nodes._data[selected_node_idx];
element_properties = '<h2>' + node.label + '</h2>\n'
element_properties += '<h3>Props:</h3>\n' + node.props + '\n';
element_properties += '<h3>Remotes:</h3>\n' + node.remotes;
} else if (params.edges[0]) {
console.log(params.edges[0]);
var selected_edge_idx = params.edges[0];
var edge = data.edges._data[selected_edge_idx];
console.log(edge);
element_properties = '<h2>' + edge.label + '</h2>\n';
element_properties += '<h3>Type:</h3>\n' + edge.type + '\n';
element_properties += '<h3>Model:</h3>\n' + edge.model + '\n';
element_properties += '<h3>ForeignKey:</h3>\n' + edge.foreignKey + '\n';
if (edge.options) element_properties += '<h3>Options:</h3>\n' + JSON.stringify(edge.options) + '\n';
if (edge.through) element_properties += '<h3>Through:</h3>\n' + edge.through + '\n';
} else {
element_properties = "Please select a node or an edge";
}
document.getElementById('element_properties').innerHTML = element_properties;
});
</script>
<div class="white_content" id="light">
</div>
<div class="black_overlay" id="fade"></div>
</body>
</html>