diff --git a/hyrax/app/controllers/hyrax/dashboard_controller.rb b/hyrax/app/controllers/hyrax/dashboard_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..6927391f20232f2a44a5d6e12fd0bbcf8d3331b6 --- /dev/null +++ b/hyrax/app/controllers/hyrax/dashboard_controller.rb @@ -0,0 +1,40 @@ +# 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 diff --git a/hyrax/app/helpers/hyrax_helper.rb b/hyrax/app/helpers/hyrax_helper.rb index 90ffd21576d24dcc9a0521e18e9745dbbcce6331..06a26fcb58fe5b9554299411dc1747d3e38cdc23 100644 --- a/hyrax/app/helpers/hyrax_helper.rb +++ b/hyrax/app/helpers/hyrax_helper.rb @@ -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 diff --git a/hyrax/app/views/hyrax/dashboard/show_admin.html.erb b/hyrax/app/views/hyrax/dashboard/show_admin.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..067b42ef29c7119941cf990fa393c8c056e5f3be --- /dev/null +++ b/hyrax/app/views/hyrax/dashboard/show_admin.html.erb @@ -0,0 +1,53 @@ +<% 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 diff --git a/hyrax/app/views/hyrax/dashboard/show_user.html.erb b/hyrax/app/views/hyrax/dashboard/show_user.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..90cc21a927f3bbf8d94b3db69ec6b655ffa93ed5 --- /dev/null +++ b/hyrax/app/views/hyrax/dashboard/show_user.html.erb @@ -0,0 +1,45 @@ +<% 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 diff --git a/hyrax/app/views/shared/_collections_to_display.html.erb b/hyrax/app/views/shared/_collections_to_display.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..752614e9e208b535b69250ddbdef0efb4257aaca --- /dev/null +++ b/hyrax/app/views/shared/_collections_to_display.html.erb @@ -0,0 +1,16 @@ +<% 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 %> diff --git a/hyrax/config/collections_to_display.yml b/hyrax/config/collections_to_display.yml new file mode 100644 index 0000000000000000000000000000000000000000..7b59856307e984504e1f044095d172e48445751c --- /dev/null +++ b/hyrax/config/collections_to_display.yml @@ -0,0 +1,2 @@ +collections_to_display: + - <%= ENV['CRC_1280_COLLECTION'] || 'CRC 1280' %> \ No newline at end of file diff --git a/hyrax/config/locales/hyrax.en.yml b/hyrax/config/locales/hyrax.en.yml index 58aa4d17395dd34191c166e8f8b8fa0216db58eb..2662897fc01455ac2b53069d4bdc11204313e355 100644 --- a/hyrax/config/locales/hyrax.en.yml +++ b/hyrax/config/locales/hyrax.en.yml @@ -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).