{{/*
  Copyright 2014 Team 254. All Rights Reserved.
  Author: pat@patfairbank.com (Patrick Fairbank)

  UI for controlling ephemeral aspects of the playing field.
*/}}
{{define "title"}}Field Configuration{{end}}
{{define "body"}}
<div class="row">
  <div class="col-lg-3">
    <div class="well">
      <legend>Alliance Station Displays</legend>
      {{range $displayId, $station := .AllianceStationDisplays}}
        <form class="form-horizontal" action="/setup/field" method="POST">
          <div class="form-group">
            <label class="col-lg-5 control-label">Display {{$displayId}}</label>
            <div class="col-lg-7">
              <input type="hidden" name="displayId" value="{{$displayId}}" />
              <select class="form-control" name="allianceStation" onchange="this.form.submit();">
                <option value=""></option>
                <option value="R1"{{if eq $station "R1"}} selected{{end}}>Red 1</option>
                <option value="R2"{{if eq $station "R2"}} selected{{end}}>Red 2</option>
                <option value="R3"{{if eq $station "R3"}} selected{{end}}>Red 3</option>
                <option value="B1"{{if eq $station "B1"}} selected{{end}}>Blue 1</option>
                <option value="B2"{{if eq $station "B2"}} selected{{end}}>Blue 2</option>
                <option value="B3"{{if eq $station "B3"}} selected{{end}}>Blue 3</option>
              </select>
            </div>
          </div>
        </form>
      {{end}}
      <legend>Reload All Displays</legend>
      <div class="form-group">
        <a href="/setup/field/reload_displays" class="btn btn-primary">Force Reload of All Displays</a>
      </div>
    </div>
  </div>
  <div class="col-lg-7">
    <div class="well">
      <legend>PLC</legend>
      <div class="row">
        <div class="col-lg-4">
          <table class="table">
            <tr>
              <th colspan="2">Inputs</th>
            </tr>
            {{range $i, $value := .Inputs}}
            <tr>
              <td>{{index $.InputNames $i}}</td>
              <td>{{$value}}</td>
            </tr>
            {{end}}
          </table>
        </div>
        <div class="col-lg-4">
          <table class="table">
            <tr>
              <th colspan="2">Registers</th>
            </tr>
            {{range $i, $value := .Registers}}
            <tr>
              <td>{{index $.RegisterNames $i}}</td>
              <td>{{$value}}</td>
            </tr>
            {{end}}
          </table>
        </div>
        <div class="col-lg-4">
          <table class="table">
            <tr>
              <th colspan="2">Coils</th>
            </tr>
            {{range $i, $value := .Coils}}
            <tr>
              <td>{{index $.CoilNames $i}}</td>
              <td>{{$value}}</td>
            </tr>
            {{end}}
          </table>
        </div>
      </div>
    </div>
  </div>
  <div class="col-lg-2">
    <div class="well">
      <legend>LEDs</legend>
      <form class="" action="/setup/field/test" method="POST">
        <div class="form-group">
          {{range $i, $name := .LedModeNames}}
            <div class="radio">
              <label>
                <input type="radio" name="mode" value="{{$i}}" onclick="this.form.submit()"
                       {{if eq $.CurrentLedMode $i}}checked{{end}}>{{$name}}
              </label>
            </div>
          {{end}}
        </div>
      </form>
    </div>
  </div>
</div>
{{end}}
{{define "script"}}
{{end}}
