-
Notifications
You must be signed in to change notification settings - Fork 48
Add TaskProgress components and remove obsolete UI #1127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jeremylenz
merged 12 commits into
theforeman:develop
from
jeremylenz:redesign/inventory-upload-ui-part2
Dec 8, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2f2ad36
Add TaskProgress components and modernize inventory upload UI
jeremylenz 4f435ed
Add missing ouiaId properties to PatternFly components
jeremylenz 5d1bfc2
Fix JS tests: add RelativeDateTime mock, update snapshots, remove obs…
jeremylenz faa20bb
Add input validation and remove obsolete GenerateReportJob
jeremylenz 2357ace
Address PR review feedback
jeremylenz c7f3ddb
Address final PR review feedback from qcjames53
jeremylenz 425f279
Add permission check to TasksController
jeremylenz af28aad
Add permission check to AccountsController
jeremylenz 56b2787
Add permission check to ReportsController
jeremylenz 3bee2a5
Add ouiaId to DescriptionList in TaskProgress
jeremylenz f3adf77
Simplify organizationId PropType to number only
jeremylenz 0c11b77
Remove ouiaId from Progress, keep on DescriptionList
jeremylenz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
app/controllers/foreman_inventory_upload/api/tasks_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| module ForemanInventoryUpload | ||
| module Api | ||
| class TasksController < ::Api::V2::BaseController | ||
jeremylenz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ACTION_TYPES = [ | ||
| 'ForemanInventoryUpload::Async::HostInventoryReportJob', | ||
| 'ForemanInventoryUpload::Async::UploadReportDirectJob', | ||
| ].freeze | ||
|
|
||
| # GET /foreman_inventory_upload/api/tasks/current | ||
| # Returns current running/active tasks for inventory operations | ||
| def current | ||
| organization_id = validate_organization_id if params[:organization_id].present? | ||
| return if performed? | ||
|
|
||
| tasks = ForemanTasks::Task | ||
| .active | ||
| .for_action_types(ACTION_TYPES) | ||
| .with_duration | ||
|
|
||
| if organization_id.present? | ||
| tasks = tasks.joins(:links) | ||
| .where(foreman_tasks_links: { | ||
| resource_type: 'Organization', | ||
| resource_id: organization_id, | ||
| }) | ||
| end | ||
|
|
||
| render json: { | ||
| tasks: tasks.map { |task| task_json(task) }, | ||
| } | ||
| end | ||
|
|
||
| # GET /foreman_inventory_upload/api/tasks/history | ||
| # Returns recent task history for inventory operations | ||
| def history | ||
| organization_id = validate_organization_id if params[:organization_id].present? | ||
| return if performed? | ||
|
|
||
| limit = validated_limit | ||
|
|
||
| tasks = ForemanTasks::Task | ||
| .for_action_types(ACTION_TYPES) | ||
| .with_duration | ||
| .order('started_at DESC') | ||
| .limit(limit) | ||
|
|
||
| if organization_id.present? | ||
| tasks = tasks.joins(:links) | ||
| .where(foreman_tasks_links: { | ||
| resource_type: 'Organization', | ||
| resource_id: organization_id, | ||
| }) | ||
| end | ||
|
|
||
| render json: { | ||
| tasks: tasks.map { |task| task_json(task) }, | ||
| } | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def controller_permission | ||
| 'foreman_rh_cloud' | ||
| end | ||
|
|
||
| def task_json(task) | ||
| { | ||
| id: task.id, | ||
| label: task.label, | ||
| action: task.action, | ||
| state: task.state, | ||
| result: task.result, | ||
| progress: task.progress, | ||
| started_at: task.started_at, | ||
| ended_at: task.ended_at, | ||
| duration: task.duration&.to_f, | ||
| humanized: task.humanized, | ||
| report_file_path: task_report_file_path(task), | ||
| } | ||
| end | ||
|
|
||
| def task_report_file_path(task) | ||
| return nil unless task.state == 'stopped' && task.result == 'success' | ||
| return nil unless task.action == 'ForemanInventoryUpload::Async::HostInventoryReportJob' | ||
|
|
||
| task.main_action&.output&.[]('report_file') | ||
| end | ||
|
|
||
| def validate_organization_id | ||
| org_id = params[:organization_id].to_i | ||
| if org_id.zero? | ||
| render json: { message: 'Invalid organization_id parameter' }, status: :bad_request | ||
| return nil | ||
| end | ||
|
|
||
| begin | ||
| Organization.find(org_id).id | ||
| rescue ActiveRecord::RecordNotFound | ||
| render json: { message: "Organization with id #{org_id} not found" }, status: :not_found | ||
| nil | ||
| end | ||
| end | ||
|
|
||
| def validated_limit | ||
| limit = params[:limit]&.to_i || 10 | ||
| limit.clamp(1, 100) | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeremylenz marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeremylenz marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jeremylenz marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.