Skip to content

Commit

Permalink
Added Success, Failled and Unfinished Buttons to company page job list
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Apr 11, 2024
1 parent 37cba1f commit 0df6479
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/MultiFlexi/Ui/CompanyDbStatus.php
Expand Up @@ -45,17 +45,17 @@ public function __construct($company)
[_('Jobs Total') . ' ', new \Ease\TWB4\PillBadge('info', $jobs)],
['class' => 'btn btn-default', 'type' => 'button']
));
$this->addColumn(2, new \Ease\Html\ButtonTag(
$this->addColumn(2, new \Ease\TWB4\LinkButton('?showOnly=success&id='.$companyId,
[_('Success Jobs') . ' ', new \Ease\TWB4\PillBadge('success', $jobsSuccess)],
['class' => 'btn btn-default', 'type' => 'button']
'success'
));
$this->addColumn(2, new \Ease\TWB4\LinkButton('showOnly=failed&id='.$companyId,
$this->addColumn(2, new \Ease\TWB4\LinkButton('?showOnly=failed&id='.$companyId,
[_('Failed Jobs') . ' ', new \Ease\TWB4\PillBadge('danger', $jobs - $jobsSuccess - $jobsUnfinished)],
'danger'
));
$this->addColumn(2, new \Ease\Html\ButtonTag(
$this->addColumn(2, new \Ease\TWB4\LinkButton('?showOnly=unfinished&id='.$companyId,
[_('Unfinished Jobs') . ' ', new \Ease\TWB4\PillBadge('warning', $jobsUnfinished)],
['class' => 'btn btn-default', 'type' => 'button']
'warning'
));
// $this->addColumn(2, new \Ease\Html\ButtonTag(
// [_('Customers') . ' ', new \Ease\TWB4\PillBadge('info', $customers)],
Expand Down
20 changes: 19 additions & 1 deletion src/company.php
Expand Up @@ -24,7 +24,25 @@
$companyEnver = new \MultiFlexi\CompanyEnv($companies->getMyKey());
$jobber = new \MultiFlexi\Job();
$jobber->setDataValue('company_id', $companies->getMyKey());
$jobs = $jobber->listingQuery()->select(['apps.name AS appname', 'apps.image AS appimage', 'job.id', 'begin', 'exitcode', 'launched_by', 'job.executor', 'login', 'job.app_id AS app_id', 'runtemplate.id AS runtemplateid', 'schedule AS scheduled'], true)->leftJoin('apps ON apps.id = job.app_id')->leftJoin('user ON user.id = job.launched_by')->leftJoin('runtemplate ON runtemplate.company_id = job.company_id AND runtemplate.app_id = job.app_id')->where('job.company_id', $companies->getMyKey())->limit(20)->orderBy('job.id DESC')->fetchAll();


$showOnly = WebPage::getRequestValue('showOnly');
switch ($showOnly) {
case 'failed':
$condition['exitcode'] = [255,128,1];
break;
case 'unfinished':
$condition['exitcode'] = -1;
break;
case 'success':
$condition['exitcode'] = 0;
break;
default:
$condition = [];
break;
}

$jobs = $jobber->listingQuery()->select(['apps.name AS appname', 'apps.image AS appimage', 'job.id', 'begin', 'exitcode', 'launched_by', 'job.executor', 'login', 'job.app_id AS app_id', 'runtemplate.id AS runtemplateid', 'schedule AS scheduled'], true)->leftJoin('apps ON apps.id = job.app_id')->leftJoin('user ON user.id = job.launched_by')->leftJoin('runtemplate ON runtemplate.company_id = job.company_id AND runtemplate.app_id = job.app_id')->where('job.company_id', $companies->getMyKey())->limit(20)->orderBy('job.id DESC')->where($condition)->fetchAll();
$jobList = new \Ease\TWB4\Table();
$jobList->addRowHeaderColumns([_('Application'), _('Job ID'), _('Launch time'), _('Exit Code'), _('Launcher'), _('Launch now'), _('Launch in Background')]);
foreach ($jobs as $job) {
Expand Down

0 comments on commit 0df6479

Please sign in to comment.