Added support for transmitter and receivers edit

This commit is contained in:
Lukáš Plevač 2023-10-16 19:54:13 +02:00
parent e91f12ba01
commit cf23afd409
17 changed files with 906 additions and 35 deletions

View File

@ -13,7 +13,10 @@
//register API functions
include_once(__DIR__ . "/observations.php");
include_once(__DIR__ . "/stations.php");
include_once(__DIR__ . "/targets.php");
include_once(__DIR__ . "/crons.php");
include_once(__DIR__ . "/transmitters.php");
include_once(__DIR__ . "/receivers.php");
//init API
$api->serve($router->getArgs());

67
web/API/receivers.php Normal file
View File

@ -0,0 +1,67 @@
<?php
namespace API\receiver;
function get($params) {
$receiver = new \DAL\receiver();
$receiver->id->set($params["id"]);
$receiver->fetch();
/**
* Create array of autoPlan with names
*/
$autoplan = new \wsos\structs\vector();
foreach ($receiver->autoPlan->get() as $transmitterId) {
$transmitter = new \DAL\transmitter();
$transmitter->id->set($transmitterId);
$transmitter->fetch();
$autoplan->append([
"id" => $transmitter->id->get(),
"target" => $transmitter->target->get()->name->get(),
"modulation" => $transmitter->modulation->get()->name->get(),
"dataType" => $transmitter->dataType->get()->name->get(),
"freq" => $transmitter->centerFrequency->get(),
]);
}
return [
"id" => $receiver->id->get(),
"freq" => $receiver->centerFrequency->get(),
"band" => $receiver->bandwidth->get(),
"params" => $receiver->params->get(),
"gain" => $receiver->gain->get(),
"autoPlan" => $autoplan,
"antenna" => $receiver->antenna->get()->id->get(),
"station" => $receiver->station->get()->id->get()
];
}
function save($params) {
$receiver = new \DAL\receiver();
if ($params["id"] <> "null") {
$receiver->id->set($params["id"]);
// try fetch from DB?
$receiver->fetch();
}
$receiver->centerFrequency->set($params["freq"]);
$receiver->bandwidth->set($params["band"]);
$receiver->gain->set($params["gain"]);
$receiver->params->set(json_decode($params["params"]));
$receiver->autoPlan->set(json_decode($params["autoPlan"]));
$receiver->station->set($params["station"]);
$receiver->antenna->set($params["antenna"]);
$receiver->commit();
return [
"id" => $receiver->id->get()
];
}

View File

@ -12,3 +12,17 @@
"locator" => $target->locator->get()
];
}
function add($params) {
$target = new \DAL\target();
$target->name->set($params["name"]);
$target->type->set($params["type"]);
$target->orbit->set($params["orbit"]);
$target->locator->set($params["locator"]);
$target->commit();
return ["id" => $target->id->get()];
}

49
web/API/transmitters.php Normal file
View File

@ -0,0 +1,49 @@
<?php
namespace API\transmitter;
function get($params) {
$transmitter = new \DAL\transmitter();
$transmitter->id->set($params["id"]);
$transmitter->fetch();
return [
"id" => $transmitter->id->get(),
"freq" => $transmitter->centerFrequency->get(),
"band" => $transmitter->bandwidth->get(),
"priority" => $transmitter->priority->get(),
"pipe" => $transmitter->processPipe->get()->id->get(),
"dataType" => $transmitter->dataType->get()->id->get(),
"modulation" => $transmitter->modulation->get()->id->get(),
"antenna" => $transmitter->antenna->get()->id->get(),
"target" => $transmitter->target->get()->id->get(),
];
}
function save($params) {
$transmitter = new \DAL\transmitter();
if ($params["id"] <> "null") {
$transmitter->id->set($params["id"]);
// try fetch from DB?
$transmitter->fetch();
}
$transmitter->centerFrequency->set($params["freq"]);
$transmitter->bandwidth->set($params["band"]);
$transmitter->priority->set($params["priority"]);
$transmitter->processPipe->set($params["pipe"]);
$transmitter->dataType->set($params["dataType"]);
$transmitter->modulation->set($params["modulation"]);
$transmitter->antenna->set($params["antenna"]);
$transmitter->target->set($params["target"]);
$transmitter->commit();
return [
"id" => $transmitter->id->get()
];
}

