Sha256: b803a949bfd73f9b28d021b666b2863cbb5093f9a1ab7bce743a04bb8879a6ad

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module ForemanInventoryUpload
  class AccountsController < ::ApplicationController
    # override default "welcome screen behavior, since we don't have a model"
    def welcome
      true
    end

    def index
      labels = Organization.all.pluck(:id, :name)

      accounts = Hash[
        labels.map do |id, label|
          generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
          upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)

          [
            id,
            {
              generate_report_status: generate_report_status,
              upload_report_status: upload_report_status,
              label: label,
            },
          ]
        end
      ]

      render json: {
        autoUploadEnabled: Setting[:allow_auto_inventory_upload],
        accounts: accounts,
      }, status: :ok
    end

    private

    def status_for(label, job_class)
      label = job_class.output_label(label)
      ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.6 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.6 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.6 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-0.9.5 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.5 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.5 app/controllers/foreman_inventory_upload/accounts_controller.rb