Box improvement and some experimental signalk code in webgui

This commit is contained in:
2026-09-15 08:42:56 +02:00
parent 57c42d1398
commit a76848e1da
6 changed files with 91 additions and 9 deletions
+36 -2
View File
@@ -10,6 +10,7 @@ require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
require 'lib/fileutils.inc';
require 'lib/signalk.inc';
$pagetitle = _('Equipment');
@@ -394,7 +395,7 @@ foreach ($res as $row) {
echo "<td>", $row['model'], "</td>\n";
echo "<td>", $row['serial'], "</td>\n";
echo "<td>", $age, "</td>\n";
echo "<td>", $row['remarks'], "</td>\n";
echo "<td>", h($row['remarks'], br:true), "</td>\n";
// Edit current record button
echo "<td>";
echo '<a title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['eid'], '"><i class="bi-pencil"></i></a>', "\n";
@@ -615,6 +616,39 @@ echo '<a href="measurement.php?f=add&id=', $id, '" class="btn btn-primary" role=
echo _('Add measurement'), "</a>\n";
echo "</div>\n";
// Signal-K Integration
$res = $pdo->query("SELECT valint, valstr FROM settings WHERE userid=0 AND sno=5");
$sk_active = false;
$sk_url = NULL;
if ($res !== false) {
$row = $res->fetch(PDO::FETCH_ASSOC);
if ($row !== false && $row['valint'] == 1
&& !empty($row['valstr'])
&& filter_var($settings['valstr'], FILTER_VALIDATE_URL))
{
$sk_active = true;
$sk_url = rtrim($row['valstr'], '/');
}
}
if ($sk_active) {
// TODO this ist just experimental
$sql = "SELECT skpath FROM signalk WHERE vid=? AND objid=? AND objtype='equipment'";
$sth = $pdo->prepare($sql);
$sth->execute([$user->vid, $id]);
if ($sth->rowCount() > 0) {
echo '<h3>', _('Signal K data'), "</h3>";
$skpath = $sth->fetchColumn();
// REST Example:
// GET http://127.0.0.1:3000/signalk/v1/api/vessels/self/propulsion/mainEngine/runTime
try {
$data = signalk_get($url, $skpath);
print_r($data);
} catch (Exception $e) {
echo "<p>signalk-timeout!</p>\n";
}
}
}
// Spare parts
echo '<h3>', _('Spare parts'), "</h3>";
@@ -707,7 +741,7 @@ form_create_select('category', _('Category'), $g_opt_unknown + $opt_ecat, $equip
?>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($equipment->remarks, br:true)?></textarea>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($equipment->remarks, br:false)?></textarea>
</div>
<?php
$opt_flags = db_load_enum('equipment', 'flags', true, true, false);