webcron/public/resources/job/add.js

106 lines
3.7 KiB
JavaScript
Raw Normal View History

2021-04-13 14:07:11 +02:00
$(function() {
initDatePickers();
initCronType();
2021-05-19 13:24:38 +02:00
initHostType();
2021-05-20 13:06:53 +02:00
initContainerType();
2021-05-06 13:30:12 +02:00
initVarInputs();
2021-05-06 15:53:21 +02:00
initIntervalPattern();
2021-04-15 13:52:27 +02:00
bsCustomFileInput.init()
2021-04-13 14:07:11 +02:00
});
function initDatePickers()
{
2021-05-21 13:09:48 +02:00
$('#nextrunselector').datetimepicker({format: 'DD/MM/YYYY HH:mm:ss'});
$('#lastrunselector').datetimepicker({format: 'DD/MM/YYYY HH:mm:ss'});
2021-04-13 14:07:11 +02:00
}
function initCronType()
{
2021-05-20 13:06:53 +02:00
$('.crontype-group button').data('default-text', $('.crontype-group button').html());
2021-04-13 14:07:11 +02:00
$('.crontype-item').on('click', function() {
let type = $(this).data('type');
2021-05-19 13:41:29 +02:00
$('#crontypeButton').html($(this).html());
2021-04-13 14:07:11 +02:00
$('.crontype').val(type);
2021-04-13 14:44:58 +02:00
$('.crontype-inputs:not(.hidden)').addClass('hidden');
$('.crontype-' + type).removeClass('hidden');
2021-04-15 13:52:27 +02:00
$('.crontype-inputs:not(.hidden) input').prop('disabled', false);
$('.crontype-inputs.hidden input').prop('disabled', true);
2021-05-19 13:24:38 +02:00
if(type != 'http') {
$('.croncategory-group').addClass('btn-group');
2021-05-20 13:06:53 +02:00
$('.croncategory-group').removeClass('hidden');
2021-05-19 13:24:38 +02:00
} else {
2021-05-20 13:06:53 +02:00
$('.croncategory-group:not(.crontype-group) button').each(function() {
$(this).html($(this).data('default-text'))
})
2021-05-19 13:41:29 +02:00
2021-05-19 13:24:38 +02:00
$('.croncategory-group').removeClass('btn-group');
2021-05-20 13:06:53 +02:00
$('.croncategory-group:not(.crontype-group)').addClass('hidden');
$('.croncategory-inputs:not(.crontype-inputs)').addClass('hidden');
2021-05-19 13:24:38 +02:00
2021-05-20 13:06:53 +02:00
$('.croncategory-inputs:not(.hidden) input').prop('disabled', false);
$('.croncategory-inputs.hidden input').prop('disabled', true);
2021-05-19 13:24:38 +02:00
}
})
}
2021-05-20 13:06:53 +02:00
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);
})
}
2021-05-19 13:24:38 +02:00
function initHostType()
{
2021-05-20 13:06:53 +02:00
$('.hosttype-group button').data('default-text', $('.hosttype-group button').html());
2021-05-19 13:24:38 +02:00
$('.hosttype-item').on('click', function() {
2021-05-19 13:41:29 +02:00
$('#hosttypeButton').html($(this).html());
2021-05-19 13:24:38 +02:00
let type = $(this).data('type');
$('.hosttype').val(type);
$('.hosttype-inputs:not(.hidden)').addClass('hidden');
$('.hosttype-' + type).removeClass('hidden');
$('.hosttype-inputs:not(.hidden) input').prop('disabled', false);
$('.hosttype-inputs.hidden input').prop('disabled', true);
2021-04-13 14:44:58 +02:00
})
}
2021-05-06 13:30:12 +02:00
function initVarInputs()
2021-04-13 14:44:58 +02:00
{
2021-05-06 13:30:12 +02:00
$('.addvar-btn').on('click', function() {
let index = $('.var-group').length;
$('.var-group:first-child').clone().appendTo('.vars').removeClass('hidden');
$('.var-group:last-child').data({index: index});
$('.var-group:last-child .var-issecret').prop('name', 'var-issecret[' + index + ']');
$('.var-group:last-child .var-id').prop('name', 'var-id[' + index + ']');
$('.var-group:last-child .var-value').prop('name', 'var-value[' + index + ']');
$('.vars-description').removeClass('hidden');
})
$(document).on('click', '.var-issecret', function() {
let ischecked = $(this).prop('checked');
$(this).parents('.var-group').find('.var-value').prop('type', ischecked ? 'password' : 'text');
2021-04-13 14:07:11 +02:00
})
2021-04-13 19:04:32 +02:00
}
2021-05-06 15:53:21 +02:00
function initIntervalPattern()
2021-04-13 19:04:32 +02:00
{
2021-05-06 15:53:21 +02:00
$('.intervalpattern-item').on('click', function() {
2021-04-13 19:04:32 +02:00
let time = $(this).data('time');
2021-05-06 15:53:21 +02:00
$('#interval').val(time);
2021-04-13 19:04:32 +02:00
})
2021-04-13 14:07:11 +02:00
}