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

Improve dashboard UI, fix button state, add unfiltering #181

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/app/controllers/good_job/dashboards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def job_classes
GoodJob::Job.group("serialized_params->>'job_class'").count
end

def to_query(override)
def to_params(override)
{
state: params[:state],
job_class: params[:job_class],
}.merge(override).delete_if { |_, v| v.nil? }.to_query
}.merge(override).delete_if { |_, v| v.nil? }
end
end

Expand Down
26 changes: 19 additions & 7 deletions engine/app/views/good_job/dashboards/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@
<small>Filter by job class</small>
<br>
<% @filter.job_classes.each do |name, count| %>
<a href='<%= request.path + "?#{@filter.to_query(job_class: name)}" %>' class='btn btn-sm btn-outline-secondary <%= "active" if params[:job_class] == name %>'>
<%= name %> (<%= count %>)
</a>
<% if params[:job_class] == name %>
<%= link_to(root_path(@filter.to_params(job_class: nil)), class: 'btn btn-sm btn-outline-secondary active', role: "button", "aria-pressed": true) do %>
<%= name %> (<%= count %>)
<% end %>
<% else %>
<%= link_to(root_path(@filter.to_params(job_class: name)), class: 'btn btn-sm btn-outline-secondary', role: "button") do %>
<%= name %> (<%= count %>)
<% end %>
<% end %>
<% end %>
</div>
<div>
<small>Filter by state</small>
<br>
<% @filter.states.each do |name, count| %>
<a href='<%= request.path + "?#{@filter.to_query(state: name)}" %>' class='btn btn-sm btn-outline-secondary <%= "active" if params[:state] == name %>'>
<%= name %> (<%= count %>)
</a>
<% if params[:state] == name %>
<%= link_to(root_path(@filter.to_params(state: nil)), class: 'btn btn-sm btn-outline-secondary active', role: "button", "aria-pressed": true) do %>
<%= name %> (<%= count %>)
<% end %>
<% else %>
<%= link_to(root_path(@filter.to_params(state: name)), class: 'btn btn-sm btn-outline-secondary', role: "button") do %>
<%= name %> (<%= count %>)
<% end %>
<% end %>
<% end %>
</div>
</div>
Expand All @@ -28,7 +40,7 @@
<% if @filter.jobs.present? %>
<%= render 'shared/jobs_table', jobs: @filter.jobs %>

<nav aria-label="Job pagination">
<nav aria-label="Job pagination" class="mt-3">
<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
10 changes: 5 additions & 5 deletions engine/app/views/layouts/good_job/base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<%= csp_meta_tag %>

<style>
<%= render file: GoodJob::Engine.root.join("app", "assets", "vendor", "bootstrap", "bootstrap.css") %>
<%= render file: GoodJob::Engine.root.join("app", "assets", "vendor", "chartist", "chartist.css") %>
<%= render file: GoodJob::Engine.root.join("app", "assets", "style.css") %>
<%== render file: GoodJob::Engine.root.join("app", "assets", "vendor", "bootstrap", "bootstrap.css") %>
<%== render file: GoodJob::Engine.root.join("app", "assets", "vendor", "chartist", "chartist.css") %>
<%== render file: GoodJob::Engine.root.join("app", "assets", "style.css") %>
</style>

<script>
<%= render file: GoodJob::Engine.root.join("app", "assets", "vendor", "bootstrap", "bootstrap-native.js") %>
<%= render file: GoodJob::Engine.root.join("app", "assets", "vendor", "chartist", "chartist.js") %>
<%== render file: GoodJob::Engine.root.join("app", "assets", "vendor", "bootstrap", "bootstrap-native.js") %>
<%== render file: GoodJob::Engine.root.join("app", "assets", "vendor", "chartist", "chartist.js") %>
</script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion engine/app/views/shared/_chart.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="chart"></div>

<script>
new Chartist.Line('#chart', <%= raw chart_data.to_json %>, {
new Chartist.Line('#chart', <%== chart_data.to_json %>, {
height: '300px',
fullWidth: true,
chartPadding: {
Expand Down
52 changes: 27 additions & 25 deletions engine/app/views/shared/_jobs_table.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
<div class="table-responsive">
<table class="table table-bordered table-hover table-sm">
<thead>
<th>GoodJob ID</th>
<th>ActiveJob ID</th>
<th>Job Class</th>
<th>Queue</th>
<th>Scheduled At</th>
<th>Error</th>
<th>ActiveJob Params</th>
</thead>
<tbody>
<% jobs.each do |job| %>
<tr id="<%= dom_id(job) %>">
<td><%= link_to job.id, active_job_path(job.serialized_params['job_id'], anchor: dom_id(job)) %></td>
<td><%= link_to job.serialized_params['job_id'], active_job_path(job.serialized_params['job_id']) %></td>
<td><%= job.serialized_params['job_class'] %></td>
<td><%= job.queue_name %></td>
<td><%= job.scheduled_at || job.created_at %></td>
<td><%= job.error %></td>
<td><pre><%= JSON.pretty_generate(job.serialized_params) %></pre></td>
</tr>
<% end %>
</tbody>
</table>
<div class="card my-3">
<div class="table-responsive">
<table class="table card-table table-bordered table-hover table-sm mb-0">
<thead>
<th>GoodJob ID</th>
<th>ActiveJob ID</th>
<th>Job Class</th>
<th>Queue</th>
<th>Scheduled At</th>
<th>Error</th>
<th>ActiveJob Params</th>
</thead>
<tbody>
<% jobs.each do |job| %>
<tr id="<%= dom_id(job) %>">
<td><%= link_to job.id, active_job_path(job.serialized_params['job_id'], anchor: dom_id(job)) %></td>
<td><%= link_to job.serialized_params['job_id'], active_job_path(job.serialized_params['job_id']) %></td>
<td><%= job.serialized_params['job_class'] %></td>
<td><%= job.queue_name %></td>
<td><%= job.scheduled_at || job.created_at %></td>
<td><%= job.error %></td>
<td><pre><%= JSON.pretty_generate(job.serialized_params) %></pre></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>