Fixed file store access, added builders page in admin section

This commit is contained in:
Wedge 2016-03-25 12:45:14 +03:00
parent 710d6096ba
commit 1f18eca69c
5 changed files with 40 additions and 5 deletions

19
app/admin/builders.rb Normal file
View File

@ -0,0 +1,19 @@
ActiveAdmin.register_page 'Builders' do
content do
table do
thead do
["id", "system?", "Hostname", "Busy workers", "Supported Arches", "Supported Platforms"].each &method(:th)
end
tbody do
RpmBuildNode.all.to_a.each do |node|
next unless node.user_id
tr do
%w(id system host busy_workers supported_arches supported_platforms).each do |col|
td { node.send(col) }
end
end
end
end
end
end
end

View File

@ -23,6 +23,14 @@ class Api::V1::BaseController < ApplicationController
end
end
def check_auth_pw_or_token
authenticate_or_request_with_http_basic do |username,pw|
if user = User.auth_by_token_or_login_pass(username, pw)
sign_in user, false
end
end
end
def set_csv_file_headers(file_name)
headers['Content-Type'] = 'text/csv'
headers['Content-disposition'] = "attachment; filename=\"#{file_name}.csv\""

View File

@ -42,11 +42,14 @@ class Api::V1::JobsController < Api::V1::BaseController
def statistics
if params[:uid].present?
RpmBuildNode.create(
id: params[:uid],
user_id: current_user.id,
system: current_user.system?,
worker_count: params[:worker_count],
busy_workers: params[:busy_workers]
id: params[:uid],
user_id: current_user.id,
system: current_user.system?,
worker_count: params[:worker_count],
busy_workers: params[:busy_workers],
host: params[:host],
supported_arches: params[:supported_arches],
supported_platforms: params[:supported_platforms]
) rescue nil
end
render nothing: true

View File

@ -1,6 +1,8 @@
class Api::V1::UsersController < Api::V1::BaseController
before_action :authenticate_user!
before_action :check_auth_pw_or_token, only: :show_current_user
skip_before_action :check_auth, only: :show_current_user
skip_before_action :check_auth, only: [:show] if APP_CONFIG['anonymous_access']
skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
before_action :load_user, only: %i(show)

View File

@ -12,6 +12,9 @@ class RpmBuildNode < Ohm::Model
attribute :worker_count
attribute :busy_workers
attribute :system
attribute :host
attribute :supported_arches
attribute :supported_platforms
def user
User.where(id: user_id).first