Commit 6b29e1a8 authored by Roman Ondráček's avatar Roman Ondráček

Install: add GW information download button (fix #218)

Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent 2c54e7dc
Pipeline #2118 failed with stages
in 6 minutes and 25 seconds
......@@ -23,6 +23,9 @@ namespace App\InstallModule\Presenters;
use App\GatewayModule\Models\InfoManager;
use App\GatewayModule\Models\NetworkManager;
use App\GatewayModule\Models\VersionManager;
use App\IqrfNetModule\Exceptions\DpaErrorException;
use App\IqrfNetModule\Exceptions\EmptyResponseException;
use Nette\Utils\JsonException;
/**
* IQRF Gateway info presenter
......@@ -65,10 +68,39 @@ class GatewayInfoPresenter extends InstallationPresenter {
$this->template->macAddresses = $this->networkManager->getMacAddresses();
$this->template->board = $this->infoManager->getBoard();
$this->template->hostname = $this->networkManager->getHostname();
$this->template->controllerVersion = $this->versionManager->getController();
$this->template->daemonVersion = $this->versionManager->getDaemon(true);
$this->template->webAppVersion = $this->versionManager->getWebapp(true);
$this->template->gwId = $this->infoManager->getId();
$this->template->gwmonId = $this->infoManager->getPixlaToken();
try {
$this->template->module = $this->infoManager->getCoordinatorInfo()['response']->data->rsp;
} catch (DpaErrorException | EmptyResponseException | JsonException $e) {
$this->flashError('gateway.info.tr.error');
}
}
/**
* Downloads gateway information as JSON
*/
public function actionDownload(): void {
$data = [
'board' => $this->infoManager->getBoard(),
'gwId' => $this->infoManager->getId(),
'pixla' => $this->infoManager->getPixlaToken(),
'controllerVersion' => $this->versionManager->getController(),
'daemonVersion' => $this->versionManager->getDaemon(true),
'webappVersion' => $this->versionManager->getWebapp(true),
'hostname' => $this->networkManager->getHostname(),
'ipAddresses' => $this->networkManager->getIpAddresses(),
'macAddresses' => $this->networkManager->getMacAddresses(),
];
try {
$data['coordinator'] = $this->infoManager->getCoordinatorInfo();
} catch (DpaErrorException | EmptyResponseException | JsonException $e) {
$data['coordinator'] = 'ERROR';
}
$this->sendJson($data);
}
}
......@@ -22,12 +22,15 @@ namespace App\InstallModule\Presenters;
use App\CoreModule\Models\UserManager;
use App\CoreModule\Presenters\BasePresenter;
use App\CoreModule\Traits\TPresenterFlashMessage;
/**
* Installation presenter
*/
abstract class InstallationPresenter extends BasePresenter {
use TPresenterFlashMessage;
/**
* @var UserManager User manager
*/
......
......@@ -27,18 +27,26 @@
<th>{_gateway.info.board}</th>
<td>{$board}</td>
</tr>
{ifset $gwId}
<tr>
<th>{_gateway.info.gwId}</th>
<td>{$gwId}</td>
</tr>
{/ifset}
{ifset $gwmonId}
<tr>
<th>{_gateway.info.gwmonId}</th>
<td>{$gwmonId}</td>
</tr>
{/ifset}
<tr n:ifset='$gwId'>
<th>{_gateway.info.gwId}</th>
<td>{$gwId}</td>
</tr>
<tr n:ifset='$gwmonId'>
<th><a href='https://www.pixla.online/'>{_gateway.info.gwmonId}</a></th>
<td>{$gwmonId}</td>
</tr>
<tr n:ifset='$controllerVersion'>
<th>{_gateway.info.version.iqrf-gw-controller}</th>
<td>{$controllerVersion}</td>
</tr>
<tr>
<th>{_gateway.info.version.iqrf-gw-daemon}</th>
<td>{$daemonVersion}</td>
</tr>
<tr>
<th>{_gateway.info.version.iqrf-gw-webapp}</th>
<td>{$webAppVersion}</td>
</tr>
<tr>
<th>{_gateway.info.hostname}</th>
<td>{$hostname}</td>
......@@ -64,13 +72,28 @@
</td>
</tr>
<tr>
<th>{_gateway.info.version.iqrf-gw-daemon}</th>
<td>{$daemonVersion}</td>
</tr>
<tr>
<th>{_gateway.info.version.iqrf-gw-webapp}</th>
<td>{$webAppVersion}</td>
<th>{_gateway.info.tr.title}</th>
<td>
{ifset $module}
{var $osInfo = $module->osRead}
{var $enumeration = $module->peripheralEnumeration}
<strong>{_gateway.info.tr.moduleType}:</strong> {$osInfo->trMcuType->trType}<br>
<strong>{_gateway.info.tr.mcuType}:</strong> {$osInfo->trMcuType->mcuType}<br>
<strong>{_gateway.info.tr.moduleId}:</strong> {$osInfo->mid}<br>
<strong>{_gateway.info.tr.os}:</strong> {$osInfo->osVersion} ({$osInfo->osBuild})<br>
<strong>{_gateway.info.tr.dpa}:</strong> {$enumeration->dpaVer}<br>
{ifset $enumeration->flags->rfMode}
<strong>{_gateway.info.tr.rfMode}:</strong> {$enumeration->flags->rfMode}<br>
{elseifset $enumeration->flags->networkType}
<strong>{_gateway.info.tr.networkType}:</strong> {$enumeration->flags->networkType}<br>
{/ifset}
<strong>{_gateway.info.tr.voltage}:</strong> {$osInfo->supplyVoltage}
{else}
{_gateway.info.tr.error}
{/ifset}
</td>
</tr>
</table>
<a class='btn btn-primary' n:href='download' role='button'>{_install.gwInfo.download}</a>
</section>
</div>
......@@ -11,3 +11,4 @@ createUser:
gwInfo:
title: Some information about this gateway
button: Show GW info
download: Download as JSON
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment