Skip to content

Commit

Permalink
use Phoenix.LiveView.HTMLFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk committed Dec 11, 2023
1 parent eac1083 commit d7cec19
Show file tree
Hide file tree
Showing 44 changed files with 415 additions and 366 deletions.
4 changes: 3 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{heex,ex,exs}"],
heex_line_length: 200
]
4 changes: 2 additions & 2 deletions lib/nerves_hub_web/templates/account/delete.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<%= form_for @conn, Routes.account_path(@conn, :delete, @user.username), [method: "delete"], fn f -> %>
<div class="form-group">
<label for="username_input">Please type <%= @user.username %> to confirm.</label>
<%= text_input f, :confirm_username, class: "form-control", id: "username_input" %>
<%= text_input(f, :confirm_username, class: "form-control", id: "username_input") %>
</div>

<div class="button-submit-wrapper">
<%= submit "I understand the consequences, delete this account", class: "btn btn-primary" %>
<%= submit("I understand the consequences, delete this account", class: "btn btn-primary") %>
</div>
<% end %>
32 changes: 15 additions & 17 deletions lib/nerves_hub_web/templates/account/edit.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,42 @@
</h1>

<div class="mb-4">
<%=
link(
"Delete Account",
class: "btn btn-outline-light",
aria_label: "Delete Account",
to: Routes.account_path(@conn, :confirm_delete, @user.username)
)
%>
<%= link(
"Delete Account",
class: "btn btn-outline-light",
aria_label: "Delete Account",
to: Routes.account_path(@conn, :confirm_delete, @user.username)
) %>
</div>

<%= form_for @changeset, Routes.account_path(@conn, :update, @user.username), fn f -> %>
<div class="form-group">
<label for="username_input">Username</label>
<%= text_input f, :username, class: "form-control", id: "username_input" %>
<div class="has-error"><%= error_tag f, :username %></div>
<%= text_input(f, :username, class: "form-control", id: "username_input") %>
<div class="has-error"><%= error_tag(f, :username) %></div>
</div>

<div class="form-group">
<label for="email_input">Email</label>
<%= email_input f, :email, class: "form-control", id: "email_input" %>
<div class="has-error"><%= error_tag f, :email %></div>
<%= email_input(f, :email, class: "form-control", id: "email_input") %>
<div class="has-error"><%= error_tag(f, :email) %></div>
</div>

<h4 class="color-white mt-4 mb-2">Change Password</h4>

<div class="form-group">
<label for="current_password_input">Old Password</label>
<%= password_input f, :current_password, class: "form-control", id: "current_password_input" %>
<div class="has-error"><%= error_tag f, :current_password %></div>
<%= password_input(f, :current_password, class: "form-control", id: "current_password_input") %>
<div class="has-error"><%= error_tag(f, :current_password) %></div>
</div>

<div class="form-group">
<label for="password_input">New Password</label>
<%= password_input f, :password, class: "form-control", id: "password_input" %>
<div class="has-error"><%= error_tag f, :password %></div>
<%= password_input(f, :password, class: "form-control", id: "password_input") %>
<div class="has-error"><%= error_tag(f, :password) %></div>
</div>

<div class="button-submit-wrapper">
<%= submit "Save Changes", class: "btn btn-primary" %>
<%= submit("Save Changes", class: "btn btn-primary") %>
</div>
<% end %>
12 changes: 6 additions & 6 deletions lib/nerves_hub_web/templates/account/invite.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<h2 class="form-title">
Create New Account
</h2>
<h5 class="mt-2"><%= gettext "You will be added to the %{organization_name} organization", organization_name: @org.name %></h5>
<h5 class="mt-2"><%= gettext("You will be added to the %{organization_name} organization", organization_name: @org.name) %></h5>

<%= form_for @changeset, Routes.account_path(@conn, :accept_invite, @token), [as: :user, method: "post", class: "form-page"], fn f -> %>
<div class="form-group">
<label for="username_input">Username</label>
<%= text_input f, :username, class: "form-control", id: "username_input" %>
<div class="has-error"><%= error_tag f, :username %></div>
<%= text_input(f, :username, class: "form-control", id: "username_input") %>
<div class="has-error"><%= error_tag(f, :username) %></div>
</div>
<div class="form-group">
<label for="password_input">Password</label>
<%= password_input f, :password, class: "form-control", id: "password_input" %>
<div class="has-error"><%= error_tag f, :password %></div>
<%= password_input(f, :password, class: "form-control", id: "password_input") %>
<div class="has-error"><%= error_tag(f, :password) %></div>
</div>

