/node_routes.rb (083df9b345eb65f5367541d747e26b32447a98f3) (2155 bytes) (mode 100644) (type blob)
#node_routes.rb
# NODE SEARCH
post('/:graph/node') do
@graph = params[:graph]
node_id = params[:node_id]
if Storage.all_nodes(@graph).include?(node_id)
redirect '/'+@graph+'/node/'+node_id+'/'
else
redirect '/'+@graph+'?style=SFDP'
end
end
# NODE DETAILS
get '/:graph/node/:id/' do
id = params[:id]
@graph = params[:graph]
return status 404 unless Storage.all_nodes(@graph).include?(id)
@title = 'Node Details'
@node = Storage.get_node(@graph,id)
erb :node_details
end
#####################################
# insert a visualisation of the graph
get '/:graph' do
@graph = params[:graph]
@style = params['style']
@title = 'Visualisation of Graph '+@graph.to_s
erb :visualisation
end
get '/*pics/:file' do
file_name = params[:file]
send_file('/CORIA/coria-frontend/pics/'+file_name)
#, :disposition => 'inline')
erb
end
get '/*pics/show/:file' do
@pic = params[:file]
erb :show_picture
end
#####################################
#NODE NEIGHBORHOOD AJAX ENDPOINT FOR DISPLAY VIA d3.js
#color notes by unified risk score value
get '/:graph/node/:id/neighbors.json' do
content_type :json
@graph = params[:graph].to_s
id = params[:id].to_s
node = Storage.get_node(@graph,id)
#build response for d3.js utilization
response = {}
response[:nodes] = []
response[:links] = []
color_code = node.scores.fetch(CONFIG.node_coloring_field,{}).fetch(:color_code, nil) || node.metrics.fetch(CONFIG.node_coloring_field,{}).fetch(:color_code, nil)
response[:nodes] << {:name => node.id, :color_code => color_code}
neighbors = node.neighbors[0..CONFIG.max_graph_neighbors]
neighbors.each_with_index do |node_id, i|
neighbor = Storage.get_node(@graph,node_id)
color_code = neighbor.scores.fetch(CONFIG.node_coloring_field,{}).fetch(:color_code, nil) || neighbor.metrics.fetch(CONFIG.node_coloring_field,{}).fetch(:color_code, nil)
response[:nodes] << {:name => neighbor.id, :color_code => color_code}
response[:links] << {:source => 0, :target => i+1}
end
return response.to_json
end
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
32 |
02d771bb174550ee73ca245d5452a371c7ff568e |
Gemfile |
100644 |
blob |
71 |
5a0b34f4c7ea7ff499826db4642432a1e5940c5d |
Gemfile.lock |
100644 |
blob |
79 |
04e9bf5219f1065f2d2f20519a988f41a274d7d9 |
README.md |
100644 |
blob |
494 |
9eca68213c93af98fde713132b619df2393bbd39 |
color_helper.rb |
100644 |
blob |
5758 |
22d80d32c1036d9629bf3121812518e650c573ab |
config.rb |
100644 |
blob |
231 |
3a145ad82816a6a5ff94d25c6f0f555dc8a89910 |
index.rb |
100644 |
blob |
616 |
27c598cf96f2f8a8cd59b771096e781a486d3d52 |
metric_routes.rb |
100644 |
blob |
2155 |
083df9b345eb65f5367541d747e26b32447a98f3 |
node_routes.rb |
100644 |
blob |
2230980 |
5dadf2edab67df737f2d86e2c4790b110230a064 |
nohup.out |
100644 |
blob |
649 |
e7daa8d38b126863ae1e75d2bc738e3b13c47fe6 |
percolation_routes.rb |
040000 |
tree |
- |
118a9bd7235757f947a5fccc49084c45e51e92db |
public |
100755 |
blob |
317 |
e674f04472635862c107448bd013e91fa68a4acf |
run.rb |
100644 |
blob |
546 |
bed129cf69ccede24d821dd48c9dba0a5fef44be |
score_routes.rb |
100755 |
blob |
53 |
1f1911e7f2691de68e0331d32d57fbf1101bebe5 |
start_run.rb.sh |
100644 |
blob |
493 |
07311526c68d9a623caa01ddecff1cccb8b0ae7e |
statistics_routes.rb |
100644 |
blob |
7466 |
0e13f2a7785f5afd3d7bb8ac9acdf775987d4e97 |
storage.rb |
100644 |
blob |
104 |
dd18016d10c430cc64dfe5a3ff97ae7f859ea991 |
test.rb |
100644 |
blob |
5111 |
7986577b4c94bca4a9b464d04ed0dbda6d124d48 |
test_config.rb |
040000 |
tree |
- |
14484f653711cb6dd995ebf5ed61274b85efc2a6 |
views |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/coria/coria-frontend
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/coria/coria-frontend
Clone this repository using git:
git clone git://git.rocketgit.com/user/coria/coria-frontend
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main