.jumbotron.hidden-xs.hidden-sm

%h1 🚦 All of the Lights
%p Cop lights, flashlights, spotlights, strobe lights…

.main

- if lights.empty?
  .alert.alert-warning{role: 'alert'}
    %strong No lights found.
    Ensure that your Stoplight data store is properly configured and that your Stoplight blocks have been run.
- else
  .well
    %form{method: 'post', action: url('/green_all')}
      %button.btn-lg.btn.btn-success{type: 'submit', disabled: count_red + count_yellow > 0 ? nil : 'disabled'} Greenify All

  .progress
    .progress-bar.progress-bar-danger{style: "width: #{percent_red}%"}
      .span= count_red
    .progress-bar.progress-bar-warning{style: "width: #{percent_yellow}%"}
      .span= count_yellow
    .progress-bar.progress-bar-success{style: "width: #{percent_green}%"}
      .span= count_green

  .lights
    %table.table.table-hover
      %thead.hidden-xs
        %tr
          %th Status
          %th
            %abbr{title: 'Locked lights will not change color automatically.'} Locked?
          %th Name
          %th
            %abbr{title: 'Exceptions which caused the light to turn red.'} Failures
      %tbody
        - lights.each do |l|
          %tr
            %td.indicator
              - if l[:color] == GREEN
                %form{method: 'post', action: url('/red')}
                  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
                  %button{type: 'submit', class: 'btn btn-success'}
                    G
                    %span.hidden-xs> REEN
              - elsif l[:color] == YELLOW
                %form{method: 'post', action: url('/green')}
                  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
                  %button{type: 'submit', class: 'btn btn-warning'}
                    Y
                    %span.hidden-xs> ELLOW
              - else
                %form{method: 'post', action: url('/green')}
                  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
                  %button{type: 'submit', class: 'btn btn-danger'}
                    R
                    %span.hidden-xs> ED
            %td.locked
              - if l[:locked]
                %form{method: 'post', action: url('/unlock')}
                  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
                  %button{type: 'submit', class: 'btn btn-link'}
                    %span{class: 'glyphicon glyphicon-lock'}
              - else
                %form{method: 'post', action: url('/lock')}
                  %input{type: 'hidden', name: 'names', value: URI.escape(l[:name])}
                  %button{type: 'submit', class: 'btn btn-link'}
                    %span{class: 'glyphicon glyphicon-minus'}
            %td.name
              = l[:name]
            %td.failures
              - if l[:failures]
                %ul
                  - l[:failures].each do |failure|
                    %li
                      %span.error
                        &= failure.error_class
                        \:
                        &= failure.error_message
                      @
                      %span.timestamp
                        &= failure.time