<%= submit "Register", class: "btn btn-primary btn-lg w-100" %>
<%= submit("Register", class: "btn btn-primary btn-lg w-100") %>
<% end %>
</div>
7 changes: 6 additions & 1 deletion lib/nerves_hub_web/templates/archive/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@
<div class="dropdown-menu dropdown-menu-right">
<%= link("Download", class: "dropdown-item", to: Routes.archive_path(@conn, :download, @org.name, @product.name, archive.uuid)) %>
<div class="dropdown-divider"></div>
<%= link "Delete", class: "dropdown-item", to: Routes.archive_path(@conn, :delete, @org.name, @product.name, archive.uuid), method: :delete, data: [confirm: "Are you sure you want to delete this archive? This can not be undone."] %>
<%= link("Delete",
class: "dropdown-item",
to: Routes.archive_path(@conn, :delete, @org.name, @product.name, archive.uuid),
method: :delete,
data: [confirm: "Are you sure you want to delete this archive? This can not be undone."]
) %>
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<% else %>
<%= for audit_log <- @audit_logs do %>
<div class="audit-log-item" id={audit_log.id}>
<div class={"audit-action-icon icon-update"}></div>
<div class="audit-action-icon icon-update"></div>
<div>
<p class="audit-description"><%= audit_log.description %></p>
<div class="help-text">
Expand Down
111 changes: 54 additions & 57 deletions lib/nerves_hub_web/templates/deployment/edit.html.heex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= link "Back to Deployment", to: Routes.deployment_path(@conn, :show, @org.name, @product.name, @deployment.name), class: "back-link"%>
<%= link("Back to Deployment", to: Routes.deployment_path(@conn, :show, @org.name, @product.name, @deployment.name), class: "back-link") %>
<h1>Edit Deployment</h1>

<h5 class="mb-2">Firmware version details</h5>
Expand All @@ -10,12 +10,10 @@
<div>
<div class="help-text mb-1">Version</div>
<p>
<%=
case @firmware.version do
nil -> "--"
version -> version
end
%>
<%= case @firmware.version do
nil -> "--"
version -> version
end %>
</p>
</div>
<div>
Expand All @@ -31,12 +29,12 @@
<div class="divider"></div>

<%= form_for @changeset, Routes.deployment_path(@conn, :update, @org.name, @product.name, @deployment.name), [as: :deployment], fn f -> %>
<%= hidden_input f, :firmware_id, value: @firmware.id %>
<%= hidden_input(f, :firmware_id, value: @firmware.id) %>

<div class="form-group">
<label for="name_input">Deployment name</label>
<%= text_input f, :name, class: "form-control", id: "name_input" %>
<div class="has-error"><%= error_tag f, :name %></div>
<%= text_input(f, :name, class: "form-control", id: "name_input") %>
<div class="has-error"><%= error_tag(f, :name) %></div>
</div>

<div class="form-group">
Expand All @@ -45,9 +43,9 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">Firmware listed is the same platform and architecture as the currently selected firmware.</span>
</label>
<%= select f, :firmware_id, firmware_dropdown_options(@firmwares), required: true, id: "firmware_id", class: "form-control" %>
<%= select(f, :firmware_id, firmware_dropdown_options(@firmwares), required: true, id: "firmware_id", class: "form-control") %>
<div class="select-icon"></div>
<div class="has-error"><%= error_tag f, :firmware_id %></div>
<div class="has-error"><%= error_tag(f, :firmware_id) %></div>
</div>

<h3 class="mb-2">Conditions</h3>
Expand All @@ -60,15 +58,15 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">Changing tags will reset all devices on this deployment</span>
</label>
<%= text_input f, :tags,
class: "form-control",
id: "tags_input",
value:
@changeset
|> Ecto.Changeset.get_change(:conditions, %{})
|> Map.get("tags", "")
%>
<div class="has-error"><%= error_tag f, :tags %></div>
<%= text_input(f, :tags,
class: "form-control",
id: "tags_input",
value:
@changeset
|> Ecto.Changeset.get_change(:conditions, %{})
|> Map.get("tags", "")
) %>
<div class="has-error"><%= error_tag(f, :tags) %></div>
</div>

