diff --git a/.tool-versions b/.tool-versions index d8606fb6f..bd6ca00f1 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,4 @@ elixir 1.10.3-otp-23 erlang 23.0.2 nodejs 10.20.1 +python 3.7.7 diff --git a/apps/fg_http/lib/fg_http/users/session.ex b/apps/fg_http/lib/fg_http/users/session.ex index 1c79e5807..dd0bea0d2 100644 --- a/apps/fg_http/lib/fg_http/users/session.ex +++ b/apps/fg_http/lib/fg_http/users/session.ex @@ -17,15 +17,10 @@ defmodule FgHttp.Users.Session do def create_changeset(session, attrs \\ %{}) do session |> cast(attrs, [:email, :password, :last_signed_in_at]) - |> log_it() |> authenticate_user() |> set_last_signed_in_at() end - defp log_it(changeset) do - changeset - end - defp set_last_signed_in_at(%Ecto.Changeset{valid?: true} = changeset) do last_signed_in_at = DateTime.utc_now() change(changeset, last_signed_in_at: last_signed_in_at) diff --git a/apps/fg_http/lib/fg_http_web/controllers/session_controller.ex b/apps/fg_http/lib/fg_http_web/controllers/session_controller.ex index 6ff135490..9e90d8f11 100644 --- a/apps/fg_http/lib/fg_http_web/controllers/session_controller.ex +++ b/apps/fg_http/lib/fg_http_web/controllers/session_controller.ex @@ -24,14 +24,14 @@ defmodule FgHttpWeb.SessionController do |> clear_session() |> put_session(:user_id, session.id) |> assign(:session, session) - |> put_flash(:info, "Session created successfully") + |> put_flash(:info, "Signed in successfully.") |> redirect(to: Routes.device_path(conn, :index)) {:error, changeset} -> conn |> clear_session() |> assign(:session, nil) - |> put_flash(:error, "Error creating session.") + |> put_flash(:error, "Error signing in.") |> render("new.html", changeset: changeset) end diff --git a/apps/fg_http/lib/fg_http_web/templates/device/edit.html.eex b/apps/fg_http/lib/fg_http_web/templates/device/edit.html.eex index b011f3920..f25354674 100644 --- a/apps/fg_http/lib/fg_http_web/templates/device/edit.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/device/edit.html.eex @@ -1,4 +1,4 @@ -

Edit Device

+

Edit Device

<%= render "form.html", Map.put(assigns, :action, Routes.device_path(@conn, :update, @device)) %> diff --git a/apps/fg_http/lib/fg_http_web/templates/device/form.html.eex b/apps/fg_http/lib/fg_http_web/templates/device/form.html.eex index 2cd1a0abe..c54dda416 100644 --- a/apps/fg_http/lib/fg_http_web/templates/device/form.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/device/form.html.eex @@ -1,15 +1,25 @@ -<%= form_for @changeset, @action, fn f -> %> - <%= if @changeset.action do %> -
-

Oops, something went wrong! Please check the errors below.

-
- <% end %> +
+
+ <%= form_for @changeset, @action, fn f -> %> + <%= if @changeset.action do %> +
+

Oops, something went wrong! Please check the errors below.

+
+ <% end %> - <%= label f, :name %> - <%= text_input f, :name %> - <%= error_tag f, :name %> +
+ <%= label f, :name, class: "label" %> +
+ <%= text_input f, :name, class: "input" %> +
+

+ <%= error_tag f, :name %> +

+
-
- <%= submit "Save" %> +
+ <%= submit "Save", class: "button is-primary" %> +
+ <% end %>
-<% end %> +
diff --git a/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex b/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex index 291a5c024..0ef201812 100644 --- a/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/device/index.html.eex @@ -25,6 +25,4 @@ -

- <%= link "New Device", to: Routes.device_path(@conn, :new) %> -

+<%= link "New Device", to: Routes.device_path(@conn, :new) %> diff --git a/apps/fg_http/lib/fg_http_web/templates/rule/edit.html.eex b/apps/fg_http/lib/fg_http_web/templates/rule/edit.html.eex index 473e03412..179b5f2ba 100644 --- a/apps/fg_http/lib/fg_http_web/templates/rule/edit.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/rule/edit.html.eex @@ -1,4 +1,4 @@ -

Edit Rule

+

Edit Rule

<%= render "form.html", Map.put(assigns, :action, Routes.rule_path(@conn, :update, @rule)) %> diff --git a/apps/fg_http/lib/fg_http_web/templates/rule/form.html.eex b/apps/fg_http/lib/fg_http_web/templates/rule/form.html.eex index bdf4a802a..cbe542139 100644 --- a/apps/fg_http/lib/fg_http_web/templates/rule/form.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/rule/form.html.eex @@ -1,41 +1,70 @@ -<%= form_for @changeset, @action, [class: "black-80"], fn f -> %> - <%= if @changeset.action do %> -
-

