emory-libraries/dlp-selfdeposit

View on GitHub
app/views/hyrax/dashboard/show_admin.html.erb

Summary

Maintainability
Test Coverage
<%# Hyrax v5.0.1 Override:
      - removes the repository growth section since there's no easy or preferable CSS or jQuery way.
      - the display of `content_genre` statistics is more desirable than `resource_type` here. %>

<% provide :page_header do %>
  <h1><%= t("hyrax.dashboard.title") %></h1>
<% end %>

<div class="spaced-rows">
  <% if Hyrax.config.analytics? %>
  <div class="row">
    <div class="col">
      <div class="card">
        <div class="card-header">
          <h2 class="card-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="card-body">
          <%= render "hyrax/admin/analytics/date_range_form", redirect_path: hyrax.dashboard_path %>
        </div>
      </div>
    </div>
  </div>

  <div class="row">
    <div class="col">
      <div class="card">
        <%= render 'user_activity' %>
      </div>
    </div>
  </div>
  <% end %>

  <div class="row">
    <div class="col">
      <%= render 'visibility_graph' %>
    </div>

    <div class="col">
      <%= render 'work_type_graph' %>
    </div>

    <div class="col">
      <div class="card">
        <div class="card-header">Publication Type</div>
        <div class="card-body">
          <div id="dashboard-resource-types" aria-hidden="true" style="height: 200px">
            <% @content_genres = SelfDeposit::Statistic.content_genres %>
            <script>
              Morris.Donut({
                  element: 'dashboard-resource-types',
                  data: [
                    <% @content_genres.each do |row| %>
                      { label: "<%= row[0] %>", value: <%= row[1].to_i %> },
                    <% end %>
                  ],
                  colors: ['#001219','#005f73','#0a9396','#94d2bd','#e9d8a6','#ee9b00','#ca6702','#bb3e03','#ae2012','#9b2226'],
                  gridTextSize: '12px',
                  resize: true
                });
            </script>
          </div>

          <table aria-label="Publication Type" class="table table-striped sr-only text-left">
            <thead>
              <tr>
                <th>Publication Type</th>
                <th><%= t('.count') %></th>
              </tr>
            </thead>
            <tbody>
              <% @content_genres.each do |row| %>
                <tr>
                  <td><%= row[0] %></td>
                  <td><%= row[1] %></td>
                </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="clearfix mt-5">
  <%= render 'tabs' %>
</div>