From 497c8dc27c4401d67bc329899bdc08d9a6de5eaa Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 20 May 2021 13:06:53 +0200 Subject: [PATCH] Added docker containers --- public/resources/job/add.js | 36 +++++++++++++++++++++----- src/Repository/Job.php | 9 +++++++ templates/job/add.html.twig | 51 +++++++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 18 deletions(-) diff --git a/public/resources/job/add.js b/public/resources/job/add.js index 4bf179d..60dab5f 100644 --- a/public/resources/job/add.js +++ b/public/resources/job/add.js @@ -2,6 +2,7 @@ $(function() { initDatePickers(); initCronType(); initHostType(); + initContainerType(); initVarInputs(); initIntervalPattern(); bsCustomFileInput.init() @@ -15,6 +16,7 @@ function initDatePickers() function initCronType() { + $('.crontype-group button').data('default-text', $('.crontype-group button').html()); $('.crontype-item').on('click', function() { let type = $(this).data('type'); $('#crontypeButton').html($(this).html()); @@ -27,22 +29,42 @@ function initCronType() if(type != 'http') { $('.croncategory-group').addClass('btn-group'); - $('.hosttype-group').removeClass('hidden'); + $('.croncategory-group').removeClass('hidden'); } else { - let hosttypebtn = $('#hosttypeButton') - hosttypebtn.html(hosttypebtn.data('default-text')) + $('.croncategory-group:not(.crontype-group) button').each(function() { + $(this).html($(this).data('default-text')) + }) $('.croncategory-group').removeClass('btn-group'); - $('.hosttype-group').addClass('hidden'); - $('.hosttype-inputs').addClass('hidden'); + $('.croncategory-group:not(.crontype-group)').addClass('hidden'); + $('.croncategory-inputs:not(.crontype-inputs)').addClass('hidden'); - $('.hosttype-inputs:not(.hidden) input').prop('disabled', false); - $('.hosttype-inputs.hidden input').prop('disabled', true); + $('.croncategory-inputs:not(.hidden) input').prop('disabled', false); + $('.croncategory-inputs.hidden input').prop('disabled', true); } }) } +function initContainerType() +{ + + $('.containertype-group button').data('default-text', $('.containertype-group button').html()); + $('.containertype-item').on('click', function() { + + $('#containertypeButton').html($(this).html()); + let type = $(this).data('type'); + $('.containertype').val(type); + $('.containertype-inputs:not(.hidden)').addClass('hidden'); + $('.containertype-' + type).removeClass('hidden'); + + $('.containertype-inputs:not(.hidden) input').prop('disabled', false); + $('.containertype-inputs.hidden input').prop('disabled', true); + }) +} + function initHostType() { + + $('.hosttype-group button').data('default-text', $('.hosttype-group button').html()); $('.hosttype-item').on('click', function() { $('#hosttypeButton').html($(this).html()); diff --git a/src/Repository/Job.php b/src/Repository/Job.php index 50458f1..10ca80c 100644 --- a/src/Repository/Job.php +++ b/src/Repository/Job.php @@ -47,6 +47,7 @@ class Job $values['nextrun'] = DateTime::createFromFormat('m/d/Y g:i:s A', $values['nextrun'])->getTimestamp(); $data['crontype'] = $values['crontype']; $data['hosttype'] = $values['hosttype']; + $data['containertype'] = $values['containertype']; switch($data['crontype']) { @@ -110,6 +111,14 @@ class Job break; } + + switch($data['containertype']) { + case 'docker': + $data['service'] = $values['service']; + $data['user'] = $values['user']; + break; + } + if(!empty($values['var-value'])) { foreach($values['var-value'] as $key => $name) { if(!empty($name)) { diff --git a/templates/job/add.html.twig b/templates/job/add.html.twig index 0942491..236316f 100644 --- a/templates/job/add.html.twig +++ b/templates/job/add.html.twig @@ -39,7 +39,7 @@

Job details

+ + +
-