Skip to content

Commit

Permalink
Update dashboard ui design
Browse files Browse the repository at this point in the history
  • Loading branch information
mdromi committed Feb 12, 2024
1 parent 4f2c11e commit 4b3ec9e
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 98 deletions.
67 changes: 35 additions & 32 deletions app/views/admin/dashboard/guest_user_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
<div class="border-t border-gray-300 py-6">
<%= render 'menu' %>
<h1 class="text-lg font-semibold">Guest user links</h1>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP Address</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Views</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Copy Link</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @guest_user_links.each.each do |link| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap"><%= link.ip_address %></td>
<td class="px-6 py-4 whitespace-nowrap">
<%= render partial: 'shared/link_component', locals: { link: link, view_path: view_path(link), title_length: 20, description_length: 30 } %>
</td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to pluralize( link.views_count, "views"), link, class: "px-1 py-1 text-sm rounded bg-gray-100 no-underline" %></td>
<td class="px-6 py-4 whitespace-nowrap"><%= button_tag "Copy", class: "text-sm px-1 py-1 rounded bg-gray-100 no-underline", data: {controller: "clipboard", clipboard_text: view_url(link)} %></td>
<td class="px-6 py-4 whitespace-nowrap">
<%= button_to "Delete", link, method: :delete, class: "text-red-500 hover:underline", data: { turbo_confirm: "Are you sure?" }, params: { redirect_to: 'current_page' } %>
</td>
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<%= render 'menu' %>
<p class="mt-1 max-w-2xl text-center text-sm text-gray-500">Summary of all guest links</p>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">IP Address</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Views</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Copy Link</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</div>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @guest_user_links.each do |link| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap"><%= link.ip_address %></td>
<td class="px-6 py-4 whitespace-nowrap">
<%= render partial: 'shared/link_component', locals: { link: link, view_path: view_path(link), title_length: 20, description_length: 30 } %>
</td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to pluralize(link.views_count, "view"), link, class: "px-1 py-1 text-sm rounded bg-gray-100 no-underline" %></td>
<td class="px-6 py-4 whitespace-nowrap">
<%= button_tag "Copy", class: "text-sm px-1 py-1 rounded bg-gray-100 no-underline", data: { controller: "clipboard", clipboard_text: view_url(link) } %>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<%= button_to "Delete", link, method: :delete, class: "text-red-500 hover:underline", data: { turbo_confirm: "Are you sure?" }, params: { redirect_to: request.original_url } %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</div>
</div>
28 changes: 19 additions & 9 deletions app/views/admin/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<div class="border-t border-gray-300 py-6">
<%= render 'menu' %>
<h1>Dashboard</h1>
<p>Registered Users Amount: <%= registered_users_amount %></p>
<p>Guest User Links Amount: <%= guest_user_links_amount %></p>
<p>All Users Amount: <%= all_users_amount %></p>
<%= pie_chart [["Guest Users #{guest_user_links_amount}", guest_user_links_amount], ["Registered Users #{registered_users_amount}", registered_users_amount]] %>
<h1>Users Chart</h1>
<%==line_chart user_signups_data(7), download: true %>
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<%= render 'menu' %>
<p class="mt-1 max-w-2xl text-center text-sm text-gray-500">Summary of user activity</p>
</div>
<div class="border-t border-gray-200">
<dl>
<div class="bg-white px-4 py-5">
<h2 class="text-lg leading-6 font-medium text-gray-900">All Users Ratio</h2>
<%= pie_chart [["Registered Users #{registered_users_amount}", registered_users_amount], ["Guest Users #{guest_user_links_amount}", guest_user_links_amount], ["Total Users #{all_users_amount}"]],
height: '300px',
colors: ['#3B82F6', '#22C55E', '#EAB308'] %>
</div>
<div class="bg-gray-50 px-4 py-5">
<h2 class="text-lg leading-6 font-medium text-gray-900">Users Chart (Last 7 Days)</h2>
<%== line_chart user_signups_data(7), download: true, height: '300px' %>
</div>
</dl>
</div>
</div>
71 changes: 37 additions & 34 deletions app/views/admin/dashboard/links.html.erb
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
<div class="border-t border-gray-300 py-6">
<%= render 'menu' %>
<h1 class="text-lg font-semibold">Links</h1>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total Views</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Copy Link</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">User</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @links.each do |link| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap">
<%= render partial: 'shared/link_component', locals: { link: link, view_path: view_path(link), title_length: 20, description_length: 30 } %>
</td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to pluralize( link.views_count, "views"), link, class: "px-1 py-1 text-sm rounded bg-gray-100 no-underline" %></td>
<td class="px-6 py-4 whitespace-nowrap"><%= button_tag "Copy", class: "text-sm px-1 py-1 rounded bg-gray-100 no-underline", data: {controller: "clipboard", clipboard_text: view_url(link)} %></td>
<td class="px-6 py-4 whitespace-nowrap">
<% if link.user_id.present? %>
<%= link_to link.user.email, profile_path(link.user), class: "text-blue-500 hover:underline" %>
<% else %>
Guest User
<% end %>
</td>
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<%= render 'menu' %>
<p class="mt-1 max-w-2xl text-center text-sm text-gray-500">Summary of all links</p>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Total Views</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Copy Link</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">User</th>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</div>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @links.each do |link| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap">
<%= render partial: 'shared/link_component', locals: { link: link, view_path: view_path(link), title_length: 20, description_length: 30 } %>
</td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to pluralize(link.views_count, "view"), link, class: "px-1 py-1 text-sm rounded bg-gray-100 no-underline" %></td>
<td class="px-6 py-4 whitespace-nowrap">
<%= button_tag "Copy", class: "text-sm px-1 py-1 rounded bg-gray-100 no-underline", data: { controller: "clipboard", clipboard_text: view_url(link) } %>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<% if link.user_id.present? %>
<%= link_to link.user.email, profile_path(link.user), class: "text-blue-500 hover:underline" %>
<% else %>
Guest User
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</div>
</div>
48 changes: 25 additions & 23 deletions app/views/admin/dashboard/users.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<div class="border-t border-gray-300 py-6">
<%= render 'menu' %>
<h1 class="text-lg font-semibold">Users</h1>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Total Links</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Profile</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @users.each do |user| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap"><%= user.email %></td>
<td class="px-6 py-4 whitespace-nowrap text-center"><%= find_links_by_user_id(user.id).count %></td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to 'View Profile', profile_path(user), class: 'text-blue-500 hover:underline' %></td>
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 sm:px-6">
<%= render 'menu' %>
<p class="mt-1 max-w-2xl text-center text-sm text-gray-500">Summary of all user</p>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">Total Links</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Profile</th>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<% @users.each do |user| %>
<tr class="hover:bg-gray-50 transition-colors duration-300">
<td class="px-6 py-4 whitespace-nowrap"><%= user.email %></td>
<td class="px-6 py-4 whitespace-nowrap text-center"><%= find_links_by_user_id(user.id).count %></td>
<td class="px-6 py-4 whitespace-nowrap"><%= link_to 'View Profile', profile_path(user), class: 'text-blue-500 hover:underline' %></td>
</tr>
<% end %>
</tbody>
</table>
<%= render partial: 'shared/pagination', locals: { pagy: @pagy } %>
</div>
</div>

0 comments on commit 4b3ec9e

Please sign in to comment.