2017-01-29 23:51:08 +00:00
|
|
|
define(['chroma-js', 'map', 'sidebar', 'tabs', 'container', 'legend',
|
|
|
|
'linklist', 'nodelist', 'simplenodelist', 'infobox/main',
|
|
|
|
'proportions', 'forcegraph', 'title', 'about', 'datadistributor',
|
2017-02-01 21:13:06 +00:00
|
|
|
'filters/filtergui', 'filters/hostname'],
|
2017-01-26 22:52:34 +00:00
|
|
|
function (chroma, Map, Sidebar, Tabs, Container, Legend, Linklist,
|
2016-05-22 12:51:30 +00:00
|
|
|
Nodelist, SimpleNodelist, Infobox, Proportions, ForceGraph,
|
2017-02-01 21:13:06 +00:00
|
|
|
Title, About, DataDistributor, FilterGUI, HostnameFilter) {
|
2017-01-29 23:51:08 +00:00
|
|
|
'use strict';
|
2016-05-27 21:59:01 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
return function (config, router) {
|
|
|
|
var self = this;
|
|
|
|
var content;
|
|
|
|
var contentDiv;
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var linkScale = chroma.scale(chroma.bezier(['#04C714', '#FF5500', '#F02311'])).domain([1, 5]);
|
2016-05-22 12:51:30 +00:00
|
|
|
var sidebar;
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var buttons = document.createElement('div');
|
|
|
|
buttons.classList.add('buttons');
|
2016-05-22 12:51:30 +00:00
|
|
|
|
|
|
|
var fanout = new DataDistributor();
|
|
|
|
var fanoutUnfiltered = new DataDistributor();
|
|
|
|
fanoutUnfiltered.add(fanout);
|
|
|
|
|
|
|
|
function removeContent() {
|
|
|
|
if (!content) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
router.removeTarget(content);
|
|
|
|
fanout.remove(content);
|
|
|
|
|
|
|
|
content.destroy();
|
|
|
|
|
|
|
|
content = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function addContent(K) {
|
|
|
|
removeContent();
|
|
|
|
|
|
|
|
content = new K(config, linkScale, sidebar.getWidth, router, buttons);
|
|
|
|
content.render(contentDiv);
|
|
|
|
|
|
|
|
fanout.add(content);
|
|
|
|
router.addTarget(content);
|
|
|
|
}
|
|
|
|
|
|
|
|
function mkView(K) {
|
|
|
|
return function () {
|
|
|
|
addContent(K);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var loader = document.getElementsByClassName('loader')[0];
|
|
|
|
loader.classList.add('hide');
|
2016-06-01 20:56:26 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
contentDiv = document.createElement('div');
|
|
|
|
contentDiv.classList.add('content');
|
2016-05-22 12:51:30 +00:00
|
|
|
document.body.appendChild(contentDiv);
|
|
|
|
|
|
|
|
sidebar = new Sidebar(document.body);
|
|
|
|
|
|
|
|
contentDiv.appendChild(buttons);
|
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var buttonToggle = document.createElement('button');
|
|
|
|
buttonToggle.classList.add('ion-eye', 'shadow');
|
|
|
|
buttonToggle.onclick = function onclick() {
|
2016-05-22 12:51:30 +00:00
|
|
|
if (content.constructor === Map) {
|
2017-01-29 23:51:08 +00:00
|
|
|
router.view('g');
|
2016-05-22 12:51:30 +00:00
|
|
|
} else {
|
2017-01-29 23:51:08 +00:00
|
|
|
router.view('m');
|
2016-05-22 12:51:30 +00:00
|
|
|
}
|
|
|
|
};
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
buttons.appendChild(buttonToggle);
|
2015-07-06 23:56:11 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
var title = new Title(config);
|
2015-07-08 19:28:00 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
var header = new Container('header');
|
2016-05-22 12:51:30 +00:00
|
|
|
var infobox = new Infobox(config, sidebar, router);
|
|
|
|
var tabs = new Tabs();
|
|
|
|
var overview = new Container();
|
2017-01-26 22:52:34 +00:00
|
|
|
var legend = new Legend(config);
|
2017-01-28 14:33:13 +00:00
|
|
|
var newnodeslist = new SimpleNodelist('new', 'firstseen', router, _.t('node.new'));
|
|
|
|
var lostnodeslist = new SimpleNodelist('lost', 'lastseen', router, _.t('node.missing'));
|
2016-05-22 12:51:30 +00:00
|
|
|
var nodelist = new Nodelist(router);
|
|
|
|
var linklist = new Linklist(linkScale, router);
|
|
|
|
var statistics = new Proportions(config, fanout);
|
|
|
|
var about = new About();
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-01-26 22:52:34 +00:00
|
|
|
fanoutUnfiltered.add(legend);
|
2016-05-22 12:51:30 +00:00
|
|
|
fanoutUnfiltered.add(newnodeslist);
|
|
|
|
fanoutUnfiltered.add(lostnodeslist);
|
|
|
|
fanout.add(nodelist);
|
|
|
|
fanout.add(linklist);
|
|
|
|
fanout.add(statistics);
|
2015-07-07 22:36:57 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
sidebar.add(header);
|
|
|
|
header.add(legend);
|
2015-07-11 22:11:18 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
overview.add(newnodeslist);
|
|
|
|
overview.add(lostnodeslist);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
var filterGUI = new FilterGUI(fanout);
|
|
|
|
fanout.watchFilters(filterGUI);
|
|
|
|
header.add(filterGUI);
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-02-01 21:13:06 +00:00
|
|
|
var hostnameFilter = new HostnameFilter();
|
|
|
|
fanout.addFilter(hostnameFilter);
|
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
sidebar.add(tabs);
|
2017-01-28 14:33:13 +00:00
|
|
|
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
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
router.addTarget(title);
|
|
|
|
router.addTarget(infobox);
|
2015-07-06 22:06:38 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
router.addView('m', mkView(Map));
|
|
|
|
router.addView('g', mkView(ForceGraph));
|
2015-04-01 01:55:45 +00:00
|
|
|
|
2017-01-29 23:51:08 +00:00
|
|
|
router.view('m');
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
self.setData = fanoutUnfiltered.setData;
|
2015-04-02 02:11:49 +00:00
|
|
|
|
2016-05-22 12:51:30 +00:00
|
|
|
return self;
|
2016-05-22 11:23:43 +00:00
|
|
|
};
|
2016-05-22 12:51:30 +00:00
|
|
|
});
|