<div class="form-group">
Expand All @@ -77,15 +75,15 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">Changing the version requirement will reset all devices on this deployment</span>
</label>
<%= text_input f, :version,
class: "form-control",
id: "version_requirement",
value:
@changeset
|> Ecto.Changeset.get_change(:conditions, %{})
|> Map.get("version", "")
%>
<div class="has-error"><%= error_tag f, :version %></div>
<%= text_input(f, :version,
class: "form-control",
id: "version_requirement",
value:
@changeset
|> Ecto.Changeset.get_change(:conditions, %{})
|> Map.get("version", "")
) %>
<div class="has-error"><%= error_tag(f, :version) %></div>
</div>

<h3 class="mb-2">Rolling Updates</h3>
Expand All @@ -96,8 +94,8 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">The number of devices that will update at any given time. This is a soft limit and concurrent updates may be slightly above this number.</span>
</label>
<%= number_input f, :concurrent_updates, class: "form-control", id: "concurrent_updates" %>
<div class="has-error"><%= error_tag f, :concurrent_updates %></div>
<%= number_input(f, :concurrent_updates, class: "form-control", id: "concurrent_updates") %>
<div class="has-error"><%= error_tag(f, :concurrent_updates) %></div>
</div>

<div class="form-group">
Expand All @@ -106,10 +104,9 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">The number of minutes before an inflight update expires to clear the queue</span>
</label>
<%= number_input f, :inflight_update_expiration_minutes, class: "form-control", id: "concurrent_updates" %>
<div class="has-error"><%= error_tag f, :inflight_update_expiration_minutes %></div>
<%= number_input(f, :inflight_update_expiration_minutes, class: "form-control", id: "concurrent_updates") %>
<div class="has-error"><%= error_tag(f, :inflight_update_expiration_minutes) %></div>
</div>

<!-- Advanced Options -->
<button class="btn btn-outline-light mb-4" type="button" data-toggle="collapse" data-target="#advancedOptionsToggle" aria-expanded="false" aria-controls="advancedOptionsToggle">
Show Advanced Options
Expand All @@ -123,18 +120,18 @@
<span class="tooltip-text"><%= help_message_for(:failure_rate) %></span>
</label>
<div class="failure-rate-grid">
<%= number_input f, :failure_rate_amount,
<%= number_input(f, :failure_rate_amount,
class: "form-control form-control-sm",
id: "failure_rate_amount"
%>
) %>
<span class="help-text">devices per</span>
<%= number_input f, :failure_rate_seconds,
<%= number_input(f, :failure_rate_seconds,
class: "form-control form-control-sm",
id: "failure_rate_input"
%>
) %>
<span class="help-text">sec</span>
</div>
<div class="has-error invalid-tooltip"><%= error_tag f, :failure_rate_seconds %></div>
<div class="has-error invalid-tooltip"><%= error_tag(f, :failure_rate_seconds) %></div>
</div>

<div class="form-group">
Expand All @@ -143,11 +140,11 @@
<span class="tooltip-info"></span>
<span class="tooltip-text"><%= help_message_for(:failure_threshold) %></span>
</label>
<%= number_input f, :failure_threshold,
<%= number_input(f, :failure_threshold,
class: "form-control",
id: "failure_threshold"
%>
<div class="has-error"><%= error_tag f, :failure_threshold %></div>
) %>
<div class="has-error"><%= error_tag(f, :failure_threshold) %></div>
</div>

<div class="form-group">
Expand All @@ -157,18 +154,18 @@
<span class="tooltip-text"><%= help_message_for(:device_failure_rate) %></span>
</label>
<div class="failure-rate-grid">
<%= number_input f, :device_failure_rate_amount,
<%= number_input(f, :device_failure_rate_amount,
class: "form-control form-control-sm",
id: "device_failure_rate_amount"
%>
) %>
<span class="help-text">failures per</span>
<%= number_input f, :device_failure_rate_seconds,
<%= number_input(f, :device_failure_rate_seconds,
class: "form-control form-control-sm",
id: "device_failure_rate_input"
%>
) %>
<span class="help-text">sec</span>
</div>
<div class="has-error"><%= error_tag f, :device_failure_rate_seconds %></div>
<div class="has-error"><%= error_tag(f, :device_failure_rate_seconds) %></div>
</div>

