Sha256: 92476de4818d9cb27825f5336aa87dacf74a921f93961eb0fcfd1b0b64754476

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

module ForemanInventoryUpload
  class UploadsController < ::ApplicationController
    def last
      label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
      output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output

      render json: {
        output: output,
      }, status: :ok
    end

    def download_file
      filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
      files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]

      return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
      throw_flash_error "File doesn't exist"
    end

    def throw_flash_error(message)
      process_error(
        :redirect => foreman_inventory_upload_index_path,
        :error_msg => message
      )
    end

    def auto_upload
      Setting[:allow_auto_inventory_upload] = auto_upload_params
      render json: {
        autoUploadEnabled: Setting[:allow_auto_inventory_upload],
      }
    end

    def auto_upload_params
      ActiveModel::Type::Boolean.new.cast(params.require(:value))
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.7 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-1.0.7 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-2.0.7 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-0.9.6 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-1.0.6 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-2.0.6 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-0.9.5 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-1.0.5 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-2.0.5 app/controllers/foreman_inventory_upload/uploads_controller.rb