2017-03-09 23:53:23 +00:00
|
|
|
define(['d3-interpolate', 'map', 'sidebar', 'tabs', 'container', 'legend',
|
2017-01-29 23:51:08 +00:00
|
|
|
'linklist', 'nodelist', 'simplenodelist', 'infobox/main',
|
|
|
|
'proportions', 'forcegraph', 'title', 'about', 'datadistributor',
|
2017-02-01 21:13:06 +00:00
|
|
|
'filters/filtergui', 'filters/hostname'],
|
2017-07-12 21:44:42 +00:00
|
|
|
function (d3Interpolate, Map, Sidebar, Tabs, Container, Legend, Linklist,
|
|
|
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
|
|
|
Title, About, DataDistributor, FilterGUI, HostnameFilter) {
|
|
|
|
'use strict';
|
2016-05-27 21:59:01 +00:00
|
|
|
|
2017-11-03 21:07:22 +00:00
|
|
|
return function (language) {
|
2017-07-12 21:44:42 +00:00
|
|
|
var self = this;
|
|
|
|
var content;
|
|
|
|
var contentDiv;
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var linkScale = d3Interpolate.interpolate('#F02311', '#04C714');
|
|
|
|
var sidebar;
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var buttons = document.createElement('div');
|
|
|
|
buttons.classList.add('buttons');
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var fanout = new DataDistributor();
|
|
|
|
var fanoutUnfiltered = new DataDistributor();
|
|
|
|
fanoutUnfiltered.add(fanout);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
function removeContent() {
|
|
|
|
if (!content) {
|
|
|
|
return;
|
|
|
|
}
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
router.removeTarget(content);
|
|
|
|
fanout.remove(content);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
content.destroy();
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
content = null;
|
|
|
|
}
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
function addContent(K) {
|
|
|
|
removeContent();
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-11-03 21:07:22 +00:00
|
|
|
content = new K(linkScale, sidebar.getWidth, buttons);
|
2017-07-12 21:44:42 +00:00
|
|
|
content.render(contentDiv);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
fanout.add(content);
|
|
|
|
router.addTarget(content);
|
|
|
|
}
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
function mkView(K) {
|
|
|
|
return function () {
|
|
|
|
addContent(K);
|
|
|
|
};
|
|
|
|
}
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var loader = document.getElementsByClassName('loader')[0];
|
|
|
|
loader.classList.add('hide');
|
2016-06-01 20:56:26 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
contentDiv = document.createElement('div');
|
|
|
|
contentDiv.classList.add('content');
|
|
|
|
document.body.appendChild(contentDiv);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
sidebar = new Sidebar(document.body);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
contentDiv.appendChild(buttons);
|
2016-05-22 12:51:30 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var buttonToggle = document.createElement('button');
|
2017-10-26 19:40:55 +00:00
|
|
|
buttonToggle.classList.add('ion-eye');
|
2017-10-21 00:06:42 +00:00
|
|
|
buttonToggle.setAttribute('aria-label', _.t('button.switchView'));
|
2017-07-12 21:44:42 +00:00
|
|
|
buttonToggle.onclick = function onclick() {
|
|
|
|
var data;
|
|
|
|
if (content.constructor === Map) {
|
|
|
|
data = { view: 'graph', lat: undefined, lng: undefined, zoom: undefined };
|
|
|
|
} else {
|
|
|
|
data = { view: 'map' };
|
|
|
|
}
|
|
|
|
router.fullUrl(data, false, true);
|
|
|
|
};
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
buttons.appendChild(buttonToggle);
|
2015-07-06 23:56:11 +00:00
|
|
|
|
2017-11-03 21:07:22 +00:00
|
|
|
var title = new Title();
|
2015-07-08 19:28:00 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var header = new Container('header');
|
2017-11-03 21:07:22 +00:00
|
|
|
var infobox = new Infobox(sidebar, linkScale);
|
2017-07-12 21:44:42 +00:00
|
|
|
var tabs = new Tabs();
|
|
|
|
var overview = new Container();
|
2017-11-03 21:07:22 +00:00
|
|
|
var legend = new Legend(language);
|
|
|
|
var newnodeslist = new SimpleNodelist('new', 'firstseen', _.t('node.new'));
|
|
|
|
var lostnodeslist = new SimpleNodelist('lost', 'lastseen', _.t('node.missing'));
|
|
|
|
var nodelist = new Nodelist();
|
|
|
|
var linklist = new Linklist(linkScale);
|
|
|
|
var statistics = new Proportions(fanout);
|
2017-07-12 21:44:42 +00:00
|
|
|
var about = new About();
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
fanoutUnfiltered.add(legend);
|
|
|
|
fanoutUnfiltered.add(newnodeslist);
|
|
|
|
fanoutUnfiltered.add(lostnodeslist);
|
2017-10-29 14:11:24 +00:00
|
|
|
fanoutUnfiltered.add(infobox);
|
2017-07-12 21:44:42 +00:00
|
|
|
fanout.add(nodelist);
|
|
|
|
fanout.add(linklist);
|
|
|
|
fanout.add(statistics);
|
2015-07-07 22:36:57 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
sidebar.add(header);
|
|
|
|
header.add(legend);
|
2015-07-11 22:11:18 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
overview.add(newnodeslist);
|
|
|
|
overview.add(lostnodeslist);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var filterGUI = new FilterGUI(fanout);
|
|
|
|
fanout.watchFilters(filterGUI);
|
|
|
|
header.add(filterGUI);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
var hostnameFilter = new HostnameFilter();
|
|
|
|
fanout.addFilter(hostnameFilter);
|
2017-02-01 21:13:06 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
sidebar.add(tabs);
|
|
|
|
tabs.add('sidebar.actual', overview);
|
|
|
|
tabs.add('node.nodes', nodelist);
|
|
|
|
tabs.add('node.links', linklist);
|
|
|
|
tabs.add('sidebar.stats', statistics);
|
|
|
|
tabs.add('sidebar.about', about);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
router.addTarget(title);
|
|
|
|
router.addTarget(infobox);
|
2015-07-06 22:06:38 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
router.addView('map', mkView(Map));
|
|
|
|
router.addView('graph', mkView(ForceGraph));
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
self.setData = fanoutUnfiltered.setData;
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2017-07-12 21:44:42 +00:00
|
|
|
return self;
|
|
|
|
};
|
|
|
|
});
|