<div class="form-group">
Expand All @@ -177,11 +174,11 @@
<span class="tooltip-info"></span>
<span class="tooltip-text"><%= help_message_for(:device_failure_threshold) %></span>
</label>
<%= number_input f, :device_failure_threshold,
<%= number_input(f, :device_failure_threshold,
class: "form-control",
id: "device_failure_threshold"
%>
<div class="has-error"><%= error_tag f, :device_failure_threshold %></div>
) %>
<div class="has-error"><%= error_tag(f, :device_failure_threshold) %></div>
</div>

<div class="form-group">
Expand All @@ -190,11 +187,11 @@
<span class="tooltip-info"></span>
<span class="tooltip-text"><%= help_message_for(:penalty_timeout_minutes) %></span>
</label>
<%= number_input f, :penalty_timeout_minutes,
<%= number_input(f, :penalty_timeout_minutes,
class: "form-control",
id: "penalty_timeout_minutes"
%>
<div class="has-error"><%= error_tag f, :penalty_timeout_minutes %></div>
) %>
<div class="has-error"><%= error_tag(f, :penalty_timeout_minutes) %></div>
</div>
</div>

Expand All @@ -204,14 +201,14 @@
<span class="tooltip-info"></span>
<span class="tooltip-text">Run this code when the device first connects to the console.</span>
</label>
<%= textarea f, :connecting_code, rows: 6, class: "form-control", id: "connecting_code" %>
<%= textarea(f, :connecting_code, rows: 6, class: "form-control", id: "connecting_code") %>
<small class="form-text text-muted mt-1">
Make sure this is valid Elixir and will not crash the device. This will run before device specific first connect code.
</small>
<div class="has-error"><%= error_tag f, :connecting_code %></div>
<div class="has-error"><%= error_tag(f, :connecting_code) %></div>
</div>

<div class="button-submit-wrapper">
<%= submit "Save Changes", class: "btn btn-primary" %>
<%= submit("Save Changes", class: "btn btn-primary") %>
</div>
<% end %>
12 changes: 6 additions & 6 deletions lib/nerves_hub_web/templates/deployment/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
<td>
<div class="mobile-label help-text">Firmware version</div>
<div>
<%= link(to: Routes.firmware_path(@conn, :show, @org.name, @product.name, deployment.firmware.uuid)) do %>
<span class="badge ff-m">
<%= firmware_simple_display_name(deployment.firmware) %>
</span>
<%= link(to: Routes.firmware_path(@conn, :show, @org.name, @product.name, deployment.firmware.uuid)) do %>
<span class="badge ff-m">
<%= firmware_simple_display_name(deployment.firmware) %>
</span>
<% end %>
</div>
</td>
Expand Down Expand Up @@ -81,9 +81,9 @@
<img src="/images/icons/more.svg" alt="options" />
</a>
<div class="dropdown-menu dropdown-menu-right">
<%= link "details", class: "dropdown-item", to: Routes.deployment_path(@conn, :show, @org.name, @product.name, deployment.name) %>
<%= link("details", class: "dropdown-item", to: Routes.deployment_path(@conn, :show, @org.name, @product.name, deployment.name)) %>
<div class="dropdown-divider"></div>
<%= link "edit", class: "dropdown-item", to: Routes.deployment_path(@conn, :edit, @org.name, @product.name, deployment.name) %>
<%= link("edit", class: "dropdown-item", to: Routes.deployment_path(@conn, :edit, @org.name, @product.name, deployment.name)) %>
<div class="dropdown-divider"></div>
<a class="dropdown-item" aria-label="Download Audit Logs" href={Routes.deployment_path(@conn, :export_audit_logs, @org.name, @product.name, deployment.name)}>
<div class="button-icon download"></div>
Expand Down
Loading

0 comments on commit d7cec19

Please sign in to comment.