diff --git a/app/lib/prymn_web/components/core_components.ex b/app/lib/prymn_web/components/core_components.ex index 12b0e4e..23b2883 100644 --- a/app/lib/prymn_web/components/core_components.ex +++ b/app/lib/prymn_web/components/core_components.ex @@ -473,11 +473,7 @@ defmodule PrymnWeb.CoreComponents do <%= col[:label] %> - <%= if @gettext do %> - <%= gettext("Actions") %> - <% else %> - Actions - <% end %> + Actions diff --git a/app/lib/prymn_web/components/layouts/app.html.heex b/app/lib/prymn_web/components/layouts/app.html.heex index 83b54a8..b91bc3b 100644 --- a/app/lib/prymn_web/components/layouts/app.html.heex +++ b/app/lib/prymn_web/components/layouts/app.html.heex @@ -1,43 +1,39 @@ -
+
<%= gettext("Skip to content") %> -
-
- - +
+
+

codename

+
+ Prymn -

- v<%= Application.spec(:phoenix, :vsn) %> +

+ v<%= Application.spec(:prymn, :vsn) %>

-
- - @elixirphoenix - - - GitHub - - - Get Started - - <.link href={~p"/users/settings"} class="hover:text-zinc-700"> - <%= @current_user.email %> - - <.link href={~p"/auth/log_out"} method="delete" class="hover:text-zinc-700"> - Log out +
+ <.link class="px-3 py-4" href={~p"/users/settings"}> + <.icon name="hero-user" /> + <.icon name="hero-chevron-down" />
-
-
+
+
+
    +
  • Projects
  • +
  • Usage
  • +
  • Activities
  • +
  • Limits
  • +
  • Support
  • +
+
+
<.flash_group flash={@flash} /> <%= @inner_content %>
diff --git a/app/lib/prymn_web/components/layouts/root.html.heex b/app/lib/prymn_web/components/layouts/root.html.heex index 2439499..c37628a 100644 --- a/app/lib/prymn_web/components/layouts/root.html.heex +++ b/app/lib/prymn_web/components/layouts/root.html.heex @@ -4,7 +4,7 @@ - <.live_title suffix=" · Phoenix Framework"> + <.live_title suffix="|Prymn"> <%= assigns[:page_title] || "Prymn" %> diff --git a/app/lib/prymn_web/controllers/page_html/home.html.heex b/app/lib/prymn_web/controllers/page_html/home.html.heex deleted file mode 100644 index 2a2a822..0000000 --- a/app/lib/prymn_web/controllers/page_html/home.html.heex +++ /dev/null @@ -1,27 +0,0 @@ -
-
- -

- Phoenix Framework - - v<%= Application.spec(:phoenix, :vsn) %> - -

-

- Welcome -

-

- Create your server or your site -

-
- <.link navigate={~p"/servers"} class="block rounded bg-black px-4 py-2 text-white"> - Servers - -
-
-
diff --git a/app/lib/prymn_web/live/dashboard_live.ex b/app/lib/prymn_web/live/dashboard_live.ex new file mode 100644 index 0000000..c84437a --- /dev/null +++ b/app/lib/prymn_web/live/dashboard_live.ex @@ -0,0 +1,47 @@ +defmodule PrymnWeb.DashboardLive do + use PrymnWeb, :live_view + + @impl true + def render(assigns) do + ~H""" +
+
+

Good morning, <%= @current_user.email %>!

+

Your overview

+
+ +
+
+ 0 +

Total Servers

+ <.link class="text-sm text-blue-600" navigate={~p"/servers"}> + <.icon class="h-3 w-4" name="hero-arrow-right" /> View your servers + +
+
+ 0 +

Apps

+ <.link class="text-sm text-blue-600"> + <.icon class="h-3 w-4" name="hero-arrow-right" /> View your apps + +
+
+
+ +
+
+
+ + + +
+

15 November — 16 November

+
+
+
+
+
+
+ """ + end +end diff --git a/app/lib/prymn_web/live/server_live/index.html.heex b/app/lib/prymn_web/live/server_live/index.html.heex index 2039b9b..afee90f 100644 --- a/app/lib/prymn_web/live/server_live/index.html.heex +++ b/app/lib/prymn_web/live/server_live/index.html.heex @@ -1,38 +1,40 @@ -<.header> - Your servers - - <%= "#{Enum.count(@servers)} servers" %> - - <:actions> - <.button type="link" patch={~p"/servers/new"}>Connect a Server - - +
+ <.header> + Your servers + + <%= "#{Enum.count(@servers)} servers" %> + + <:actions> + <.button type="link" patch={~p"/servers/new"}>Connect a Server + + -
- <.link - :for={server <- @servers} - navigate={~p"/servers/#{server}"} - class="group block rounded-lg bg-gray-100 p-5 shadow-sm shadow-gray-300 hover:bg-black hover:text-white" - > -
-