View File

@ -37,6 +37,9 @@
"fail" => $observationsTable->count("status==? && receiver.station.id == ?", [$ob->status->getVal("fail"), $stationId])
];
$context["transmitters"] = new \wsos\database\core\table(\DAL\transmitter::class);
$context["antennas"] = new \wsos\database\core\table(\DAL\antenna::class);
$templates->load("station.html");
$templates->render($context);
$templates->show();

View File

@ -0,0 +1,53 @@
<?php
$container = new \wsos\structs\container();
$templates = $container->get("templateLoader");
$router = $container->get("router");
$context = $container->get("context");
$auth = $container->get("auth");
// to show this page user must be logined
$auth->requireLogin();
//get target ID
$targetID = $router->getArgs()[0];
//get correct observation
$context["target"] = new \DAL\target(new \wsos\database\types\uuid($targetID));
$context["target"]->fetch();
$observationsTable = new \wsos\database\core\table(\DAL\observation::class);
$dummy_ob = new \DAL\observation();
$context["transmitters"] = new \wsos\database\core\table(\DAL\transmitter::class);
$context["transmitters"] = $context["transmitters"]->query(
"target.id == ?", [$targetID]
)->values;
$locatorsKey = array_keys($context["target"]->locator->get());
$last = (new \wsos\database\core\table(\DAL\observation::class))->query("(transmitter.target.id == ?) && (status == ?)", [$targetID, $dummy_ob->status->getVal("success")], "DESC end", 1);
$last = $last->len() > 0 ? $last->values[0]->end->strDelta() . " ago" : "never";
$context["target"] = [
"id" => $context["target"]->id->get(),
"name" => $context["target"]->name->get(),
"locatorsKey" => count($locatorsKey) > 0 ? $locatorsKey : ["none"],
"locators" => $context["target"]->locator->get(),
"type" => $context["target"]->type->get()->name->get(),
"description" => $context["target"]->description->get(),
"orbit" => $context["target"]->orbit->get(),
"transmitters" => count($context["transmitters"]),
"lastObservation" => $last,
"success" => $observationsTable->count("(status==?) && (transmitter.target.id == ?)", [$dummy_ob ->status->getVal("success"), $targetID]),
"fail" => $observationsTable->count("(status==?) && (transmitter.target.id == ?)", [$dummy_ob ->status->getVal("fail"), $targetID])
];
$context["pipes"] = new \wsos\database\core\table(\DAL\processPipe::class);
$context["dataTypes"] = new \wsos\database\core\table(\DAL\dataType::class);
$context["modulations"] = new \wsos\database\core\table(\DAL\modulation::class);
$context["antennas"] = new \wsos\database\core\table(\DAL\antenna::class);
$templates->load("target.html");
$templates->render($context);
$templates->show();

View File

@ -13,12 +13,13 @@
$targets = (new \wsos\database\core\table(\DAL\target::class))->getAll();
// create planed template observations
$ob = new \DAL\observation();
$dummy_ob = new \DAL\observation();
$dummy_target = new \DAL\target();
foreach ($targets->values as $target) {
$last = (new \wsos\database\core\table(\DAL\observation::class))->query("transmitter.target.id == ? && status == ?", [$target->id->get(), $ob->status->getVal("success")], "DESC end", 1);
$last = $last->len() > 0 ? "ago " . $last->values[0]->end->strDelta() : "never";
$last = (new \wsos\database\core\table(\DAL\observation::class))->query("(transmitter.target.id == ?) && (status == ?)", [$target->id->get(), $dummy_ob->status->getVal("success")], "DESC end", 1);
$last = $last->len() > 0 ? $last->values[0]->end->strDelta() . " ago" : "never";
$observations = (new \wsos\database\core\table(\DAL\observation::class))->count("transmitter.target.id == ?", [$target->id->get()]);
@ -32,7 +33,9 @@
]);
}
$context["targets"] = $context["targets"]->values;
$context["targets"] = $context["targets"]->values;
$context["types"] = new \wsos\database\core\table(\DAL\targetType::class);
$context["orbit_types"] = $dummy_target->orbit->getOptions()->values;
$templates->load("targets.html");

