From 0288e23ede2058b659f9e44cd4064c8dd98ac6fd Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Sun, 15 Dec 2024 02:10:04 +0100 Subject: [PATCH] Show credentials on Job page --- src/MultiFlexi/CompanyApp.php | 6 ++++-- src/MultiFlexi/CredentialType.php | 9 +++++++-- src/MultiFlexi/RunTemplate.php | 6 +++++- src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php | 6 +++--- src/MultiFlexi/Ui/EnvironmentView.php | 12 ++++++++++-- src/companyapp.php | 2 +- src/job.php | 4 ---- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/MultiFlexi/CompanyApp.php b/src/MultiFlexi/CompanyApp.php index 69f2689..be43a6c 100644 --- a/src/MultiFlexi/CompanyApp.php +++ b/src/MultiFlexi/CompanyApp.php @@ -35,11 +35,13 @@ public function __construct(?Company $company = null, $options = []) $this->company = $company; } - public function setApp(Application $application): self { + public function setApp(Application $application): self + { $this->app = $application; + return $this; } - + public function getAssigned() { return $this->getAll()->where('company_id', $this->company->getMyKey()); diff --git a/src/MultiFlexi/CredentialType.php b/src/MultiFlexi/CredentialType.php index 8d815fe..afd6be1 100644 --- a/src/MultiFlexi/CredentialType.php +++ b/src/MultiFlexi/CredentialType.php @@ -22,10 +22,15 @@ */ class CredentialType extends DBEngine { - #[\Override] public function __construct($init = null, $filter = []) { $this->myTable = 'credential_types'; - parent::__construct($init, $filter); + parent::__construct(false /* TODO $init */, $filter); + $formClass = '\\MultiFlexi\\Ui\\Form\\'.$init; + + if (class_exists($formClass)) { + $this->setDataValue('logo', $formClass::$logo); + $this->setDataValue('name', $formClass::name()); + } } } diff --git a/src/MultiFlexi/RunTemplate.php b/src/MultiFlexi/RunTemplate.php index f947eb5..f2006e4 100644 --- a/src/MultiFlexi/RunTemplate.php +++ b/src/MultiFlexi/RunTemplate.php @@ -440,13 +440,17 @@ public function credentialsEnvironment() $kredenc = new Credential(); foreach ($rtplCrds->getCredentialsForRuntemplate($this->getMyKey())->select(['name', 'formType', 'credentials_id'])->leftJoin('credentials ON credentials.id = runtplcreds.credentials_id') as $crds) { + $kredenc->dataReset(); $kredenc->loadFromSQL($crds['credentials_id']); $creds = $kredenc->getData(); unset($creds['id'],$creds['name'], $creds['company_id'], $creds['formType']); + $this->addStatusMessage('Credentials: '.$crds['formType'].' "'.$crds['name'].'" '.implode(',', array_keys($creds)), 'debug'); foreach ($creds as $key => $value) { $credentials[$key]['value'] = $value; - $credentials[$key]['source'] = $crds['formType'].': '.$crds['name']; + $credentials[$key]['source'] = $crds['name']; + $credentials[$key]['credential_type'] = $crds['formType']; + $credentials[$key]['credential_id'] = $crds['id']; } } diff --git a/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php b/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php index c62459b..5705874 100644 --- a/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php +++ b/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php @@ -22,11 +22,11 @@ */ class CompanyAppJobsLastMonthChart extends JobChart { - - public function __construct(\MultiFlexi\CompanyApp $engine, $properties = []) { + public function __construct(\MultiFlexi\CompanyApp $engine, $properties = []) + { parent::__construct($engine, $properties); } - + /** * @return type */ diff --git a/src/MultiFlexi/Ui/EnvironmentView.php b/src/MultiFlexi/Ui/EnvironmentView.php index 233a0fe..54e8903 100644 --- a/src/MultiFlexi/Ui/EnvironmentView.php +++ b/src/MultiFlexi/Ui/EnvironmentView.php @@ -54,8 +54,16 @@ public function __construct($environment = [], array $properties = []) // TODO $envData['value'] = new \Ease\TWB4\Badge('danger',_('Required')); // } - $ns = \array_key_exists('source', $envData) ? explode('\\', $envData['source']) : ['n/a']; - $this->addRowColumns([new \Ease\Html\SpanTag($key, ['title' => \array_key_exists('description', $envData) ? $envData['description'] : '']), $envData['value'], end($ns)]); + if (\array_key_exists('credential_id', $envData)) { + $source = new \Ease\Html\DivTag(new \Ease\Html\ATag('credential.php?id='.$envData['credential_id'], $envData['source'])); + $credTyper = new \MultiFlexi\CredentialType($envData['credential_type']); + $source->addItem(new \Ease\Html\ImgTag($credTyper->getDataValue('logo'), $envData['credential_type'], ['title' => $credTyper->getRecordName(), 'height' => '30', 'align' => 'right'])); + } else { + $ns = \array_key_exists('source', $envData) ? explode('\\', $envData['source']) : ['n/a']; + $source = end($ns); + } + + $this->addRowColumns([new \Ease\Html\SpanTag($key, ['title' => \array_key_exists('description', $envData) ? $envData['description'] : '']), $envData['value'], $source]); } } } diff --git a/src/companyapp.php b/src/companyapp.php index 0fec0dd..1f5e0f4 100644 --- a/src/companyapp.php +++ b/src/companyapp.php @@ -113,7 +113,7 @@ $companyAppJobChart = new CompanyAppJobsLastMonthChart((new \MultiFlexi\CompanyApp($companer))->setApp($application)); -WebPage::singleton()->container->addItem(new CompanyPanel($companer, new ApplicationPanel($application,$companyAppColumns,$companyAppJobChart))); +WebPage::singleton()->container->addItem(new CompanyPanel($companer, new ApplicationPanel($application, $companyAppColumns, $companyAppJobChart))); WebPage::singleton()->addItem(new PageBottom()); WebPage::singleton()->draw(); diff --git a/src/job.php b/src/job.php index 7ec2748..65e6655 100644 --- a/src/job.php +++ b/src/job.php @@ -24,10 +24,6 @@ $jobber = new \MultiFlexi\Job($jobID); $runTemplate = new \MultiFlexi\RunTemplate($jobber->getDataValue('runtemplate_id')); -if (null === $runTemplate->getMyKey()) { // TODO: Remove - $runTemplate->setMyKey($runTemplate->runTemplateID($jobber->getDataValue('app_id'), $jobber->getDataValue('company_id'))); -} - $appInfo = $runTemplate->getAppInfo(); $apps = new Application($appInfo['app_id']); $instanceName = $appInfo['app_name'];