Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #37 from mena-devs/profile-stats
Browse files Browse the repository at this point in the history
Enhance admin view of members with stats
  • Loading branch information
cnicolaou authored Mar 28, 2020
2 parents 369686a + f43b591 commit 95a7206
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 49 deletions.
17 changes: 17 additions & 0 deletions app/helpers/members_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module MembersHelper
def complete_profile(profile)
profile ? "Yes" : "No"
end

def display_provider(provider)
provider ? provider.titleize : "Email"
end

def display_user_name(user)
user.name.blank? ? details = "(Name not set yet)" : details = user.name
end

def display_user_description(biography)
biography.blank? ? "Biography not set yet" : truncate(biography, length: 200, omission: '...')
end
end
86 changes: 82 additions & 4 deletions app/views/directory/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
<% end %>
<!-- Looking for ends -->
</div>
<% end %>

<br/>
<br/>
<br/>
<br/>
<% end %>
<% unless @user.profile.twitter_handle.blank? %>

Expand All @@ -189,9 +189,87 @@

<br/>
<br/>

<% end %>
<% if current_user.admin? %>

<div class="alert alert-info" role="alert">
<h4>Details for Admins</h4>

<div class="row">
<div class="col-md-2">
Active
</div>
<div class="col-md-10">
<%= @user.active %>
</div>

<div class="col-md-2">
Profile complete?
</div>
<div class="col-md-10">
<%= @user.profile.complete? %>
</div>

<div class="col-md-2">
Created at
</div>
<div class="col-md-10">
<%= @user.created_at %> (<%= time_ago_in_words(@user.created_at) %>)
</div>

<div class="col-md-2">
Confirmed at
</div>
<div class="col-md-10">
<%= @user.confirmed_at %> (<%= time_ago_in_words(@user.confirmed_at) %>)
</div>

<div class="col-md-2">
Updated at
</div>
<div class="col-md-10">
<%= @user.updated_at %> (<%= time_ago_in_words(@user.updated_at) %>)
</div>

<div class="col-md-2">
Last signed in
</div>
<div class="col-md-10">
<%= @user.last_sign_in_at %> (<%= time_ago_in_words(@user.last_sign_in_at) %>)
</div>

<div class="col-md-2">
Sign in count
</div>
<div class="col-md-10">
<%= @user.sign_in_count %>
</div>


<div class="col-md-2">
Last sign in IP
</div>
<div class="col-md-10">
<%= @user.last_sign_in_ip %>
</div>

<div class="col-md-2">
Provider
</div>
<div class="col-md-10">
<%= @user.provider %>
</div>

<div class="col-md-2">
Time zone
</div>
<div class="col-md-10">
<%= @user.time_zone %>
</div>
</div>
</div>
<% end %>
</div>
</div>
</section>
6 changes: 3 additions & 3 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@

<div class="col_one_fourth nobottommargin center" data-animate="bounceIn" data-delay="200">
<i class="i-plain i-xlarge divcenter nobottommargin icon-magic"></i>
<div class="counter counter-lined"><span data-from="0" data-to="340" data-refresh-interval="100" data-speed="2500"></span>+</div>
<div class="counter counter-lined"><span data-from="0" data-to="816" data-refresh-interval="100" data-speed="2500"></span>+</div>
<h5>Active Members and Counting</h5>
</div>

<div class="col_one_fourth nobottommargin center" data-animate="bounceIn" data-delay="400">
<i class="i-plain i-xlarge divcenter nobottommargin icon-file-text"></i>
<div class="counter counter-lined"><span data-from="0" data-to="19" data-refresh-interval="25" data-speed="3500"></span>*</div>
<div class="counter counter-lined"><span data-from="0" data-to="23" data-refresh-interval="25" data-speed="3500"></span>*</div>
<h5>Channels</h5>
</div>

<div class="col_one_fourth nobottommargin center col_last" data-animate="bounceIn" data-delay="600">
<i class="i-plain i-xlarge divcenter nobottommargin icon-time"></i>
<div class="counter counter-lined"><span data-from="60" data-to="11300" data-refresh-interval="30" data-speed="2700"></span>+</div>
<div class="counter counter-lined"><span data-from="60" data-to="10000" data-refresh-interval="30" data-speed="2700"></span>+</div>
<h5>Messages Per Week (on average)</h5>
</div>

Expand Down
24 changes: 4 additions & 20 deletions app/views/invitations/admin_index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="container clearfix">
<div class="row clearfix">
<div class="col-md-8 col-xs-8 nopadding">
<h1>Sent invitations [ADMIN]</h1>
<h1>Sent invitations - Admin view</h1>
<span>Browse all invitations sent on MENAdevs</span>
</div>
</div>
Expand All @@ -26,29 +26,13 @@
<% if @admin_invitations %>
<%= render "admin_invitations_table", locals: { admin_invitations: @admin_invitations } %>

