Sha256: 2b81335ee0c77be9608101f97f16d6597c1068ef0a511f4cb2e241ac085f6227

Contents?: true

Size: 913 Bytes

Versions: 15

Compression:

Stored size: 913 Bytes

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])
      path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
      unless File.exist? path
        return throw_flash_error(
          "Path doesn't exist: #{path}"
        )
      end

      send_file path, disposition: 'attachment', filename: filename
    end

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

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.4.1 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-1.0.4.1 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-1.0.4 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-2.0.4 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_rh_cloud-0.9.4 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-2.0.4.pre.2 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-2.0.4.pre.1 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-2.0.3 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-1.0.3 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-0.9.2 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-1.0.2 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-0.9.1 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-1.0.1 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-0.9.0 app/controllers/foreman_inventory_upload/uploads_controller.rb
foreman_inventory_upload-1.0.0 app/controllers/foreman_inventory_upload/uploads_controller.rb