-
Notifications
You must be signed in to change notification settings - Fork 65
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
use actioncable to track indexing progress #3182
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div data-behavior='progress-panel' data-exhibit-id="<%= exhibit.id %>" data-monitor-url="<%= helpers.actioncable? ? false : helpers.monitor_exhibit_bulk_updates_path(exhibit) %>"> | ||
<div class="card index-status border-info mb-3"> | ||
<h3 class="card-header bg-info text-white h4"><%= t("heading", scope: translation_field) %></h3> | ||
<div class="card-body"> | ||
<p data-behavior='monitor-start'> | ||
<span class="text-muted" data-behavior='date'></span> <%= t("begin_html", scope: translation_field) %> | ||
</p> | ||
|
||
<% if I18n.exists?("current_html", scope: translation_field) %> | ||
<p data-behavior='monitor-current'> | ||
<span class="text-muted" data-behavior='date'></span> <%= t("current_html", scope: translation_field) %> | ||
</p> | ||
<% end %> | ||
|
||
<% if I18n.exists?("completed_html", scope: translation_field) %> | ||
<p data-behavior='monitor-completed'> | ||
<span class="text-muted" data-behavior='date'></span> <%= t("completed_html", scope: translation_field) %> | ||
</p> | ||
<% end %> | ||
|
||
<p class="bg-warning" data-behavior='monitor-error' style='display:none;'> | ||
<%= t("error", scope: translation_field) %> | ||
</p> | ||
|
||
<div class="progress"> | ||
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="" aria-valuemin="0" aria-valuemax=""></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
# Renders progress bar html which is updated by progress_monitor.js | ||
class ProgressBarComponent < ViewComponent::Base | ||
attr_reader :exhibit, :translation_field | ||
|
||
def initialize(exhibit:, translation_field:) | ||
@exhibit = exhibit | ||
@translation_field = translation_field | ||
super | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
## | ||
# General helper for checking and using ActionCable | ||
module ActioncableHelper | ||
def actioncable? | ||
defined?(ActionCable.server) && ActionCable.server.config.cable.present? | ||
end | ||
|
||
def ws_broadcast(channel, data) | ||
return unless actioncable? | ||
|
||
ActionCable.server.broadcast channel, data | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Action Cable provides the framework to deal with WebSockets in Rails. | ||
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command. | ||
|
||
import { createConsumer } from "@rails/actioncable" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this file belongs in the engine. It should be in the host application. By doing that you can remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are suggesting this goes in the install generator? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it already in the actioncabel generator? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Okay so you are suggesting I put the
I am guessing for existing apps we are going to need to include instructions on how to install. I am not quite sure how this works with existing apps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is the path I would use. Yes, we would need instructions for how to install this. It should include something like "Install and configure Redis and actioncable" (assuming we're not doing Solid + Rails 8). |
||
|
||
export default createConsumer() |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use use the
<progress>
element? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progressThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is a bootstrap class: https://getbootstrap.com/docs/4.0/components/progress/. Changing this to it breaks the CSS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the semantic element better for accessibility than a bootstrap component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. I think if we are trying to solve the accessibility issue then we should open a new ticket. This is the progress bar that was used in app/views/spotlight/catalog/_reindex_progress_panel.html.erb and app/views/spotlight/bulk_updates/_progress_panel.html.erb