<%= server.name %>

- <.server_status status={server.status} health={@healths[server.public_ip]} /> -
-
- IP: <%= server.public_ip || "N/A" %> - - <%= for {name, task} <- Enum.take(@healths[server.public_ip].tasks, 1) do %> -
In progress: <%= name %>
-
<%= task.progress %>
- <% end %> -
-
- +
+ <.link + :for={server <- @servers} + navigate={~p"/servers/#{server}"} + class="group block rounded-lg bg-gray-100 p-5 shadow-sm shadow-gray-300 hover:bg-black hover:text-white" + > +
+

<%= server.name %>

+ <.server_status status={server.status} health={@healths[server.public_ip]} /> +
+
+ IP: <%= server.public_ip || "N/A" %> + + <%= for {name, task} <- Enum.take(@healths[server.public_ip].tasks, 1) do %> +
In progress: <%= name %>
+
<%= task.progress %>
+ <% end %> +
+
+ +
+ + <.modal :if={@live_action == :new} id="server-modal" show on_cancel={JS.patch(~p"/servers")}> + <.live_component module={PrymnWeb.ServerLive.NewServer} id={:new} patch={~p"/servers"} /> +
- -<.modal :if={@live_action == :new} id="server-modal" show on_cancel={JS.patch(~p"/servers")}> - <.live_component module={PrymnWeb.ServerLive.NewServer} id={:new} patch={~p"/servers"} /> - diff --git a/app/lib/prymn_web/live/server_live/show.ex b/app/lib/prymn_web/live/server_live/show.ex index 5eb0683..09e5baa 100644 --- a/app/lib/prymn_web/live/server_live/show.ex +++ b/app/lib/prymn_web/live/server_live/show.ex @@ -23,7 +23,7 @@ defmodule PrymnWeb.ServerLive.Show do {:noreply, socket - |> assign(:health, health || %{message: "Connecting..."}) + |> assign(:health, health || %{message: "Connecting...", tasks: []}) |> assign(:page_title, server.name) |> assign(:server, server) |> assign(:dry_run, false) diff --git a/app/lib/prymn_web/live/server_live/show.html.heex b/app/lib/prymn_web/live/server_live/show.html.heex index b381b89..589acdf 100644 --- a/app/lib/prymn_web/live/server_live/show.html.heex +++ b/app/lib/prymn_web/live/server_live/show.html.heex @@ -1,110 +1,145 @@ -<.header> - - Server <%= @server.name %> - - <%= case @health.message do %> - <% "Connected" -> %> - - - <% "Disconnected" -> %> - - <% _ -> %> - - <% end %> - - - <:subtitle> - <%= @server.public_ip %> - - - -
- <%= for {name, task} <- @health.tasks do %> - Background task in progress: <%= name %> -

<%= task.progress %> complete

- <% end %> -
- -
-

- Connect to your server using root credentials and execute the following command: -

-
- - # - - <%= @registration_command %> +
+ <.header> + + + + + <%= case @health.message do %> + <% "Connected" -> %> + + + <% "Disconnected" -> %> + + <% _ -> %> + + <% end %> - - -
-
- -
-
-
-

<%= @sys_info.uptime || "" %>s

-

Uptime

-
-
-

<%= Enum.count(@sys_info.cpus || []) %>

-

CPUs

-
-
-

<%= calculate_cpu_usage(@sys_info.cpus) %>

-

CPU%

-
-
-

- <%= bytes_to_gigabytes(@sys_info.mem_total_bytes - @sys_info.mem_avail_bytes) %> - / - <%= bytes_to_gigabytes(@sys_info.mem_total_bytes) %> - GiB -

-

Memory

-
-
-

- <%= calculate_disk_used_percent(@sys_info.disks) %> - % -

-

Used Disk

-
-
- -
-
- <.input type="checkbox" name="dry_run" value={@dry_run} label="Enable dry-run operations" /> -
-
- -
-

System

-

- Updates: <%= @sys_info.updates_available %> pending updates. - <.button type="button" class="ml-4" phx-click="system_update"> - Update now + + <:subtitle> + <%= @server.public_ip %> + + <:actions> + <.button>+ New App + <.button class="border border-black bg-transparent text-black hover:text-white"> + Quick actions <.icon name="hero-chevron-down" /> -

- <%= output %> -

+ + +
+ <%= for {name, task} <- @health.tasks do %> + Background task in progress: <%= name %> +

<%= task.progress %> complete

+ <% end %> +
+
+

+ Connect to your server using root credentials and execute the following command:

-
+
+ + # + + <%= @registration_command %> + + + +
+
+
+
+
+

<%= @sys_info.uptime || "" %>s

+

Uptime

+
+
+

<%= Enum.count(@sys_info.cpus || []) %>

+

CPUs

+
+
+

<%= calculate_cpu_usage(@sys_info.cpus) %>

+

CPU%

+
+
+

+ <%= bytes_to_gigabytes(@sys_info.mem_total_bytes - @sys_info.mem_avail_bytes) %> + / + <%= bytes_to_gigabytes(@sys_info.mem_total_bytes) %> + GiB +

+

Memory

+
+
+

+ <%= calculate_disk_used_percent(@sys_info.disks) %> + % +

+

Used Disk

+
+
+
+
+ <.input type="checkbox" name="dry_run" value={@dry_run} label="Enable dry-run operations" /> +
+
+
+

System

+

+ Updates: <%= @sys_info.updates_available %> pending updates. + <.button type="button" class="ml-4" phx-click="system_update"> + Update now + +

+ <%= output %> +

+

+
+
+

+ Backups +

+ <.table id="backups" rows={[%{date: "2023-10-11"}, %{date: "2023-10-10"}]}> + <:col :let={backup} label="Date"><%= backup.date %> + <:action> + <.button>Restore + + +
+
+

+ Manage Services +

+ <.table + id="services" + rows={[%{name: "mariadb", status: "Active"}, %{name: "php8.0", status: "Disabled"}]} + > + <:col :let={service} label="Service"><%= service.name %> + <:col :let={service} label="Status"><%= service.status %> + <:action> + <.button>Activate + <.button>Deactivate + + +
+
+ <.back navigate={~p"/servers"}>Back to servers
- -<.back navigate={~p"/servers"}>Back to servers diff --git a/app/lib/prymn_web/router.ex b/app/lib/prymn_web/router.ex index 0548e6d..21ccd5c 100644 --- a/app/lib/prymn_web/router.ex +++ b/app/lib/prymn_web/router.ex @@ -27,10 +27,10 @@ defmodule PrymnWeb.Router do scope "/", PrymnWeb do pipe_through [:browser, :require_authenticated_user] - get "/", PageController, :home - live_session :require_authenticated_user, on_mount: [{PrymnWeb.UserAuth, :ensure_authenticated}] do + live "/", DashboardLive + live "/users/settings", UserSettingsLive live "/users/settings/confirm_email/:token", UserSettingsLive