<% if (channels["vfdipp.downholetoolenabled"].value == 0){ %>
    <div class="row">
        <div class="well mar15 text-center">
            <h1>THE DOWNHOLE SENSOR IS DISABLED</h1>
            <h1>IT CAN BE ENABLED FROM THE CONFIGURATION SCREEN</h1>
        </div>
    </div>
<% } %>

<div class="text-center"><h1>LIVE VALUES</h1></div>
<div class='row row-flex'>
    <div class='col-xs-4 text-center box-me'>
        <h2>Intake Pressure</h2>
        <div class="gauge-box">
            <div data-labelheight="10" style="height: 170px; background: transparent; margin: 0 auto;" id="gauge-dhintakepressure" data-chart="solidgauge" data-nodename="vfdipp.dhintakepressure" data-units="PSI" data-min="0" data-max="<%= channels["vfdipp.dhpsirating"].value %>" data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B" data-valuefontsize="18px"></div>
            <span data-timeupdate="dhintakepressure"><%= channels["vfdipp.dhintakepressure"].timestamp %></span>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>Fluid Level</h2>
        <div class="gauge-box">
            <div data-labelheight="10" style="height: 170px; background: transparent; margin: 0 auto;" id="gauge-dhfluidlevel" data-chart="solidgauge" data-nodename="vfdipp.dhfluidlevel" data-units="ft." data-min="0" data-max="1000" data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B" data-valuefontsize="18px"></div>
            <span data-timeupdate="dhfluidlevel"><%= channels["vfdipp.dhfluidlevel"].timestamp %></span>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>Intake Temperature</h2>
        <div class="gauge-box">
            <div data-labelheight="10" style="height: 170px; background: transparent; margin: 0 auto;" id="gauge-dhintaketemperature" data-chart="solidgauge" data-nodename="vfdipp.dhintaketemperature" data-units="&deg;F" data-min="0" data-max="200" data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B" data-valuefontsize="18px"></div>
            <span data-timeupdate="dhintaketemperature"><%= channels["vfdipp.dhintaketemperature"].timestamp %></span>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>Instrument Status</h2>
        <div class="gauge-box">
            <h1 data-valueupdate="dhdownholestatusint">
              <% if(channels["vfdipp.dhdownholestatusint"].value == 0) { %>
                <span class="label label-success">OK</span>
              <% } else if (channels["vfdipp.dhdownholestatusint"].value == 1){ %>
                <span class="label label-warning">Connecting...</span>
              <% } else if (channels["vfdipp.dhdownholestatusint"].value == 2){ %>
                <span class="label label-danger">Open Circuit</span>
              <% } else if (channels["vfdipp.dhdownholestatusint"].value == 3){ %>
                <span class="label label-danger">Shorted</span>
              <% } else if (channels["vfdipp.dhdownholestatusint"].value == 4){ %>
                <span class="label label-danger">Cannot Decode</span>
              <% } %>
            </h1>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>MAX VALUES</h2>
        <div class="gauge-box">
            <table class="table">
                <tbody>
                    <tr>
                        <td>Max Pressure (Startup)</td>
                        <td><%= channels["vfdipp.dhmaxintakepressurestartup"].value %></td>
                    </tr>

                    <tr>
                        <td>Max Pressure (Lifetime)</td>
                        <td><%= channels["vfdipp.dhmaxintakepressureforever"].value %></td>
                    </tr>

                    <tr>
                        <td>Max Temp. (Startup)</td>
                        <td><%= channels["vfdipp.dhmaxintaketemperaturestartup"].value %></td>
                    </tr>

                    <tr>
                        <td>Max Temp. (Lifetime)</td>
                        <td><%= channels["vfdipp.dhmaxintaketemperatureforever"].value %></td>
                    </tr>

                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="text-center"><h1>TRENDS</h1></div>
<div class="row box-me">
  <div class='col-xs-12' style="padding-top: 1em; margin-bottom: 1em;">
     <div class="input-daterange input-group" id="datepicker">
         <input data-chartid="dynamicChart" id="fromDate" data-daysofhistory="7"  type="text" class="form-control" name="start">
          <span class="input-group-addon">to</span>
         <input class="form-control" data-chartid="dynamicChart" id="toDate" type="text"  name="end">
          <span class='input-group-btn'>
             <a href="#!" data-chartid="dynamicChart" data-otherchartids="statusTimeline" class="btn chart-update btn-theme">Run</a>
          </span>
      </div>
  </div>
  <hr>
  <div class='clearfix col-xs-12' style='height: 300px' id="dynamicChart" data-chart="dynamicchart" data-daysofhistory="7"  data-chartlabel="Data" data-ylabel="" data-xlabel="Date" data-units=""  data-channelnames="vfdipp.dhintakepressure,vfdipp.dhintaketemperature,vfdipp.dhmaxintakepressureforever,vfdipp.dhmaxintakepressurestartup,vfdipp.dhmaxintaketemperaturestartup,vfdipp.dhmaxintaketemperatureforever"></div>
