Skip to content
Snippets Groups Projects
Commit 72a325ea authored by Anusha Ranganathan's avatar Anusha Ranganathan Committed by Johannes Frenzel
Browse files

Display buttons to easily access groups

parent c3ffd813
No related branches found
No related tags found
1 merge request!361Display buttons to easily access groups
# frozen_string_literal: true
module Hyrax
class DashboardController < ApplicationController
include Blacklight::Base
include Hyrax::Breadcrumbs
include HyraxHelper
with_themed_layout 'dashboard'
before_action :authenticate_user!
before_action :build_breadcrumbs, only: [:show]
before_action :set_date_range
##
# @!attribute [rw] sidebar_partials
# @return [Hash]
#
# @example Add a custom partial to the tasks sidebar block
# Hyrax::DashboardController.sidebar_partials[:tasks] << "hyrax/dashboard/sidebar/custom_task"
class_attribute :sidebar_partials
self.sidebar_partials = { activity: [], configuration: [], repository_content: [], tasks: [] }
def show
@collections_to_display = list_collections_to_display
if can? :read, :admin_dashboard
@presenter = Hyrax::Admin::DashboardPresenter.new
@admin_set_rows = Hyrax::AdminSetService.new(self).search_results_with_work_count(:read)
render 'show_admin'
else
@presenter = Dashboard::UserPresenter.new(current_user, view_context, params[:since])
render 'show_user'
end
end
private
def set_date_range
@start_date = params[:start_date] || Time.zone.today - 1.month
@end_date = params[:end_date] || Time.zone.today + 1.day
end
end
end
\ No newline at end of file
......@@ -212,4 +212,17 @@ module HyraxHelper
[status.titleize, parsed_datetime, newest_file]
end
def list_collections_to_display
collections_to_display = []
file_contents = File.new(Rails.root.join('config', 'collections_to_display.yml')).read
template = ERB.new file_contents
parsed_file = YAML.load(template.result(binding))
parsed_file['collections_to_display'].each do |collection_name|
c = Collection.where(title: collection_name).first
collections_to_display.append({id: c.id, title: c.title&.first, url: "/dashboard/collections/#{c.id}"})
# collections_to_display.append({id: c.id, title: c.title&.first, url: dashboard_collection_path(c.id)})
end
collections_to_display
end
end
<% provide :page_header do %>
<h1><%= t("hyrax.dashboard.title") %></h1>
<% end %>
<%= render 'shared/collections_to_display' %>
<% if Hyrax.config.analytics? %>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><%= t(".graph_reports") %>:</h2>
<%= params[:start_date].present? ? params[:start_date].to_date : 1.month.ago.beginning_of_day.to_date %> -
<%= params[:end_date].present? ? params[:end_date].to_date : Time.zone.now.end_of_day.to_date %>
</div>
<div class="panel-body">
<%= render "hyrax/admin/analytics/date_range_form", redirect_path: hyrax.dashboard_path %>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<%= render 'user_activity' %>
</div>
</div>
</div>
<% end %>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<%= render 'repository_growth' %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<%= render 'visibility_graph' %>
</div>
<div class="col-md-4">
<%= render 'work_type_graph' %>
</div>
<div class="col-md-4">
<%= render "resource_type_graph" %>
</div>
</div>
<br>
<br>
<%= render 'tabs' %>
\ No newline at end of file
<% provide :page_header do %>
<h1><%= t("hyrax.dashboard.title") %></h1>
<% end %>
<%= render 'shared/collections_to_display' %>
<div class="panel panel-default user-activity">
<div class="panel-heading">
<h2 class="panel-title "><%= t("hyrax.dashboard.user_activity.title") %></h2>
</div>
<div class="panel-body">
<%= @presenter.render_recent_activity %>
</div>
</div>
<div class="panel panel-default" id="notifications">
<div class="panel-heading">
<h2 class="panel-title "><%= t("hyrax.dashboard.user_notifications") %></h2>
</div>
<div class="panel-body">
<%= @presenter.render_recent_notifications %>
<%= @presenter.link_to_additional_notifications %>
</div>
</div>
<% if Flipflop.proxy_deposit? %>
<div class="panel panel-default" id="proxy_management">
<div class="panel-heading">
<h2 class="panel-title "><%= t("hyrax.dashboard.current_proxies") %></h2>
</div>
<div class="panel-body">
<%= render 'hyrax/dashboard/_index_partials/current_proxy_rights', user: current_user %>
<%= @presenter.link_to_manage_proxies %>
</div>
</div>
<% end %>
<div class="panel panel-default transfers">
<div class="panel-heading">
<h2 class="panel-title "><%= t("hyrax.dashboard.transfer_of_ownership") %></h2>
</div>
<div class="panel-body">
<%= render 'hyrax/dashboard/_index_partials/transfers', presenter: @presenter.transfers %>
</div>
</div>
\ No newline at end of file
<% if @collections_to_display.present? %>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" id="user_groups">
<div class="panel-heading">
<h2 class="panel-title "><%= t("hyrax.dashboard.my_groups") %></h2>
</div>
<div class="panel-body">
<% @collections_to_display.each do |col| %>
<a href="<%= col[:url] %>" class="btn btn-info btn-inline" role="button"><%= col[:title] %></a>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
collections_to_display:
- <%= ENV['CRC_1280_COLLECTION'] || 'CRC 1280' %>
\ No newline at end of file
......@@ -412,6 +412,7 @@ en:
shared: Works (datasets) Shared with Me
works: Works (datasets)
your_works: Your Works (datasets)
my_groups: My groups
no_transfer_requests: You haven't received any work (dataset) transfer requests
no_transfers: You haven't transferred any work (dataset)
proxy_help: Select a user who can deposit works (datasets) on your behalf. Both you and your proxy will be able to make changes to these works (datasets). You can revoke a proxy by clicking the Delete Proxy button. To revoke their ability to edit a work they previously submitted, remove them from the Sharing tab on each work (dataset).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment