Skip to content

Commit

Permalink
ALl files for Sensor Management Component
Browse files Browse the repository at this point in the history
  • Loading branch information
MSiddharthReddy committed Apr 14, 2016
1 parent f26f7d7 commit 2b25d97
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 50 deletions.
21 changes: 21 additions & 0 deletions del2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
include 'connect.php';



//if ($conn->query($r) === TRUE) {
//echo "New record created successfully";
//} else {
//echo "Error: " . $sql . "<br>" . $conn->er


$id = $_GET['id'];
$query = "DELETE FROM hub_list WHERE id='".$id."'";
echo $query;
if ($conn->query($query) === TRUE) {
echo 'ok';
}

exit; // finish execution since we only need the "ok" or "err" answers from the server.

?>
4 changes: 2 additions & 2 deletions handle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
$stat = $_GET["status"];
$freq = $_GET["freq"];

$sql = "INSERT INTO sensor_list (Sensor_name, Sensor_id, lon, lat)
VALUES ('$sensor', '$fromat', '$desc', '$url ')";
$sql = "INSERT INTO sensor_list (Sensor_name, Sensor_id, lon, lat, hub_id,status)
VALUES ('$sensor', '$fromat', '$desc', '$url ', '$hub', '$api')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
Expand Down
21 changes: 21 additions & 0 deletions handle2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
include 'connect.php';

$sensor = $_GET["sensorname"];
$fromat = $_GET["format"];
$desc = $_GET["Longitude"];
$hub = $_GET["Latitude"];


$sql = "INSERT INTO hub_list (name, id, lat, lon)
VALUES ('$sensor', '$fromat', '$hub', '$desc ')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}


mysqli_close($conn);
?>
24 changes: 24 additions & 0 deletions handle3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
include 'connect.php';

$sensor = $_GET["sensorname"];
$desc = $_GET["Description"];
$fromat = $_GET["format"];
$hub = $_GET["hub"];
$url = $_GET["url"];
$api = $_GET["api"];
$stat = $_GET["status"];
$freq = $_GET["freq"];

$sql = "INSERT INTO sensor_list (Sensor_name, Sensor_id, lon, lat, hub_id,status)
VALUES ('$sensor', '$fromat', '$desc', '$url ', '$hub', '$api')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}


mysqli_close($conn);
?>
149 changes: 149 additions & 0 deletions sensor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@

<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-2.0.2.js'></script>
<link rel="stylesheet" type="text/css"
href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/simple-sidebar.css">
<script type='text/javascript'
src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">

<style type="text/css">
table{
text-align: center;
margin: auto;
width: 400px;

}
th
{
text-align: center;
}
button *{
margin-right: 30px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<a class="navbar-brand" href="markers.html"><span class="glyphicon glyphicon-home"></span></a>
</nav>
<br>
<a href="untitled.php"> <button class="btn btn-success btn-lg" style="width: 200px; position: fixed; left:30px;"> Go Back</button></a>
<button data-toggle="modal" data-target="#myModal" class="btn btn-success btn-lg" style="width: 200px; position: fixed; right:30px;"> Add Sensor</button> <br><br>
<hr>
<table style="width: 800px" id="myTable" class="table table-hover">
<thead>
<tr >
<th>Sensor Name</th>
<th>Sensor ID</th>
<th>Status</th>
<th>Manage</th>
</tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbnam = "sensor";

// Create connection
$conn = new mysqli($servername, $username, $password,$dbnam);

$id = $_GET['id'];

//if ($conn->query($r) === TRUE) {
//echo "New record created successfully";
//} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
//}
$r = "Select * FROM sensor_list WHERE hub_id = '".$id."'";

$a = $conn->query($r);
while( $row = mysqli_fetch_array($a) ){
echo "<tr><td>" . $row['Sensor_name'] . "</td><td>" . $row['Sensor_id'] . "</td><td>" . $row['status'] . "</td>";
$id = $row['Sensor_name']; //$row['index'] the index here is a field name
echo '<td> <a class="btn btn-danger" href="del.php?id='.$id.'" ><span class="glyphicon glyphicon-trash">';
echo '</span> Delete </a> &nbsp<button data-toggle="modal" data-target="#myModal2" class="btn btn-info">';
echo '<span class="glyphicon glyphicon-pencil"></span> Edit Status</a>';
echo '</td>';
echo '</tr>';
}
?>

</tbody>
</table>
</div>
</div>
</div>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Provide Details of Your Sensor</h4>
</div>
<form action="handle.php" method="Get" >

<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<label for="sensorname">Sensor Name</label>
<input type="email" class="form-control" name="sensorname" placeholder="Sensor Name"><br>

<label for="type">Long</label>
<input type="email" class="form-control" name="Description" placeholder="What Type"><br>
<label for="url">Latitude</label>
<input type="email" class="form-control" name="url" placeholder="URL"><br>

<label for="format">Sensor Id</label>
<input type="email" class="form-control" name="format" placeholder="Data Format"><br>
<label for="hub">Select Existing Sensor hub</label>
<input type="email" class="form-control" name="hub" placeholder="Select Existing Sensor hub"><br>

<label for="api">Sensor Status</label>
<input type="email" class="form-control" name="api" placeholder="API Token"><br>
<p class="help-block">Please Provide the Correct Information so that We can MAP your Sensor correctly.</p>
<div style="text-align: center;">
<button type="submit" class="btn btn-success">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button><br><br>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="myModal2" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Provide Details of the Group</h4>
</div>
<form action="handle3.php" method="Get">

<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<label for="sensorname">New Status</label>
<input type="email" class="form-control" id="sensorname" placeholder="Sensor Name"><br>
<input id="id" value=''><br>

<div style="text-align: center;">
<button type="submit" class="btn btn-success">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button><br><br>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions un.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
//}
$r = "Select * FROM sensor_list";
$r = "Select * FROM hub_list";

$a = $conn->query($r);
$rows = array();
Expand All @@ -23,7 +23,7 @@

$lat = $row['lat'];
$lon = $row['lon'];
$name = $row['Sensor_name'];
$name = $row['name'];

$rows[] = array("lat" => $lat, "lon" => $lon, "sensor" => $name );
# code...
Expand Down
61 changes: 15 additions & 46 deletions untitled.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<a class="navbar-brand" href="markers.html"><span class="glyphicon glyphicon-home"></span></a>
</nav>
<br>
<button data-toggle="modal" data-target="#myModal" class="btn btn-success btn-lg" style="width: 200px; position: fixed; right:30px;"> Add Sensor</button> <br><br>
<button data-toggle="modal" data-target="#myModal" class="btn btn-success btn-lg" style="width: 200px; position: fixed; right:30px;"> Add a HUB</button> <br><br>
<hr>
<table style="width: 800px" id="myTable" class="table table-hover">
<thead>
<tr >
<th>Group Name</th>
<th>Group Description</th>
<th>Hub ID</th>
<th>Hub Name</th>
<th>Manage</th>
</tr>
</thead>
Expand All @@ -60,14 +60,14 @@
//} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
//}
$r = "Select * FROM sensor_list";
$r = "Select * FROM hub_list";

$a = $conn->query($r);
while( $row = mysqli_fetch_array($a) ){
echo "<tr><td>" . $row['Sensor_name'] . "</td><td>" . $row['Sensor_id'] . "</td>";
$id = $row['Sensor_name']; //$row['index'] the index here is a field name
echo '<td> <a class="btn btn-danger" href="del.php?id='.$id.'" ><span class="glyphicon glyphicon-trash">';
echo '</span> Delete </a> &nbsp<a href="#" class="btn btn-info">';
echo "<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td>";
$id = $row['id']; //$row['index'] the index here is a field name
echo '<td> <a class="btn btn-danger" href="del2.php?id='.$id.'" ><span class="glyphicon glyphicon-trash">';
echo '</span> Delete </a> &nbsp<a href="sensor.php?id='.$id.'" class="btn btn-info">';
echo '<span class="glyphicon glyphicon-pencil"></span> Edit</a>';
echo '</td>';
echo '</tr>';
Expand All @@ -84,34 +84,23 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Provide Details of Your Sensor</h4>
<h4 class="modal-title">Provide Details of Your Hub</h4>
</div>
<form action="handle.php" method="Get" >
<form action="handle2.php" method="Get" >

<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<label for="sensorname">Sensor Name</label>
<label for="sensorname">Hub Name</label>
<input type="email" class="form-control" name="sensorname" placeholder="Sensor Name"><br>

<label for="type">Long</label>
<input type="email" class="form-control" name="Description" placeholder="What Type"><br>
<input type="email" class="form-control" name="Longitude" placeholder="What Type"><br>

<label for="format">Sensor Id</label>
<label for="format">Hub Id</label>
<input type="email" class="form-control" name="format" placeholder="Data Format"><br>
<label for="hub">Select Existing Sensor hub</label>
<input type="email" class="form-control" name="hub" placeholder="Select Existing Sensor hub"><br>

<label for="url"></label>
<input type="email" class="form-control" name="url" placeholder="URL"><br>

<label for="api">API Token</label>
<input type="email" class="form-control" name="api" placeholder="API Token"><br>
<label for="status">Sensor Status ON</label>
<input type="checkbox" checked data-toggle="toggle" name="status"><br><br>
<label for="freq">Frequency</label>
<input type="email" class="form-control" name="freq" placeholder="Frequency"><br>
<p class="help-block">Please Provide the Correct Information so that We can MAP your Sensor correctly.</p>
<label for="url">Latitude</label>
<input type="email" class="form-control" name="Latitude" placeholder="URL"><br>
<div style="text-align: center;">
<button type="submit" class="btn btn-success">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button><br><br>
Expand All @@ -122,27 +111,7 @@
</div>
</div>
</div>
<div class="modal fade" id="myModal2" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Provide Details of the Group</h4>
</div>
<form>

<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<label for="sensorname">Group Name</label>
<input type="email" class="form-control" id="sensorname" placeholder="Sensor Name"><br>

<label for="type">Description</label>
<input type="email" class="form-control" id="Description" placeholder="What Type"><br>
<div style="text-align: center;">
<button type="submit" class="btn btn-success">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button><br><br>
</div>
</div>
</div>
</form>
Expand Down

0 comments on commit 2b25d97

Please sign in to comment.