Oops, something went wrong! Please check the errors below.

-
- <% end %> +
+
+ <%= form_for @changeset, @action, [], fn f -> %> + <%= if @changeset.action do %> +
+

Oops, something went wrong! Please check the errors below.

+
+ <% end %> -
- <%= label f, :destination, class: "f6 b db mb2" %> - <%= text_input f, :destination, class: "input-reset ba b--black-20 pa2 mb2 db w-100" %> - <%= error_tag f, :destination %> -
+
+ <%= label f, :destination, class: "label" %> +
+ <%= + text_input f, + :destination, + class: "input", + placeholder: "IPv4/6 CIDR range or address" + %> +
+

+ <%= error_tag f, :destination %> +

+
-
- <%= label f, :port, class: "f6 b db mb2" %> - <%= text_input f, :port, class: "input-reset ba b--black-20 pa2 mb2 db w-100" %> - <%= error_tag f, :port %> -
+
+ <%= label f, :port, class: "label" %> +
+ <%= text_input f, :port, class: "input", placeholder: "1 - 65535" %> +
+

+ <%= error_tag f, :port %> +

+
-
- <%= label f, :protocol, class: "f6 b db mb2" %> - <%= text_input f, :protocol, class: "input-reset ba b--black-20 pa2 mb2 db w-100" %> - <%= error_tag f, :protocol %> -
+
+ <%= label f, :protocol, class: "label" %> +
+ <%= select f, :protocol, protocol_options_for_select() %> +
+

+ <%= error_tag f, :protocol %> +

+
-
- <%= label f, :priority, class: "f6 b db mb2" %> - <%= text_input f, :priority, class: "input-reset ba b--black-20 pa2 mb2 db w-100" %> - <%= error_tag f, :priority %> -
+
+ <%= label f, :priority, class: "label" %> +
+ <%= text_input f, :priority, class: "input" %> +
+

+ <%= error_tag f, :priority %> +

+
-
- <%= label f, :enabled, class: "f6 b db mb2" %> - <%= checkbox f, :enabled %> - <%= error_tag f, :enabled %> -
+
+ +

+ <%= error_tag f, :enabled %> +

+
-
- <%= submit "Save" %> +
+ <%= submit "Save", class: "button is-primary" %> +
+ <% end %>
-<% end %> +
diff --git a/apps/fg_http/lib/fg_http_web/templates/rule/index.html.eex b/apps/fg_http/lib/fg_http_web/templates/rule/index.html.eex index 6624cef3a..cbac5cd0e 100644 --- a/apps/fg_http/lib/fg_http_web/templates/rule/index.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/rule/index.html.eex @@ -1,29 +1,33 @@ -

Listing Rules for Device <%= @device.name %>

+

Listing Rules for Device <%= @device.name %>

- - - - - - - - - +
ActionDestinationPortProtocolPriorityEnabled
+ + + + + + + + + + <%= for rule <- @rules do %> - - - - - - - - + + + + + + + + @@ -31,6 +35,8 @@
ActionDestinationPortProtocolPriorityEnabled
<%= rule.action %><%= rule.destination %><%= rule.port %><%= rule.protocol %><%= rule.priority %><%= rule.enabled %>
<%= rule.action %><%= rule.destination %><%= rule.port %><%= rule.protocol %><%= rule.priority %><%= rule.enabled %> <%= link "Show", to: Routes.rule_path(@conn, :show, rule) %> + | <%= link "Edit", to: Routes.rule_path(@conn, :edit, rule) %> + | <%= link "Delete", to: Routes.rule_path(@conn, :delete, rule), method: :delete, data: [confirm: "Are you sure?"] %>
-

- <%= link "New Rule", to: Routes.device_rule_path(@conn, :new, @device) %> -

+<%= + link "New Rule", + to: Routes.device_rule_path(@conn, :new, @device), + class: "button is-primary" +%> diff --git a/apps/fg_http/lib/fg_http_web/templates/rule/show.html.eex b/apps/fg_http/lib/fg_http_web/templates/rule/show.html.eex index 90198176b..f9afe3814 100644 --- a/apps/fg_http/lib/fg_http_web/templates/rule/show.html.eex +++ b/apps/fg_http/lib/fg_http_web/templates/rule/show.html.eex @@ -1,4 +1,4 @@ -

Show Rule

+

Show Rule