Compare commits

..

No commits in common. "2069cb104544d4211763d5b8c4d241a7781fe4d8" and "2fba4db0af33488303591e8516ab3fb00e5d5acc" have entirely different histories.

6 changed files with 1 additions and 130 deletions

View File

@ -1,26 +0,0 @@
<?php
require "../header.php";
$query = "SELECT mac, ipaddress, label, board, firmware, service, lastupdate FROM devices ORDER BY label, lastupdate DESC";
$sth = $globaldbh->prepare($query);
$sth->execute();
$data = array();
while ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) {
$d = array();
$d["mac"] = $row["mac"];
$d["ipaddress"] = $row["ipaddress"];
$d["label"] = $row["label"];
$d["board"] = $row["board"];
$d["firmware"] = $row["firmware"];
$d["service"] = $row["service"];
$d["lastupdate"] = $row["lastupdate"];
$data[] = $d;
}
header('Content-Type: application/json');
echo json_encode($data);
exit();
// vim: et ai sw=3 ts=3:

View File

@ -1,30 +0,0 @@
<?php
require 'header.php';
$ipaddress = $_SERVER['REMOTE_ADDR'];
$mac = "";
$board = "";
$firmware = "";
$service = "";
if ( isset($_REQUEST['mac']) ) $mac = $_REQUEST['mac'];
if ( $mac == "" ) exit();
if ( isset($_REQUEST['board']) ) $board = $_REQUEST['board'];
if ( isset($_REQUEST['firmware']) ) $firmware = $_REQUEST['firmware'];
if ( isset($_REQUEST['service']) ) $service = $_REQUEST['service'];
$query = "INSERT INTO devices (mac, ipaddress, board, firmware, service, lastupdate) ";
$query .= "VALUES(:mac, :ipaddress, :board, :firmware, :service, NOW()) ";
$query .= "ON DUPLICATE KEY UPDATE ";
$query .= "ipaddress=:ipaddress, board=:board, firmware=:firmware, service=:service, lastupdate=NOW()";
$sth = $globaldbh->prepare($query);
$sth->bindValue(":mac", $mac, PDO::PARAM_STR);
$sth->bindValue(":ipaddress", $ipaddress, PDO::PARAM_STR);
$sth->bindValue(":board", $board, PDO::PARAM_STR);
$sth->bindValue(":firmware", $firmware, PDO::PARAM_STR);
$sth->bindValue(":service", $service, PDO::PARAM_STR);
$sth->execute();
exit();

View File

@ -108,31 +108,3 @@ input[type=button] {
color: #D8D8D8;
padding: 0px;
}
.devices {
width: 80%;
margin-left: auto;
margin-right: auto;
}
.device-container {
width: 100%;
text-align: left;
margin-top: 0.5em;
padding: 0.25em;
border: 2px solid gray;
}
.device-property {
width: 100%;
text-align: left;
}
.device-property-label {
width: 12em;
text-align: right;
font-weight: bold;
color: white;
display: inline-block;
margin-right: 1em;
}
.button-refresh {
margin-top: 0.5em;
width: 12em;
}

View File

@ -14,7 +14,6 @@ require "htmlheader.php";
<ul>
<li><a href='#main'>Main</a></li>
<li><a href='#picker'>Picker</a></li>
<li><a href='#devices'>Devices</a></li>
</ul>
<div id='main'>
<p><input type='button' class='buttonquarter' value='ALL' onClick='setTarget(0);' id='active-all'>
@ -54,10 +53,6 @@ require "htmlheader.php";
<input type='button' style='height: 3em; margin-bottom: 0.25em; width: 8em;' value='Set Color' onClick='setColor();'>
<input type='text' name='colorwheel' id='colorwheel' value='ff0000' /><br />
</div>
<div>
<p><button class="button-refresh" id="btn-refresh-devices">Refresh List</button></p>
<div id="devices" class="devices"></div>
</div>
</div>
</div>
<?php

View File

@ -26,7 +26,6 @@ CREATE TABLE `devices` (
`ipaddress` varchar(20) NOT NULL,
`label` varchar(255) NOT NULL DEFAULT '',
`board` varchar(255) NOT NULL DEFAULT '',
`firmware` varchar(255) NOT NULL DEFAULT '',
`service` varchar(255) NOT NULL DEFAULT '',
`lastupdate` datetime NOT NULL,
PRIMARY KEY (`mac`)

View File

@ -1,11 +1,7 @@
$(document).ready(function() {
$('#tabs').tabs({
});
$('#tabs').tabs();
$('#colorwheel').wheelColorPicker();
$("#btn-refresh-devices").on("click", getDevices);
getActive();
getDevices();
});
function setColor() {
@ -52,39 +48,6 @@ function getActive() {
});
}
function escapeHTML(str) {
return str.replace(/[<>]/g, function(match) {
switch (match) {
case '&': return '&amp;';
case '<': return '&lt;';
case '>': return '&gt;';
default: return match;
}
});
}
function getDevices() {
$.ajax({
url: 'ajax/getdevices.php',
dataType: 'json',
success: function(data, stat, jqo) {
var div = $("#devices");
div.html("");
var html = "";
data.forEach((device) => {
html += "<div class='device-container'>";
html += "<div class='device-property'><span class='device-property-label'>Service:</span>" + escapeHTML(device.service) + "</div>";
html += "<div class='device-property'><span class='device-property-label'>Label:</span>" + escapeHTML(device.label) + "</div>";
html += "<div class='device-property'><span class='device-property-label'>Board:</span>" + escapeHTML(device.board) + "</div>";
html += "<div class='device-property'><span class='device-property-label'>IP Address:</span>" + escapeHTML(device.ipaddress) + "</div>";
html += "<div class='device-property'><span class='device-property-label'>Last Update:</span>" + escapeHTML(device.lastupdate) + "</div>";
html += "</div>";
});
div.html(html);
}
});
}
function setTarget(id) {
$.ajax({
url: 'ajax/ajax_settarget.php',
@ -95,5 +58,3 @@ function setTarget(id) {
}
});
}
// vim: ts=3 sw=3 ai: