Sha256: 4fe5b87b993b9cd8eafcc267ea19649b548ab172391628c3095278c188cb9ee4
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require "grape" require "haml" require "sys/cpu" require "facter" module RestFtpDaemon module API # Offers an HTML dashboard through the Grape API (hum...) class Dashbaord < Grape::API ### HELPERS helpers do def logger Root.logger end def render name, values={} template = File.read("#{APP_LIBS}/views/#{name}.haml") haml_engine = Haml::Engine.new(template, encoding: Encoding::UTF_8) #:encoding => Encoding::ASCII_8BIT haml_engine.render(binding, values) end end ### Common request logging before do log_info "HTTP #{request.request_method} #{request.fullpath}", params end ### DASHBOARD get "/" do # Initialize Facter Facter.loadfacts # Detect QS filters @only = params["only"].to_s # Get jobs for this view, order jobs by their weights result = $queue.filter_jobs(@only).reverse # Provide queue only if no filtering set @queue = [] @queue = $queue.queue.reverse if @only.empty? # Get workers status @worker_variables = $pool.worker_variables # Build paginator @paginate = Paginate.new result @paginate.only = params["only"] @paginate.page = params["page"] @paginate.all = params.keys.include? "all" # Compile haml template output = render :dashboard # Send response env["api.format"] = :html format "html" status 200 content_type "text/html" body output end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rest-ftp-daemon-0.243.2 | lib/rest-ftp-daemon/api/dashboard.rb |
rest-ftp-daemon-0.243.1 | lib/rest-ftp-daemon/api/dashboard.rb |
rest-ftp-daemon-0.243 | lib/rest-ftp-daemon/api/dashboard.rb |