<tr id="<%= dom_id(company) %>">
<td><%= link_to company.name, company %></td>
<td><%= company.program_type.capitalize %></td>
<td><%= company.metadata['allow_continuous_discovery'] ? 'Yes' : 'No' %></td>
<td><%= company.metadata['verified'] ? 'Yes' : 'No' %></td>
<td>
<%= link_to 'Edit', edit_company_path(company), class: 'btn btn-sm btn-secondary' %>
<%= link_to 'Delete', company, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger', data: { turbo_confirm: 'Delete this company?' } %>
<% if company.program_type == 'private' && !company.metadata['verified'] %>
<%= button_to 'Verify', verify_company_path(company), method: :post, class: 'btn btn-sm btn-warning', data: { turbo_stream: true } %>
<% end %>
</td>
</tr>
<h1><%= @company.new_record? ? 'New Company' : 'Edit Company' %></h1>
<%= form_with(model: @company, local: false) do |f| %>
<div class="mb-3">
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
</div>
<div class="mb-3">
<%= f.label :program_url %>
<%= f.text_field :program_url, class: 'form-control' %>
</div>
<div class="mb-3">
<%= f.label :program_type %>
<%= f.select :program_type, options_for_select([['Public', 'public'], ['Private', 'private']], @company.program_type), {}, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :metadata_allow_continuous_discovery, {}, true, false, class: 'form-check-input' %>
<%= f.label :metadata_allow_continuous_discovery, "Allow Continuous Discovery", class: 'form-check-label' %>
</div>
<%= f.submit class: 'btn btn-primary' %>
<%= link_to 'Back', companies_path, class: 'btn btn-secondary' %>
<% end %>
<h1>Companies</h1>
<%= link_to 'New Company', new_company_path, class: 'btn btn-primary' %>
<table class="table mt-3">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Continuous Discovery</th>
<th>Verified</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @collection.each do |company| %>
<tr>
<td><%= link_to company.name, company %></td>
<td><%= company.program_type.capitalize %></td>
<td><%= company.metadata['allow_continuous_discovery'] ? 'Yes' : 'No' %></td>
<td><%= company.metadata['verified'] ? 'Yes' : 'No' %></td>
<td>
<%= link_to 'Edit', edit_company_path(company), class: 'btn btn-sm btn-secondary' %>
<%= link_to 'Delete', company, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' %>
<% if company.program_type == 'private' %>
<%= button_to 'Verify', verify_company_path(company), method: :post, class: 'btn btn-sm btn-warning' %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= turbo_stream_from "companies" %><h1><%= @resource.new_record? ? 'New Company' : 'Edit Company' %></h1>
<%= form_with(model: @resource, local: false) do |f| %>
<div class="mb-3">
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
</div>
<div class="mb-3">
<%= f.label :program_url %>
<%= f.text_field :program_url, class: 'form-control' %>
</div>
<div class="mb-3">
<%= f.label :program_type %>
<%= f.select :program_type, options_for_select([['Public', 'public'], ['Private', 'private']], @resource.program_type), {}, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :metadata_allow_continuous_discovery, { checked: true, class: 'form-check-input' }, true, false %>
<%= f.label :metadata_allow_continuous_discovery, "Allow Continuous Discovery", class: 'form-check-label' %>
</div>
<%= f.submit class: 'btn btn-primary' %>
<%= link_to 'Back', companies_path, class: 'btn btn-secondary' %>
<% end %>
<h1><%= @company.name %></h1>
<p><%= @company.program_url %></p>
<h2>Domains</h2>
<table>
<thead><tr><th>Domain</th><th>Subdomains</th><th>Actions</th></tr></thead>
<tbody>
<% @domains.each do |d| %>
<tr>
<td><%= link_to d.domain, company_domain_path(@company, d) %></td>
<td><%= d.subdomains.count %></td>
<td><%= link_to "Run CAD", trigger_company_workflow_path(@company, Workflow.find_by(name: 'Continuous Discovery')), method: :post %></td>
</tr>
<% end %>
</tbody>
</table>
<tr id="<%= dom_id(domain) %>">
<td><%= link_to domain.domain, [@company, domain] %></td>
<td><%= domain.wildcard_scope ? 'Yes' : 'No' %></td>
<td><%= domain.in_scope ? 'Yes' : 'No' %></td>
<td>
<%= link_to 'Edit', edit_company_domain_path(@company, domain), class: 'btn btn-sm btn-secondary' %>
<%= link_to 'Delete', company_domain_path(@company, domain), method: :delete, data: { turbo_confirm: 'Delete this domain?' }, class: 'btn btn-sm btn-danger' %>
</td>
</tr>
<h1><%= @domain.new_record? ? 'New Domain' : 'Edit Domain' %> for <%= @company.name %></h1>
<%= form_with(model: [@company, @domain], local: false) do |f| %>
<div class="mb-3">
<%= f.label :domain %>
<%= f.text_field :domain, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :wildcard_scope, {}, true, false, class: 'form-check-input' %>
<%= f.label :wildcard_scope, "Wildcard Scope", class: 'form-check-label' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :in_scope, {}, true, false, class: 'form-check-input' %>
<%= f.label :in_scope, "In Scope", class: 'form-check-label' %>
</div>
<%= f.submit class: 'btn btn-primary' %>
<%= link_to 'Back', company_domains_path(@company), class: 'btn btn-secondary' %>
<% end %>
<h1>Domains for <%= @company.name %></h1>
<%= link_to 'New Domain', new_company_domain_path(@company), class: 'btn btn-primary mb-3' %>
<table class="table table-striped">
<thead>
<tr>
<th>Domain</th>
<th>Wildcard Scope</th>
<th>In Scope</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="domains_list">
<%= render partial: 'domain', collection: @domains, as: :domain %>
</tbody>
</table>
<%= turbo_stream_from [@company, "domains"] %>
<h1><%= @domain.new_record? ? 'New Domain' : 'Edit Domain' %> for <%= @company.name %></h1>
<%= form_with(model: [@company, @domain], local: false) do |f| %>
<div class="mb-3">
<%= f.label :domain %>
<%= f.text_field :domain, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :wildcard_scope, {}, true, false, class: 'form-check-input' %>
<%= f.label :wildcard_scope, "Wildcard Scope", class: 'form-check-label' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :in_scope, {}, true, false, class: 'form-check-input' %>
<%= f.label :in_scope, "In Scope", class: 'form-check-label' %>
</div>
<%= f.submit class: 'btn btn-primary' %>
<%= link_to 'Back', company_domains_path(@company), class: 'btn btn-secondary' %>
<% end %>
<!DOCTYPE html>
<html>
<head>
<title>Basm</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<!-- Bootstrap CSS (CDN) -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<%= javascript_importmap_tags %>
</head>
<body class="bg-light">
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom">
<div class="container">
<a class="navbar-brand" href="/">Basm</a>
</div>
</nav>
<div class="container my-4">
<%= yield %>
</div>
<!-- Bootstrap JS bundle (includes Popper) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
</head>
<body>
<%= yield %>
</body>
</html>
<%= yield %>
<div class="card">
<div class="card-body">
<h3 class="card-title"><%= @subdomain.new_record? ? 'New Subdomain' : 'Edit Subdomain' %> for <%= @domain.domain %></h3>
<%= form_with(model: [@company, @domain, @subdomain], local: false) do |f| %>
<div class="mb-3">
<%= f.label :subdomain, class: 'form-label' %>
<%= f.text_field :subdomain, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :in_scope, { class: 'form-check-input' }, '1', '0' %>
<%= f.label :in_scope, "In Scope", class: 'form-check-label ms-2' %>
</div>
<div class="d-flex gap-2">
<%= f.submit @subdomain.new_record? ? 'Create' : 'Update', class: 'btn btn-primary' %>
<%= link_to 'Back', company_domain_subdomains_path(@company, @domain), class: 'btn btn-outline-secondary' %>
</div>
<% end %>
</div>
</div>
<h1>Subdomains for <%= @domain.domain %></h1>
<%= link_to 'New Subdomain', new_company_domain_subdomain_path(@company, @domain), class: 'btn btn-primary mb-3' %>
<table class="table table-striped">
<thead>
<tr>
<th>Subdomain</th>
<th>In Scope</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="subdomains_list">
<%= render partial: 'subdomain', collection: @fetch_resource, as: :subdomain %>
</tbody>
</table>
<%= turbo_stream_from [@company, @domain, "subdomains"] %>
<h1><%= @subdomain.new_record? ? 'New Subdomain' : 'Edit Subdomain' %> for <%= @domain.domain %></h1>
<%= form_with(model: [@company, @domain, @subdomain], local: false) do |f| %>
<div class="mb-3">
<%= f.label :subdomain %>
<%= f.text_field :subdomain, class: 'form-control' %>
</div>
<div class="mb-3 form-check">
<%= f.check_box :in_scope, {}, true, false, class: 'form-check-input' %>
<%= f.label :in_scope, "In Scope", class: 'form-check-label' %>
</div>
<%= f.submit class: 'btn btn-primary' %>
<%= link_to 'Back', company_domain_subdomains_path(@company, @domain), class: 'btn btn-secondary' %>
<% end %>
<tr id="<%= dom_id(subdomain) %>">
<td><%= subdomain.subdomain %></td>
<td><%= subdomain.in_scope ? 'Yes' : 'No' %></td>
<td>
<%= link_to 'Edit', edit_company_domain_subdomain_path(@company, @domain, subdomain), class: 'btn btn-sm btn-secondary' %>
<%= link_to 'Delete', company_domain_subdomain_path(@company, @domain, subdomain), method: :delete, data: { turbo_confirm: 'Delete this subdomain?' }, class: 'btn btn-sm btn-danger' %>
</td>
</tr>
<%= turbo_stream.replace dom_id(@fetch_resource), partial: 'tasks/task', locals: { task: @fetch_resource } %>
<h3>Task: <%= @fetch_resource.name %></h3>
<p>Status: <%= @fetch_resource.status.capitalize %></p>
<%= turbo_stream_from @fetch_resource %>
<div id="task_<%= @fetch_resource.id %>_result">
<% if @fetch_resource.result.present? %>
<pre><%= JSON.pretty_generate(@fetch_resource.result) rescue @fetch_resource.result.to_s %></pre>
<% else %>
<p>No result yet...</p>
<% end %>
</div>
<%= button_to 'Retry', retry_task_path(@fetch_resource), method: :post, class: 'btn btn-warning', data: { turbo_stream: true } %>
<%= link_to 'Back', workflows_path, class: 'btn btn-secondary' %>
<div id="<%= dom_id(fetch_resource) %>" class="card my-2 p-2">
<div class="d-flex justify-content-between">
<div>
<strong><%= fetch_resource.name %></strong><br>
Step: <%= fetch_resource.workflow_step.name %> |
Status: <%= fetch_resource.status.capitalize %>
</div>
<div>
<% if fetch_resource.status == 'failed' %>
<%= button_to 'Retry', retry_task_path(fetch_resource), method: :post, class: 'btn btn-warning', data: { turbo_stream: true } %>
<% end %>
</div>
</div>
<% if fetch_resource.result.present? %>
<pre class="mt-2 bg-light p-2"><%= JSON.pretty_generate(fetch_resource.result) rescue fetch_resource.result.to_s %></pre>
<% end %>
</div>
<h1>Workflows</h1>
<%= link_to 'New Workflow', new_workflow_path, class: 'btn btn-primary' %>
<table class="table mt-3">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @workflows.each do |workflow| %>
<tr id="<%= dom_id(workflow) %>">
<td><%= workflow.workflow_number %></td>
<td><%= link_to workflow.name, workflow %></td>
<td><%= workflow.description %></td>
<td>
<%= button_to 'Run', run_workflow_path(workflow), method: :post, class: 'btn btn-success', data: { turbo_stream: true } %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= turbo_stream.replace "tasks", partial: "tasks/task", collection: @fetch_resource.tasks, as: :task %>
<h2><%= @workflow.name %></h2>
<p><%= @workflow.description %></p>
<div class="d-flex justify-content-between">
<%= button_to 'Run Again', run_workflow_path(@workflow), method: :post, class: 'btn btn-primary', data: { turbo_stream: true } %>
<%= link_to 'Back', workflows_path, class: 'btn btn-secondary' %>
</div>
<hr>
<h3>Tasks</h3>
<div id="tasks">
<%= render partial: 'tasks/task', collection: @tasks, as: :task %>
</div>
<%= turbo_stream_from @workflow %>