Skip to content

Commit

Permalink
JobChart added
Browse files Browse the repository at this point in the history
JobEnv downloader added
RuntemplateChart added
  • Loading branch information
Vitexus committed Dec 15, 2024
1 parent 6f0c518 commit efc2060
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 9 deletions.
41 changes: 41 additions & 0 deletions src/MultiFlexi/Ui/AppLastMonthChart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/**
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Ui;

/**
* Description of AllJobsLastMonthChart.
*
* @author vitex
*/
class AppLastMonthChart extends JobChart
{
public function __construct(\MultiFlexi\Application $engine, $properties = [])
{
parent::__construct($engine, $properties);
}

/**
* @return type
*/
public function getJobs()
{
$today = date('Y-m-d');
$lastMonth = date('Y-m-d', strtotime('-30 days', strtotime($today)));

return parent::getJobs()->where("begin BETWEEN date('".$lastMonth."') AND date('".$today."')")->where('app_id', $this->engine->getMyKey());
// return parent::getJobs()->where('begin BETWEEN (CURDATE() - INTERVAL 30 DAY) AND CURDATE()');
}
}
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/ApplicationInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Application $application)
$body = new \Ease\Html\DivTag();
$body->addItem(new AppLogo($application));

parent::__construct($this->headerRow($application), 'inverse', $body, 'footer');
parent::__construct($this->headerRow($application), 'inverse', $body, new AppLastMonthChart($application));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getJobs()
$today = date('Y-m-d');
$lastMonth = date('Y-m-d', strtotime('-30 days', strtotime($today)));

return parent::getJobs()->from('job')->where('app_id', $this->engine->app->getMyKey())->where("begin BETWEEN date('".$lastMonth."') AND date('".$today."')");
return parent::getJobs()->where('app_id', $this->engine->app->getMyKey())->where("begin BETWEEN date('".$lastMonth."') AND date('".$today."')");
// return parent::getJobs()->where('begin BETWEEN (CURDATE() - INTERVAL 30 DAY) AND CURDATE()');
}
}
6 changes: 3 additions & 3 deletions src/MultiFlexi/Ui/JobChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
*/
class JobChart extends \Ease\Html\DivTag
{
protected \MultiFlexi\Engine $engine;
protected \Ease\SQL\Engine $engine;

public function __construct(\MultiFlexi\Engine $engine, $properties = [])
public function __construct(\Ease\SQL\Engine $engine, $properties = [])
{
$this->engine = $engine;
$allJobs = $this->getJobs()->fetchAll();
Expand Down Expand Up @@ -132,6 +132,6 @@ public function __construct(\MultiFlexi\Engine $engine, $properties = [])
*/
public function getJobs()
{
return $this->engine->listingQuery()->select(['begin', 'exitcode'], true)->order('begin');
return $this->engine->getFluentPDO(true)->from('job')->select(['begin', 'exitcode'], true)->order('begin');
}
}
36 changes: 36 additions & 0 deletions src/MultiFlexi/Ui/JobDotEnv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

/**
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Ui;

/**
* Description of AppJson.
*
* @author vitex
*/
class JobDotEnv extends \Ease\Html\DivTag
{
/**
* APP JSON Viewer.
*
* @param array<string, string> $properties
*/
public function __construct(\MultiFlexi\Job $job, array $properties = [])
{
parent::__construct(new \Ease\Html\PreTag($job->envFile()), $properties);
$this->addTagClass('ui-monospace custom-control');
$this->addItem(new \Ease\TWB4\LinkButton('jobenv.php?id='.$job->getMyKey(), _('Download').' multiflexi_job_'.$job->getMyKey().'.env', 'info '));
}
}
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/JobInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct(\MultiFlexi\Job $job, $properties = [])
// $scheduler = new \MultiFlexi\Scheduler();
// $scheduled = $scheduler->listingQuery()->where('job', $job->getMyKey())->fetch();

$jobTabs->addTab(_('Environment'), [$jobInfoRow, new EnvironmentView($job->getEnv())]);
$jobTabs->addTab(_('Environment'), [$jobInfoRow, new EnvironmentView($job->getEnv()), new JobDotEnv($job)]);

$this->addItem($jobTabs);
}
Expand Down
40 changes: 40 additions & 0 deletions src/MultiFlexi/Ui/RunTemplateJobsLastMonthChart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

/**
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Ui;

/**
* Description of RunTemplateJobsLastMonthChart.
*
* @author Vitex <info@vitexsoftware.cz>
*/
class RunTemplateJobsLastMonthChart extends JobChart
{
public function __construct(\MultiFlexi\RunTemplate $engine, $properties = [])
{
parent::__construct($engine, $properties);
}

/**
* @return type
*/
public function getJobs()
{
$today = date('Y-m-d');
$lastMonth = date('Y-m-d', strtotime('-30 days', strtotime($today)));

return parent::getJobs()->where("begin BETWEEN date('".$lastMonth."') AND date('".$today."')")->where('runtemplate_id', $this->engine->getMyKey());
}
}
2 changes: 1 addition & 1 deletion src/MultiFlexi/Ui/RunTemplatePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(\MultiFlexi\RunTemplate $runtemplate)
$this->addJavaScript("$('.editable').editable();", null, true);

$runtemplateTabs = new \Ease\TWB4\Tabs();
$runtemplateTabs->addTab(_('Jobs'), [$runtemplateJobs]);
$runtemplateTabs->addTab(_('Jobs'), [$runtemplateJobs, new RunTemplateJobsLastMonthChart($runtemplate)]);
$runtemplateTabs->addTab(_('Options'), [new RuntemplateConfigForm($runtemplate)]);

$this->addItem($runtemplateTabs);
Expand Down
4 changes: 2 additions & 2 deletions src/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
$appPanel->headRow->addItem(new RuntemplateButton($runTemplater));

$actionsRow = new \Ease\TWB4\Tabs();
$actionsRow->addTab(_('Success Actions'), new ActionsChooser('success', $app, $succesActions), (bool)$periodcalTaskInfo['success']);
$actionsRow->addTab(_('Fail Actions'), new ActionsChooser('fail', $app, $failActions), (bool)$periodcalTaskInfo['fail']);
$actionsRow->addTab(_('Success Actions'), new ActionsChooser('success', $app, $succesActions), (bool) $periodcalTaskInfo['success']);
$actionsRow->addTab(_('Fail Actions'), new ActionsChooser('fail', $app, $failActions), (bool) $periodcalTaskInfo['fail']);

$appPanel->addItem($actionsRow);
$jobtempform = new \Ease\TWB4\Form();
Expand Down
27 changes: 27 additions & 0 deletions src/jobenv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/**
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Ui;

require_once './init.php';
WebPage::singleton()->onlyForLogged();
$jobID = WebPage::singleton()->getRequestValue('id', 'int');

if ($jobID) {
$jobber = new \MultiFlexi\Job($jobID);
header('Content-Type: text/x-env');
header('Content-Disposition: attachment; filename="multiflexi_job_'.$jobID.'.env"');
echo $jobber->envFile();
}

0 comments on commit efc2060

Please sign in to comment.