Commit 5d2e84ce authored by Roman Ondráček's avatar Roman Ondráček

Config: add IQRF Info configuration tool (fix #200)

Signed-off-by: Roman Ondráček's avatarRoman Ondráček <ondracek.roman@centrum.cz>
parent 122d061a
Pipeline #2115 failed with stages
in 7 minutes and 29 seconds
<?php
/**
* Copyright 2017 MICRORISC s.r.o.
* Copyright 2017-2019 IQRF Tech s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace App\ConfigModule\Forms;
use App\ConfigModule\Presenters\IqrfInfoPresenter;
use Nette\Application\UI\Form;
use Nette\SmartObject;
use Nette\Utils\JsonException;
/**
* IQRF Info configuration form factory
*/
class IqrfInfoFormFactory extends GenericConfigFormFactory {
use SmartObject;
/**
* Creates the IQRF Info configuration form
* @param IqrfInfoPresenter $presenter IQRF Info configuration presenter
* @return Form IQRF Info configuration form
* @throws JsonException
*/
public function create(IqrfInfoPresenter $presenter): Form {
$this->manager->setComponent('iqrf::IqrfInfo');
$this->presenter = $presenter;
$form = $this->factory->create('config.iqrfInfo.form');
$form->addText('instance', 'instance')
->setRequired('messages.instance');
$form->addCheckbox('enumAtStartUp', 'enumAtStartUp');
$form->addInteger('enumPeriod', 'enumPeriod')
->addRule(Form::MIN, 'messages.enumPeriod', 0);
$form->addCheckbox('enumUniformDpaVer', 'enumUniformDpaVer');
$form->addSubmit('save', 'save');
$form->addProtection('core.errors.form-timeout');
$form->setDefaults($this->manager->load(0));
$form->onSuccess[] = [$this, 'save'];
return $form;
}
}
<?php
/**
* Copyright 2017 MICRORISC s.r.o.
* Copyright 2017-2019 IQRF Tech s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
declare(strict_types = 1);
namespace App\ConfigModule\Presenters;
use App\ConfigModule\Forms\IqrfInfoFormFactory;
use App\ConfigModule\Models\GenericManager;
use Nette\Application\UI\Form;
use Nette\Utils\JsonException;
/**
* IQRF Info configuration presenter
*/
class IqrfInfoPresenter extends GenericPresenter {
/**
* @var IqrfInfoFormFactory IQRF Info configuration form factory
* @inject
*/
public $formFactory;
/**
* Constructor
* @param GenericManager $genericManager Generic configuration manager
*/
public function __construct(GenericManager $genericManager) {
$components = ['iqrf::IqrfInfo'];
parent::__construct($components, $genericManager);
}
/**
* Creates the IQRF Info configuration form
* @return Form IQRF Info configuration form
* @throws JsonException
*/
protected function createComponentConfigIqrfInfoForm(): Form {
return $this->formFactory->create($this);
}
}
......@@ -3,6 +3,7 @@ services:
- App\ConfigModule\Forms\GenericConfigFormFactory
- App\ConfigModule\Forms\IqrfCdcFormFactory
- App\ConfigModule\Forms\IqrfDpaFormFactory
- App\ConfigModule\Forms\IqrfInfoFormFactory
- App\ConfigModule\Forms\IqrfRepositoryFormFactory
- App\ConfigModule\Forms\IqrfSpiFormFactory
- App\ConfigModule\Forms\IqrfUartFormFactory
......
......@@ -58,6 +58,10 @@
<header class='list-group-item-heading'>{_config.iqrfRepository.title}</header>
<p class='list-group-item-text'>{_config.iqrfRepository.description}</p>
</a>
<a n:if='$user->isInRole("power")' n:href='IqrfInfo:default' class='list-group-item'>
<header class='list-group-item-heading'>{_config.iqrfInfo.title}</header>
<p class='list-group-item-text'>{_config.iqrfInfo.description}</p>
</a>
<a n:if='$user->isInRole("power")' n:href='Iqmesh:default' class='list-group-item'>
<header class='list-group-item-heading'>{_config.iqmesh.title}</header>
<p class='list-group-item-text'>{_config.iqmesh.description}</p>
......
{**
* Copyright 2017 MICRORISC s.r.o.
* Copyright 2017-2019 IQRF Tech s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*}
{block title}{_config.iqrfInfo.title}{/block}
{block content}
<div class='panel panel-default'>
<div class='panel-body'>
{control configIqrfInfoForm}
</div>
</div>
......@@ -88,6 +88,19 @@ iqrfDpa:
DpaHandlerTimeout-rule: DPA Handler timeout must be bigger than 0.
Save: Save
iqrfInfo:
title: IQRF Info
description: IQRF Info database settings.
form:
instance: Name of instance
enumAtStartUp: Initialize network full enumeration just after startup
enumPeriod: Period in minutes of regular check enumeration
enumUniformDpaVer: Obtain only HWPID and HWPID version from nodes
messages:
instance: Please enter name of IQRF Info instance.
enumPeriod: Period must be bigger than 0.
save: Save
iqrfRepository:
title: IQRF Repository
description: "Manage IQRF Repository's settings."
......
......@@ -82,6 +82,9 @@
<li n:class='isLinkCurrent(":Config:IqrfRepository:*") ? "active"'>
<a n:href=':Config:IqrfRepository:default'>{_config.iqrfRepository.title}</a>
</li>
<li n:if='$user->isInRole("power")' n:class='isLinkCurrent(":Config:IqrfInfo:*") ? "active"'>
<a n:href=':Config:IqrfInfo:default'>{_config.iqrfInfo.title}</a>
</li>
<li n:if='$user->isInRole("power")' n:class='isLinkCurrent(":Config:Iqmesh:*") ? "active"'>
<a n:href=':Config:Iqmesh:default'>{_config.iqmesh.title}</a>
</li>
......
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