zdravko/web/templates/pages/settings_healthchecks_create.tmpl

66 lines
2.2 KiB
Cheetah
Raw Normal View History

{{define "settings"}}
2024-02-23 11:18:02 +00:00
<section class="p-5">
<form action="/settings/healthchecks/create" method="post">
<label for="name">Name</label>
<input type="name" name="name" id="name" placeholder="Github.com">
<p> Name of the healthcheck can be anything.</p>
<label for="workergroups">Worker Groups</label>
<input type="text" name="workergroups" id="workergroups" placeholder="NA EU"/>
<p> Worker groups are used to distribute the healthcheck to specific workers.</p>
<label for="schedule">Schedule</label>
<input type="text" name="schedule" id="schedule" placeholder="* * * * *"/>
<p> Schedule is a cron expression that defines when the healthcheck should be executed.</p>
<label for="script">Script</label>
<input required type="hidden" id="script" name="script">
<div id="editor" class="block w-full h-96 rounded-lg border border-gray-300 overflow-hidden"></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/" class="text-blue-700">k6 documentation</a>.
</p>
<button type="submit" onclick="save()">Create</button>
</form>
</section>
<script src="/static/monaco/vs/loader.js"></script>
<script>
function save() {
const script = window.editor.getValue();
document.getElementById('script').value = script;
}
script = `import http from 'k6/http';
export const options = {
thresholds: {
// http errors should be less than 1%
http_req_failed: ['rate<0.01'],
2024-02-22 19:20:34 +00:00
},
vus: 10,
duration: '5s',
};
export default function () {
http.get('https://example.com');
}
`
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 },
2024-02-22 16:29:17 +00:00
codeLens: false,
contextmenu: false,
});
const divElem = document.getElementById('editor');
const resizeObserver = new ResizeObserver(entries => {
window.editor.layout();
});
resizeObserver.observe(divElem);
});
</script>
{{end}}