unclesp1d3r/CipherSwarm

View on GitHub
app/views/agents/show.html.erb

Summary

Maintainability
Test Coverage
<%= render Railsboot::HeaderComponent.new do |header| %>
  <% header.with_heading do %>
    <%= title @agent.name %>
  <% end %>
  <% header.with_breadcrumb.with_items([
       { text: "Dashboard", href: root_path },
       { text: "Agents", href: agents_path },
       { text: @agent.name, href: @agent, active: true }
                                       ]) %>
<% end %>

<div id="<%= dom_id @agent %>">
  <%= show_for @agent do |s| %>
    <%= turbo_stream_from @agent %>
    <%= s.attribute :client_signature %>
    <%= s.attribute :state %>
    <%= s.attribute :last_ipaddress %>
    <%= s.attribute :last_seen_at, format: :short %>
    <%= s.attribute :operating_system %>
    <%= s.attribute :token %>
    <%= s.association :user %>
    <%= s.association :projects %>
    <%= s.attribute :current_running_attack do |a| %>
      <%= link_to a.to_full_label, [a.campaign, a], class: "btn btn-outline-info btn-sm" if can? :read, a %>
    <% end %>
    <%= s.attribute :devices %>
    <%= s.association :advanced_configuration do |a| %>
      <dl>
        <dt>Agent Update Interval</dt>
        <dd><%= a.agent_update_interval %></dd>
      </dl>
      <dl>
        <dt>Use Native Hashcat</dt>
        <dd><%= a.use_native_hashcat %></dd>
      </dl>
      <% unless a.backend_device.blank? %>
        <dl>
          <dt>Backend Devices</dt>
          <dd><%= a.backend_device %></dd>
        </dl>
      <% end %>
    <% end %>
    <% cache @agent do %>
      <%= s.association :aggregate_benchmarks do |b| %>
        <%= render partial: "benchmark", locals: { benchmark: b } %>
      <% end %>
    <% end %>
  <% end %>
  <div id="agent_errors">
    <div>
      <%== pagy_info(@pagy) %>
    </div>
    <table class="table table-sm table-hover">
      <thead>
      <tr>
        <th>Date</th>
        <th>Severity</th>
        <th>Message</th>
        <th></th>
      </tr>
      </thead>
      <tbody>
      <%= render partial: "error", collection: @errors, cached: true %>
      </tbody>
    </table>
    <div data-controller="pagy-initializer">
      <%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %> <!-- Pagy pagination -->
    </div>
    <noscript><%== pagy_nav(@pagy) %></noscript>
  </div>
</div>

<div class="btn-group">
  <%= link_to "Edit", edit_agent_path(@agent), class: "btn btn-outline-primary" if can? :update, @agent %>
  <%= link_to "Back", agents_path, class: "btn btn-outline-secondary" %>
</div>