Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
3.2 KB
Raw Blame
<%= content_for :page_title, t(".page_title") %>

<%= turbo_frame_tag "background_jobs_console",
    data: {
      controller: "polling",
      polling_url_value: settings_background_jobs_path,
      polling_interval_value: 10000
    } do %>
  <div class="space-y-4">
    <%= settings_section title: t(".title"), subtitle: t(".subtitle") do %>
      <% if @console.redis_error? || @console.stats.nil? %>
        <%= render DS::Alert.new(variant: :warning, message: t(".redis_unreachable")) %>
      <% else %>
        <div class="space-y-3">
          <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">
            <% {
              workers: @console.stats.processes,
              busy: @console.stats.busy,
              enqueued: @console.stats.enqueued,
              retries: @console.stats.retry_size,
              scheduled: @console.stats.scheduled_size,
              dead: @console.stats.dead_size
            }.each do |label, value| %>
              <div class="rounded-lg bg-container-inset p-3">
                <p class="text-xs text-secondary uppercase"><%= t(".stats.#{label}") %></p>
                <p class="text-lg font-medium text-primary"><%= value %></p>
              </div>
            <% end %>
          </div>

          <div class="flex flex-wrap gap-2">
            <% @console.stats.queues.each do |queue| %>
              <%= render DS::Pill.new(
                    label: t(".stats.queue_label", name: queue[:name], size: queue[:size], latency: queue[:latency]),
                    tone: :neutral,
                    marker: false,
                    show_dot: false,
                    mono: true
                  ) %>
            <% end %>
          </div>
        </div>
      <% end %>
    <% end %>

    <%= settings_section title: t(".operations_title"), subtitle: t(".operations_subtitle") do %>
      <% if @operations.any? %>
        <div class="overflow-x-auto">
          <table class="w-full">
            <thead class="bg-surface border-b border-primary">
              <tr>
                <th class="px-4 py-3 text-left text-xs font-medium text-secondary uppercase"><%= t(".table.type") %></th>
                <th class="px-4 py-3 text-left text-xs font-medium text-secondary uppercase"><%= t(".table.family") %></th>
                <th class="px-4 py-3 text-left text-xs font-medium text-secondary uppercase"><%= t(".table.status") %></th>
                <th class="px-4 py-3 text-left text-xs font-medium text-secondary uppercase"><%= t(".table.last_activity") %></th>
                <th class="px-4 py-3 text-left text-xs font-medium text-secondary uppercase"><%= t(".table.liveness") %></th>
                <th class="px-4 py-3 text-right text-xs font-medium text-secondary uppercase"><%= t(".table.action") %></th>
              </tr>
            </thead>
            <tbody class="divide-y divide-alpha-black-200 theme-dark:divide-alpha-white-200">
              <% @operations.each do |operation| %>
                <%= render "settings/background_jobs/operation", operation: operation, console: @console %>
              <% end %>
            </tbody>
          </table>
        </div>
      <% else %>
        <div class="p-8 text-center text-secondary"><%= t(".empty") %></div>
      <% end %>
    <% end %>
  </div>
<% end %>