Implements recent items tabs and top submitter for dashboard
This commit is contained in:
parent
25a1c116fd
commit
28293cb4c4
11 changed files with 186 additions and 1 deletions
|
|
@ -79,3 +79,7 @@ body {
|
||||||
.todolist-ok span {
|
.todolist-ok span {
|
||||||
color: #02A10F;
|
color: #02A10F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.top-submitter img {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,12 @@ class Admin::ConferenceController < ApplicationController
|
||||||
@conferences = Conference.select('id, short_title, color, start_date,
|
@conferences = Conference.select('id, short_title, color, start_date,
|
||||||
registration_end_date, registration_start_date')
|
registration_end_date, registration_start_date')
|
||||||
|
|
||||||
|
@recent_users = User.limit(5).order(created_at: :desc)
|
||||||
|
@recent_events = Event.limit(5).order(created_at: :desc)
|
||||||
|
@recent_registrations = Registration.limit(5).order(created_at: :desc)
|
||||||
|
|
||||||
|
@top_submitter = Conference.get_top_submitter
|
||||||
|
|
||||||
@submissions = {}
|
@submissions = {}
|
||||||
@cfp_weeks = [0]
|
@cfp_weeks = [0]
|
||||||
|
|
||||||
|
|
@ -78,6 +84,7 @@ class Admin::ConferenceController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@conference = Conference.find_by(short_title: params[:id])
|
@conference = Conference.find_by(short_title: params[:id])
|
||||||
@conference_progress = @conference.get_status
|
@conference_progress = @conference.get_status
|
||||||
|
@top_submitter = @conference.get_top_submitter
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json { render json: @conference.to_json }
|
format.json { render json: @conference.to_json }
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,27 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def label_for(event_state)
|
||||||
|
result = ''
|
||||||
|
case event_state
|
||||||
|
when 'Withdrawn'
|
||||||
|
result = 'label label-danger'
|
||||||
|
when 'Review Pending'
|
||||||
|
result = 'label label-primary'
|
||||||
|
when 'Accepted (confirmation pending)'
|
||||||
|
result = 'label label-success'
|
||||||
|
when 'Confirmed'
|
||||||
|
result = 'label label-success'
|
||||||
|
when 'Rejected'
|
||||||
|
result = 'label label-warning'
|
||||||
|
when 'Cancelled'
|
||||||
|
result = 'label label-danger'
|
||||||
|
when 'Submitted'
|
||||||
|
result = 'label label-primary'
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
def icon_for_todo(bool)
|
def icon_for_todo(bool)
|
||||||
if bool
|
if bool
|
||||||
return 'glyphicon glyphicon-ok'
|
return 'glyphicon glyphicon-ok'
|
||||||
|
|
|
||||||
|
|
@ -239,8 +239,46 @@ class Conference < ActiveRecord::Base
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a hash with person => submissions ordered by submissions for all conferences
|
||||||
|
#
|
||||||
|
# ====Returns
|
||||||
|
# * +hash+ -> person: submissions
|
||||||
|
def self.get_top_submitter(limit = 5)
|
||||||
|
submitter = EventPerson.where('event_role = ?', 'submitter').limit(limit).group(:person_id)
|
||||||
|
counter = submitter.count
|
||||||
|
calculate_person_submission_hash(submitter, counter)
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a hash with person => submissions ordered by submissions
|
||||||
|
#
|
||||||
|
# ====Returns
|
||||||
|
# * +hash+ -> person: submissions
|
||||||
|
def get_top_submitter(limit = 5)
|
||||||
|
submitter = EventPerson.joins(:event).
|
||||||
|
where('event_role = ? and conference_id = ?', 'submitter', id).
|
||||||
|
limit(limit).group(:person_id)
|
||||||
|
|
||||||
|
counter = submitter.count
|
||||||
|
Conference.calculate_person_submission_hash(submitter, counter)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a hash with person => submissions ordered by submissions for all conferences
|
||||||
|
#
|
||||||
|
# ====Returns
|
||||||
|
# * +hash+ -> person: submissions
|
||||||
|
def self.calculate_person_submission_hash(submitter, counter)
|
||||||
|
result = {}
|
||||||
|
submitter.each do |s|
|
||||||
|
result[s.person] = counter[s.person_id]
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Creates a venue and sets self.venue_id to it's id. Used as before_create.
|
# Creates a venue and sets self.venue_id to it's id. Used as before_create.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,10 @@ class User < ActiveRecord::Base
|
||||||
details += "#{self.created_at}<br>"
|
details += "#{self.created_at}<br>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def confirmed?
|
||||||
|
!confirmed_at.nil?
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def create_person
|
def create_person
|
||||||
# TODO Search people for existing email address, add to their account
|
# TODO Search people for existing email address, add to their account
|
||||||
|
|
|
||||||
18
app/views/admin/conference/_recent_registrations.html.haml
Normal file
18
app/views/admin/conference/_recent_registrations.html.haml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
- if recent_registrations && !recent_registrations.empty?
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th #
|
||||||
|
%th Public Name
|
||||||
|
%th Conference
|
||||||
|
%th Date
|
||||||
|
- recent_registrations.each_with_index do |registration, index|
|
||||||
|
%tbody
|
||||||
|
%tr
|
||||||
|
%td #{index + 1}
|
||||||
|
%td #{registration.public_name}
|
||||||
|
%td #{registration.conference.title}
|
||||||
|
%td #{registration.created_at.strftime('%m/%d/%Y')}
|
||||||
|
- else
|
||||||
|
%h5.text-warning.text-center
|
||||||
|
No registrations!
|
||||||
21
app/views/admin/conference/_recent_submissions.html.haml
Normal file
21
app/views/admin/conference/_recent_submissions.html.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
- if recent_events && !recent_events.empty?
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th #
|
||||||
|
%th Submitter
|
||||||
|
%th Title
|
||||||
|
%th Conference
|
||||||
|
%th Status
|
||||||
|
- recent_events.each_with_index do |event, index|
|
||||||
|
%tbody
|
||||||
|
%tr
|
||||||
|
%td #{index + 1}
|
||||||
|
%td #{event.submitter}
|
||||||
|
%td #{event.title}
|
||||||
|
%td #{event.conference.title}
|
||||||
|
%td
|
||||||
|
.span{'class'=>label_for(event.public_state)} #{event.public_state}
|
||||||
|
- else
|
||||||
|
%h5.text-warning.text-center
|
||||||
|
No submissions!
|
||||||
22
app/views/admin/conference/_recent_users.html.haml
Normal file
22
app/views/admin/conference/_recent_users.html.haml
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
- if recent_users && !recent_users.empty?
|
||||||
|
%table.table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th #
|
||||||
|
%th E-Mail
|
||||||
|
%th Date registered
|
||||||
|
%th Status
|
||||||
|
- recent_users.each_with_index do |user, index|
|
||||||
|
%tbody
|
||||||
|
%tr
|
||||||
|
%td #{index}
|
||||||
|
%td #{user.email}
|
||||||
|
%td #{user.created_at.strftime('%m/%d/%Y')}
|
||||||
|
%td
|
||||||
|
- if user.confirmed?
|
||||||
|
%span.label.label-success Confirmed
|
||||||
|
-else
|
||||||
|
%span.label.label-danger Unconfirmed
|
||||||
|
- else
|
||||||
|
%h5.text-warning.text-center
|
||||||
|
No sign ups!
|
||||||
17
app/views/admin/conference/_top_submitter.html.haml
Normal file
17
app/views/admin/conference/_top_submitter.html.haml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
.row
|
||||||
|
%h3
|
||||||
|
Top Submitter
|
||||||
|
- if @top_submitter && !@top_submitter.empty?
|
||||||
|
- @top_submitter.each do |key, value|
|
||||||
|
.row.top-submitter
|
||||||
|
.col-md-2
|
||||||
|
= image_tag(key.gravatar_url(size: '25'), title: "Yo #{key.public_name}!", :alt => '', 'class'=>'img-circle img-responsive text-center')
|
||||||
|
.col-md-10
|
||||||
|
%h4
|
||||||
|
#{key}
|
||||||
|
%div
|
||||||
|
%small
|
||||||
|
#{pluralize(value, 'submission')}
|
||||||
|
- else
|
||||||
|
%h4.text-warning
|
||||||
|
No submissions!
|
||||||
|
|
@ -11,3 +11,34 @@
|
||||||
= render partial: 'registrations', locals: { conferences: @conferences, registrations: @registrations,
|
= render partial: 'registrations', locals: { conferences: @conferences, registrations: @registrations,
|
||||||
registration_weeks: @registration_weeks }
|
registration_weeks: @registration_weeks }
|
||||||
.col-md-4
|
.col-md-4
|
||||||
|
.col-md-8
|
||||||
|
.row
|
||||||
|
%ul.nav.nav-tabs#recentTable
|
||||||
|
%li.active
|
||||||
|
%a{:href=>"#recent_user", "data-toggle"=>"tab"}
|
||||||
|
%span.glyphicon.glyphicon-user
|
||||||
|
Recent Users
|
||||||
|
%li
|
||||||
|
%a{:href=>"#recent_reg", "data-toggle"=>"tab"}
|
||||||
|
%span.glyphicon.glyphicon-star
|
||||||
|
Recent Registrations
|
||||||
|
%li
|
||||||
|
%a{:href=>"#recent_submissions", "data-toggle"=>"tab"}
|
||||||
|
%span.glyphicon.glyphicon-comment
|
||||||
|
Recent Submissions
|
||||||
|
.tab-content
|
||||||
|
.tab-pane.active#recent_user
|
||||||
|
= render partial: 'recent_users', locals: {recent_users: @recent_users}
|
||||||
|
.tab-pane#recent_reg
|
||||||
|
= render partial: 'recent_registrations', locals: {recent_registrations: @recent_registrations}
|
||||||
|
.tab-pane#recent_submissions
|
||||||
|
= render partial: 'recent_submissions', locals: {recent_events: @recent_events}
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'top_submitter', locals: {top_submitter: @top_submitter}
|
||||||
|
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$('#recentTable a').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).tab('show');
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,5 @@
|
||||||
.row
|
.row
|
||||||
.col-md-4
|
.col-md-4
|
||||||
= render partial: 'todo_list', locals: { conference_progress: @conference_progress }
|
= render partial: 'todo_list', locals: { conference_progress: @conference_progress }
|
||||||
|
.col-md-4
|
||||||
|
= render partial: 'top_submitter', locals: {top_submitter: @top_submitter}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue