示例#1
0
function chartsPrepColNames($devName)
{
    $dataNames = dbGetNameOfFields($devName);
    foreach ($dataNames as $name) {
        echo "data.addColumn('number', '.{$name}.' )";
    }
}
示例#2
0
sec_session_start();
if (!isset($_SESSION['username'])) {
    header("Location: ../logout.php");
    exit;
}
//Set variables
$errorMessage = "";
if (isset($_GET['errorMessage'])) {
    $errorMessage = $_GET['errorMessage'];
}
$success = "";
if (isset($_GET['success'])) {
    $success = $_GET['success'];
}
$devInfo = dbGetDevInfo($_GET['devName']);
$nameOfFields = dbGetNameOfFields($_GET['devName']);
/*************
 * PRINT HTML
 *************/
$header = new outputHeader();
$header->printSimpleHeader("IoT MyAdmin - Device Details");
$header->closeHeader();
openBody();
printNavbarAndSidebar("devDetails");
printBody($devInfo, $nameOfFields, $errorMessage, $success);
closeBody();
$footer = new outputFooter();
$footer->closeHtml();
/**************************************************************************
 * custom html code
 *******************/
示例#3
0
function printBody($table)
{
    ?>
<div id="page-wrapper">
    <div class="container-fluid">

        <!-- Page Heading -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Last Logs
                </h1>
                <ol class="breadcrumb">
                    <li>
                        <a href="devices.php"> Devices</a>
                    </li>
                    <li class="active">
                        <i class="fa fa-bolt"></i> Last Logs
                    </li>
                </ol>                           
            </div>
        </div>
        <!-- /.Page Heading -->
        
        <!-- Data table -->
        <div class="row">
            <div class="col-lg-12">
                <?php 
    //pagination
    echo $table['links'];
    ?>
                <div class="table-responsive">
                    <table class="table table-bordered table-condensed table-striped">
                        <thead>
                            <tr>
                                <th class="text-center">Log ID</th>
                                <th class="text-center">Device Name</th>
                                <th class="text-center">Log Date</th>
                                <th class="text-center">Log Time</th>
                                <th class="text-center">Data</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php 
    if ($table != "") {
        $index = 0;
        foreach ($table as $row) {
            if ($row[0] != '<') {
                $index = $index + 1;
                echo "<tr>";
                echo "<td class='col-xs-1 text-center'>" . $row['logId'] . "</td>";
                echo "<td class='col-xs-2 text-center'>" . $row['devName'] . "</td>";
                echo "<td class='col-xs-1 text-center'>" . $row['logDate'] . "</td>";
                echo "<td class='col-xs-1 text-center'>" . $row['logTime'] . "</td>";
                echo "<td class='col-xs-1 text-center'>";
                ?>
                                    <!-- Show data button: trigger modal -->
                                    <button type="button" class="btn btn-primary btn-md" data-toggle="modal" data-target="#myModal<?php 
                echo $index;
                ?>
">
                                        Show data
                                    </button>

                                    <!-- Modal -->
                                    <div class="modal fade" id="myModal<?php 
                echo $index;
                ?>
" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title" id="myModalLabel">Data</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <div>
                                                        <div class="table-responsive">
                                                            <table class="table table-bordered table-striped table-condensed">
                                                                <tr>
                                                                <?php 
                $data = $row['data'];
                $nameOfFields = dbGetNameOfFields($row['devName']);
                for ($i = 0; $i < sizeof($data); $i++) {
                    if ($nameOfFields[$i] == "") {
                        $nameOfFields[$i] = "dataField" . $i;
                    }
                    echo "<th class='text-center'><small>" . $nameOfFields[$i] . "</small></th>";
                }
                ?>
                                                                </tr>
                                                                <tr>
                                                                <?php 
                for ($i = 0; $i < sizeof($data); $i++) {
                    echo "<td class='text-center'><small>" . $data[$i] . "</small></td>";
                }
                ?>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.Modal -->
                        <?php 
                echo "</td>";
                echo "</tr>";
            }
        }
    }
    ?>
                                  
                        </tbody>
                    </table>
                </div>
                <?php 
    //pagination
    echo $table['links'];
    ?>
            </div>
        </div>
        <!-- /Data table -->
        
    </div>
    <!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
<?php 
}
示例#4
0
function printBody($devNamesList, $table, $devName)
{
    ?>
<div id="page-wrapper">
    <div class="container-fluid">

        <!-- Page Heading -->
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    Data Table
                </h1>
                <ol class="breadcrumb">
                    <li>
                        <a href="devices.php"> Devices</a>
                    </li>
                    <li class="active">
                        <i class="fa fa-table"></i> Data Table
                    </li>
                </ol>                           
            </div>
        </div>
        <!-- /.Page Heading -->
        
        <!-- Selection -->
        <div class="row">
            <div class="col-lg-2" style="margin-bottom: 10px">
                <div class="dropdown">
                    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                         Select Device
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                        <?php 
    if ($devNamesList != "") {
        foreach ($devNamesList as $value) {
            echo "<li role='presentation'><a role='menuitem' tabindex='-1' href='dataTables.php?devName=" . $value . "'>" . $value . "</a></li>";
        }
    } else {
        echo "<li role='presentation'><a role='menuitem' tabindex='-1'>There is not devices registed</a></li>";
    }
    ?>
                    </ul>
                </div>
            </div>
            <?php 
    if (isset($_GET['devName'])) {
        ?>
            <div class="col-lg-2">
                <a class="btn btn-primary dropdown-toggle" type="button" id="btnRandomData" href="actions/addRandomData.php?devName=<?php 
        echo $_GET['devName'];
        ?>
&url=<?php 
        echo $_SERVER[REQUEST_URI];
        ?>
">
                     Add random data
                </a>
            </div>
            <?php 
    }
    ?>
        </div>
        <!-- /.Selection -->
        
        <?php 
    if ($table == "") {
        ?>
        <!-- No data info Message -->
        <div class="row">
            <div class="col-lg-12">
                <div class="text-center alert alert-info" role="alert" style="margin-bottom: 10px">
                    <h2> Oops!! This device has no data. <br></h2>
                </div>                
            </div>
        </div>
        <!-- /.Message --> 
        <?php 
    }
    if ($table != "selectDevice" && $table != "") {
        ?>
        <div class="row">
                <div class="col-lg-12"> 
                <?php 
        //Pagination
        echo $table['links'];
        ?>
                <!-- Data table -->
                <div class="table-responsive">
                    <table class="table table-bordered table-condensed table-striped">
                        <thead>
                            <tr>
                                <th class="text-center">Log ID</th>
                                <th class="text-center">Log Date</th>
                                <th class="text-center">Log Time</th>
                                <th class="text-center">Data</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
        if ($table != "") {
            $index = 0;
            //for each data row
            foreach ($table as $row) {
                if ($row[0] != '<') {
                    $index = $index + 1;
                    echo "<tr>";
                    echo "<td class='col-xs-1 text-center'>" . $row['logId'] . "</td>";
                    echo "<td class='col-xs-1 text-center'>" . $row['logDate'] . "</td>";
                    echo "<td class='col-xs-1 text-center'>" . $row['logTime'] . "</td>";
                    echo "<td class='col-xs-1 text-center'>";
                    ?>

                                        <!-- Show data button: trigger modal -->
                                        <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal<?php 
                    echo $index;
                    ?>
">
                                            Show data
                                        </button>

                                        <!-- Modal -->
                                        <div class="modal fade" id="myModal<?php 
                    echo $index;
                    ?>
" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                        <h4 class="modal-title" id="myModalLabel">Data</h4>
                                                    </div>
                                                    <div class="modal-body">
                                                        <div class="table-responsive">
                                                            <table class="table table-bordered table-striped table-condensed">
                                                                <tr>
                                                                <?php 
                    $data = $row['data'];
                    $nameOfFields = dbGetNameOfFields($devName);
                    for ($i = 0; $i < sizeof($data); $i++) {
                        if ($nameOfFields[$i] == "") {
                            $nameOfFields[$i] = "dataField" . $i;
                        }
                        echo "<th class='col-xs-1 text-center'><small>" . $nameOfFields[$i] . "</small></th>";
                    }
                    ?>
                                                                </tr>
                                                                <tr>
                                                                <?php 
                    for ($i = 0; $i < sizeof($data); $i++) {
                        echo "<td class='col-xs-1 text-center'><small>" . $data[$i] . "</small></td>";
                    }
                    ?>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- /.Modal -->
                                        
                                        <?php 
                    echo "</td>";
                    echo "</tr>";
                }
            }
            //.END for each data row
        }
        ?>
                        </tbody>
                    </table>
                </div>
                <!-- /.Data table -->
                <?php 
        // pagination
        echo $table['links'];
        ?>
            </div>
        </div>
        <?php 
    }
    //end if
    ?>
 
    </div>
    <!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
<?php 
}
示例#5
0
function printChartsScript($devName, $chartType, $firstData, $numOfData)
{
    $dataNames = dbGetNameOfFields($devName);
    $dataStr = chartsPrepMultData_offset($devName, $firstData, $numOfData);
    ?>
<script type="text/javascript">
    
  // Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});

  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawVisualization);

  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawVisualization() {
    var data = new google.visualization.DataTable();
    
    data.addColumn('datetime', 'Time of Day');
    <?php 
    foreach ($dataNames as $name) {
        ?>
        data.addColumn('number', '<?php 
        echo $name;
        ?>
' );
    <?php 
    }
    ?>
    data.addRows([<?php 
    echo $dataStr;
    ?>
]);

    var options = {
      title: 'Device: <?php 
    echo $devName;
    ?>
',
      curveType: 'function',
      height: 400,
      vAxis:{minValue:0}
    };

    new google.visualization.<?php 
    echo $chartType;
    ?>
Chart(document.getElementById('chartHolder')).
      draw(data, options);
    }
</script>
<?php 
}