thedrummeraki/tanoshimu

View on GitHub
app/views/admin/application/home.html.erb

Summary

Maintainability
Test Coverage
<section class="hero is-info welcome is-small">
  <div class="hero-body">
    <div class="container">
      <h1 class="title">
        Hello, <%= current_user.name %>.
      </h1>
      <h2 class="subtitle">
        Here are some quick facts.
      </h2>
    </div>
  </div>
</section>
<section class="info-tiles" style="margin: 1rem 0">
  <div class="tile is-ancestor has-text-centered">
    <div class="tile is-parent">
      <%= link_to admin_users_path, class: 'tile is-child box' do %>
      <p class="title"><%= @users_count %></p>
      <p class="subtitle">Users</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_shows_path, class: 'tile is-child box' do %>
      <p class="title"><%= @shows_count %> </p>
      <p class="subtitle">Published shows</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_shows_path(live: true), class: 'tile is-child box' do %>
      <p class="title"><%= @currently_watching_count %></p>
      <p class="subtitle">Currently watching</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_users_path(prompt: :sessions), class: 'tile is-child box' do %>
      <p class="title"><%= @currently_logged_in_count %></p>
      <p class="subtitle">Currenlty logged in</p>
      <% end %>
    </div>
  </div>
  <div class="tile is-ancestor has-text-centered">
    <div class="tile is-parent">
      <%= link_to admin_users_path(oauth: true), class: 'tile is-child box' do %>
      <p class="title"><%= @oauth_users_count %></p>
      <p class="subtitle">OAuth users</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_shows_path, class: 'tile is-child box' do %>
      <p class="title"><%= Show.all.count %> </p>
      <p class="subtitle">Shows</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_shows_path, class: 'tile is-child box' do %>
      <p class="title"><%= 0 %></p>
      <p class="subtitle">Total shows views</p>
      <% end %>
    </div>
    <div class="tile is-parent">
      <%= link_to admin_shows_path(prompt: :episodes), class: 'tile is-child box' do %>
      <p class="title"><%= 0 %></p>
      <p class="subtitle">Total episodes views</p>
      <% end %>
    </div>
  </div>
</section>
<div class="columns">
  <div class="column is-6">
    <div class="card events-card">
      <header class="card-header">
        <p class="card-header-title">
          Latest additions on YourAnime.moe
        </p>
        <a href="#" class="card-header-icon" aria-label="more options">
        <span class="icon">
        <i class="fa fa-angle-down" aria-hidden="true"></i>
        </span>
        </a>
      </header>
      <div class="card-table">
        <div class="content">
          <table class="table is-fullwidth is-striped">
            <tbody>
            <% @latest_additions.each do |show| %>
              <tr>
                <td>
                  <%= show.title %>
                  <p class="has-text-grey">
                    <small>
                    Added: <%= time_ago_in_words(show.created_at) %> ago (<%= show.created_at.strftime('%B %d, %Y at %H:%M') %>)
                    </small>
                  </p>
                </td>
              </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
      <footer class="card-footer">
        <a href="#" class="card-footer-item">View All</a>
      </footer>
    </div>
  </div>
  <div class="column is-6">
    <div class="card events-card">
      <header class="card-header">
        <p class="card-header-title">
          Latest job events
        </p>
        <a href="#" class="card-header-icon" aria-label="more options">
        <span class="icon">
        <i class="fa fa-angle-down" aria-hidden="true"></i>
        </span>
        </a>
      </header>
      <div class="card-table">
        <div class="content">
          <table class="table is-fullwidth is-striped">
            <tbody>
              <% @latest_events.each do |event| %>
              <tr>
                <td>
                  <%= job_event_status_tag(event) %> <code><%= event.job_name %></code>
                  <p class="has-text-grey">
                    <small>
                      <% if event.running? %>
                        Started <%= time_ago_in_words(event.started_at) %> ago
                      <% else %>
                        Finished <%= time_ago_in_words(event.ended_at) %> ago -
                        Ran for <%= distance_of_time_in_words(event.ended_at - event.started_at) %>
                      <% end %>
                    </small>
                  </p>
                </td>
              </tr>
              <% end %>
            </tbody>
          </table>
        </div>
      </div>
      <footer class="card-footer">
        <%= link_to('View all', admin_job_events_path, class: 'card-footer-item') %>
      </footer>
    </div>
  </div>
</div>