-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4f3928
commit 09d8db2
Showing
10 changed files
with
452 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
document.querySelectorAll<HTMLElement>('[data-scu-form]').forEach((el) => { | ||
el.addEventListener('submit', (ev) => { | ||
// eslint-disable-next-line no-alert | ||
if (!window.confirm(el.dataset.prompt)) { | ||
ev.preventDefault(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule SignsUiWeb.ScuController do | ||
use SignsUiWeb, :controller | ||
|
||
def index(conn, _params) do | ||
scus = | ||
SignsUi.Config.State.get_all().scus_migrated | ||
|> Enum.sort_by(&elem(&1, 0)) | ||
|
||
render(conn, "index.html", layout: {SignsUiWeb.LayoutView, "scu.html"}, scus: scus) | ||
end | ||
|
||
def update(conn, %{"migrated" => migrated, "scu_id" => scu_id}) do | ||
case Guardian.Plug.current_claims(conn) |> SignsUiWeb.AuthManager.claims_access_level() do | ||
:admin -> | ||
value = | ||
case migrated do | ||
"true" -> true | ||
_ -> false | ||
end | ||
|
||
SignsUi.Config.State.update_scu(scu_id, value) | ||
redirect(conn, to: "/scu") | ||
|
||
_ -> | ||
send_resp(conn, 403, "Admin only") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<title>SCU configuration</title> | ||
<link rel="stylesheet" href="<%= static_path(@conn, "/vendor/bootstrap.min.css") %>"> | ||
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>"> | ||
</head> | ||
<body> | ||
<%= @inner_content %> | ||
<script src="<%= static_path(@conn, "/js/scu.js") %>"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="container"> | ||
<h1>SCU configuration</h1> | ||
<p> | ||
Controls which SCU application the system will use, on a per-station basis. | ||
<strong>Caution:</strong> setting these values incorrectly will cause signs to stop working. | ||
Do not change any values here unless instructed by someone conducting an in-station SCU upgrade. | ||
</p> | ||
<table class="table table-sm table-striped"> | ||
<thead> | ||
<tr> | ||
<th>SCU</th> | ||
<th>Application</th> | ||
<th>Action</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<%= for {scu_id, migrated} <- @scus do %> | ||
<tr> | ||
<td><%= scu_id %></td> | ||
<td><%= if migrated do %>New<% else %>Legacy<% end %></td> | ||
<td> | ||
<%= if !assigns[:read_only_view] do %> | ||
<% new_text = if(migrated, do: "legacy", else: "new") %> | ||
<form action="" method="post" data-scu-form data-prompt="Change <%= scu_id %> to <%= new_text %> application?"> | ||
<input type="hidden" name="_csrf_token" value="<%= Phoenix.Controller.get_csrf_token() %>" /> | ||
<input type="hidden" name="scu_id" value="<%= scu_id %>" /> | ||
<button class="btn btn-sm btn-outline-secondary" name="migrated" value="<%= if migrated do %>false<% else %>true<% end %>"> | ||
Change to <%= new_text %> application | ||
</button> | ||
</form> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule SignsUiWeb.ScuView do | ||
use SignsUiWeb, :view | ||
end |
Oops, something went wrong.