-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IP space visualization module #59
base: development
Are you sure you want to change the base?
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.
nodewatcher/settings.py
Outdated
@@ -665,6 +666,11 @@ def user_url(user): | |||
'weight': 60, | |||
'visible': True, | |||
}, | |||
{ | |||
'name': 'Ip space', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to "IP space".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -277,7 +277,7 @@ def import_pools(self, data): | |||
pool_mdl = pool_models.IpPool( | |||
family='ipv4', | |||
network=pool['network'], | |||
prefix_length=pool['cidr'], | |||
prefix_length=pool['ip_space'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes in import_nw2.py
seem incorrect - was this a too broad search and replace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't see where these partials are currently used? Are they needed at all? If not, they should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rasovica where are you using these partials?
BTW, please fix your GitHub or the commits' e-mail address as they don't seem to correspond (unknown author). |
nodewatcher/settings.py
Outdated
@@ -665,6 +666,11 @@ def user_url(user): | |||
'weight': 60, | |||
'visible': True, | |||
}, | |||
{ | |||
'name': 'IP space', | |||
'weight': 70, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be placed before the API entry instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put it before Map entry so it's next to network toplogoy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
self.loadedPrefixes++; | ||
if(self.data[i] == undefined){ | ||
self.data[i] = data.results; | ||
}else{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Into new line.
jQuery('rect').tipsy({ | ||
gravity: 'w', | ||
html: true, | ||
title: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space around operators.
while( Math.pow(2, mask) < ips_needed){ | ||
mask++; | ||
} | ||
mask = 32-mask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space around operators.
this.svg = svg; | ||
this.loadedPrefixes = 0; | ||
|
||
this.n_ips = Math.pow(2, 32 - parseInt(subnet.split("/")[1])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ip
-> IP
this.data = new Array(33); | ||
this.base_url = url; | ||
self = this; | ||
$('#topnodes').on('click', '#cidr', function(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, style for anonymous functions is function (event) {
.
return false; | ||
} | ||
|
||
UpdateQueryString(key, value, url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Camel case. Start with lower case.
|
||
subnetSize(subnet) { | ||
var subnet_str = String(subnet); | ||
var times = 32 - parseInt(subnet_str.split("/")[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'
.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split this into multiple lines. No ,
.
t = v * (1 - (1 - f) * s); | ||
switch (i % 6) { | ||
case 0: | ||
r = v, g = t, b = p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
return '#' + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b); | ||
} | ||
|
||
get_url_param(sParam) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use camelCase
not under_scores
.
|
||
get_url_param(sParam) { | ||
var sPageURL = decodeURIComponent(window.location.search.substring(1)), | ||
sURLVariables = sPageURL.split('&'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No ,
. Simply define one var per line.
} | ||
|
||
UpdateQueryString(key, value, url) { | ||
if (!url){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after )
.
else { | ||
hash = url.split('#'); | ||
url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, ''); | ||
if (typeof hash[1] !== 'undefined' && hash[1] !== null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No if
without {...}
.
hash = url.split('#'); | ||
url = hash[0] + separator + key + '=' + value; | ||
if (typeof hash[1] !== 'undefined' && hash[1] !== null) | ||
url += '#' + hash[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
url += '#' + hash[1]; | ||
return url; | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
|
||
loadPrefix(i, url) { | ||
var self = this; | ||
$.getJSON(url, function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use (data) => {...}
.
$.getJSON(url, function(data) { | ||
if(data.next != null){ | ||
self.loadPrefix(i, data.next); | ||
if (self.data[i] == undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use ===
.
loadPrefix(i, url) { | ||
var self = this; | ||
$.getJSON(url, function(data) { | ||
if(data.next != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces. Always use !==
.
… 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.