lib/sensu-dashboard/app.rb in sensu-dashboard-0.7.0 vs lib/sensu-dashboard/app.rb in sensu-dashboard-0.8.0

- old
+ new

@@ -39,10 +39,16 @@ content_type 'text/html' @js = erb :client_templates, :layout => false body erb :clients end + aget '/stashes' do + content_type 'text/html' + @js = erb :stash_templates, :layout => false + body erb :stashes + end + aget '/css/sonian.css' do content_type 'text/css' body sass :sonian end @@ -273,9 +279,65 @@ end http.callback do status http.response_header.status body http.response + end + end + + aget '/stashes.json' do + begin + request_options = { +# :body => request.body.read, + :head => { + 'content-type' => 'application/json' + } + } + http = EventMachine::HttpRequest.new("#{api_server}/stashes").get request_options + rescue => e + puts e + status 404 + body '{"error":"could not retrieve a list of stashes from the sensu api"}' + end + + http.errback do + status 404 + body '{"error":"could not retrieve a list of stashes from the sensu api"}' + end + + http.callback do + resp = http.response + puts resp + status http.response_header.status + body resp + end + end + + apost '/stashes.json' do + begin + request_options = { + :body => request.body.read, + :head => { + 'content-type' => 'application/json' + } + } + http = EventMachine::HttpRequest.new("#{api_server}/stashes").post request_options + rescue => e + puts e + status 404 + body '{\"error\":\"could not retrieve a list of stashes from the sensu api\"}' + end + + http.errback do + status 404 + body '{\"error\":\"could not retrieve a list of stashes from the sensu api\"}' + end + + http.callback do + resp = http.response + puts resp + status http.response_header.status + body resp end end websocket_connections = Array.new EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 9000) do |websocket|