Class: ForemanInventoryUpload::AccountsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_inventory_upload/accounts_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/foreman_inventory_upload/accounts_controller.rb', line 3

def index
  organizations = User.current.my_organizations
  labels = organizations.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)

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

  render json: {
    accounts: accounts,
    CloudConnectorStatus: ForemanInventoryUpload::UploadsSettingsController.cloud_connector_status,
  }, status: :ok
end