
<div class="row row-flex">
    <div class="col-xs-12 text-center">
        <h1>Current Values</h1>
    </div>
    <div class="col-xs-3 text-center box-me">
        <h2>Flow Rate</h2>
        <div class="gauge-box">
            <div data-labelheight="10"
            style="height: 170px; background: transparent; margin: 0 auto;"
            id="gauge-flow_rate"
            data-chart="solidgauge"
            data-nodename="rigpump.flow_rate"
            data-units="BPM"
            data-min="0"
            data-max="5000"
            data-decimalplaces="1"
            data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
            data-valuefontsize="18px">
            </div>
            <div class- "timestamp-box">
                <a href="#" data-channelId="<%= channels['rigpump.flow_rate'].channelId %>" class="data-table" title="Download Channel History">
                    <i class="fa fa-download"></i>
                </a>
            </div>
            <span data-timeupdate="flow_rate">
                <%= channels["rigpump.flow_rate"].timestamp %>
            </span>
        </div>
    </div>

    <div class="col-xs-3 text-center box-me">
        <h2>Discharge Pressure</h2>
        <div class="gauge-box">
            <div data-labelheight="10"
            style="height: 170px; background: transparent; margin: 0 auto;"
            id="gauge-discharge_pressure"
            data-chart="solidgauge"
            data-nodename="rigpump.discharge_pressure"
            data-units="PSI"
            data-min="0"
            data-max="5000"
            data-decimalplaces="1"
            data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
            data-valuefontsize="18px">
            </div>
            <div class- "timestamp-box">
                <a href="#" data-channelId="<%= channels['rigpump.discharge_pressure'].channelId %>" class="data-table" title="Download Channel History">
                    <i class="fa fa-download"></i>
                </a>
            </div>
            <span data-timeupdate="discharge_pressure">
                <%= channels["rigpump.discharge_pressure"].timestamp %>
            </span>
        </div>
    </div>

    <div class="col-xs-3 text-center box-me">
        <h2>VFD Frequency</h2>
        <div class="gauge-box">
            <div data-labelheight="10"
            style="height: 170px; background: transparent; margin: 0 auto;"
            id="gauge-vfd_frequency"
            data-chart="solidgauge"
            data-nodename="rigpump.vfd_frequency"
            data-units="Hz"
            data-min="0"
            data-max="75"
            data-decimalplaces="1"
            data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
            data-valuefontsize="18px">
            </div>
            <div class- "timestamp-box">
                <a href="#" data-channelId="<%= channels['rigpump.vfd_frequency'].channelId %>" class="data-table" title="Download Channel History">
                    <i class="fa fa-download"></i>
                </a>
            </div>
            <span data-timeupdate="vfd_frequency">
                <%= channels["rigpump.vfd_frequency"].timestamp %>
            </span>
        </div>
    </div>

    <div class="col-xs-3 text-center box-me">
        <h2>VFD Current</h2>
        <div class="gauge-box">
            <div data-labelheight="10"
            style="height: 170px; background: transparent; margin: 0 auto;"
            id="gauge-vfd_current"
            data-chart="solidgauge"
            data-nodename="rigpump.vfd_current"
            data-units="Amps"
            data-min="0"
            data-max="200"
            data-decimalplaces="1"
            data-colors="0.1:#DF5353,0.5:#DDDF0D,0.9:#55BF3B"
            data-valuefontsize="18px">
            </div>
            <div class- "timestamp-box">
                <a href="#" data-channelId="<%= channels['rigpump.vfd_current'].channelId %>" class="data-table" title="Download Channel History">
                    <i class="fa fa-download"></i>
                </a>
            </div>
            <span data-timeupdate="vfd_current">
                <%= channels["rigpump.vfd_current"].timestamp %>
            </span>
        </div>
    </div>
</div>

<div class="row row-flex">
    <div class="col-md-6 box-me" style="text-align:center;">
        <h2>Mode</h2>
        <h3 data-valueupdate="auto_manual"><%= channels["rigpump.auto_manual"].value %></h3>
    </div>
    <div class="col-md-6 box-me" style="text-align:center;">
        <h2>Control Parameter</h2>
        <div data-valueupdate="auto_manual" data-refreshonupdate=true>
            <% if (channels["rigpump.auto_manual"].value === "Auto") { %>

                <h3 data-valueupdate="auto_control_mode"><%= channels["rigpump.auto_control_mode"].value %></h3>
                <div data-valueupdate="auto_control_mode" data-refreshonupdate=true>
                    <% if (channels["rigpump.auto_control_mode"].value === "Pressure"){ %>
                        <h3 data-valueupdate="discharge_pressure_setpoint" data-refreshonupdate=true><%= channels["rigpump.discharge_pressure_setpoint"].value %> PSI</h3>
                    <% } else { %>
                        <h3 data-valueupdate="flow_rate_setpoint" data-refreshonupdate=true><%= channels["rigpump.flow_rate_setpoint"].value %> BPM</h3>
                    <% } %>
                </div>
            <% } else { %>
                <h3>VFD Frequency</h3>
                <h3 data-valueupdate="vfd_frequency_setpoint" data-refreshonupdate=true><%= channels["rigpump.vfd_frequency_setpoint"].value %> Hz</h3>
            <% } %>
        </div>
    </div>
</div>

<div class="row row-flex">
    <div class='col-xs-12'>
        <div style="height:300px"
        id="chart-overview"
        data-chart="chart"
        data-nodename1="rigpump.flow_rate"
        data-datalabel1="Flow Rate"
        data-nodename2="rigpump.discharge_pressure"
        data-datalabel2="Discharge Pressure"
        data-nodename3="rigpump.vfd_frequency"
        data-datalabel3="VFD Frequency"
        data-nodename4="rigpump.vfd_current"
        data-datalabel4="VFD Current"
        data-daysofhistory="2"
        data-chartlabel="Last 48 Hours"
        data-ylabel=""
        data-xlabel="Date"
        data-units=""></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;
}

.pad15 {
    margin: 15px 15px;
}

.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;
}

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

.slice.node-detail hr {
    border-color: #ccc;
}
.slice.node-detail #alarms li {
    margin-bottom: 1em;
    padding: 0.5em;
}
.slice.node-detail #alarms li:nth-child(even){
    background-color: whiteSmoke;
}
.slice.node-detail #alarms li span {
    margin-left: 1em;
    color: #aaa;
}
</style>

<script>

$('.val_box').each(function(topLevel){
    $(this).change(function(){
        var id = "#" + $(this).closest(".entry-top-level").attr('id');
        if (id !== "#undefined"){
            var val = $(id).find('.val_box').val();
            var tag = $(id).find('.setstatic').attr('data-staticsend', val);
            console.log($(id).find('.setstatic').attr('data-staticsend'));
        }
    });
});

</script>
