diff --git a/db/migrations/20241212075548_artifact_note.php b/db/migrations/20241212075548_artifact_note.php index c10b736..d03b9c6 100644 --- a/db/migrations/20241212075548_artifact_note.php +++ b/db/migrations/20241212075548_artifact_note.php @@ -1,6 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + use Phinx\Migration\AbstractMigration; final class ArtifactNote extends AbstractMigration @@ -20,6 +32,6 @@ public function change(): void { $table = $this->table('artifacts'); $table->addColumn('note', 'string', ['limit' => 255, 'null' => true]) - ->update(); + ->update(); } } diff --git a/lib/cli.php b/lib/cli.php index 72f796c..2c14c4e 100644 --- a/lib/cli.php +++ b/lib/cli.php @@ -22,11 +22,11 @@ Shared::init(['DB_CONNECTION', 'DB_HOST', 'DB_PORT', 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD'], '../.env'); $loggers = ['syslog', '\MultiFlexi\LogToSQL', 'console']; -if (\Ease\Shared::cfg('ZABBIX_SERVER') && \Ease\Shared::cfg('ZABBIX_HOST') && class_exists('\MultiFlexi\LogToZabbix')) { +if (Shared::cfg('ZABBIX_SERVER') && Shared::cfg('ZABBIX_HOST') && class_exists('\MultiFlexi\LogToZabbix')) { $loggers[] = '\MultiFlexi\LogToZabbix'; } -if (\Ease\Shared::cfg('APP_DEBUG') === 'true') { +if (Shared::cfg('APP_DEBUG') === 'true') { $loggers[] = 'console'; } @@ -66,7 +66,7 @@ switch ($command) { case 'version': - echo \Ease\Shared::appName().' '.\Ease\Shared::appVersion()."\n"; + echo Shared::appName().' '.Shared::appVersion().\PHP_EOL; break; case 'remove': @@ -86,6 +86,10 @@ case 'runtemplate': $engine = new \MultiFlexi\RunTemplate((int) $identifier); + break; + case 'job': + $engine = new \MultiFlexi\Job((int) $identifier); + break; default: @@ -132,6 +136,28 @@ $checkData = ['code' => (string) $identifier]; $engine = new \MultiFlexi\Company(['code' => (string) $identifier, 'name' => $property ? $property : $identifier], ['autoload' => false]); + break; + case 'credential_type': + if (empty($identifier)) { + echo $argv[0].' add credential_type '; + + exit; + } + + $checkData = ['name' => (string) $identifier]; + $engine = new \MultiFlexi\CredentialType($checkData, ['autoload' => false]); + + break; + case 'credential': + if (empty($identifier)) { + echo $argv[0].' add credential [--CONFIG_FIELD=VALUE ..]'; + + exit; + } + + $checkData = ['name' => (string) $identifier, 'type_id' => $property, 'company_id' => $option]; + $engine = new \MultiFlexi\Credential($checkData, ['autoload' => false]); + break; case 'runtemplate': if (empty($identifier)) { diff --git a/src/MultiFlexi/Action/Zabbix.php b/src/MultiFlexi/Action/Zabbix.php index 38c00a4..940eda6 100644 --- a/src/MultiFlexi/Action/Zabbix.php +++ b/src/MultiFlexi/Action/Zabbix.php @@ -84,7 +84,7 @@ public function perform(\MultiFlexi\Job $job): void if ($dataForZabbix) { $artifactor = new \MultiFlexi\Artifact(); - $artifactor->createArtifact($job->getMyKey(), $dataForZabbix, $metricsfile, file_exists($metricsfile) ? mime_content_type($metricsfile) : 'application/json', sprintf(_('Reported to Zabbix: from %s sent to %s as %s '), $me, $server , $zabbixKey) ); + $artifactor->createArtifact($job->getMyKey(), $dataForZabbix, $metricsfile, file_exists($metricsfile) ? mime_content_type($metricsfile) : 'application/json', sprintf(_('Reported to Zabbix: from %s sent to %s as %s '), $me, $server, $zabbixKey)); if (\Ease\Shared::cfg('USE_ZABBIX_SENDER') && file_exists('/usr/bin/zabbix_sender')) { $cmd = sprintf("zabbix_sender -v -z %s -s %s -k %s -o '%s'", $server, $me, $zabbixKey, $dataForZabbix); diff --git a/src/MultiFlexi/Artifact.php b/src/MultiFlexi/Artifact.php index ea273ab..a71a4b7 100644 --- a/src/MultiFlexi/Artifact.php +++ b/src/MultiFlexi/Artifact.php @@ -39,9 +39,10 @@ public function __construct($identifier = null, $options = []) /** * Create a new artifact record. * - * @param int $jobId Number of producing job + * @param int $jobId Number of producing job * @param mixed $filename * @param mixed $contentType + * @param mixed $note * * @return int Atrifacts Record ID */ @@ -53,7 +54,7 @@ public function createArtifact(int $jobId, string $artifact, $filename = '', $co 'content_type' => $contentType, 'artifact' => $artifact, 'created_at' => date('Y-m-d H:i:s'), - 'note' => $note + 'note' => $note, ]); } diff --git a/src/MultiFlexi/CredentialType.php b/src/MultiFlexi/CredentialType.php new file mode 100644 index 0000000..8d815fe --- /dev/null +++ b/src/MultiFlexi/CredentialType.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace MultiFlexi; + +/** + * Description of CredentialType. + * + * @author Vitex + */ +class CredentialType extends DBEngine +{ + #[\Override] + public function __construct($init = null, $filter = []) + { + $this->myTable = 'credential_types'; + parent::__construct($init, $filter); + } +} diff --git a/src/MultiFlexi/DBEngine.php b/src/MultiFlexi/DBEngine.php index 7d7e923..08ba3f3 100644 --- a/src/MultiFlexi/DBEngine.php +++ b/src/MultiFlexi/DBEngine.php @@ -67,7 +67,7 @@ class DBEngine extends \Ease\SQL\Engine * Data Processing Engine. * * @param int $init - * @param int $filter Initial conditons + * @param int $filter Initial conditions */ public function __construct($init = null, $filter = []) { @@ -117,7 +117,7 @@ public function takemyTable($myTable) } /** - * Set page where to work wiht one row detail. + * Set page where to work with one row detail. * * @param string $detailPage */ diff --git a/src/MultiFlexi/RunTemplate.php b/src/MultiFlexi/RunTemplate.php index 5961657..f947eb5 100644 --- a/src/MultiFlexi/RunTemplate.php +++ b/src/MultiFlexi/RunTemplate.php @@ -21,7 +21,7 @@ /** * @author vitex */ -class RunTemplate extends \MultiFlexi\Engine +class RunTemplate extends \MultiFlexi\DBEngine { public static array $intervalCode = [ 'y' => 'yearly', @@ -452,4 +452,32 @@ public function credentialsEnvironment() return $credentials; } + + public function columns($columns = []) + { + return parent::columns([ + ['name' => 'id', 'type' => 'text', 'label' => _('ID')], + ['name' => 'interv', 'type' => 'text', 'label' => _('Interval')], + ['name' => 'delay', 'type' => 'text', 'label' => _('Delay')], + ['name' => 'executor', 'type' => 'text', 'label' => _('Executor')], + // ['name' => 'created', 'type' => 'datetime', 'label' => _('Created')], + // ['name' => 'resolved', 'type' => 'datetime', 'label' => _('Resolved')], + ['name' => 'app_id', 'type' => 'selectize', 'label' => _('Application'), + 'listingPage' => 'apps.php', + 'detailPage' => 'app.php', + 'idColumn' => 'apps', + 'valueColumn' => 'apps.name', + 'engine' => '\MultiFlexi\Application', + 'filterby' => 'name', + ], + ['name' => 'company_id', 'type' => 'selectize', 'label' => _('Company'), + 'listingPage' => 'companies.php', + 'detailPage' => 'company.php', + 'idColumn' => 'company', + 'valueColumn' => 'company.name', + 'engine' => '\MultiFlexi\Company', + 'filterby' => 'name', + ], + ]); + } } diff --git a/src/MultiFlexi/Ui/CompaniesBar.php b/src/MultiFlexi/Ui/CompaniesBar.php index 3452084..9e9a540 100644 --- a/src/MultiFlexi/Ui/CompaniesBar.php +++ b/src/MultiFlexi/Ui/CompaniesBar.php @@ -34,18 +34,15 @@ public function __construct(array $properties = []) $companyAppCard->addTagClass('text-center'); $companyAppCard->addItem(new \Ease\Html\DivTag(new \Ease\Html\H5Tag($companyData['name'], ['class' => 'card-title']), ['class' => 'card-body'])); - - - - + $companyAppStatus = new \Ease\Html\DivTag(); $companyApps = (new CompanyApp($companer))->getAssigned()->leftJoin('apps ON apps.id = companyapp.app_id')->select(['apps.name', 'apps.description', 'apps.id', 'apps.uuid'], true)->fetchAll(); - - foreach ($companyApps as $companyApp){ - $companyAppStatus->addItem(new \Ease\Html\ATag('companyapp.php?company_id='.$companer->getMyKey().'&app_id='.$companyApp['id'], new \Ease\Html\ImgTag('appimage.php?uuid='.$companyApp['uuid'], _($companyApp['name']), ['title' => _($companyApp['description']), 'style' => 'padding: 5px; margin: 5px;max-height: 50px;max-width: 50px;']))); + + foreach ($companyApps as $companyApp) { + $companyAppStatus->addItem(new \Ease\Html\ATag('companyapp.php?company_id='.$companer->getMyKey().'&app_id='.$companyApp['id'], new \Ease\Html\ImgTag('appimage.php?uuid='.$companyApp['uuid'], _($companyApp['name']), ['title' => _($companyApp['description']), 'style' => 'padding: 5px; margin: 5px;max-height: 50px;max-width: 50px;']))); } - + $companyAppCard->addItem(new \Ease\Html\DivTag($companyAppStatus, ['class' => 'card-footer bg-transparent'])); $cardGroup->addItem($companyAppCard); diff --git a/src/MultiFlexi/Ui/IntervalChooser.php b/src/MultiFlexi/Ui/IntervalChooser.php index 0617d35..6e6992b 100644 --- a/src/MultiFlexi/Ui/IntervalChooser.php +++ b/src/MultiFlexi/Ui/IntervalChooser.php @@ -30,13 +30,13 @@ class IntervalChooser extends \Ease\Html\SelectTag public function __construct(string $name, string $defaultValue = '', array $properties = []) { parent::__construct($name, [ - 'n' => RunTemplate::getIntervalEmoji('n') .' '. _('Disabled'), - 'i' => RunTemplate::getIntervalEmoji('i') .' '._('Minutly'), - 'h' => RunTemplate::getIntervalEmoji('h') .' '._('Hourly'), - 'd' => RunTemplate::getIntervalEmoji('d') .' '._('Daily'), - 'w' => RunTemplate::getIntervalEmoji('w') .' '. _('Weekly'), - 'm' => RunTemplate::getIntervalEmoji('m') .' '. _('Monthly'), - 'y' => RunTemplate::getIntervalEmoji('y') .' '. _('Yearly'), + 'n' => RunTemplate::getIntervalEmoji('n').' '._('Disabled'), + 'i' => RunTemplate::getIntervalEmoji('i').' '._('Minutly'), + 'h' => RunTemplate::getIntervalEmoji('h').' '._('Hourly'), + 'd' => RunTemplate::getIntervalEmoji('d').' '._('Daily'), + 'w' => RunTemplate::getIntervalEmoji('w').' '._('Weekly'), + 'm' => RunTemplate::getIntervalEmoji('m').' '._('Monthly'), + 'y' => RunTemplate::getIntervalEmoji('y').' '._('Yearly'), ], $defaultValue, $properties); } } diff --git a/src/job.php b/src/job.php index f262fc9..7ec2748 100644 --- a/src/job.php +++ b/src/job.php @@ -46,7 +46,7 @@ $artifactsDiv = new \Ease\Html\DivTag(); foreach ($artifacts->fetchAll() as $artifactData) { - $artifactsDiv->addItem( new \Ease\TWB4\Panel($artifactData['filename'],'inverse', new \Ease\Html\DivTag(nl2br($artifactData['artifact']), ['style' => 'font-family: monospace; color: black']), $artifactData['note'] ) ); + $artifactsDiv->addItem(new \Ease\TWB4\Panel($artifactData['filename'], 'inverse', new \Ease\Html\DivTag(nl2br($artifactData['artifact']), ['style' => 'font-family: monospace; color: black']), $artifactData['note'])); } $outputTabs->addTab(_('Artifacts'), $artifactsDiv);