views.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # frozen_string_literal: true
  2. lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'lib')
  3. $LOAD_PATH.unshift(lib_dir) unless
  4. $LOAD_PATH.include?(lib_dir) || $LOAD_PATH.include?(lib_dir)
  5. require 'json'
  6. require 'neoinfra'
  7. require 'sinatra'
  8. require 'sinatra/base'
  9. require 'sinatra/contrib'
  10. # Handle loading data into the graph db
  11. class Views < Sinatra::Base
  12. register Sinatra::RespondWith
  13. set :views, File.join(File.dirname(__FILE__), '..', '/views')
  14. get '/vpcs' do
  15. w = NeoInfra::Vpcs.new
  16. respond_to do |wants|
  17. wants.html do
  18. erb :view_vpcs,
  19. layout: :base_layout,
  20. locals: { vpcs: w.list_vpcs }
  21. end
  22. end
  23. end
  24. get '/buckets' do
  25. j = NeoInfra::Aws.new
  26. respond_to do |wants|
  27. wants.html do
  28. erb :view_buckets,
  29. layout: :base_layout,
  30. locals: { buckets: j.list_buckets }
  31. end
  32. end
  33. end
  34. get '/dynamos' do
  35. j = NeoInfra::Aws.new
  36. respond_to do |wants|
  37. wants.html do
  38. erb :view_dynamos,
  39. layout: :base_layout,
  40. locals: { dynamos: j.list_dynamos }
  41. end
  42. end
  43. end
  44. get '/lambdas' do
  45. j = NeoInfra::Aws.new
  46. respond_to do |wants|
  47. wants.html do
  48. erb :view_lambdas,
  49. layout: :base_layout,
  50. locals: { lambdas: j.list_lambdas }
  51. end
  52. end
  53. end
  54. get '/rds' do
  55. j = NeoInfra::Aws.new
  56. respond_to do |wants|
  57. wants.html do
  58. erb :view_rds,
  59. layout: :base_layout,
  60. locals: { rds: j.list_rds }
  61. end
  62. end
  63. end
  64. get '/queues' do
  65. j = NeoInfra::Aws.new
  66. respond_to do |wants|
  67. wants.html do
  68. erb :view_queues,
  69. layout: :base_layout,
  70. locals: { queues: j.list_queues }
  71. end
  72. end
  73. end
  74. get '/graph/:graph_type' do
  75. respond_to do |wants|
  76. wants.html do
  77. erb :graphview,
  78. layout: :base_layout,
  79. locals: { graph_type: params['graph_type'] }
  80. end
  81. end
  82. end
  83. end