2021-05-26 13:09:13 +02:00
|
|
|
import 'tempusdominus-bootstrap-4';
|
|
|
|
import bsCustomFileInput from 'bs-custom-file-input';
|
2021-05-26 16:26:01 +02:00
|
|
|
import 'bootstrap';
|
2021-05-26 13:09:13 +02:00
|
|
|
|
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-05-26 13:34:19 +02:00
|
|
|
initEternalCheckbox();
|
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-05-26 13:09:13 +02:00
|
|
|
$('.crontype-inputs:not(.d-none)').addClass('d-none');
|
|
|
|
$('.crontype-' + type).removeClass('d-none');
|
2021-04-15 13:52:27 +02:00
|
|
|
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.crontype-inputs:not(.d-none) input').prop('disabled', false);
|
|
|
|
$('.crontype-inputs.d-none input').prop('disabled', true);
|
2021-05-19 13:24:38 +02:00
|
|
|
|
2021-05-27 20:24:20 +02:00
|
|
|
if(type == 'http') {
|
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-26 13:09:13 +02:00
|
|
|
$('.croncategory-group:not(.crontype-group)').addClass('d-none');
|
|
|
|
$('.croncategory-inputs:not(.crontype-inputs)').addClass('d-none');
|
2021-05-19 13:24:38 +02:00
|
|
|
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.croncategory-inputs:not(.d-none) input').prop('disabled', false);
|
|
|
|
$('.croncategory-inputs.d-none input').prop('disabled', true);
|
2021-05-19 13:24:38 +02:00
|
|
|
}
|
2021-05-27 20:24:20 +02:00
|
|
|
if(type == 'reboot') {
|
|
|
|
if($('#btn-group-discriminator').length == 0) {
|
|
|
|
$('body').append('<div id="btn-group-discriminator" class="d-none">');
|
|
|
|
}
|
|
|
|
$('.croncategory-group.containertype-group button').each(function() {
|
|
|
|
$(this).html($(this).data('default-text'))
|
|
|
|
})
|
|
|
|
$('.croncategory-group').addClass('btn-group');
|
|
|
|
$('.croncategory-group').removeClass('d-none');
|
|
|
|
|
|
|
|
$('#btn-group-discriminator').append($('.containertype-group'));
|
|
|
|
$('.croncategory-selector .containertype-group').remove();
|
|
|
|
$('.croncategory-group.containertype-group').addClass('d-none');
|
|
|
|
$('.croncategory-inputs.containertype-inputs').addClass('d-none');
|
|
|
|
|
|
|
|
$('.croncategory-inputs:not(.d-none) input').prop('disabled', false);
|
|
|
|
$('.croncategory-inputs.d-none input').prop('disabled', true);
|
|
|
|
}
|
|
|
|
if(type == 'command') {
|
|
|
|
if($('#btn-group-discriminator .containertype-group').length > 0) {
|
|
|
|
$('.croncategory-selector').append($('#btn-group-discriminator .containertype-group'));
|
|
|
|
}
|
|
|
|
$('.croncategory-group').addClass('btn-group');
|
|
|
|
$('.croncategory-group').removeClass('d-none');
|
|
|
|
}
|
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);
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.containertype-inputs:not(.d-none)').addClass('d-none');
|
|
|
|
$('.containertype-' + type).removeClass('d-none');
|
2021-05-20 13:06:53 +02:00
|
|
|
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.containertype-inputs:not(.d-none) input').prop('disabled', false);
|
|
|
|
$('.containertype-inputs.d-none input').prop('disabled', true);
|
2021-05-20 13:06:53 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
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);
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.hosttype-inputs:not(.d-none)').addClass('d-none');
|
|
|
|
$('.hosttype-' + type).removeClass('d-none');
|
2021-05-19 13:24:38 +02:00
|
|
|
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.hosttype-inputs:not(.d-none) input').prop('disabled', false);
|
|
|
|
$('.hosttype-inputs.d-none input').prop('disabled', true);
|
2021-04-13 14:44:58 +02:00
|
|
|
})
|
2021-05-24 12:28:47 +02:00
|
|
|
|
|
|
|
$('.privkey-keep').on('click', function() {
|
|
|
|
$('#privkey').prop('disabled', $(this).prop('checked'));
|
|
|
|
})
|
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;
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.var-group:first-child').clone().appendTo('.vars').removeClass('d-none');
|
2021-05-06 13:30:12 +02:00
|
|
|
$('.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 + ']');
|
2021-05-26 13:09:13 +02:00
|
|
|
$('.vars-description').removeClass('d-none');
|
2021-05-06 13:30:12 +02:00
|
|
|
})
|
|
|
|
$(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-26 13:34:19 +02:00
|
|
|
function initEternalCheckbox() {
|
|
|
|
$('.lastrun-eternal').on('click', function() {
|
|
|
|
$('#lastrunselector').prop('disabled', $(this).prop('checked'));
|
|
|
|
$('#lastrunselector').prop('value', '');
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
}
|