<%
  # This template can be configure the following way with environment variables
  # CONSUL_TOOLS_SUFFIX: suffix for the address of consul tools
  # CONSUL_TOOLS_PREFIX: prefix for the address of consul tools
  # CONSUL_TOOLS: comma sperated list of consul tools
  tools = (ENV['CONSUL_TOOLS'] || 'services').split(",")
  tools_suffix = ENV['CONSUL_TOOLS_PREFIX'] || '-ui.html'
  tools_prefix = ENV['CONSUL_TOOLS_SUFFIX'] || 'consul-'

  dc_suffix = ENV['CONSUL_DC_SUFFIX'] || ''
  dc_prefix = ENV['CONSUL_DC_PREFIX'] || '#'

%><!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <meta name="description" content="Display Consul information"/>
    <meta name="author" content="Criteo"/>
    <title><%= param('title', 'Consul Real Time information') %></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.11/css/all.css" integrity="sha384-p2jx59pefphTFIpeqCcISO9MdVfIm4pNnsL08A6v5vaQc4owkQqxMV8kg4Yvhaw/" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css">
    <style id="css-states">
      .service-tags { display: none; }
    </style>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-secondary">
      <div class="collapse navbar-collapse">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item dropdown">
            <a class="navbar-brand dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Consul
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <% datacenters.each do |dc| %>
              <a class="dropdown-item" href="<%= dc_prefix + dc + dc_suffix %>"><%= dc %></a>
              <% end %>
            </div>
          </li>
          <% tools.each do |tool| %>
          <li class="nav-item">
            <a class="nav-link" href="<%= tools_prefix + tool + tools_suffix %>"><%= tool.gsub('_', ' ').capitalize %></a>
          </li>
          <% end %>
        </ul>
      </div>
    </nav>