├── Block └── Adminhtml │ ├── Job │ └── Listing │ │ └── Actions.php │ ├── Task │ ├── Listing │ │ └── Actions.php │ ├── Timeline.php │ └── Timeline │ │ └── Actions.php │ └── UpgradeToPro.php ├── Console └── Command │ ├── Job │ └── Listing.php │ └── Task │ ├── Listing.php │ └── Show.php ├── Controller └── Adminhtml │ ├── Job │ ├── GenerateSchedule.php │ └── Listing.php │ ├── Task.php │ └── Task │ ├── Listing.php │ ├── MassDelete.php │ ├── Timeline.php │ └── View.php ├── Cron └── HeartBeat.php ├── Helper ├── HeartBeat.php ├── Job.php ├── Task.php └── Url.php ├── INSTALL.txt ├── Model └── ResourceModel │ └── Task │ └── Collection.php ├── Plugin └── Cron │ └── Observer │ ├── ProcessCronQueueObserver.php │ ├── ProcessCronQueueObserver_2.0.php │ ├── ProcessCronQueueObserver_2.1.php │ └── ProcessCronQueueObserver_2.2.php ├── README.md ├── Setup ├── InstallSchema.php └── UpgradeData.php ├── Ui ├── Component │ ├── JobListing │ │ └── Column │ │ │ ├── Code │ │ │ └── Options.php │ │ │ └── Group │ │ │ └── Options.php │ └── TaskListing │ │ └── Column │ │ ├── Actions.php │ │ ├── Code │ │ └── Options.php │ │ ├── Messages.php │ │ └── Status │ │ └── Options.php └── DataProvider │ ├── JobProvider.php │ └── TaskProvider.php ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── menu.xml │ ├── routes.xml │ └── system.xml ├── config.xml ├── cron_groups.xml ├── crontab.xml ├── di.xml └── module.xml ├── i18n ├── en_US.csv └── fr_FR.csv ├── registration.php └── view └── adminhtml ├── layout ├── cronscheduler_job_listing.xml ├── cronscheduler_task_listing.xml └── cronscheduler_task_timeline.xml ├── requirejs-config.js ├── templates ├── job │ └── listing │ │ └── actions.phtml ├── task │ ├── listing │ │ └── actions.phtml │ ├── timeline.phtml │ ├── timeline │ │ └── actions.phtml │ └── view.phtml └── upgradeToPro.phtml ├── ui_component ├── cronscheduler_job_listing.xml ├── cronscheduler_job_listing_2.0.xml ├── cronscheduler_job_listing_Mage20.xml ├── cronscheduler_task_listing.xml ├── cronscheduler_task_listing_2.0.xml └── cronscheduler_task_listing_Mage20.xml └── web ├── css ├── common.css └── timeline.css ├── js ├── task.js └── timeline.js └── template └── task └── grid └── status.html /Block/Adminhtml/Job/Listing/Actions.php: -------------------------------------------------------------------------------- 1 | Cron Scheduler > Jobs List (button : Generate Schedule) 12 | * @version 1.0.0 13 | */ 14 | class Actions extends \Magento\Backend\Block\Template 15 | { 16 | 17 | /** 18 | * @var \Magento\Framework\Authorization 19 | */ 20 | protected $_authorization = null; 21 | 22 | /** 23 | * @var string 24 | */ 25 | protected $_aclResource = "generate_schedule"; 26 | 27 | /** 28 | * Class constructor 29 | * @param \Magento\Backend\Block\Template\Context $context 30 | * @param array $data 31 | */ 32 | public function __construct( 33 | \Magento\Backend\Block\Template\Context $context, 34 | array $data = [] 35 | ) 36 | { 37 | $this->_authorization = $context->getAuthorization(); 38 | $this->setTemplate('job/listing/actions.phtml'); 39 | parent::__construct($context, $data); 40 | } 41 | 42 | public function isAllowed() 43 | { 44 | return $this->_authorization->isAllowed('Wyomind_CronScheduler::' . $this->_aclResource); 45 | } 46 | 47 | /** 48 | * Get the url to generate schedule 49 | * @return string the url 50 | */ 51 | public function getGenerateScheduleUrl() 52 | { 53 | return $this->getUrl("*/job/generateSchedule", ["redirect" => "cronscheduler_job_listing"]); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Block/Adminhtml/Task/Listing/Actions.php: -------------------------------------------------------------------------------- 1 | Cron Scheduler > Tasks List (button : Generate Schedule) 12 | * @version 1.0.0 13 | */ 14 | class Actions extends \Magento\Backend\Block\Template 15 | { 16 | 17 | /** 18 | * @var \Magento\Framework\Authorization 19 | */ 20 | protected $_authorization = null; 21 | 22 | /** 23 | * @var string 24 | */ 25 | protected $_aclResource = "generate_schedule"; 26 | 27 | /** 28 | * Class constructor 29 | * @param \Magento\Backend\Block\Template\Context $context 30 | * @param array $data 31 | */ 32 | public function __construct( 33 | \Magento\Backend\Block\Template\Context $context, 34 | array $data = [] 35 | ) 36 | { 37 | parent::__construct($context, $data); 38 | $this->_authorization = $context->getAuthorization(); 39 | $this->setTemplate('task/listing/actions.phtml'); 40 | } 41 | 42 | public function isAllowed() 43 | { 44 | return $this->_authorization->isAllowed('Wyomind_CronScheduler::' . $this->_aclResource); 45 | } 46 | 47 | /** 48 | * Get the url to generate schedule 49 | * @return string the url 50 | */ 51 | public function getGenerateScheduleUrl() 52 | { 53 | return $this->getUrl("*/job/generateSchedule", ["redirect" => "cronscheduler_task_listing"]); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Block/Adminhtml/Task/Timeline.php: -------------------------------------------------------------------------------- 1 | _datetime = $datetime; 54 | $this->_taskHelper = $taskHelper; 55 | $this->_collectionFactory = $collectionFactory; 56 | $explodedVersion = explode("-", $productMetaData->getVersion()); // in case of 2.2.0-dev 57 | $this->_magentoVersion = $explodedVersion[0]; 58 | parent::__construct($context, $data); 59 | $this->setTemplate('task/timeline.phtml'); 60 | } 61 | 62 | /** 63 | * Get the task view modal popup url 64 | * @return string 65 | */ 66 | public function getViewUrl() 67 | { 68 | return $this->getUrl(\Wyomind\CronScheduler\Helper\Url::TASK_VIEW); 69 | } 70 | 71 | /** 72 | * Add the timezone offset to a datetime 73 | * @param string $datetime 74 | * @return string 75 | */ 76 | private function addOffset($datetime) 77 | { 78 | if ($datetime == null) { 79 | return null; 80 | } 81 | if (version_compare($this->_magentoVersion, "2.2.0") >= 0) { 82 | return $this->_datetime->date("Y-m-d H:i:s", strtotime($datetime) + $this->_datetime->getGmtOffSet('seconds')); 83 | } else { 84 | return $datetime; 85 | } 86 | } 87 | 88 | /** 89 | * Get the system current date for javascript use 90 | * @return string 91 | */ 92 | public function getCurrentJsDate() 93 | { 94 | $current = $this->_datetime->date('U') + $this->_datetime->getGmtOffSet('seconds'); 95 | return "new Date(" . $this->_datetime->date("Y,", $current) . ($this->_datetime->date("m", $current) - 1) . $this->_datetime->date(",d,H,i,s", $current) . ")"; 96 | } 97 | 98 | /** 99 | * Get the data to construct the timeline 100 | * @return array 101 | */ 102 | public function getTimelineData() 103 | { 104 | 105 | $data = []; 106 | $tasks = $this->_collectionFactory->create(); 107 | $tasks->getSelect()->order('job_code'); 108 | 109 | foreach ($tasks as $task) { 110 | $start = $this->addOffset($task->getExecutedAt()); 111 | $end = $this->addOffset($task->getFinishedAt()); 112 | 113 | 114 | list ($type, $inner) = $this->_taskHelper->getStatusRenderer($task->getStatus()); 115 | 116 | $messages = $task->getMessages(); 117 | if (strlen($messages) > 200) { 118 | $messages = substr($messages, 0, 200) . "..."; 119 | } 120 | $messages = nl2br($messages); 121 | 122 | 123 | $tooltip = "
" 125 | . $task->getJobCode() 126 | . " | |
" 128 | . __('Id') 129 | . " | " 130 | . $task->getId() . " |
" 132 | . __('Status') 133 | . " | " 134 | . "" . $inner . "" 135 | . " |
" 137 | . __('Created at') 138 | . " | " 139 | . $this->addOffset($task->getCreatedAt()) 140 | . " |
" 142 | . __('Scheduled at') 143 | . " | " 144 | . $this->addOffset($task->getScheduledAt()) 145 | . " |
" 147 | . __('Executed at') 148 | . " | " 149 | . ($start != null ? $start : "") 150 | . " |
" 152 | . __('Finished at') 153 | . " | " 154 | . ($end != null ? $end : "") 155 | . " |
" 158 | . __('Messages') 159 | . " | " 160 | . $messages 161 | . " |