intercity/intercity-next

View on GitHub
app/views/servers/_server.html.erb

Summary

Maintainability
Test Coverage
<%= content_tag :div, id: dom_id(server), class: "server" do %>
  <div class="card server-<%= server.formatted_status %>">
    <header class="card-header">
      <div class="status">
        <%= render "status", server: server %>
      </div>
      <p class="card-header-title"><%= link_to truncate(server.name, length: 25), server %></p>
    </header>
    <div class="card-content">
      <div class="columns">
        <div class="column has-text-centered address">
          <%= server.ip %>
        </div>
      </div>
      <div class="columns has-text-centered is-hidden-touch resources">
        <div class="column">
          <%= image_tag "cpu.svg" %><br>
          <% if server.total_cpu.present? %>
            <%= (server.total_cpu.to_f / 1000).round(2) %>GHz
          <% else %>
            ?
          <% end %>
        </div>
        <div class="column">
          <%= image_tag "ram.svg" %><br>
          <% if server.total_ram.present? %>
            <%= (server.total_ram.to_f / 1048576).round(2) %>GiB
          <% else %>
            ?
          <% end %>
        </div>
        <div class="column">
          <%= image_tag "disk.svg" %><br>
          <% if server.total_disk.present? %>
            <%= server.total_disk / 1048576 %>GiB
          <% else %>
            ?
          <% end %>
        </div>
      </div>
    </div>
    <div class="card-footer">
      <%= link_to icon("trash"), server_path(server), method: :delete,
        data: { confirm: "You're about to remove this server, are you REALLY sure?" }, class: "card-footer-item" %>
    </div>
  </div>
<% end %>