webcron/templates/job/edit.html.twig

297 lines
22 KiB
Twig

{% extends "base.html.twig" %}
{% block title %}{{ 'job.edit.title' | trans }}{% endblock %}
{% block content %}
<h2>{{ 'job.edit.header' | trans({'_jobname_': (job.name | parsetags) }) | raw }}</h2>
<form method="post" class="form-horizontal" enctype="multipart/form-data" action="{{ path('job_edit', { id : job.id }) }}">
<h3>{{ 'job.addedit.generalinfo.header' | trans }}</h3>
<div class="mb-3">
<label for="name">{{ 'job.addedit.generalinfo.name.label' | trans }}</label>
<input type="text" name="name" class="form-control" id="name" placeholder="{{ 'job.addedit.generalinfo.name.placeholder' | trans }}" value="{{ job.name }}">
<small id="name-help" class="form-text text-muted">{{ 'job.addedit.generalinfo.name.helptext' | trans }}</small>
</div>
<div class="mb-3">
<label for="name">{{ 'job.addedit.generalinfo.interval.label' | trans }}</label>
<div class="input-group">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="intervalButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ 'job.addedit.generalinfo.interval.patterns.label' | trans }}
</button>
<ul class="dropdown-menu" aria-labelledby="intervalButton">
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="60">{{ 'job.addedit.generalinfo.interval.patterns.minute' | trans }}</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="3600">{{ 'job.addedit.generalinfo.interval.patterns.hour' | trans }}</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="86400">{{ 'job.addedit.generalinfo.interval.patterns.day' | trans }}</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="604800">{{ 'job.addedit.generalinfo.interval.patterns.week' | trans }}</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="2419200">{{ 'job.addedit.generalinfo.interval.patterns.4week' | trans }}</a></li>
</ul>
<input type="number" class="form-control" id="interval" name="interval" placeholder="{{ 'job.addedit.generalinfo.interval.placeholder' | trans }}" value="{{ job.interval }}">
</div>
</div>
<div class="mb-3">
<label for="nextrun">{{ 'job.addedit.generalinfo.nextrun.label' | trans }}</label>
<input type="text" autocomplete="off" pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}" placeholder="{{ date() | date("d/m/Y H:i:s")}}" id="nextrunselector" class="form-control datetimepicker-input" data-target="#nextrunselector" data-bs-toggle="datetimepicker" name="nextrun" value="{{ job.nextrun | date("d/m/Y H:i:s")}}">
</div>
<div class="mb-3">
<label for="lastrun">{{ 'job.addedit.generalinfo.lastrun.label' | trans }}</label>
<div class="input-group">
<div class="input-group-text border-end-0">
<input type="checkbox" name="lastrun-eternal" class="lastrun-eternal" placeholder="value" value="true"{% if job.lastrun is not defined or job.lastrun is empty %} checked{% endif %}>
</div>
<span class="input-group-text border-start-0">{{ 'job.addedit.generalinfo.lastrun.eternal.label' | trans }}</span>
<input type="text" autocomplete="off" pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}" data-placeholder="{{ date() | date("d/m/Y H:i:s")}}" id="lastrunselector" class="form-control datetimepicker-input" data-target="#lastrunselector" data-bs-toggle="datetimepicker" name="lastrun"{% if job.lastrun is not defined or job.lastrun is empty %} disabled{% else %} value="{{ job.lastrun | date("d/m/Y H:i:s")}}"{% endif %}>
</div>
</div>
<div class="mb-3">
<label for="retention">{{ 'job.addedit.generalinfo.retention.label' | trans }}</label>
<input type="number" name="retention" class="form-control" id="retention" placeholder="{{ 'job.addedit.generalinfo.retention.placeholder' | trans }}" value="{% if attribute(job.data, 'retention') is defined %}{{ attribute(job.data, 'retention') }}{% endif %}">
<small id="retention-help" class="form-text text-muted">{{ 'job.addedit.generalinfo.retention.helptext' | trans }}</small>
</div>
<div class="mb-3">
<label for="fail-pct">{{ 'job.addedit.generalinfo.failpercentage.label' | trans }}</label>
<div class="input-group d-flex">
<div class="range-value range-value-fail-pct pe-1">{% if attribute(job.data, 'fail-pct') is defined %}{{ attribute(job.data, 'fail-pct') }}{% else %}50{% endif %}%</div>
<div class="range-input ps-1 flex-grow-1">
<input type="range" name="fail-pct" class="form-range range-input-fail-pct" id="fail-pct" max="100" step="5" value="{% if attribute(job.data, 'fail-pct') is defined %}{{ attribute(job.data, 'fail-pct') }}{% else %}50{% endif %}">
</div>
</div>
</div>
<div class="mb-3">
<label for="fail-days">{{ 'job.addedit.generalinfo.faildays.label' | trans }}</label>
<input type="number" name="fail-days" class="form-control" id="fail-days" placeholder="{{ 'job.addedit.generalinfo.faildays.placeholder' | trans }}" value="{% if attribute(job.data, 'fail-days') is defined %}{{ attribute(job.data, 'fail-days') }}{% endif %}">
</div>
<div class="mb-3">
<label for="hostlabel">{{ 'job.addedit.generalinfo.hostlabel.label' | trans }}</label>
<input type="text" name="hostlabel" class="form-control" id="hostlabel" placeholder="{{ 'job.addedit.generalinfo.hostlabel.placeholder' | trans }}" value="{% if attribute(job.data, 'hostlabel') is defined %}{{ attribute(job.data, 'hostlabel') }}{% endif %}">
<small id="hostlabel-help" class="form-text text-muted">{{ 'job.addedit.generalinfo.hostlabel.helptext' | trans }}</small>
</div>
<h3>Job details</h3>
<div class="mb-3 btn-group croncategory-selector">
<div class="dropdown croncategory-group crontype-group{% if job.data.crontype != 'http' %} btn-group{% endif %}">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="crontypeButton" data-default-text="Job type" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% if job.data.crontype == 'command' %}
{{ 'job.addedit.crontype.command.label' | trans }}
{% elseif job.data.crontype == 'reboot' %}
{{ 'job.addedit.crontype.reboot.label' | trans }}
{% elseif job.data.crontype == 'http' %}
{{ 'job.addedit.crontype.http.label' | trans }}
{% else %}
{{ 'job.addedit.crontype.label' | trans }}
{% endif %}
</button>
<div class="dropdown-menu" aria-labelledby="crontypeButton">
<a class="dropdown-item crontype-item" href="#" data-type="command">{{ 'job.addedit.crontype.command.label' | trans }}</a>
<a class="dropdown-item crontype-item" href="#" data-type="reboot">{{ 'job.addedit.crontype.reboot.label' | trans }}</a>
<a class="dropdown-item crontype-item" href="#" data-type="http">{{ 'job.addedit.crontype.http.label' | trans }}</a>
</div>
</div>
<div class="dropdown croncategory-group hosttype-group{% if job.data.crontype != 'http' %} btn-group{% else %} d-none{% endif %}">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="hosttypeButton" data-default-text="Host type" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% if job.data.hosttype == 'local' %}
{{ 'job.addedit.hosttype.local.label' | trans }}
{% elseif job.data.hosttype == 'ssh' %}
{{ 'job.addedit.hosttype.ssh.label' | trans }}
{% else %}
{{ 'job.addedit.hosttype.label' | trans }}
{% endif %}
</button>
<div class="dropdown-menu" aria-labelledby="hosttypeButton">
<a class="dropdown-item hosttype-item" href="#" data-type="local">{{ 'job.addedit.hosttype.local.label' | trans }}</a>
<a class="dropdown-item hosttype-item" href="#" data-type="ssh">{{ 'job.addedit.hosttype.ssh.label' | trans }}</a>
</div>
</div>
{% if job.data.crontype == 'reboot' %}
</div>
<div id="btn-group-discriminator" class="d-none">
{% endif %}
<div class="dropdown croncategory-group containertype-group{% if job.data.crontype != 'http' %} btn-group{% else %} d-none{% endif %}">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="containertypeButton" data-default-text="Container" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{% if job.data.containertype == 'none' or job.data.containertype == '' %}
{{ 'job.addedit.containertype.none.label' | trans }}
{% elseif job.data.containertype == 'docker' %}
{{ 'job.addedit.containertype.docker.label' | trans }}
{% else %}
{{ 'job.addedit.containertype.label' | trans }}
{% endif %}
</button>
<div class="dropdown-menu" aria-labelledby="containertypeButton">
<a class="dropdown-item containertype-item" href="#" data-type="none">{{ 'job.addedit.containertype.none.label' | trans }}</a>
<a class="dropdown-item containertype-item" href="#" data-type="docker">{{ 'job.addedit.containertype.docker.label' | trans }}</a>
</div>
</div>
</div>
<div class="crontype-command crontype-inputs croncategory-inputs{% if job.data.crontype != 'command' %} d-none{% endif %}">
<h4>{{ "job.addedit.crontype.command.header"| trans }}</h4>
<div class="mb-3">
<label for="command">{{ "job.addedit.crontype.command.command.label" | trans }}</label>
<input type="text" name="command" class="form-control" id="command" placeholder="{{ "job.addedit.crontype.command.command.placeholder"| trans }}" value="{% if job.data.command is defined %}{{ job.data.command }}{% endif %}">
</div>
<div class="mb-3">
<label for="response">{{ "job.addedit.crontype.command.response.label" | trans }}</label>
<input type="text" name="response" class="form-control" id="response" placeholder="{{ "job.addedit.crontype.command.response.placeholder"| trans }}" value="{% if job.data.response is defined %}{{ job.data.response | join(',') }}{% endif %}">
</div>
</div>
<div class="crontype-reboot crontype-inputs croncategory-inputs{% if job.data.crontype != 'reboot' %} d-none{% endif %}">
<h4>{{ "job.addedit.crontype.reboot.header" | trans }}</h4>
<div class="mb-3">
<label for="reboot-command">{{ "job.addedit.crontype.reboot.reboot.command.label" | trans }}</label>
<input type="text" name="reboot-command" class="form-control" id="reboot-command" placeholder="{{ "job.addedit.crontype.reboot.reboot.command.placeholder" | trans }}" value="{% if attribute(job.data, 'reboot-command') is defined %}{{ attribute(job.data, 'reboot-command') }}{% endif %}">
<small id="reboot-command-help" class="form-text text-muted">{{ "job.addedit.crontype.reboot.reboot.command.helptext" | trans }}</small>
</div>
<div class="mb-3">
<label for="getservices-command">{{ "job.addedit.crontype.reboot.getservices.command.label" | trans }}</label>
<input type="text" name="getservices-command" class="form-control" id="getservices-command" placeholder="{{ "job.addedit.crontype.reboot.getservices.command.placeholder" | trans }}" value="{% if attribute(job.data, 'getservices-command') is defined %}{{ attribute(job.data, 'getservices-command') }}{% endif %}">
</div>
<div class="mb-3">
<label for="getservices-response">{{ "job.addedit.crontype.reboot.getservices.response.label" | trans }}</label>
<input type="text" name="getservices-response" class="form-control" id="getservices-response" placeholder="{{ "job.addedit.crontype.reboot.getservices.command.placeholder" | trans }}" value="{% if attribute(job.data, 'getservices-response') is defined %}{{ attribute(job.data, 'getservices-response') | join(',') }}{% endif %}">
</div>
<div class="mb-3">
<label for="reboot-delay">{{ "job.addedit.crontype.reboot.reboot.delay.label" | trans }}</label>
<input type="number" name="reboot-delay" class="form-control" placeholder="{{ "job.addedit.crontype.reboot.reboot.delay.placeholder" | trans }}" value="{% if attribute(job.data, 'reboot-delay') is defined %}{{ attribute(job.data, 'reboot-delay') }}{% endif %}">
<small id="reboot-delay-help" class="form-text text-muted">{{ "job.addedit.crontype.reboot.reboot.delay.helptext" | trans }}</small>
</div>
<div class="mb-3">
<label for="reboot-duration">{{ "job.addedit.crontype.reboot.reboot.duration.label" | trans }}</label>
<input type="number" name="reboot-duration" class="form-control" placeholder="{{ "job.addedit.crontype.reboot.reboot.duration.placeholder" | trans }}" value="{% if attribute(job.data, 'reboot-duration') is defined %}{{ attribute(job.data, 'reboot-duration') }}{% endif %}">
<small id="reboot-duration-help" class="form-text text-muted">{{ "job.addedit.crontype.reboot.reboot.duration.helptext" | trans }}</small>
</div>
</div>
<div class="crontype-http crontype-inputs croncategory-inputs{% if job.data.crontype != 'http' %} d-none{% endif %}">
<h4>{{ "job.addedit.crontype.http.header" | trans }}</h4>
<div class="mb-3">
<label for="url">{{ "job.addedit.crontype.http.url.label" | trans }}</label>
<input type="text" name="url" class="form-control" id="url" placeholder="{{ "job.addedit.crontype.http.url.placeholder" | trans }}" value="{% if job.data.url is defined %}{{ job.data.url }}{% endif %}">
</div>
<div class="mb-3">
<label for="basicauth-username">{{ "job.addedit.crontype.http.basic-auth.username.label" | trans }}</label>
<input type="text" name="basicauth-username" class="form-control" id="basicauth-username" placeholder="{{ "job.addedit.crontype.http.basic-auth.username.placeholder" | trans }}" value="{% if attribute(job.data, 'basicauth-username') is defined %}{{ attribute(job.data, 'basicauth-username') }}{% endif %}">
</div>
<div class="mb-3">
<label for="basicauth-password">{{ "job.addedit.crontype.http.basic-auth.password.label" | trans }}</label>
<input type="password" name="basicauth-password" class="form-control" placeholder="{{ "job.addedit.crontype.http.basic-auth.password.placeholder" | trans }}" value="{% if attribute(job.data, 'basicauth-password') is defined %}{{ attribute(job.data, 'basicauth-password') | decryptsecret }}{% endif %}">
<small id="basicauth-password-help" class="form-text text-muted">{{ "job.addedit.crontype.http.basic-auth.password.helptext" | trans }}</small>
</div>
<div class="mb-3">
<label for="http-status">{{ "job.addedit.crontype.http.response.label" | trans }}</label>
<input type="text" name="http-status" class="form-control" id="http-status" placeholder="{{ "job.addedit.crontype.http.response.placeholder" | trans }}" value="{% if attribute(job.data, 'http-status') is defined %}{{ attribute(job.data, 'http-status') | join(',')}}{% endif %}">
</div>
</div>
<div class="hosttype-local hosttype-inputs croncategory-inputs{% if job.data.hosttype != 'local' %} d-none{% endif %}">
<h4>{{ "job.addedit.hosttype.local.header" | trans }}</h4>
<h5>{{ "job.addedit.hosttype.local.nodetails" | trans }}</h5>
</div>
<div class="hosttype-ssh hosttype-inputs croncategory-inputs{% if job.data.hosttype != 'ssh' %} d-none{% endif %}">
<h4>{{ "job.addedit.hosttype.ssh.header" | trans }}</h4>
<div class="mb-3">
<label for="host">{{ "job.addedit.hosttype.ssh.hostname.label" | trans }}</label>
<input type="text" name="host" class="form-control" id="host" placeholder="{{ "job.addedit.hosttype.ssh.hostname.placeholder" | trans }}" value="{% if job.data.host is defined %}{{ job.data.host }}{% endif %}">
</div>
<div class="mb-3">
<label for="user">{{ "job.addedit.hosttype.ssh.username.label" | trans }}</label>
<input type="text" name="user" class="form-control" id="user" placeholder="{{ "job.addedit.hosttype.ssh.username.placeholder" | trans }}" value="{% if job.data.user is defined %}{{ job.data.user }}{% endif %}">
</div>
<div class="mb-3">
<label for="privkey">{{ "job.addedit.hosttype.ssh.privatekey.label" | trans }}</label>
<div class="input-group">
<span class=" input-group-text border-end-0">
<input type="checkbox" name="privkey-keep" class="privkey-keep" value="true" data-privkey="{% if attribute(job.data, 'ssh-privkey') is defined %}{{ attribute(job.data, 'ssh-privkey') | decryptsecret }}{% endif %}" checked>
</span>
<input type="hidden" name="privkey-orig" class="privkey-orig" value="{% if attribute(job.data, 'ssh-privkey') is defined %}{{ attribute(job.data, 'ssh-privkey') | decryptsecret }}{% endif %}">
<span class="input-group-text border-start-0">{{ "job.addedit.hosttype.ssh.privatekey.keep.label" | trans }}</span>
<input type="file" id="privkey" name="privkey" class="form-control " disabled>
</div>
<small id="custom-file-help" class="form-text text-muted">{{ "job.addedit.hosttype.ssh.privatekey.helptext" | trans }}</small>
</div>
<div class="mb-3">
<label for="privkey-password">{{ "job.addedit.hosttype.ssh.passphrase.label" | trans }}</label>
<input type="password" name="privkey-password" class="form-control" placeholder="{{ "job.addedit.hosttype.ssh.passphrase.placeholder" | trans }}" value="{% if attribute(job.data, 'privkey-password') is defined %}{{ attribute(job.data, 'privkey-password') | decryptsecret }}{% endif %}">
<small id="privkey-password-help" class="form-text text-muted">{{ "job.addedit.hosttype.ssh.passphrase.helptext" | trans }}</small>
</div>
</div>
<div class="containertype-none containertype-inputs croncategory-inputs{% if job.data.containertype != 'none' %} d-none{% endif %}">
</div>
<div class="containertype-docker containertype-inputs croncategory-inputs{% if job.data.containertype != 'docker' %} d-none{% endif %}">
<h4>{{ "job.addedit.containertype.docker.header" | trans }}</h4>
<div class="mb-3">
<label for="service">{{ "job.addedit.containertype.docker.service.label" | trans }}</label>
<input type="text" name="service" class="form-control" id="service" placeholder="{{ "job.addedit.containertype.docker.service.placeholder" | trans }}" value="{% if attribute(job.data, 'service') is defined %}{{ attribute(job.data, 'service') }}{% endif %}">
</div>
<div class="mb-3">
<label for="container-user">{{ "job.addedit.containertype.docker.username.label" | trans }}</label>
<input type="text" name="container-user" class="form-control" id="container-user" placeholder="{{ "job.addedit.containertype.docker.username.placeholder" | trans }}" value="{% if attribute(job.data, 'container-user') is defined %}{{ attribute(job.data, 'container-user') }}{% endif %}">
</div>
</div>
<h3>{{ "job.addedit.variables.header" | trans }}</h3>
<div class="vars mb-3">
<div class="input-group var-group d-none">
<div class="input-group-text border-end-0">
<input type="checkbox" name="var-issecret[0]" class="var-issecret" placeholder="value" value="true">
</div>
<span class="input-group-text border-start-0">{{ "job.addedit.variables.secret.label" | trans }}</span>
<input type="text" name="var-id[0]" class="form-control var-id" placeholder="{{ "job.addedit.variables.name.placeholder" | trans }}">
<input type="text" name="var-value[0]" class="form-control var-value" placeholder="{{ "job.addedit.variables.value.placeholder" | trans }}">
</div>
{% set key = 1 %}
{% if job.data.vars is defined %}
{% for id,var in job.data.vars %}
<div class="input-group var-group">
<div class="input-group-text border-end-0">
<input type="checkbox" name="var-issecret[{{ key }}]" class="var-issecret" placeholder="value" value="true"{% if var.issecret %} checked{% endif %}>
</div>
<span class="input-group-text border-start-0">{{ "job.addedit.variables.secret.label" | trans }}</span>
<input type="text" name="var-id[{{ key }}]" class="form-control var-id" placeholder="{{ "job.addedit.variables.name.placeholder" | trans }}" value="{{ id }}">
<input type="{% if var.issecret %}password{% else %}text{% endif %}" name="var-value[{{ key }}]" class="form-control var-value" placeholder="{{ "job.addedit.variables.value.placeholder" | trans }}" value="{% if var.issecret %}{{ var.value | decryptsecret }}{% else %}{{ var.value }}{% endif %}">
</div>
{% endfor %}
{% endif %}
</div>
<div class="vars-description mb-3 d-none">
<p>
{{ "job.addedit.variables.helptext" | trans }}
</p>
</div>
<div class="mb-3">
<a href="#" class="btn btn-outline-primary addvar-btn">{{ "job.addedit.variables.add.label" | trans }}</a>
</div>
<input type="hidden" name="crontype" class="crontype" value="{{ job.data.crontype }}">
<input type="hidden" name="hosttype" class="hosttype" value="{{ job.data.hosttype }}">
<input type="hidden" name="containertype" class="containertype" value="{{ job.data.containertype }}">
<button type="submit" class="btn btn-outline-primary">{{ "job.addedit.submit.label" | trans }}</button>
</form>
{% endblock %}
{% block styles %}
{{ encore_entry_link_tags('job.add') }}
{% endblock %}
{% block scripts %}
{{ encore_entry_script_tags('job.add') }}
{% endblock %}