webcron/templates/job/add.html.twig

255 lines
12 KiB
Twig

{% extends "base.html.twig" %}
{% block title %}Add job{% endblock %}
{% block content %}
<h2>Add a cronjob</h2>
<form method="post" class="form-horizontal" enctype="multipart/form-data" action="{{ path('job_add') }}">
<h3>General info</h3>
<div class="mb-3">
<label for="name">Name</label>
<input type="text" name="name" class="form-control" id="name" placeholder="System update">
<small id="name-help" class="form-text text-muted">You can create colored tags by using [tag]</small>
</div>
<div class="mb-3">
<label for="name">Interval (in seconds)</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">
Patterns
</button>
<ul class="dropdown-menu" aria-labelledby="intervalButton">
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="60">Every minute</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="3600">Every hour</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="86400">Every day</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="604800">Every week</a></li>
<li><a class="dropdown-item intervalpattern-item" href="#" data-time="2419200">Every 4 weeks</a></li>
</ul>
<input type="number" class="form-control" id="interval" name="interval">
</div>
</div>
<div class="mb-3">
<label for="nextrun">Next run</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")}}" step="1" id="nextrunselector" class="form-control datetimepicker-input" data-target="#nextrunselector" data-bs-toggle="datetimepicker" name="nextrun">
</div>
<div class="mb-3">
<label for="lastrun">Last run</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">
</div>
<span class="input-group-text border-start-0">Eternal</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}" placeholder="{{ date() | date("d/m/Y H:i:s")}}" 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">
</div>
</div>
<div class="mb-3">
<label for="retention">Retention (in days)</label>
<input type="number" name="retention" class="form-control" id="retention" placeholder="7">
<small id="retention-help" class="form-text text-muted">How many days (at least) to keep runs of this job in the database</small>
</div>
<div class="mb-3">
<label for="fail-pct">Max fail percentage</label>
<div class="input-group d-flex">
<div class="range-value range-value-fail-pct pe-1">50%</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="50">
</div>
</div>
</div>
<div class="mb-3">
<label for="fail-days">Number of days calculated for fail percentage</label>
<input type="number" name="fail-days" class="form-control" id="fail-days" placeholder="7">
</div>
<h3>Job details</h3>
<div class="mb-3 btn-group croncategory-selector">
<div class="dropdown croncategory-group crontype-group">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="crontypeButton" data-default-text="" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Job type
</button>
<ul class="dropdown-menu" aria-labelledby="crontypeButton">
<li><a class="dropdown-item crontype-item" href="#" data-type="command">Command</a></li>
<li><a class="dropdown-item crontype-item" href="#" data-type="reboot">Reboot</a></li>
<li><a class="dropdown-item crontype-item" href="#" data-type="http">Http request</a></li>
</ul>
</div>
<div class="dropdown croncategory-group d-none hosttype-group">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="hosttypeButton" data-default-text="" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Host type
</button>
<ul class="dropdown-menu" aria-labelledby="hosttypeButton">
<li><a class="dropdown-item hosttype-item" href="#" data-type="local">Local</a></li>
<li><a class="dropdown-item hosttype-item" href="#" data-type="ssh">SSH</a></li>
</ul>
</div>
<div class="dropdown croncategory-group d-none containertype-group">
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="containertypeButton" data-default-text="" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Container
</button>
<ul class="dropdown-menu" aria-labelledby="containertypeButton">
<li><a class="dropdown-item containertype-item" href="#" data-type="none">None</a></li>
<li><a class="dropdown-item containertype-item" href="#" data-type="docker">Docker</a></li>
</ul>
</div>
</div>
<div class="crontype-command crontype-inputs croncategory-inputs d-none">
<h4>Command details</h4>
<div class="mb-3">
<label for="command">Command</label>
<input type="text" name="command" class="form-control" id="command" placeholder="sudo apt update">
</div>
<div class="mb-3">
<label for="response">Expected exit code</label>
<input type="text" name="response" class="form-control" id="response" placeholder="0">
</div>
</div>
<div class="crontype-reboot crontype-inputs croncategory-inputs d-none">
<h4>Reboot job details</h4>
<div class="mb-3">
<label for="reboot-command">Reboot command</label>
<input type="text" name="reboot-command" class="form-control" id="reboot-command" placeholder="systemctl reboot">
<small id="reboot-command-help" class="form-text text-muted">Use {reboot-delay} or {reboot-delay-secs} to add the delay in your command</small>
</div>
<div class="mb-3">
<label for="getservices-command">Get services command</label>
<input type="text" name="getservices-command" class="form-control" id="getservices-command" placeholder="systemctl list-units">
</div>
<div class="mb-3">
<label for="getservices-response">Get services command exit code</label>
<input type="text" name="getservices-response" class="form-control" id="getservices-response" placeholder="0">
</div>
<div class="mb-3">
<label for="reboot-delay">Reboot delay (in minutes)</label>
<input type="number" name="reboot-delay" class="form-control" placeholder="5">
<small id="reboot-delay-help" class="form-text text-muted">Delay between triggering reboot and actual reboot</small>
</div>
<div class="mb-3">
<label for="reboot-duration">Reboot duration (in minutes)</label>
<input type="number" name="reboot-duration" class="form-control" placeholder="10">
<small id="reboot-duration-help" class="form-text text-muted">The amount of time the system takes to actually reboot</small>
</div>
</div>
<div class="crontype-http crontype-inputs croncategory-inputs d-none">
<h4>HTTP request details</h4>
<div class="mb-3">
<label for="url">Url</label>
<input type="text" name="url" class="form-control" id="url" placeholder="https://scripts.example.com/">
</div>
<div class="mb-3">
<label for="basicauth-username">Username for Basic-Auth</label>
<input type="text" name="basicauth-username" class="form-control" id="basicauth-username" placeholder="www-data">
</div>
<div class="mb-3">
<label for="basicauth-password">Password for Basic-Auth</label>
<input type="password" name="basicauth-password" class="form-control" placeholder="correct horse battery staple">
<small id="basicauth-password-help" class="form-text text-muted">This field is being saved as a secret</small>
</div>
<div class="mb-3">
<label for="http-status">Expected response status code</label>
<input type="text" name="http-status" class="form-control" id="http-status" placeholder="200">
</div>
</div>
<div class="hosttype-local hosttype-inputs croncategory-inputs d-none">
<h4>Localhost details</h4>
<h5>No options</h5>
</div>
<div class="hosttype-ssh hosttype-inputs croncategory-inputs d-none">
<h4>SSH host details</h4>
<div class="mb-3">
<label for="host">Hostname</label>
<input type="text" name="host" class="form-control" id="host" placeholder="ssh.abc.xyz">
</div>
<div class="mb-3">
<label for="user">Username</label>
<input type="text" name="user" class="form-control" id="user" placeholder="larry">
</div>
<div class="mb-3">
<label for="privkey">Private key</label>
<div class="input-group">
<input type="file" class="form-control" id="privkey" class="form-control" name="privkey">
</div>
<small id="custom-file-help" class="form-text text-muted">This file is being saved as a secret</small>
</div>
<div class="mb-3">
<label for="privkey-password">Password for private key</label>
<input type="password" name="privkey-password" class="form-control" placeholder="correct horse battery staple">
<small id="privkey-password-help" class="form-text text-muted">If private key is empty this field is being used as ssh-password</small>
<small id="privkey-password-help-2" class="form-text text-muted">This field is being saved as a secret</small>
</div>
</div>
<div class="containertype-none containertype-inputs croncategory-inputs d-none">
</div>
<div class="containertype-docker containertype-inputs croncategory-inputs d-none">
<h4>Docker container details</h4>
<div class="mb-3">
<label for="service">Service</label>
<input type="text" name="service" class="form-control" id="service" placeholder="mysql">
</div>
<div class="mb-3">
<label for="user">Username</label>
<input type="text" name="container-user" class="form-control" id="container-user" placeholder="larry">
</div>
</div>
<h3>Variables</h3>
<div class="vars mb-3">
<div class="input-group var-group d-none">
<span class="input-group-text border-end-0">
<input type="checkbox" name="var-issecret[0]" class="var-issecret" placeholder="value" value="true">
</span>
<span class="input-group-text border-start-0">Secret</span>
<input type="text" name="var-id[0]" class="form-control var-id" placeholder="name">
<input type="text" name="var-value[0]" class="form-control var-value" placeholder="value">
</div>
</div>
<div class="vars-description mb-3 d-none">
<p>
You can add variables by using {variable-name} in job details
</p>
</div>
<div class="mb-3">
<a href="#" class="btn btn-outline-primary addvar-btn">Add variable</a>
</div>
<input type="hidden" name="crontype" class="crontype" value="">
<input type="hidden" name="hosttype" class="hosttype" value="">
<input type="hidden" name="containertype" class="containertype" value="">
<button type="submit" class="btn btn-outline-primary">Submit</button>
</form>
{% endblock %}
{% block styles %}
{{ vite_entry_link_tags('job.add') }}
{% endblock %}
{% block scripts %}
{{ vite_entry_script_tags('job.add') }}
{% endblock %}