</div>

<div class="text-center"><h1>CONFIGURATION</h1></div>
<div class="row row-flex">
    <div class='col-xs-4 text-center box-me'>
        <h2>Pressure Trip</h2>
        <div class="gauge-box">
            <table class="table">
                <tbody>
                    <tr>
                        <td>Pressure Shutdown Enabled</td>
                        <td>
                            <% if (channels["vfdipp.dhpressureshutdownenabled"].value == 1){ %>
                                <span class="label label-success">True</span>
                            <% } else { %>
                                <span class="label label-warning">False</span>
                            <% } %>
                        </td>
                    </tr>

                    <tr>
                        <td>Pressure Shutdown Limit</td>
                        <td><%= channels["vfdipp.dhpressureshutdownlimit"].value %> PSI</td>
                    </tr>

                    <tr>
                        <td>Pressure Restart Enabled</td>
                        <td>
                            <% if (channels["vfdipp.dhpressurestartupenabled"].value == 1){ %>
                                <span class="label label-success">True</span>
                            <% } else { %>
                                <span class="label label-warning">False</span>
                            <% } %>
                        </td>
                    </tr>

                    <tr>
                        <td>Pressure Startup Limit</td>
                        <td><%= channels["vfdipp.dhpressurestartup"].value %> PSI</td>
                    </tr>

                </tbody>
            </table>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>Temperature Trip</h2>
        <div class="gauge-box">
            <table class="table">
                <tbody>
                    <tr>
                        <td>Temp. Shutdown Enabled</td>
                        <td>
                            <% if (channels["vfdipp.dhtempshutdownenabled"].value == 1){ %>
                                <span class="label label-success">True</span>
                            <% } else { %>
                                <span class="label label-warning">False</span>
                            <% } %>
                        </td>
                    </tr>

                    <tr>
                        <td>Temp. Shutdown Limit</td>
                        <td><%= channels["vfdipp.dhtempshutdown"].value %> &deg;F</td>
                    </tr>

                    <tr>
                        <td>Temp. Restart Enabled</td>
                        <td>
                            <% if (channels["vfdipp.dhtempstartupenabled"].value == 1){ %>
                                <span class="label label-success">True</span>
                            <% } else { %>
                                <span class="label label-warning">False</span>
                            <% } %>
                        </td>
                    </tr>

                    <tr>
                        <td>Temp. Startup Limit</td>
                        <td><%= channels["vfdipp.dhtempstartuplimit"].value %> &deg;F</td>
                    </tr>

                </tbody>
            </table>
        </div>
    </div>

    <div class='col-xs-4 text-center box-me'>
        <h2>Sensor Info.</h2>
        <div class="gauge-box">
            <table class="table">
                <tbody>
                    <tr>
                        <td>Number of Channels</td>
                        <td><%= channels["vfdipp.dhnumchannels"].value %></td>
                    </tr>

                    <tr>
                        <td>PSI Rating</td>
                        <td><%= channels["vfdipp.dhpsirating"].value %> PSI</td>
                    </tr>

                    <tr>
                        <td>Tool Type</td>
                        <td><%= channels["vfdipp.dhtooltype"].value %></td>
                    </tr>

                    <tr>
                        <td>Tool Voltage</td>
                        <td><%= channels["vfdipp.dhtoolvoltage"].value %> V</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>


</div>

<style>
    .box-me {
        position: relative;
        padding: 0.5em;
        padding-bottom: 1.5em;
        border: 1px solid #eee;
        /*margin: 1em 0;*/
    }
    .box-me .gauge-box {
        margin-top: -0.25em;
    }
    .box-me h2 {
        text-transform: uppercase;
        font-size: 14px;
        color: #666;
        font-weight: 400;
        letter-spacing: 1px;
        z-index: 100;
    }
    .dynamic-chart-form {
        background-color: whiteSmoke;
        padding: 1em 0.5em;
        margin-top: 1em;
    }

    .row-flex {
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display:         flex;
        flex-wrap: wrap;
    }
    .row-flex > [class*='col-'] {
        display: flex;
        flex-direction: column;
    }

    .mar15 {
        margin: 15px 15px;
    }

    #systemStatusTimelineContainer h2 {
        text-transform: uppercase;
        font-size: 14px;
        color: #666;
        font-weight: 400;
        letter-spacing: 1px;
        z-index: 100;
    }
</style>
