-
Notifications
You must be signed in to change notification settings - Fork 6
/
tracemon-loader.js
executable file
·292 lines (244 loc) · 14.8 KB
/
tracemon-loader.js
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/**
* Some require.js configurations
*/
requirejs.config({
waitSeconds: 30,
paths:{
/* environment */
"tracemon.env": window.atlas._widgets.tracemon.urls.env + "environment",
"tracemon.env.utils": window.atlas._widgets.tracemon.urls.env + "utils",
"tracemon.env.config": window.atlas._widgets.tracemon.urls.env + "config",
"tracemon.env.params-manager": window.atlas._widgets.tracemon.urls.env + "ParamsManager",
"tracemon.env.history-manager": window.atlas._widgets.tracemon.urls.env + "HistoryManager",
"tracemon.env.languages.en": window.atlas._widgets.tracemon.urls.env + "languages/language.eng",
"tracemon.env.latencymon-adapter": window.atlas._widgets.tracemon.urls.env + "latencyMonAdapter",
/* libs */
"tracemon.lib.jquery": window.atlas._widgets.tracemon.urls.libs + "jquery/jquery-1.11.1.min",
"tracemon.lib.jquery-ui": window.atlas._widgets.tracemon.urls.libs + "jquery/jquery-ui.min",
"tracemon.lib.tree-map": window.atlas._widgets.tracemon.urls.libs + "TreeMap",
"tracemon.lib.date-format": window.atlas._widgets.tracemon.urls.libs + "dateFormat",
"tracemon.lib.bootstrap": window.atlas._widgets.tracemon.urls.libs + "bootstrap/js/bootstrap.min",
"tracemon.lib.bootstrap-slider": window.atlas._widgets.tracemon.urls.libs + "bootstrap-slider/js/bootstrap-slider",
"tracemon.lib.bootstrap-select": window.atlas._widgets.tracemon.urls.libs + "bootstrap-select/js/bootstrap-select",
"tracemon.lib.socket-io": window.atlas._widgets.tracemon.urls.libs + "socket.io",
"tracemon.lib.bootstrap-table": window.atlas._widgets.tracemon.urls.libs + "bootstrap-table/bootstrap-table.min",
"tracemon.lib.jquery-amd": window.atlas._widgets.tracemon.urls.libs + "jquery-libs-amd",
"tracemon.lib.jquery-libs": window.atlas._widgets.tracemon.urls.libs + "jquery-libs",
"tracemon.lib.ip": window.atlas._widgets.tracemon.urls.libs + "ip",
"tracemon.lib.parsePrefix": window.atlas._widgets.tracemon.urls.libs + "parsePrefix",
"tracemon.lib.dagre-d3": window.atlas._widgets.tracemon.urls.libs + "dagre-d3",
"tracemon.lib.dagre": window.atlas._widgets.tracemon.urls.libs + "dagre",
"tracemon.lib.mustache": window.atlas._widgets.tracemon.urls.libs + "mustache",
"tracemon.lib.handlebars": window.atlas._widgets.tracemon.urls.libs + "handlebars",
"tracemon.lib.text": window.atlas._widgets.tracemon.urls.libs + "require-text",
"tracemon.lib.stache": window.atlas._widgets.tracemon.urls.libs + "stache",
"tracemon.lib.d3-amd": window.atlas._widgets.tracemon.urls.libs + "d3/js/d3.v3.amd",
"tracemon.lib.d3-magnetic-cursor": window.atlas._widgets.tracemon.urls.libs + "d3-magnetic-cursor",
"tracemon.lib.range-slider": window.atlas._widgets.tracemon.urls.libs + "range-slider/js/ion.rangeSlider",
"tracemon.lib.reparse": window.atlas._widgets.tracemon.urls.libs + "reparse",
"tracemon.lib.expression": window.atlas._widgets.tracemon.urls.libs + "expression",
"tracemon.lib.moment": window.atlas._widgets.tracemon.urls.libs + "moment",
"tracemon.lib.viz": window.atlas._widgets.tracemon.urls.libs + "graphviz-amd",
"tracemon.lib.graphViz": window.atlas._widgets.tracemon.urls.libs + "viz",
/* view */
"tracemon.view.main": window.atlas._widgets.tracemon.urls.view + "MainView",
"tracemon.view.as-view": window.atlas._widgets.tracemon.urls.view + "ASView",
"tracemon.view.location-view": window.atlas._widgets.tracemon.urls.view + "LocationView",
"tracemon.view.label-placement": window.atlas._widgets.tracemon.urls.view + "LabelPlacementHelper",
"tracemon.view.viewport": window.atlas._widgets.tracemon.urls.view + "ViewPort",
"tracemon.view.chartManager": window.atlas._widgets.tracemon.urls.view + "ChartManager",
"tracemon.view.templateManager": window.atlas._widgets.tracemon.urls.view + "TemplateManagerView",
"tracemon.view.timeOverview": window.atlas._widgets.tracemon.urls.view + "TimeOverviewView",
"tracemon.view.dagre-wrapper": window.atlas._widgets.tracemon.urls.view + "layout/DagreWrapper",
"tracemon.view.graphviz-wrapper": window.atlas._widgets.tracemon.urls.view + "layout/GraphvizWrapper",
"tracemon.view.single-host.single-host-view": window.atlas._widgets.tracemon.urls.view + "single-host/SingleHostView",
"tracemon.view.single-host.path-view": window.atlas._widgets.tracemon.urls.view + "single-host/PathView",
"tracemon.view.single-host.node-view": window.atlas._widgets.tracemon.urls.view + "single-host/NodeView",
"tracemon.view.single-host.label-view": window.atlas._widgets.tracemon.urls.view + "single-host/LabelView",
"tracemon.view.single-host.edge-view": window.atlas._widgets.tracemon.urls.view + "single-host/EdgeView",
/* model*/
"tracemon.model.host": window.atlas._widgets.tracemon.urls.model + "Host",
"tracemon.model.autonomousSystem": window.atlas._widgets.tracemon.urls.model + "AutonomousSystem",
"tracemon.model.hop": window.atlas._widgets.tracemon.urls.model + "Hop",
"tracemon.model.measurement": window.atlas._widgets.tracemon.urls.model + "Measurement",
"tracemon.model.traceroute": window.atlas._widgets.tracemon.urls.model + "Traceroute",
"tracemon.model.attempt": window.atlas._widgets.tracemon.urls.model + "Attempt",
/* controller */
"tracemon.controller.gesture-manager": window.atlas._widgets.tracemon.urls.controller + "GesturesManager",
"tracemon.controller.url-manager": window.atlas._widgets.tracemon.urls.controller + "UrlManager",
"tracemon.controller.main": window.atlas._widgets.tracemon.urls.controller + "main",
"tracemon.controller.history-manager": window.atlas._widgets.tracemon.urls.controller + "HistoryManager",
"tracemon.controller.header": window.atlas._widgets.tracemon.urls.controller + "HeaderController",
"tracemon.controller.boolean-search": window.atlas._widgets.tracemon.urls.controller + "BooleanSearchHelper",
"tracemon.controller.source-selection": window.atlas._widgets.tracemon.urls.controller + "SourcesSelectionHelper",
/* connector */
"tracemon.connector.facade": window.atlas._widgets.tracemon.urls.connector + "ConnectorFacade",
"tracemon.connector.history": window.atlas._widgets.tracemon.urls.connector + "HistoryConnector",
"tracemon.connector.translation": window.atlas._widgets.tracemon.urls.connector + "TranslationConnector",
"tracemon.connector.live": window.atlas._widgets.tracemon.urls.connector + "LiveConnector",
"tracemon.connector.peering-db": window.atlas._widgets.tracemon.urls.connector + "PeeringDbConnector",
"tracemon.connector.host-helper": window.atlas._widgets.tracemon.urls.connector + "HostClassificationHelper",
"tracemon.connector.asn": window.atlas._widgets.tracemon.urls.connector + "AsnLookupConnector",
"tracemon.connector.short-name": window.atlas._widgets.tracemon.urls.connector + "ShortNameConnector",
"tracemon.connector.persist-host": window.atlas._widgets.tracemon.urls.connector + "PersistHostConnector",
"tracemon.connector.log.persist": window.atlas._widgets.tracemon.urls.connector + "log/LogRestConnector",
"tracemon.connector.ripe-database": window.atlas._widgets.tracemon.urls.connector + "RipeDatabaseConnector",
"tracemon.connector.cache": window.atlas._widgets.tracemon.urls.connector + "CacheConnector",
"tracemon.connector.local.peering-db": window.atlas._widgets.tracemon.urls.connector + "local/peeringDb",
/* session */
"tracemon.session.facade": window.atlas._widgets.tracemon.urls.session + "SessionManager"
},
shim:{
"tracemon.lib.d3-magnetic-cursor": {
deps: ["tracemon.lib.d3-amd"]
},
"tracemon.lib.socket-io": {
exports: "io"
},
"tracemon.lib.jquery.cookie": {
deps: ["tracemon.lib.jquery"]
},
"tracemon.lib.jquery-ui.timepicker": {
deps: ["tracemon.lib.jquery-ui"]
},
"tracemon.lib.dagre-d3": {
deps: ["tracemon.lib.d3-amd"],
exports: 'dagreD3'
},
"tracemon.lib.dagre": {
exports: 'dagre'
},
"tracemon.lib.jquery-amd": {
deps: ["tracemon.lib.moment"]
}
},
stache: {
extension: '.html', // default = '.html'
path: 'dev/view/html/' // default = ''
}
});
define([
"tracemon.env.utils",
"tracemon.env.config",
"tracemon.env.languages.en",
"tracemon.lib.jquery-amd",
"tracemon.controller.main"
], function(Utils, config, language, $, main){
var Tracemon = function(instance){
var env, instanceParams, queryParams, parentDom, styleDownloads, objectToBeEnriched, utils;
/*
* Access to the instance
*/
instanceParams = instance.instanceParams;
queryParams = instance.queryParams;
parentDom = instance.domElement;
utils = new Utils();
/*
* Init Dependency Injection Vector
*/
// Force dev mode
if (utils.getUrlParam("hackdev") == "true"){
instanceParams.dev = true;
}
env = {
"version": "19.1.22.2",
"dev": instanceParams.dev,
"widgetUrl": TRACEMON_WIDGET_URL + "dev/",
"utils": utils,
"autoStart": (instanceParams.autoStart != undefined) ? instanceParams.autoStart : config.autoStart,
"dataApiResults": instanceParams.dataApiResults || config.dataAPIs.results,
"dataApiMetadata": instanceParams.dataApiMetadata || config.dataAPIs.metadata,
"dataApiAsAnnotation": instanceParams.dataApiAsAnnotation || config.dataAPIs.dataApiAsAnnotation,
"dataApiReverseDns": instanceParams.dataApiReverseDns || config.dataAPIs.dataApiReverseDns,
"dataApiGeolocation": instanceParams.dataApiGeolocation || config.dataAPIs.dataApiGeolocation,
"shortAsNamesApi": instanceParams.shortAsNamesApi || config.dataAPIs.shortAsNamesApi,
"persistHostApi": instanceParams.persistHostApi || config.dataAPIs.persistHostApi,
"dataApiAsnNeighbours": instanceParams.dataApiAsnNeighbours || config.dataAPIs.dataApiAsnNeighbours,
"streamingUrl": instanceParams.streamingHost || config.streamingUrl,
"trackingKey": instanceParams.trackingKey || config.defaultTrackingKey,
"viewName": instanceParams.view || config.defaultViewName,
"aggregateIPv4": instanceParams.aggregateIPv4 || config.defaultAggregationIPv4,
"aggregateIPv6": instanceParams.aggregateIPv6 || config.defaultAggregationIPv6,
"maxNumberHops": instanceParams.maxNumberHops || config.maxNumberHops,
"maximumTracerouteValiditySeconds": instanceParams.maximumTracerouteValiditySeconds || config.maximumTracerouteValiditySeconds,
"onlyGraph": instanceParams.onlyGraph,
"templatesLocation": instanceParams.templatesLocation || config.templatesLocation,
"reproductionSpeed": instanceParams.reproductionSpeed || config.reproductionSpeed,
"labelLevel": instanceParams.labelLevel || config.defaultLabelLevel,
"peeringDb": instanceParams.peeringDb || config.dataAPIs.peeringDb,
"realTimeUpdate": (instanceParams.realTimeUpdate != null) ? instanceParams.realTimeUpdate : config.realTimeUpdate,
"onlyCore": instanceParams.onlyCore,
"preloadGeolocations": (instanceParams.preloadGeolocations != null) ? instanceParams.preloadGeolocations : config.preloadGeolocations,
"bypassApiCache": instanceParams.bypassApiCache,
"sendErrors": (instanceParams.sendErrors != null) ? instanceParams.sendErrors : config.sendErrors,
"parentDom": $(parentDom),
"queryParams": queryParams,
// Defaults for internal env parameters
"loadedMeasurements": {},
"loadedSources": {},
"finalQueryParams": {
startDate: null,
stopDate: null,
sources: null,
measurements: []
},
"metaData": {
startDate: null,
stopDate: null
}
};
/*
* Check if parent dom exists
*/
if (!env.parentDom || env.parentDom.length == 0){
throw "It was not possible to find the DOM element to populate";
}
/*
* Check if stylesheets are loaded
*/
if (!instanceParams.dev){
styleDownloads = [
window.atlas._widgets.tracemon.urls.view + "css/style-lib-dist.min.css"
];
} else {
styleDownloads = [
window.atlas._widgets.tracemon.urls.view + "css/style.css",
window.atlas._widgets.tracemon.urls.libs + "jquery/jquery-ui.min.css",
window.atlas._widgets.tracemon.urls.libs + "bootstrap/css/bootstrap.min.css",
window.atlas._widgets.tracemon.urls.libs + "bootstrap/css/bootstrap-theme.min.css",
window.atlas._widgets.tracemon.urls.libs + "bootstrap-table/bootstrap-table.min.css",
window.atlas._widgets.tracemon.urls.libs + "bootstrap-slider/css/bootstrap-slider.css",
window.atlas._widgets.tracemon.urls.libs + "bootstrap-select2/css/bootstrap-select.css",
window.atlas._widgets.tracemon.urls.libs + "range-slider/css/ion.rangeSlider.css",
// window.atlas._widgets.tracemon.urls.libs + "range-slider/css/ion.rangeSlider.skinFlat.css"
window.atlas._widgets.tracemon.urls.libs + "range-slider/css/ion.rangeSlider.skinModern.css"
];
}
objectToBeEnriched = {};
utils.loadStylesheets(styleDownloads, function(){
var n, length, methodName, callbackReady;
env.main = new main(env);
if (env.autoStart){
env.main.init();
}
function enrichMethod(methodName) {
objectToBeEnriched[methodName] = function () {
return env.main[methodName].apply(env.main, arguments);
}
}
for (n=0,length=env.main.exposedMethods.length; n<length; n++){
methodName = env.main.exposedMethods[n];
enrichMethod(methodName);
}
callbackReady = window.atlas._widgets.tracemon.instances.callback[parentDom];
if (callbackReady){
callbackReady(objectToBeEnriched);
}
});
/**
* A set of methods exposed outside
*/
return objectToBeEnriched;
};
return Tracemon;
});