From a3efea0e8359452d194d53c6b4d3979334d90685 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 15 Apr 2021 13:52:27 +0200 Subject: [PATCH] Added SSH jobs --- public/resources/job/add.js | 4 +++ src/Repository/Job.php | 10 +++++++ templates/job/add.html.twig | 54 ++++++++++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/public/resources/job/add.js b/public/resources/job/add.js index 8c8fc87..10d8745 100644 --- a/public/resources/job/add.js +++ b/public/resources/job/add.js @@ -3,6 +3,7 @@ $(function() { initCronType(); initSecretInputs(); initDelayPattern(); + bsCustomFileInput.init() }); function initDatePickers() @@ -18,6 +19,9 @@ function initCronType() $('.crontype').val(type); $('.crontype-inputs:not(.hidden)').addClass('hidden'); $('.crontype-' + type).removeClass('hidden'); + + $('.crontype-inputs:not(.hidden) input').prop('disabled', false); + $('.crontype-inputs.hidden input').prop('disabled', true); }) } diff --git a/src/Repository/Job.php b/src/Repository/Job.php index 8e58506..6a1d35e 100644 --- a/src/Repository/Job.php +++ b/src/Repository/Job.php @@ -53,6 +53,16 @@ class Job $data['command'] = $values['command']; $data['host'] = 'localhost'; break; + case 'ssh': + $data['host'] = $values['host']; + $data['user'] = $values['user']; + if(!empty($_FILES['privkey']['tmp_name'])) { + $newsecretkey = count($values['secretval']); + $values['secretid'][$newsecretkey] = 'ssh-privkey'; + $values['secretval'][$newsecretkey] = base64_encode(file_get_contents($_FILES['privkey']['tmp_name'])); + } + $data['command'] = $values['command']; + break; case 'http': $parsedUrl = parse_url($values['url']); $data['url'] = $values['url']; diff --git a/templates/job/add.html.twig b/templates/job/add.html.twig index d1fcbc9..bf581cc 100644 --- a/templates/job/add.html.twig +++ b/templates/job/add.html.twig @@ -2,7 +2,7 @@ {% block title %}Add job{% endblock %} {% block content %}

Add a cronjob

-
+

General info

@@ -54,6 +54,48 @@
+ + + + - -

Secrets