Sha256: 15124e4aa2916b21ca9a07965111b6f96f89db48ef6bf7db3bdc19bf3233adc4

Contents?: true

Size: 969 Bytes

Versions: 9

Compression:

Stored size: 969 Bytes

Contents

require 'sinatra/base'
require 'haml'
require 'gon-sinatra'

module PulseMeter
  module Visualize
    class App < Sinatra::Base
      include PulseMeter::Mixins::Utils
      register Gon::Sinatra

      def initialize(layout)
        @layout = layout
        super()
      end

      configure :production, :development do
        enable :logging
      end

      get '/' do
        @title = @layout.title
        gon.pageInfos = camelize_keys(@layout.page_infos)
				gon.options = camelize_keys(@layout.options)
        haml :main
      end

			get '/pages/:id/widgets' do
				id = params[:id].to_i 

				content_type :json
        camelize_keys(@layout.widgets(id - 1)).to_json
			end

			get '/pages/:page_id/widgets/:id' do
				page_id = params[:page_id].to_i 
				id = params[:id].to_i
        timespan = params[:timespan].to_i

				content_type :json
        camelize_keys(@layout.widget(page_id - 1, id - 1, timespan: timespan)).to_json
			end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pulse-meter-0.2.1 lib/pulse-meter/visualize/app.rb
pulse-meter-0.2.0 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.11 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.10 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.9 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.8 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.7 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.6 lib/pulse-meter/visualize/app.rb
pulse-meter-0.1.5 lib/pulse-meter/visualize/app.rb