mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-27 01:33:37 +00:00
69 lines
2.3 KiB
Cheetah
69 lines
2.3 KiB
Cheetah
{{ define "settings" }}
|
|
<section class="p-5">
|
|
<form action="/settings/triggers/create" method="post">
|
|
<label for="name">Name</label>
|
|
<input
|
|
type="text"
|
|
name="name"
|
|
id="name"
|
|
value="Five subsequent failures trigger notification"
|
|
/>
|
|
<p>Name of the trigger can be anything.</p>
|
|
<label for="script">Script</label>
|
|
<textarea required id="script" name="script" class="sm:col-span-2 h-96">
|
|
{{ ScriptUnescapeString .Example }}</textarea
|
|
>
|
|
<div
|
|
id="editor-script"
|
|
class="hidden sm:col-span-2 block w-full h-96 rounded-lg border border-gray-300 overflow-hidden"
|
|
></div>
|
|
<p class="sm:col-span-2">
|
|
The trigger script executes for every matching <code>target</code>'s
|
|
execution of <code>trigger</code>. The outcome of that
|
|
<code>trigger</code> is passed to the script as a
|
|
<code>outcome</code> object. Based on that the trigger script should
|
|
decide if an incident should either be created or closed.
|
|
</p>
|
|
<button type="submit" onclick="save()">Create</button>
|
|
</form>
|
|
</section>
|
|
|
|
<script src="/static/monaco/vs/loader.js"></script>
|
|
<script>
|
|
const items = [{ name: "script", language: "javascript" }];
|
|
|
|
function save() {
|
|
for (const { name } of items) {
|
|
const elem = window.editors[name].getValue();
|
|
document.getElementById(name).value = elem;
|
|
}
|
|
}
|
|
|
|
window.editors = {};
|
|
for (const { name, language, options = {} } of items) {
|
|
const textarea = document.getElementById(name);
|
|
const editor = document.getElementById("editor-" + name);
|
|
|
|
editor.classList.remove("hidden");
|
|
textarea.hidden = true;
|
|
|
|
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,
|
|
...options,
|
|
});
|
|
|
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
window.editors[name].layout();
|
|
});
|
|
resizeObserver.observe(editor);
|
|
});
|
|
}
|
|
</script>
|
|
{{ end }}
|