Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/phoenix_kit_web/components/admin_nav.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ defmodule PhoenixKitWeb.AdminNav do
d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"
/>
</svg>
<% "modules" -> %>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"
/>
</svg>
<% _ -> %>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
Expand Down
15 changes: 11 additions & 4 deletions lib/phoenix_kit_web/components/layout_wrapper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ defmodule PhoenixKitWeb.Components.LayoutWrapper do
current_path={@current_path || ""}
/>

<.admin_nav_item
href="/phoenix_kit/admin/modules"
icon="modules"
label="Modules"
current_path={@current_path || ""}
/>

<div class="divider my-3"></div>

<!-- User Management Section -->
Expand Down Expand Up @@ -262,14 +269,14 @@ defmodule PhoenixKitWeb.Components.LayoutWrapper do
this.setTheme(savedTheme);
this.setupListeners();
},

setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('phoenix_kit_theme', theme);

// Update slider position via CSS data attribute
document.documentElement.setAttribute('data-theme', theme);

// Update active state for all theme buttons
document.querySelectorAll('[data-theme-target]').forEach(btn => {
if (btn.dataset.themeTarget === theme) {
Expand All @@ -279,7 +286,7 @@ defmodule PhoenixKitWeb.Components.LayoutWrapper do
}
});
},

setupListeners() {
// Listen to Phoenix LiveView theme events
document.addEventListener('phx:set-admin-theme', (e) => {
Expand Down
1 change: 1 addition & 0 deletions lib/phoenix_kit_web/integration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ defmodule PhoenixKitWeb.Integration do
live "/admin/users/new", Users.UserFormLive, :new
live "/admin/users/edit/:id", Users.UserFormLive, :edit
live "/admin/roles", Live.RolesLive, :index
live "/admin/modules", Live.ModulesLive, :index
end
end
end
Expand Down
20 changes: 20 additions & 0 deletions lib/phoenix_kit_web/live/modules_live.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule PhoenixKitWeb.Live.ModulesLive do
use PhoenixKitWeb, :live_view

def mount(_params, session, socket) do
# Get current path for navigation
current_path = get_current_path(socket, session)

socket =
socket
|> assign(:current_path, current_path)
|> assign(:page_title, "Modules")

{:ok, socket}
end

defp get_current_path(_socket, _session) do
# For ModulesLive, always return modules path
"/phoenix_kit/admin/modules"
end
end
49 changes: 49 additions & 0 deletions lib/phoenix_kit_web/live/modules_live.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<PhoenixKitWeb.Components.LayoutWrapper.app_layout
flash={@flash}
phoenix_kit_current_scope={assigns[:phoenix_kit_current_scope]}
page_title="PhoenixKit Modules"
current_path={@current_path}
>
<div class="container flex flex-col mx-auto px-4 py-6">
<!-- Header Section -->
<header class="w-full relative mb-6">
<!-- Back Button (Left aligned) -->
<.link
navigate="/phoenix_kit/admin/dashboard"
class="btn btn-outline btn-primary btn-sm absolute left-0 top-0 -mb-12"
>
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M10 19l-7-7m0 0l7-7m-7 7h18"
/>
</svg>
Back to Dashboard
</.link>

<!-- Title Section -->
<div class="text-center">
<h1 class="text-4xl font-bold text-base-content mb-3">Modules Management</h1>
<p class="text-lg text-base-content">Manage system modules and extensions</p>
</div>
</header>

<div class="card bg-base-100 shadow-xl">
<div class="card-body">
<h2 class="card-title text-xl mb-4">Available Modules</h2>
<div class="text-center py-12">
<div class="text-6xl mb-4">🧩</div>
<h3 class="text-xl font-semibold text-base-content mb-2">
Module System Coming Soon
</h3>
<p class="text-base-content/70 max-w-md mx-auto">
This section will allow you to manage and configure system modules,
extensions, and integrations for your PhoenixKit application.
</p>
</div>
</div>
</div>
</div>
</PhoenixKitWeb.Components.LayoutWrapper.app_layout>
72 changes: 36 additions & 36 deletions lib/phoenix_kit_web/live/users_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
current_path={@current_path}
>
<div class="container flex-col mx-auto px-4 py-6">
<!-- Header Section -->
<%!-- Header Section --%>
<header class="w-full relative mb-6">
<!-- Back Button (Left aligned) -->
<%!-- Back Button (Left aligned) --%>
<.link
navigate="/phoenix_kit/admin/dashboard"
class="btn btn-outline btn-primary btn-sm absolute left-0 top-0 -mb-12"
Expand All @@ -23,15 +23,15 @@
</svg>
Back to Dashboard
</.link>
<!-- Title Section -->

<%!-- Title Section --%>
<div class="text-center">
<h1 class="text-4xl font-bold text-base-content mb-3">User Management</h1>
<p class="text-lg text-base-content">Manage user accounts and roles</p>
</div>
</header>
<!-- Role Management Modal -->

<%!-- Role Management Modal --%>
<%= if @show_role_modal && @managing_user do %>
<div class="modal modal-open">
<div class="modal-box max-w-2xl">
Expand Down Expand Up @@ -90,11 +90,11 @@
</div>
</div>
<% end %>
<!-- Controls -->

<%!-- Controls --%>
<div class="bg-base-200 rounded-lg p-6 mb-6">
<div class="flex flex-col lg:flex-row gap-4">
<!-- Search -->
<%!-- Search --%>
<div class="flex-1">
<label class="label">
<span class="label-text">Search by email or name</span>
Expand All @@ -109,8 +109,8 @@
/>
</form>
</div>
<!-- Role Filter -->

<%!-- Role Filter --%>
<div class="w-full lg:w-48">
<label class="label">
<span class="label-text">Filter by role</span>
Expand All @@ -124,8 +124,8 @@
</select>
</form>
</div>
<!-- Add User Button -->

<%!-- Add User Button --%>
<div class="w-full lg:w-48">
<label class="label">
<span class="label-text">Quick Actions</span>
Expand All @@ -147,8 +147,8 @@
</div>
</div>
</div>
<!-- Users Table -->

<%!-- Users Table --%>
<div class="bg-base-100 rounded-lg shadow-md overflow-hidden">
<%= if length(@users) > 0 do %>
<div class="overflow-x-auto">
Expand Down Expand Up @@ -216,7 +216,7 @@
</td>
<td>
<div class="flex flex-wrap gap-1">
<!-- Edit User -->
<%!-- Edit User --%>
<.link
navigate={"/phoenix_kit/admin/users/edit/#{user.id}"}
class="btn btn-xs btn-outline btn-secondary"
Expand All @@ -237,8 +237,8 @@
</svg>
Edit
</.link>
<!-- Role Management -->

<%!-- Role Management --%>
<%= if user.id != @phoenix_kit_current_user.id do %>
<button
class="btn btn-xs btn-outline btn-primary"
Expand Down Expand Up @@ -268,8 +268,8 @@
Manage Roles
</button>
<% end %>
<!-- Status Toggle -->

<%!-- Status Toggle --%>
<%= if user.id != @phoenix_kit_current_user.id && user_primary_role(user) != "Owner" do %>
<button
class={"btn btn-xs btn-outline #{if user.is_active, do: "btn-warning", else: "btn-success"}"}
Expand Down Expand Up @@ -325,8 +325,8 @@
</tbody>
</table>
</div>
<!-- Pagination -->

<%!-- Pagination --%>
<%= if @total_pages > 1 do %>
<div class="flex justify-center p-4 border-t border-base-300">
<div class="join">
Expand All @@ -343,7 +343,7 @@
</div>
<% end %>
<% else %>
<!-- Empty state -->
<%!-- Empty state --%>
<div class="text-center py-12">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -382,12 +382,12 @@
</div>
<% end %>
</div>
<!-- Enhanced Stats -->

<%!-- Enhanced Stats --%>
<div class="mt-8">
<h3 class="text-lg font-semibold text-base-content mb-6">User Statistics</h3>
<!-- Main Role Stats -->

<%!-- Main Role Stats --%>
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<div class="bg-gradient-to-br from-blue-500 to-blue-600 text-white rounded-xl p-4 shadow-lg">
<div class="flex items-center gap-3">
Expand Down Expand Up @@ -437,10 +437,10 @@
</div>
</div>
</div>
<!-- Secondary Stats - Gradient Cards -->

<%!-- Secondary Stats - Gradient Cards --%>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<!-- Active Users -->
<%!-- Active Users --%>
<div class="bg-gradient-to-br from-green-500 via-green-600 to-emerald-600 text-white rounded-2xl p-6 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105">
<div class="flex items-center justify-between mb-4">
<div class="p-2 bg-white/20 rounded-lg">
Expand All @@ -456,8 +456,8 @@
<div class="text-green-100 font-medium">Active Users</div>
<div class="text-green-200 text-xs mt-1">Online users</div>
</div>
<!-- Inactive Users -->

<%!-- Inactive Users --%>
<div class="bg-gradient-to-br from-red-500 via-red-600 to-rose-600 text-white rounded-2xl p-6 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105">
<div class="flex items-center justify-between mb-4">
<div class="p-2 bg-white/20 rounded-lg">
Expand All @@ -473,8 +473,8 @@
<div class="text-red-100 font-medium">Inactive Users</div>
<div class="text-red-200 text-xs mt-1">Disabled</div>
</div>
<!-- Confirmed Users -->

<%!-- Confirmed Users --%>
<div class="bg-gradient-to-br from-blue-500 via-blue-600 to-cyan-600 text-white rounded-2xl p-6 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105">
<div class="flex items-center justify-between mb-4">
<div class="p-2 bg-white/20 rounded-lg">
Expand All @@ -492,8 +492,8 @@
<div class="text-blue-100 font-medium">Confirmed</div>
<div class="text-blue-200 text-xs mt-1">Verified emails</div>
</div>
<!-- Pending Users -->

<%!-- Pending Users --%>
<div class="bg-gradient-to-br from-yellow-500 via-orange-500 to-amber-600 text-white rounded-2xl p-6 shadow-xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105">
<div class="flex items-center justify-between mb-4">
<div class="p-2 bg-white/20 rounded-lg">
Expand Down