IP space visualization module - #59
Conversation
…b.com/jaz303) and a few extra classes that make graph non selecteble.
…atcher into feature/cidr
|
In which way is this different from #58? |
…static folder, Mike Bostock is author of d3.v4, hilbert2d.js and point.js are refractored from node.js version to browser version by me, original author(https://github.com/ryan-williams), jquery.tips.js is made by https://github.com/jaz303 this modules provide all i need to draw svg maps with tooltips using hilbert fractals.
| 'visible': True, | ||
| }, | ||
| { | ||
| 'name': 'Ip space', |
| family='ipv4', | ||
| network=pool['network'], | ||
| prefix_length=pool['cidr'], | ||
| prefix_length=pool['ip_space'], |
There was a problem hiding this comment.
These changes in import_nw2.py seem incorrect - was this a too broad search and replace?
There was a problem hiding this comment.
That should not be touched from what I understand.
That is only used to import old Nodewatcher 2 JSON dump for migration
There was a problem hiding this comment.
It doesn't look fixed, there are still some incorrect ip_space references in import_nw2.py? See diff.
|
Please add some description so most people can at least get a sense of what you are doing here |
|
Please put code attribution into code comments, not commit messages. |
|
Don't use minimized JavaScript files. If we need those, we will just have minimization post-processing step for all files. |
…des to svg, loading nodes asyncronusly and drawaing them to svg.
|
|
||
| components.partials.get_partial('ip_space_partial').add(components.PartialEntry( | ||
| name='general', | ||
| template='ip_space.html', |
There was a problem hiding this comment.
Is this ok that the template is at the top level? I think it should be better to move it under network/ip_space/ip_space.html or similar.
There was a problem hiding this comment.
I also don't see where these partials are currently used? Are they needed at all? If not, they should be removed.
|
BTW, please fix your GitHub or the commits' e-mail address as they don't seem to correspond (unknown author). |
| }, | ||
| { | ||
| 'name': 'IP space', | ||
| 'weight': 70, |
There was a problem hiding this comment.
Should this be placed before the API entry instead?
There was a problem hiding this comment.
I would put it before Map entry so it's next to network toplogoy
| self.loadedPrefixes++; | ||
| if(self.data[i] == undefined){ | ||
| self.data[i] = data.results; | ||
| }else{ |
| jQuery('rect').tipsy({ | ||
| gravity: 'w', | ||
| html: true, | ||
| title: function() { |
There was a problem hiding this comment.
For anonymous function, use function () { style.
|
|
||
| load() { | ||
| for (var i = 0; i < 33; i++) { | ||
| this.loadPrefix(i, 'api/v2/pool/ip/?format=json&prefix_length=' + i); |
There was a problem hiding this comment.
Get URL API from server-side and render-it into a template. See examples elsewhere how to do that.
There was a problem hiding this comment.
You do not have to add format=json because getJSON adds needed headers already.
| range[0] = (this.ip2num(cidr[0])) & ((-1 << (32 - cidr_1))); | ||
| var start = this.ip2num(range[0]) | ||
| range[1] = range[0] + Math.pow(2, (32 - cidr_1)) - 1; | ||
| return [range[0]-this.offset, range[1]-this.offset]; |
| while( Math.pow(2, mask) < ips_needed){ | ||
| mask++; | ||
| } | ||
| mask = 32-mask; |
| this.svg = svg; | ||
| this.loadedPrefixes = 0; | ||
|
|
||
| this.n_ips = Math.pow(2, 32 - parseInt(subnet.split("/")[1])); |
There was a problem hiding this comment.
' instead ". Please when I make a comment, make sure yourself to check everywhere else for the same issue.
| this.ips_side = Math.sqrt(this.n_ips); | ||
| this.ips_pixel = this.ips_side / (this.size * 1.0); | ||
| this.offset = 0; | ||
| this.draw(subnet, "Smallest possible network to fit all the ip pools"); |
| this.data = new Array(33); | ||
| this.base_url = url; | ||
| self = this; | ||
| $('#topnodes').on('click', '#cidr', function(event) { |
There was a problem hiding this comment.
You are already using class, so you can then also use (event) => { ... } which will bind this automatically so you do not have to use self.
There was a problem hiding this comment.
BTW, style for anonymous functions is function (event) {.
| return false; | ||
| } | ||
|
|
||
| UpdateQueryString(key, value, url) { |
There was a problem hiding this comment.
Camel case. Start with lower case.
|
|
||
| subnetSize(subnet) { | ||
| var subnet_str = String(subnet); | ||
| var times = 32 - parseInt(subnet_str.split("/")[1]); |
| HSVtoRGB(h, s, v) { | ||
| var r, g, b, i, f, p, q, t; | ||
| if (arguments.length === 1) { | ||
| s = h.s, v = h.v, h = h.h; |
There was a problem hiding this comment.
Split this into multiple lines. No ,.
| t = v * (1 - (1 - f) * s); | ||
| switch (i % 6) { | ||
| case 0: | ||
| r = v, g = t, b = p; |
| return '#' + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b); | ||
| } | ||
|
|
||
| get_url_param(sParam) { |
|
|
||
| get_url_param(sParam) { | ||
| var sPageURL = decodeURIComponent(window.location.search.substring(1)), | ||
| sURLVariables = sPageURL.split('&'), |
There was a problem hiding this comment.
No ,. Simply define one var per line.
| } | ||
|
|
||
| UpdateQueryString(key, value, url) { | ||
| if (!url){ |
| else { | ||
| hash = url.split('#'); | ||
| url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, ''); | ||
| if (typeof hash[1] !== 'undefined' && hash[1] !== null) |
| hash = url.split('#'); | ||
| url = hash[0] + separator + key + '=' + value; | ||
| if (typeof hash[1] !== 'undefined' && hash[1] !== null) | ||
| url += '#' + hash[1]; |
| url += '#' + hash[1]; | ||
| return url; | ||
| } | ||
| else |
|
|
||
| loadPrefix(i, url) { | ||
| var self = this; | ||
| $.getJSON(url, function(data) { |
| $.getJSON(url, function(data) { | ||
| if(data.next != null){ | ||
| self.loadPrefix(i, data.next); | ||
| if (self.data[i] == undefined) { |
| loadPrefix(i, url) { | ||
| var self = this; | ||
| $.getJSON(url, function(data) { | ||
| if(data.next != null){ |
… from Support module.
…h pool, removed git modules that we don't need.
This module will add IP space map to nodewatcher, which will visualize and report statistics about network IP space usage.