2024-02-29 11:15:15 +00:00
|
|
|
{{ define "settings" }}
|
|
|
|
<section class="p-5">
|
2024-05-16 20:15:14 +00:00
|
|
|
<form action="/settings/checks/create" method="post">
|
2024-02-29 11:15:15 +00:00
|
|
|
<label for="name">Name</label>
|
2024-05-23 16:33:30 +00:00
|
|
|
<input type="text" name="name" id="name" placeholder="HTTP GET Request" />
|
2024-05-16 20:15:14 +00:00
|
|
|
<p>Name of the check can be anything.</p>
|
2024-02-29 11:15:15 +00:00
|
|
|
<label for="workergroups">Worker Groups</label>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
name="workergroups"
|
|
|
|
id="workergroups"
|
2024-05-23 16:33:30 +00:00
|
|
|
placeholder="europe asia"
|
2024-03-04 13:20:01 +00:00
|
|
|
required
|
2024-02-29 11:15:15 +00:00
|
|
|
/>
|
2024-05-23 16:33:30 +00:00
|
|
|
<p>
|
|
|
|
Worker groups are used to distribute the check to specific workers.
|
|
|
|
Space is a separator between groups.
|
|
|
|
</p>
|
2024-02-29 11:15:15 +00:00
|
|
|
<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>
|
2024-05-16 20:15:14 +00:00
|
|
|
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>
|
2024-05-23 16:33:30 +00:00
|
|
|
<label for="filter">Filter</label>
|
|
|
|
<textarea required id="filter" name="filter" class="h-12">
|
|
|
|
{{ ScriptUnescapeString .ExampleFilter }}</textarea
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
id="editor-filter"
|
|
|
|
class="hidden block w-full h-12 rounded-lg border border-gray-300 overflow-hidden"
|
|
|
|
></div>
|
|
|
|
<p>
|
2024-05-24 20:19:06 +00:00
|
|
|
With filter we specify what targets the check will run on. The must be a
|
|
|
|
javascript expression that returns a boolean.
|
2024-05-23 16:33:30 +00:00
|
|
|
</p>
|
2024-02-29 11:15:15 +00:00
|
|
|
<label for="script">Script</label>
|
2024-03-04 13:20:01 +00:00
|
|
|
<textarea required id="script" name="script" class="h-96">
|
2024-05-23 16:33:30 +00:00
|
|
|
{{ ScriptUnescapeString .ExampleScript }}</textarea
|
2024-03-04 13:20:01 +00:00
|
|
|
>
|
2024-02-29 11:15:15 +00:00
|
|
|
<div
|
2024-05-23 16:33:30 +00:00
|
|
|
id="editor-script"
|
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-21 22:15:21 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
<script src="/static/monaco/vs/loader.js"></script>
|
|
|
|
<script>
|
2024-05-23 16:33:30 +00:00
|
|
|
const items = [
|
2024-05-24 20:19:06 +00:00
|
|
|
{ name: "filter", language: "javascript" },
|
2024-05-23 16:33:30 +00:00
|
|
|
{ name: "script", language: "javascript" },
|
|
|
|
];
|
2024-03-04 13:20:01 +00:00
|
|
|
|
2024-02-29 11:15:15 +00:00
|
|
|
function save() {
|
2024-05-23 16:33:30 +00:00
|
|
|
for (const { name } of items) {
|
|
|
|
const elem = window.editors[name].getValue();
|
|
|
|
document.getElementById(name).value = elem;
|
|
|
|
}
|
2024-02-29 11:15:15 +00:00
|
|
|
}
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-05-23 16:33:30 +00:00
|
|
|
window.editors = {};
|
|
|
|
for (const { name, language } of items) {
|
|
|
|
const textarea = document.getElementById(name);
|
|
|
|
const editor = document.getElementById("editor-" + name);
|
|
|
|
|
|
|
|
editor.classList.remove("hidden");
|
|
|
|
textarea.hidden = true;
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-05-23 16:33:30 +00:00
|
|
|
require.config({ paths: { vs: "/static/monaco/vs" } });
|
|
|
|
require(["vs/editor/editor.main"], function () {
|
|
|
|
window.editors[name] = monaco.editor.create(editor, {
|
|
|
|
value: textarea.value,
|
|
|
|
language: language,
|
|
|
|
minimap: { enabled: false },
|
|
|
|
codeLens: false,
|
|
|
|
contextmenu: false,
|
|
|
|
scrollBeyondLastLine: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
|
|
window.editors[name].layout();
|
|
|
|
});
|
|
|
|
resizeObserver.observe(editor);
|
2024-02-29 11:15:15 +00:00
|
|
|
});
|
2024-05-23 16:33:30 +00:00
|
|
|
}
|
2024-02-29 11:15:15 +00:00
|
|
|
</script>
|
|
|
|
{{ end }}
|