zdravko/web/templates/pages/settings_checks_create.tmpl

105 lines
3.2 KiB
Cheetah
Raw Normal View History

2024-02-29 11:15:15 +00:00
{{ define "settings" }}
<section class="p-5">
<form action="/settings/checks/create" method="post">
2024-02-29 11:15:15 +00:00
<label for="name">Name</label>
2024-03-03 14:28:25 +00:00
<input type="text" name="name" id="name" placeholder="Github.com" />
<p>Name of the check can be anything.</p>
<label list="existing-groups" for="group">Check Group</label>
2024-03-03 14:28:25 +00:00
<input
type="text"
name="group"
id="group"
placeholder="default"
value="default"
2024-03-04 13:20:01 +00:00
required
2024-03-03 14:28:25 +00:00
/>
2024-03-04 13:20:01 +00:00
<datalist id="existing-groups">
<option value="default"></option>
</datalist>
2024-03-03 14:28:25 +00:00
<p>
Group checks together. This affects how they are presented on the
2024-03-03 14:28:25 +00:00
homepage.
</p>
2024-02-29 11:15:15 +00:00
<label for="workergroups">Worker Groups</label>
<input
type="text"
name="workergroups"
id="workergroups"
placeholder="NA EU"
2024-03-04 13:20:01 +00:00
required
2024-02-29 11:15:15 +00:00
/>
<p>
Worker groups are used to distribute the check to specific workers.
2024-02-29 11:15:15 +00:00
</p>
<label for="schedule">Schedule</label>
<input
type="text"
name="schedule"
id="schedule"
placeholder="@every 1m"
value="@every 1m"
2024-03-04 13:20:01 +00:00
required
2024-02-29 11:15:15 +00:00
/>
<p>
Schedule is a cron expression that defines when the check should be
2024-02-29 11:15:15 +00:00
executed.
<br />
You can also use <code>@every [interval]</code> where interval is a
duration like 5m, 1h, 60s. Or use <code>@hourly</code>,
<code>@daily</code>, <code>@weekly</code>, <code>@monthly</code>,
<code>@yearly</code>.
</p>
<label for="script">Script</label>
2024-03-04 13:20:01 +00:00
<textarea required id="script" name="script" class="h-96">
{{ ScriptUnescapeString .Example }}</textarea
2024-03-04 13:20:01 +00:00
>
2024-02-29 11:15:15 +00:00
<div
id="editor"
2024-03-04 13:20:01 +00:00
class="hidden block w-full h-96 rounded-lg border border-gray-300 overflow-hidden"
2024-02-29 11:15:15 +00:00
></div>
<p>
Script is what determines the status of a service. You can read more
about it on
<a target="_blank" href="https://k6.io/docs/using-k6/http-requests/"
>k6 documentation</a
>.
</p>
<button type="submit" onclick="save()">Create</button>
</form>
</section>
2024-02-29 11:15:15 +00:00
<script src="/static/monaco/vs/loader.js"></script>
<script>
function htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}
script = htmlDecode("{{ .Example }}");
2024-03-04 13:20:01 +00:00
document.getElementById("editor").classList.remove("hidden");
document.getElementById("script").hidden = true;
2024-02-29 11:15:15 +00:00
function save() {
const script = window.editor.getValue();
document.getElementById("script").value = script;
}
2024-02-29 11:15:15 +00:00
require.config({ paths: { vs: "/static/monaco/vs" } });
require(["vs/editor/editor.main"], function () {
window.editor = monaco.editor.create(document.getElementById("editor"), {
value: script,
language: "javascript",
minimap: { enabled: false },
codeLens: false,
contextmenu: false,
});
2024-02-29 11:15:15 +00:00
const divElem = document.getElementById("editor");
const resizeObserver = new ResizeObserver((entries) => {
window.editor.layout();
2024-02-29 11:15:15 +00:00
});
resizeObserver.observe(divElem);
});
2024-02-29 11:15:15 +00:00
</script>
{{ end }}