Skip to content
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

Add support for live polling the dashboard #528

Merged
merged 9 commits into from
Feb 27, 2022
Prev Previous commit
Next Next commit
Scope poll replacement to relevant fields to input focus jank
If you have live poll enabled, and are typing in an input, your changes to the input can be replaced, resulting in a janky experience.
  • Loading branch information
danielwestendorf committed Feb 21, 2022
commit da43f8d35aaeeafc8820700aeded7e805b4fa259
2 changes: 1 addition & 1 deletion engine/app/views/good_job/executions/_table.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card my-3">
<div class="card my-3" data-gj-poll-replace id="executions-table">
<div class="table-responsive">
<table class="table card-table table-bordered table-hover table-sm mb-0" id="executions_index_table">
<thead>
Expand Down
4 changes: 2 additions & 2 deletions engine/app/views/good_job/executions/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card my-3 p-6">
<div class="card my-3 p-6" data-gj-poll-replace id="executions-chart">
<%= render 'good_job/shared/chart', chart_data: GoodJob::ScheduledByQueueChart.new(@filter).data %>
</div>

Expand All @@ -7,7 +7,7 @@
<%= render 'good_job/executions/table', executions: @filter.records %>

<% if @filter.records.present? %>
<nav aria-label="Job pagination" class="mt-3">
<nav aria-label="Job pagination" class="mt-3" data-gj-poll-replace id="executions-pagination">
<ul class="pagination">
<li class="page-item">
<%= link_to({ after_scheduled_at: (@filter.last.scheduled_at || @filter.last.created_at), after_id: @filter.last.id }, class: "page-link") do %>
Expand Down
2 changes: 1 addition & 1 deletion engine/app/views/good_job/jobs/_table.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card my-3">
<div class="card my-3" data-gj-poll-replace id="jobs-table">
<div class="table-responsive">
<table class="table card-table table-bordered table-hover table-sm mb-0">
<thead>
Expand Down
4 changes: 2 additions & 2 deletions engine/app/views/good_job/jobs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2>All Jobs</h2>
</div>

<div class="card my-3 p-6">
<div class="card my-3 p-6" data-gj-poll-replace id="jobs-chart">
<%= render 'good_job/shared/chart', chart_data: GoodJob::ScheduledByQueueChart.new(@filter).data %>
</div>

Expand All @@ -11,7 +11,7 @@
<%= render 'good_job/jobs/table', jobs: @filter.records %>

<% if @filter.records.present? %>
<nav aria-label="Job pagination" class="mt-3">
<nav aria-label="Job pagination" class="mt-3" data-gj-poll-replace id="jobs-pagination">
<ul class="pagination">
<li class="page-item">
<%= link_to(@filter.to_params(after_scheduled_at: (@filter.last.scheduled_at || @filter.last.created_at), after_id: @filter.last.id), class: "page-link") do %>
Expand Down
74 changes: 38 additions & 36 deletions engine/app/views/good_job/processes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,45 @@
<h2>Processes</h2>
</div>

<% if !GoodJob::Process.migrated? %>
<div class="card my-3">
<div class="card-body">
<p class="card-text">
<em>Feature unavailable because of pending database migration.</em>
</p>
<div data-gj-poll-replace id="processes">
<% if !GoodJob::Process.migrated? %>
<div class="card my-3">
<div class="card-body">
<p class="card-text">
<em>Feature unavailable because of pending database migration.</em>
</p>
</div>
</div>
</div>
<% elsif @processes.present? %>
<div class="card my-3">
<div class="table-responsive">
<table class="table card-table table-bordered table-hover table-sm mb-0">
<thead>
<tr>
<th>Process UUID</th>
<th>Created At</th></th>
<th>State</th>
</tr>
</thead>
<tbody>
<% @processes.each do |process| %>
<tr class="<%= dom_class(process) %>" id="<%= dom_id(process) %>">
<td><%= process.id %></td>
<td><%= relative_time(process.created_at) %></td>
<td><%= tag.pre JSON.pretty_generate(process.state) %></td>
<% elsif @processes.present? %>
<div class="card my-3">
<div class="table-responsive">
<table class="table card-table table-bordered table-hover table-sm mb-0">
<thead>
<tr>
<th>Process UUID</th>
<th>Created At</th></th>
<th>State</th>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% @processes.each do |process| %>
<tr class="<%= dom_class(process) %>" id="<%= dom_id(process) %>">
<td><%= process.id %></td>
<td><%= relative_time(process.created_at) %></td>
<td><%= tag.pre JSON.pretty_generate(process.state) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<% else %>
<div class="card my-3">
<div class="card-body">
<p class="card-text">
<em>No GoodJob processes found.</em>
</p>
<% else %>
<div class="card my-3">
<div class="card-body">
<p class="card-text">
<em>No GoodJob processes found.</em>
</p>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
4 changes: 1 addition & 3 deletions engine/app/views/layouts/good_job/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
</div>
<% end %>

<div id="content" data-gj-poll-replace>
<%= yield %>
</div>
<%= yield %>
</div>

<footer class="footer mt-auto py-3 bg-light fixed-bottom" id="footer" data-gj-poll-replace>
Expand Down