diff --git a/src/MultiFlexi/Ui/AppLastMonthChart.php b/src/MultiFlexi/Ui/AppLastMonthChart.php new file mode 100644 index 0000000..be7e04e --- /dev/null +++ b/src/MultiFlexi/Ui/AppLastMonthChart.php @@ -0,0 +1,41 @@ + + * + * 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()'); + } +} diff --git a/src/MultiFlexi/Ui/ApplicationInfo.php b/src/MultiFlexi/Ui/ApplicationInfo.php index 1221eb0..9aaa022 100644 --- a/src/MultiFlexi/Ui/ApplicationInfo.php +++ b/src/MultiFlexi/Ui/ApplicationInfo.php @@ -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)); } /** diff --git a/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php b/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php index 5705874..5c5ac83 100644 --- a/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php +++ b/src/MultiFlexi/Ui/CompanyAppJobsLastMonthChart.php @@ -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()'); } } diff --git a/src/MultiFlexi/Ui/JobChart.php b/src/MultiFlexi/Ui/JobChart.php index c94621c..3ada9f5 100644 --- a/src/MultiFlexi/Ui/JobChart.php +++ b/src/MultiFlexi/Ui/JobChart.php @@ -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(); @@ -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'); } } diff --git a/src/MultiFlexi/Ui/JobDotEnv.php b/src/MultiFlexi/Ui/JobDotEnv.php new file mode 100644 index 0000000..c4bbae8 --- /dev/null +++ b/src/MultiFlexi/Ui/JobDotEnv.php @@ -0,0 +1,36 @@ + + * + * 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 $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 ')); + } +} diff --git a/src/MultiFlexi/Ui/JobInfo.php b/src/MultiFlexi/Ui/JobInfo.php index d1d030c..d045e4c 100644 --- a/src/MultiFlexi/Ui/JobInfo.php +++ b/src/MultiFlexi/Ui/JobInfo.php @@ -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); } diff --git a/src/MultiFlexi/Ui/RunTemplateJobsLastMonthChart.php b/src/MultiFlexi/Ui/RunTemplateJobsLastMonthChart.php new file mode 100644 index 0000000..4622a0c --- /dev/null +++ b/src/MultiFlexi/Ui/RunTemplateJobsLastMonthChart.php @@ -0,0 +1,40 @@ + + * + * 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 + */ +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()); + } +} diff --git a/src/MultiFlexi/Ui/RunTemplatePanel.php b/src/MultiFlexi/Ui/RunTemplatePanel.php index 5561495..a50bfb3 100644 --- a/src/MultiFlexi/Ui/RunTemplatePanel.php +++ b/src/MultiFlexi/Ui/RunTemplatePanel.php @@ -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); diff --git a/src/actions.php b/src/actions.php index f490ac8..65a2bde 100644 --- a/src/actions.php +++ b/src/actions.php @@ -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(); diff --git a/src/jobenv.php b/src/jobenv.php new file mode 100644 index 0000000..a23b9d9 --- /dev/null +++ b/src/jobenv.php @@ -0,0 +1,27 @@ + + * + * 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(); +}