View File

@ -1,6 +1,6 @@
<tr>
<tr onclick="loadReceiver('{% BIND item.id %}')">
<td>{% BIND item.centerFrequency %}Hz</td>
<td>{% BIND item.bandwidth %}Hz</td>
<td>{% BIND item.antenna.name %}</td>
<td>{% BIND item.gain %}</td>
<td></td>
</tr>

View File

@ -0,0 +1,6 @@
<tr onclick="loadTransmitter('{% BIND item.id %}')">
<td>{% BIND item.centerFrequency %}Hz</td>
<td>{% BIND item.bandwidth %}Hz</td>
<td>{% BIND item.modulation.name %}</td>
<td>{% BIND item.dataType.name %}</td>
</tr>

View File

@ -88,12 +88,18 @@
</div>
</div>
<button type="button" style="display: none;" class="btn btn-primary ms-auto" data-bs-toggle="modal" id="receiverModal" data-bs-target="#newReceiverModal">
</button>
<div class="col-lg-6">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Station receivers</h3>
<button type="button" class="btn btn-primary ms-auto" onclick="openReceiver=null;" data-bs-toggle="modal" data-bs-target="#newReceiverModal">
+ Add
</button>
</div>
<div class="table-responsive scrollable" style="height: 400px">
<table class="table card-table table-vcenter text-nowrap datatable table-hover">
@ -101,8 +107,8 @@
<tr>
<th>Frequency</th>
<th>Bandwidth</th>
<th>Antenna</th>
<th>Gain</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@ -121,6 +127,9 @@
<div class="card">
<div class="card-header">
<h3 class="card-title">Station rotators</h3>
<button type="button" class="btn btn-primary ms-auto" onclick="openRotator=null;" data-bs-toggle="modal" data-bs-target="#newRotatorModal">
+ Add
</button>
</div>
<div class="table-responsive scrollable" style="height: 400px">
<table class="table card-table table-vcenter text-nowrap datatable table-hover">
@ -195,6 +204,157 @@
</div>
</div>
<div class="modal" id="newReceiverModal" tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Receiver</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Center frequency [hz]</label>
<input type="number" step="1" id="receiver-freq" placeholder="137100000" class="form-control">
</div>
</div>
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Bandwidth [hz]</label>
<input type="number" step="1" id="receiver-band" placeholder="250000" class="form-control">
</div>
</div>
<div class="col-lg-9">
<div class="mb-3">
<label class="form-label">Antenna</label>
<select class="form-select" id="receiver-antenna">
{% FOREACH antennas USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Gain [dB]</label>
<input type="number" step="1" id="receiver-gain" placeholder="0" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Auto plan targets</label>
<select class="form-select" id="select-transmitter" onchange="addAutoPlan()">
<option default value=""></option>
{% FOREACH transmitters USE '<option value="(\ BIND item.id \)">
(\ BIND item.target.name \) -
(\ BIND item.modulation.name \) -
(\ BIND item.dataType.name \) @
(\ BIND item.centerFrequency \)Hz
</option>' %}
</select>
<div id="receiver-auto-plan" class="mt-2">
</div>
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Receiver params [JSON]</label>
<textarea class="form-select" id="receiver-params" ></textarea>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
<button type="button" onclick="saveReceiver('{% BIND station.id %}')" class="btn btn-primary" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
</div>
<div class="modal" id="newRotatorModal" tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Rotator</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Frequency [hz]</label>
<input type="number" step="1" id="transmitter-freq" placeholder="137100000" class="form-control">
</div>
</div>
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Bandwidth [hz]</label>
<input type="number" step="1" id="transmitter-band" placeholder="250000" class="form-control">
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Antenna</label>
<select class="form-select" id="transmitter-antenna">
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Modulation</label>
<select class="form-select" id="transmitter-modulation">
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Data Type</label>
<select class="form-select" id="transmitter-datatype">
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Priority [UP]</label>
<input type="number" step="1" id="transmitter-priority" placeholder="0" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Process pipe</label>
<select class="form-select" id="transmitter-pipe">
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
<button type="button" onclick="save('{% BIND target.id %}')" class="btn btn-primary" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
</div>
</div>

282
web/VIEWS/target.html Normal file
View File

@ -0,0 +1,282 @@
<!doctype html>
<html lang="en">
{% INCLUDE layout/head.html %}
<body>
<div class="page">
{% BINDINCLUDE layout/header.html logined %}
<div class="page-header d-print-none mt-4">
<div class="container-xl">
<div class="row g-2 align-items-center">
<div class="col">
<div class="page-pretitle" id="target-id">
{% BIND target.id %}
</div>
<h2 class="page-title">
Target {% BIND target.name %}
</h2>
</div>
</div>
</div>
</div>
<div class="page-body">
<div class="container-xl">
<div class="row row-deck row-cards">
<div class="col-12">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Base info</h3>
</div>
<div class="card-body">
<div class="datagrid">
<div class="datagrid-item">
<div class="datagrid-title">Name</div>
<div class="datagrid-content">
{% BIND target.name %}
</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Type</div>
<div class="datagrid-content">
{% BIND target.type %}
</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Orbit</div>
<div class="datagrid-content">
{% BIND target.orbit %}
</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Transmitters count</div>
<div class="datagrid-content">{% BIND target.transmitters %}</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Last observation</div>
<div class="datagrid-content">{% BIND target.lastObservation %}</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Locators</div>
<div class="datagrid-content">
{% FOREACH target.locatorsKey USE '<span class="status" style="font-size: 10px;">(\ BIND item \)</span>' %}
</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Success observations</div>
<div class="datagrid-content">{% BIND target.success %}</div>
</div>
<div class="datagrid-item">
<div class="datagrid-title">Fail observations</div>
<div class="datagrid-content">{% BIND target.fail %}</div>
</div>
</div>
<hr>
<div class="col-12">
<div class="datagrid-title">Description</div>
<div class="datagrid-content">{% BIND target.description %}</div>
</div>
</div>
</div>
</div>
</div>
</div>
<button type="button" style="display:none" class="btn btn-primary ms-auto" id="transmitterModal" data-bs-toggle="modal" data-bs-target="#newTransmitterModal">
</button>
<div class="col-lg-6">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Target transmitters</h3>
<button type="button" class="btn btn-primary ms-auto" onclick="openTransmitter=null;" data-bs-toggle="modal" data-bs-target="#newTransmitterModal">
+ Add
</button>
</div>
<div class="table-responsive scrollable" style="height: 400px">
<table class="table card-table table-vcenter text-nowrap datatable table-hover">
<thead>
<tr>
<th>Frequency</th>
<th>Bandwidth</th>
<th>Modulation</th>
<th>Data Type</th>
</tr>
</thead>
<tbody>
{% FOREACH transmitters RENDER blocks/transmitter-item.html %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="row row-cards">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Target position</h3>
</div>
<div class="table-responsive scrollable" style="height: 400px">
<table class="table card-table table-vcenter text-nowrap datatable table-hover">
<thead>
<tr>
<th>Driver</th>
<th>Port/Host</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
stationId
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--div class="col-md-6 col-lg-12">
<div class="card">
<div class="card-status-start bg-danger"></div>
<div class="card-body">
<h3 class="card-title">Target basic info</h3>
<div class="row g-3">
<div class="col-md">
<div class="form-label">Name</div>
<input type="text" class="form-control" value="{% BIND target.name %}" id="traget-name">
</div>
</div>
<div class="row g-3 mt-2">
<div class="col-md">
<div class="form-label">Description</div>
<textarea class="form-control" id="station-description">{% BIND target.description %}</textarea>
</div>
</div>
<h3 class="card-title mt-4">Target locator</h3>
<div class="row g-3">
<div class="col-md">
<div class="form-label">Latitude</div>
<input type="number" class="form-control" id="station-lat" value="{% BIND station.lat %}">
</div>
<div class="col-md">
<div class="form-label">Longitude</div>
<input type="number" class="form-control" id="station-lon" value="{% BIND station.lon %}">
</div>
<div class="col-md">
<div class="form-label">Altitude [m]</div>
<input type="number" class="form-control" id="station-alt" value="{% BIND station.alt %}">
</div>
</div>
</div>
<div class="card-footer bg-transparent mt-auto">
<div class="btn-list justify-content-end">
<a href="#" class="btn btn-ghost-danger" onclick="deleteTarget('{% BIND target.id %}')">
Delete target
</a>
<a class="btn btn-primary" onclick="updateTarget('{% BIND target.id %}')">
Update target
</a>
</div>
</div>
</div>
</div-->
</div>
</div>
<div class="modal" id="newTransmitterModal" tabindex="-1">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Transmitter</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Frequency [hz]</label>
<input type="number" step="1" id="transmitter-freq" placeholder="137100000" class="form-control">
</div>
</div>
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Bandwidth [hz]</label>
<input type="number" step="1" id="transmitter-band" placeholder="250000" class="form-control">
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Antenna</label>
<select class="form-select" id="transmitter-antenna">
{% FOREACH antennas USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Modulation</label>
<select class="form-select" id="transmitter-modulation">
{% FOREACH modulations USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Data Type</label>
<select class="form-select" id="transmitter-datatype">
{% FOREACH dataTypes USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
<div class="col-lg-3">
<div class="mb-3">
<label class="form-label">Priority [UP]</label>
<input type="number" step="1" id="transmitter-priority" placeholder="0" class="form-control">
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Process pipe</label>
<select class="form-select" id="transmitter-pipe">
{% FOREACH pipes USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
<button type="button" onclick="save('{% BIND target.id %}')" class="btn btn-primary" data-bs-dismiss="modal">Save</button>
</div>
</div>
</div>
</div>
<!-- Tabler Core -->
<script src="/dist/js/tabler.min.js?1668287865" defer=""></script>
<script src="/static/js/target.js" defer=""></script>
</div>
</div>
</div>
</body>
</html>

View File

@ -71,25 +71,10 @@
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-7">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Target transmitter</label>
<select class="form-select" id="plan-transmitter">
{% FOREACH transmitters USE '<option value="(\ BIND item.id \)">
(\ BIND item.target.name \) -
(\ BIND item.modulation.name \) -
(\ BIND item.dataType.name \) @
(\ BIND item.centerFrequency \)Hz
</option>' %}
</select>
</div>
</div>
<div class="col-lg-5">
<div class="mb-3">
<label class="form-label">Station receiver</label>
<select class="form-select" id="plan-receiver">
{% FOREACH receivers USE '<option value="(\ BIND item.id \)">(\ BIND item.station.name \) @ (\ BIND item.centerFrequency \)Hz</option>' %}
</select>
<label class="form-label">Target name</label>
<input type="text" id="target-name" class="form-control" placeholder="Noaa 19">
</div>
</div>
</div>
@ -98,21 +83,55 @@
<div class="row">
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">Start UTC time</label>
<input type="datetime-local" id="plan-start" class="form-control">
<label class="form-label">Target type</label>
<select class="form-select" id="target-type">
{% FOREACH types USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
<div class="col-lg-6">
<div class="mb-3">
<label class="form-label">End UTC time</label>
<input type="datetime-local" id="plan-end" class="form-control">
<label class="form-label">Orbit type</label>
<select class="form-select" id="target-orbit">
{% FOREACH orbit_types USE '<option value="(\ BIND item.id \)">(\ BIND item.name \)</option>' %}
</select>
</div>
</div>
</div>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">Locator type</label>
<select class="form-select" id="target-locator-type" onchange="locatorChange()">
<option value="none">none</option>
<option value="tle-locator">TLE</option>
</select>
</div>
</div>
</div>
<div class="row locatorType" id="tle-locator" style="display:none">
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">TLE Line 1</label>
<input type="text" id="tle-locator-line1" class="form-control" placeholder="1 33591U 09005A 23243.18101660 .00000207 00000-0 13587-3 0 9998">
</div>
</div>
<div class="col-lg-12">
<div class="mb-3">
<label class="form-label">TLE Line 2</label>
<input type="text" id="tle-locator-line2" class="form-control" placeholder="2 33591 99.0938 290.2850 0014342 35.8617 324.3514 14.12812127750532">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn me-auto" data-bs-dismiss="modal">Close</button>
<button type="button" onclick="plan()" class="btn btn-primary" data-bs-dismiss="modal">Plan!</button>
<button type="button" onclick="add()" class="btn btn-primary" data-bs-dismiss="modal">add</button>
</div>
</div>
</div>
@ -121,7 +140,7 @@
<!-- Tabler Core -->
<script src="/dist/js/tabler.min.js?1668287865" defer=""></script>
<script src="/static/js/observations.js"></script>
<script src="/static/js/targets.js"></script>
</div>
</body>
</html>

View File

@ -23,6 +23,7 @@
*/
"observation" => ["controller" => __DIR__ . "/CONTROLLERS/observation.php", "name" => "Observation view", "menu" => false],
"station" => ["controller" => __DIR__ . "/CONTROLLERS/station.php", "name" => "Station view", "menu" => false],
"target" => ["controller" => __DIR__ . "/CONTROLLERS/target.php", "name" => "Target", "menu" => false],
"login" => ["controller" => __DIR__ . "/CONTROLLERS/login.php", "name" => "Login", "menu" => false],
"api" => ["controller" => __DIR__ . "/API/main.php", "name" => "api", "menu" => false],
],

View File

@ -24,9 +24,9 @@
$msumrType->name->set("MSU-MR");
$msumrType->commit();
$telemetryType = new \DAL\dataType();
$telemetryType->name->set("Telemetry");
$telemetryType->commit();
$beaconType = new \DAL\dataType();
$beaconType->name->set("Beacon");
$beaconType->commit();
/**
* Antennas seeds
@ -350,7 +350,7 @@
$maxvalierCW = new \DAL\transmitter();
$maxvalierCW->target->set($maxvalier);
$maxvalierCW->dataType->set($telemetryType);
$maxvalierCW->dataType->set($beaconType);
$maxvalierCW->bandwidth->set(120000);
$maxvalierCW->centerFrequency->set(145960000);
$maxvalierCW->modulation->set($cw);

View File

@ -1,3 +1,5 @@
var openReceiver = null;
function updateStation(id) {
var station = new FormData();
@ -25,6 +27,99 @@ function updateStation(id) {
xhttp.send(station);
}
function addAutoPlan() {
var sel = document.getElementById("select-transmitter");
// not not add is added
if (getAutoPlaned().includes(sel.value)) return;
var text = sel.options[sel.selectedIndex].text;
document.getElementById("receiver-auto-plan").innerHTML +=
'<span name="' + sel.value + '" class="status ms-2 mt-2" style="font-size: 10px;">' + text + '</span>';
}
function getAutoPlaned() {
var list = [];
var area = document.getElementById("receiver-auto-plan");
var transmitters = area.getElementsByClassName("status");
for (var i = 0; i < transmitters.length; i++) {
list.push(transmitters[i].getAttribute("name"));
}
return list;
}
function loadReceiver(id) {
var receiver = new FormData();
receiver.append("id", id);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText);
document.getElementById("receiver-freq").value = data.freq;
document.getElementById("receiver-band").value = data.band;
document.getElementById("receiver-antenna").value = data.antenna;
document.getElementById("receiver-gain").value = data.gain;
document.getElementById("receiver-params").value = JSON.stringify(data.params);
var block = "";
for (var i = 0; i < data.autoPlan.values.length; i++) {
block += '<span name="' + data.autoPlan.values[i].id + '" class="status ms-2 mt-2" style="font-size: 10px;">' +
data.autoPlan.values[i].target + " - " +
data.autoPlan.values[i].modulation + " - " +
data.autoPlan.values[i].dataType + " @ " +
data.autoPlan.values[i].freq + 'Hz</span>';
}
document.getElementById("receiver-auto-plan").innerHTML = block;
document.getElementById("receiverModal").click();
openReceiver = data.id;
}
};
xhttp.open("POST", "/api/receiver/get", true);
xhttp.send(receiver);
}
function saveReceiver(stationID) {
var receiver = new FormData();
var freq = document.getElementById("receiver-freq").value;
var band = document.getElementById("receiver-band").value;
var antenna = document.getElementById("receiver-antenna").value;
var gain = document.getElementById("receiver-gain").value;
var params = document.getElementById("receiver-params").value;
var autoPlan = JSON.stringify(getAutoPlaned());
var id = openReceiver;
receiver.append('id', id);
receiver.append('freq', freq);
receiver.append('band', band);
receiver.append('antenna', antenna);
receiver.append('gain', gain);
receiver.append('params', params);
receiver.append('autoPlan', autoPlan);
receiver.append('station', stationID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
location.reload();
}
};
xhttp.open("POST", "/api/receiver/save", true);
xhttp.send(receiver);
}
function deleteStation(id) {
var station = new FormData();

64
web/static/js/target.js Normal file
View File

@ -0,0 +1,64 @@
var openTransmitter = null;
function save(targetID) {
var transmitter = new FormData();
var freq = document.getElementById("transmitter-freq").value;
var band = document.getElementById("transmitter-band").value;
var antenna = document.getElementById("transmitter-antenna").value;
var modulation = document.getElementById("transmitter-modulation").value;
var datatype = document.getElementById("transmitter-datatype").value;
var priority = document.getElementById("transmitter-priority").value;
var pipe = document.getElementById("transmitter-pipe").value;
var id = openTransmitter;
transmitter.append('id', id);
transmitter.append('freq', freq);
transmitter.append('band', band);
transmitter.append('antenna', antenna);
transmitter.append('modulation', modulation);
transmitter.append('dataType', datatype);
transmitter.append('priority', priority);
transmitter.append('pipe', pipe);
transmitter.append('target', targetID);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
location.reload();
}
};
xhttp.open("POST", "/api/transmitter/save", true);
xhttp.send(transmitter);
}
function loadTransmitter(id) {
var xhttp = new XMLHttpRequest();
var transmitter = new FormData();
transmitter.append('id', id);
xhttp.open("POST", "/api/transmitter/get", true);
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = JSON.parse(this.responseText);
document.getElementById("transmitter-freq").value = data.freq;
document.getElementById("transmitter-band").value = data.band;
document.getElementById("transmitter-antenna").value = data.antenna;
document.getElementById("transmitter-modulation").value = data.modulation;
document.getElementById("transmitter-datatype").value = data.dataType;
document.getElementById("transmitter-priority").value = data.priority;
document.getElementById("transmitter-pipe").value = data.pipe;
document.getElementById("transmitterModal").click();
openTransmitter = data.id;
}
};
xhttp.send(transmitter);
}

52
web/static/js/targets.js Normal file
View File

@ -0,0 +1,52 @@
function add() {
var target = new FormData();
var name = document.getElementById("target-name").value;
var type = document.getElementById("target-type").value;
var orbit = document.getElementById("target-orbit").value;
var locator = document.getElementById("target-locator-type").value;
if (locator == "tle-locator") {
locator = {
"tle": {
"line1": document.getElementById("tle-locator-line1").value,
"line2": document.getElementById("tle-locator-line2").value
}
};
} else {
locator = {};
}
locator = JSON.stringify(locator);
target.append('name', name);
target.append('type', type);
target.append('orbit', orbit);
target.append('locator', locator);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
location.href = "/target/" + JSON.parse(this.responseText).id;
}
};
xhttp.open("POST", "/api/target/add", true);
xhttp.send(target);
}
function locatorChange() {
var locatorType = document.getElementById("target-locator-type").value;
//hide all locators options
var locators = document.getElementsByClassName("locatorType");
for (var i = 0; i < locators.length; i++) {
locators[i].style.display = "none";
}
if (locatorType != "none") {
document.getElementById(locatorType).style.display = "block";
}
}