-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (123 loc) · 5.17 KB
/
index.html
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
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="node_modules/vis/dist/vis.js"></script>
<link href="node_modules/vis/dist/vis.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#mynetwork {
width: 100%;
height: 100%;
border: 1px solid lightgray;
}
.component-info {
position: absolute;
max-width: 700px;
white-space: pre-wrap;
top: 15px;
right: 20;
text-align: left;
z-index: 99;
background-color: rgba(255,255,255,.6);
}
</style>
</head>
<body>
<img style="position: absolute; display: block; width: 8%; z-index: 2; pointer-events: none;" src="/res/legend.png"></img>
<div class="component-info">
</div>
<div id="mynetwork"></div>
<script type="text/javascript">
var maps = $.ajax({url: '/output/dependenSiMap.json?' + String(Math.random()), async: false}).responseJSON;
// create an array with nodes
var nodes = new vis.DataSet(maps);
var mapedges = $.ajax({url: '/output/dependenSiMapEdges.json?' + String(Math.random()), async: false}).responseJSON;
// create an array with edges
var edges = new vis.DataSet(mapedges);
// create a network
var container = document.getElementById('mynetwork');
// legend
// var mynetwork = document.getElementById('mynetwork');
// var x = - mynetwork.clientWidth + 50;
// var y = - mynetwork.clientHeight + 50;
// var step = 70;
// nodes.add({id: 1000, x: x, y: y, label: 'Module', shape: "square", color: { background: "#c7a3f7", border: "#896ead", highlight: { background: "#c7a3f7" , border: "#896ead"} }, value: 10, fixed: true, physics:false});
// nodes.add({id: 1001, x: x, y: y + step, label: 'Component', shape: "square", color: { background: "#82b2ff", border: "#6083bc", highlight: { background: "#82b2ff" , border: "#6083bc"} }, value: 10, fixed: true, physics:false});
// nodes.add({id: 1002, x: x, y: y + 2 * step, label: 'Injectable', shape: "square", color: { background: "#f7f5a3", border: "#a09f6b", highlight: { background: "#f7f5a3" , border: "#a09f6b"} }, value: 10, fixed: true, physics:false});
// nodes.add({id: 1003, x: x, y: y + 3 * step, label: 'Router Link', shape: "square", color: { background: "#93ffa0", border: "#5ea366", highlight: { background: "#93ffa0" , border: "#5ea366"} }, value: 10, fixed: true, physics:false});
// nodes.add({id: 1004, x: x, y: y + 4 * step, label: 'None', shape: "square", color: { background: "#c9c9c9", border: "#9e9e9e", highlight: { background: "#c9c9c9" , border: "#9e9e9e"} }, value: 10, fixed: true, physics:false});
// provide the data in the vis format
var data = {
nodes: nodes,
edges: edges
};
var options = {
nodes: {
shape: 'ellipse',
size: 30,
borderWidth: 2
},
edges: {
width: 2
}
};
// initialize your network!
var network = new vis.Network(container, data, options);
network.on('click', function(properties) {
var infoResult = "";
var ids = properties.nodes;
var clickedNodes = nodes.get(ids);
if(clickedNodes.length > 0) {
var info = clickedNodes[0].title.split('\n');
let infoMap = {};
info.forEach((item) => {
if(item) { infoMap[item.split(':')[0]] = item.split(':')[1].substring(1); }
});
Object.keys(infoMap).forEach(key => {
infoResult += "<b>" + key + ": </b>";
infoResult += "<a>" + infoMap[key] + "</a><br>";
});
$('.component-info')[0].innerHTML = infoResult;
} else {
$('.component-info')[0].innerHTML = "";
}
});
</script>
<script>
//Page Object git change mapping
let dependSi = $.ajax({url: '/output/dependenSi.json?' + String(Math.random()), async: false}).responseJSON;
let dependSiRoutes = $.ajax({url: '/output/dependenSiRoutes.json?' + String(Math.random()), async: false}).responseJSON;
//File changes
let changes = $.ajax({url: '/output/changedfiles.json?' + String(Math.random()), async: false}).responseJSON;
let hasDeepChild = function(head, filename) {
if(head.dir && (head.dir + head.filename).endsWith(filename)) return true;
if(head.importcomponents) {
if(head.importcomponents.some(item => hasDeepChild(item, filename))) return true;
}
if(head.htmlcomponents) {
return head.htmlcomponents.some(item => hasDeepChild(item, filename));
}
return false;
}
let isRoute = function(routes, comp) {
return routes.some(route => {
if(route.component && comp.name && route.component === comp.name) return true;
if(route.children) return isRoute(route.children, comp);
});
return false;
}
let affectedPOs = new Set();
dependSi.forEach((item) => {
changes.forEach(change => {
if(hasDeepChild(item, change)) {
if(isRoute(dependSiRoutes, item)) {
console.log(change);
console.log(item.name);
affectedPOs.add(item.name);
}
}
});
});
console.log(affectedPOs);
</script>
</body>
</html>