<%= paginate @admin_invitations %>
<div class="text-center">
<%= paginate @admin_invitations %>
</div>
<% end %>

</div>

</div>

</section><!-- #content end -->


<!-- Bootstrap Data Table Plugin -->
<%= javascript_include_tag "components/bs-datatable.js", "data-turbolinks-track" => false %>
<%= stylesheet_link_tag('bs-datatable', media: 'all',
'data-turbolinks-track': false) %>

<script>

$(document).ready(function() {
$('#admin-invitations-datatable').dataTable(
{
aaSorting: [[5, 'desc']]
}
);
});

</script>
36 changes: 24 additions & 12 deletions app/views/members/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="container clearfix">
<div class="row clearfix">
<div class="col-md-8 col-xs-12">
<h1>Platform users</h1>
<h1>Platform users - Admin view</h1>
<span class='hidden-xs'><%= pluralize(@users_count, 'Member') %></span>
</div>
</div>
Expand All @@ -29,7 +29,11 @@
<tr>
<th>Name</th>
<th></th>
<th>Profile</th>
<th>Provider</th>
<th>Join date</th>
<th>Signed in last</th>
<th>Sign in count</th>
</tr>
</thead>
<tbody>
Expand All @@ -38,21 +42,29 @@
<td width='5%'>
<%= image_tag(user.profile.avatar.url(:thumb), size: '50x50', class: 'img-thumbnail') %>
</td>
<td width='80%'>
<td width='50%'>
<%= link_to directory_user_path(user) do %>
<%= user.name %> | <%= user.email %>
<% if user_signed_in? && current_user == user %>
<div class="btn btn-xs btn-primary">
<%= fa_icon("check") %>
me
</div>
<% end %>
<%= display_user_name(user) %>
<% end %>
<br/>
<small><%= user.profile.biography %></small>
<%= user.email %>
<br/>
<small><%= display_user_description(user.profile.biography) %></small>
</td>
<td>
<%= complete_profile(user.profile.complete?) %>
</td>
<td>
<%= display_provider(user.provider) %>
</td>
<td>
<%= user.created_at.try(:strftime, '%a %e %b %Y') %>
</td>
<td>
<%= user.last_sign_in_at.try(:strftime, '%a %e %b %Y, %H:%m:%S') %>
</td>
<td width='15%'>
<%= user.created_at.strftime('%A %e %B %Y ') %>
<td>
<%= user.sign_in_count %>
</td>
</tr>
<% end %>
Expand Down
16 changes: 7 additions & 9 deletions app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

<div>
<address>
<strong>Headquarters:</strong><br>
No fixed office space, we're spread across Lebanon and the region<br>
<strong>Headquarters:</strong>
<br/>
We have no fixed space as we are an online community.
<br/>
Our members are spread across the world but mainly clustered in the middle-east region.<br>
</address>
</div>
</div>
Expand All @@ -26,12 +29,12 @@
<div class="row">

<div class="col-md-6 bottommargin-sm">
<div class="counter counter-small"><span data-from="50" data-to="1056000" data-refresh-interval="80" data-speed="3000" data-comma="true"></span></div>
<div class="counter counter-small"><span data-from="50" data-to="1368306" data-refresh-interval="80" data-speed="3000" data-comma="true"></span></div>
<h5 class="nobottommargin">Total Messages</h5>
</div>

<div class="col-md-6 bottommargin-sm">
<div class="counter counter-small"><span data-from="10" data-to="340" data-refresh-interval="50" data-speed="2000" data-comma="true"></span></div>
<div class="counter counter-small"><span data-from="10" data-to="816" data-refresh-interval="50" data-speed="2000" data-comma="true"></span></div>
<h5 class="nobottommargin">Members</h5>
</div>

Expand Down Expand Up @@ -99,11 +102,6 @@
<i class="icon-github"></i>
<i class="icon-github"></i>
</a>

<a href="#" class="social-icon si-small si-borderless si-linkedin">
<i class="icon-linkedin"></i>
<i class="icon-linkedin"></i>
</a>
</div>

<div class="clear"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<% end %>
<%= content_tag(:li) do %>
<%= navbar_link_to('History',
<%= navbar_link_to('Invitations Archive',
invitations_path) %>
<% end %>
<% end %>
Expand Down

0 comments on commit 95a7206

Please sign in to comment.