diff --git a/application/controllers/Cron.php b/application/controllers/Cron.php index f7a3c5a18..e2cc5fd72 100644 --- a/application/controllers/Cron.php +++ b/application/controllers/Cron.php @@ -108,4 +108,16 @@ class cron extends CI_Controller { $this->cronexpression = null; } } + + public function editDialog() { + + $this->load->model('cron_model'); + + $cron_query = $this->cron_model->cron(xss_clean($this->input->post('id', true))); + + $data['crondetails'] = $cron_query->row(); + $data['page_title'] = "Edit Cronjob"; + + $this->load->view('cron/edit', $data); + } } diff --git a/application/models/Cron_model.php b/application/models/Cron_model.php index a99d01f68..80ffcfea1 100644 --- a/application/models/Cron_model.php +++ b/application/models/Cron_model.php @@ -12,6 +12,15 @@ class Cron_model extends CI_Model return $results; } + function cron($id) { + + $clean_id = $this->security->xss_clean($id); + + $this->db->where('id', $clean_id); + + return $this->db->get('cron'); + } + function set_last_run($cron) { $data = array( 'last_run' => date('Y-m-d H:i:s') diff --git a/application/views/cron/edit.php b/application/views/cron/edit.php new file mode 100644 index 000000000..b04e6459b --- /dev/null +++ b/application/views/cron/edit.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/application/views/cron/index.php b/application/views/cron/index.php index 93ae3fd6c..2a5a5ca25 100644 --- a/application/views/cron/index.php +++ b/application/views/cron/index.php @@ -28,7 +28,7 @@ ID Description - Cron Expression + Intervall Last Run Next Run @@ -40,12 +40,10 @@ id; ?> description; ?> - ' . - $cron->expression . - ''; ?> + '.$cron->expression.''; ?> last_run ?? 'never'; ?> next_run ?? 'never'; ?> - + diff --git a/assets/js/sections/cron.js b/assets/js/sections/cron.js index d3884b413..5c66df671 100644 --- a/assets/js/sections/cron.js +++ b/assets/js/sections/cron.js @@ -1,5 +1,14 @@ $(document).ready(function () { - // empty yet + $('.crontable tbody tr').each(function(){ + var expression = $(this).find('td:eq(2)').text().trim(); + var humanReadable = cronstrue.toString(expression); + + $(this).find('#humanreadable_tooltip').attr('data-bs-original-title', humanReadable).tooltip(); + }); + + $(document).on('click', '.editCron', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS + editCron(e); + }); }); function copyCron(id) { @@ -44,3 +53,23 @@ $('.crontable').DataTable({ url: getDataTablesLanguageUrl(), } }); + +function editCron(e) { + $.ajax({ + url: base_url + 'index.php/cron/editDialog', + type: 'post', + data: { + id: e.currentTarget.id, + }, + success: function (data) { + $('body').append(data); + + var editCronModal = new bootstrap.Modal(document.getElementById('editCronModal')); + editCronModal.show(); + }, + error: function (data) { + + }, + }); + return false; +} \ No newline at end of file