Skip to content

Commit

Permalink
Show credentials on Job page
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 15, 2024
1 parent d8fea5a commit 0288e23
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/MultiFlexi/CompanyApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
9 changes: 7 additions & 2 deletions src/MultiFlexi/CredentialType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
6 changes: 5 additions & 1 deletion src/MultiFlexi/RunTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 10 additions & 2 deletions src/MultiFlexi/Ui/EnvironmentView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
2 changes: 1 addition & 1 deletion src/companyapp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
4 changes: 0 additions & 4 deletions src/job.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down

0 comments on commit 0288e23

Please sign in to comment.