diff --git a/app/admin/builders.rb b/app/admin/builders.rb new file mode 100644 index 000000000..2d78674b1 --- /dev/null +++ b/app/admin/builders.rb @@ -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 diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index 9246b85de..1f6b9c15d 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -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\"" diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index b3d06d717..a29df12d1 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -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 diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index edc125cb4..28c294aaf 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -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) diff --git a/app/models/rpm_build_node.rb b/app/models/rpm_build_node.rb index 493bd348b..c19f9508f 100644 --- a/app/models/rpm_build_node.rb +++ b/app/models/rpm_build_node.rb @@ -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